summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/preferredsim/PreferredSimFallbackContract.java
blob: 6c2f860e6b90a84a66378b25559e40e0a11b6441 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.dialer.preferredsim;

import android.content.ComponentName;
import android.net.Uri;
import android.provider.ContactsContract.CommonDataKinds;
import android.telecom.PhoneAccountHandle;
import com.android.dialer.constants.Constants;

/**
 * Extend fields for preferred SIM that is not available in {@link
 * android.provider.ContactsContract.Data} before P. Insert is not supported for this provider. The
 * update selection must be "data_id = ?". Delete is only supported directly on {@link #CONTENT_URI}
 * with {@code null} selection, which clears all preferences.
 *
 * <p>Caller must have {@link android.Manifest.permission#READ_CONTACTS} to read or {@link
 * android.Manifest.permission#WRITE_CONTACTS} to write.
 */
public final class PreferredSimFallbackContract {

  /**
   * Check the meta-data "com.android.dialer.PREFERRED_SIM_FALLBACK_AUTHORITY" to get the authority
   * of the default dialer if it support it.
   */
  public static final String AUTHORITY = Constants.get().getPreferredSimFallbackProviderAuthority();

  public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);

  /** Columns for preferred SIM. */
  public static final class PreferredSim {

    /**
     * Unique key that should match {@link
     * android.provider.ContactsContract.CommonDataKinds.Phone#_ID} of the data row it is associated
     * with.
     */
    public static final String DATA_ID = "data_id";

    /**
     * The flattened {@link android.content.ComponentName} of a {@link PhoneAccountHandle} that is
     * the preferred {@code PhoneAccountHandle} to call the contact with. Used by {@link
     * CommonDataKinds.Phone}.
     *
     * @see PhoneAccountHandle#getComponentName()
     * @see ComponentName#flattenToString()
     */
    public static final String PREFERRED_PHONE_ACCOUNT_COMPONENT_NAME =
        "preferred_phone_account_component_name";

    /**
     * The ID of a {@link PhoneAccountHandle} that is the preferred {@code PhoneAccountHandle} to
     * call the contact with. Used by {@link CommonDataKinds.Phone}.
     *
     * @see PhoneAccountHandle#getId() ()
     * @see ComponentName#flattenToString()
     */
    public static final String PREFERRED_PHONE_ACCOUNT_ID = "preferred_phone_account_id";
  }
}