Home | History | Annotate | Download | only in preferredsim
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License
     15  */
     16 
     17 package com.android.dialer.preferredsim;
     18 
     19 import android.content.ComponentName;
     20 import android.net.Uri;
     21 import android.provider.ContactsContract.CommonDataKinds;
     22 import android.telecom.PhoneAccountHandle;
     23 import com.android.dialer.constants.Constants;
     24 
     25 /**
     26  * Extend fields for preferred SIM that is not available in {@link
     27  * android.provider.ContactsContract.Data} before P. Insert is not supported for this provider. The
     28  * update selection must be "data_id = ?". Delete is only supported directly on {@link #CONTENT_URI}
     29  * with {@code null} selection, which clears all preferences.
     30  *
     31  * <p>Caller must have {@link android.Manifest.permission#READ_CONTACTS} to read or {@link
     32  * android.Manifest.permission#WRITE_CONTACTS} to write.
     33  */
     34 public final class PreferredSimFallbackContract {
     35 
     36   /**
     37    * Check the meta-data "com.android.dialer.PREFERRED_SIM_FALLBACK_AUTHORITY" to get the authority
     38    * of the default dialer if it support it.
     39    */
     40   public static final String AUTHORITY = Constants.get().getPreferredSimFallbackProviderAuthority();
     41 
     42   public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);
     43 
     44   /** Columns for preferred SIM. */
     45   public static final class PreferredSim {
     46 
     47     /**
     48      * Unique key that should match {@link
     49      * android.provider.ContactsContract.CommonDataKinds.Phone#_ID} of the data row it is associated
     50      * with.
     51      */
     52     public static final String DATA_ID = "data_id";
     53 
     54     /**
     55      * The flattened {@link android.content.ComponentName} of a {@link PhoneAccountHandle} that is
     56      * the preferred {@code PhoneAccountHandle} to call the contact with. Used by {@link
     57      * CommonDataKinds.Phone}.
     58      *
     59      * @see PhoneAccountHandle#getComponentName()
     60      * @see ComponentName#flattenToString()
     61      */
     62     public static final String PREFERRED_PHONE_ACCOUNT_COMPONENT_NAME =
     63         "preferred_phone_account_component_name";
     64 
     65     /**
     66      * The ID of a {@link PhoneAccountHandle} that is the preferred {@code PhoneAccountHandle} to
     67      * call the contact with. Used by {@link CommonDataKinds.Phone}.
     68      *
     69      * @see PhoneAccountHandle#getId() ()
     70      * @see ComponentName#flattenToString()
     71      */
     72     public static final String PREFERRED_PHONE_ACCOUNT_ID = "preferred_phone_account_id";
     73   }
     74 }
     75