From 3d00d698d7d6c10628076cca8df30adb50c52563 Mon Sep 17 00:00:00 2001 From: fionaxu Date: Mon, 29 Jan 2018 14:08:12 -0800 Subject: [PATCH] add a current table in CarrierIdProvider restructure CarrierIdProvider into two tables 1. All - a private table which stores a complete mapping of all carriers 2. Current - a public table only stores the carrier identification of the current active subs. require no permission to query. expose the content url to public so that apps could be notified on carrier identity change either on background or foreground. Bug: 72571475 Test: runtest --path CarrierIdProviderTest.java Test: Manual Change-Id: If2a20288e63d25343f5bb582b35564d769a4e13b --- api/current.txt | 7 + .../updates/CarrierIdInstallReceiver.java | 2 +- .../java/android/provider/Telephony.java | 128 ++++++++++++------ 3 files changed, 95 insertions(+), 42 deletions(-) diff --git a/api/current.txt b/api/current.txt index 4c69236aaaf9f..95fcf260f35bb 100644 --- a/api/current.txt +++ b/api/current.txt @@ -36678,6 +36678,13 @@ package android.provider { field public static final java.lang.String ADDRESS = "address"; } + public static final class Telephony.CarrierIdentification implements android.provider.BaseColumns { + method public static android.net.Uri getUriForSubscriptionId(int); + field public static final java.lang.String CID = "carrier_id"; + field public static final android.net.Uri CONTENT_URI; + field public static final java.lang.String NAME = "carrier_name"; + } + public static final class Telephony.Carriers implements android.provider.BaseColumns { field public static final java.lang.String APN = "apn"; field public static final java.lang.String AUTH_TYPE = "authtype"; diff --git a/services/core/java/com/android/server/updates/CarrierIdInstallReceiver.java b/services/core/java/com/android/server/updates/CarrierIdInstallReceiver.java index 116fe7f41babb..045081679d819 100644 --- a/services/core/java/com/android/server/updates/CarrierIdInstallReceiver.java +++ b/services/core/java/com/android/server/updates/CarrierIdInstallReceiver.java @@ -33,7 +33,7 @@ public class CarrierIdInstallReceiver extends ConfigUpdateInstallReceiver { @Override protected void postInstall(Context context, Intent intent) { ContentResolver resolver = context.getContentResolver(); - resolver.update(Uri.withAppendedPath(Telephony.CarrierIdentification.CONTENT_URI, + resolver.update(Uri.withAppendedPath(Telephony.CarrierIdentification.All.CONTENT_URI, "update_db"), new ContentValues(), null, null); } } diff --git a/telephony/java/android/provider/Telephony.java b/telephony/java/android/provider/Telephony.java index 8c4572474e6b0..63263bd372061 100644 --- a/telephony/java/android/provider/Telephony.java +++ b/telephony/java/android/provider/Telephony.java @@ -33,6 +33,7 @@ import android.telephony.Rlog; import android.telephony.ServiceState; import android.telephony.SmsMessage; import android.telephony.SubscriptionManager; +import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Patterns; @@ -3345,73 +3346,118 @@ public final class Telephony { } /** - * Contains carrier identification information. - * @hide + * Contains carrier identification information for the current subscriptions. + * @see SubscriptionManager#getActiveSubscriptionIdList() */ public static final class CarrierIdentification implements BaseColumns { /** - * Numeric operator ID (as String). {@code MCC + MNC} - *

Type: TEXT

+ * Not instantiable. + * @hide */ - public static final String MCCMNC = "mccmnc"; + private CarrierIdentification() {} /** - * Group id level 1 (as String). - *

Type: TEXT

+ * The {@code content://} style URI for this provider. */ - public static final String GID1 = "gid1"; + public static final Uri CONTENT_URI = Uri.parse("content://carrier_identification"); /** - * Group id level 2 (as String). - *

Type: TEXT

+ * The authority string for the CarrierIdentification Provider + * @hide */ - public static final String GID2 = "gid2"; + public static final String AUTHORITY = "carrier_identification"; + /** - * Public Land Mobile Network name. - *

Type: TEXT

+ * Generates a content {@link Uri} used to receive updates on carrier identity change + * on the given subscriptionId + *

+ * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the + * carrier identity {@link TelephonyManager#getAndroidCarrierIdForSubscription()} + * while your app is running. You can also use a {@link JobService} to ensure your app + * is notified of changes to the {@link Uri} even when it is not running. + * Note, however, that using a {@link JobService} does not guarantee timely delivery of + * updates to the {@link Uri}. + * + * @param subscriptionId the subscriptionId to receive updates on + * @return the Uri used to observe carrier identity changes */ - public static final String PLMN = "plmn"; + public static Uri getUriForSubscriptionId(int subscriptionId) { + return CONTENT_URI.buildUpon().appendEncodedPath( + String.valueOf(subscriptionId)).build(); + } /** - * Prefix xpattern of IMSI (International Mobile Subscriber Identity). - *

Type: TEXT

- */ - public static final String IMSI_PREFIX_XPATTERN = "imsi_prefix_xpattern"; - - /** - * Service Provider Name. - *

Type: TEXT

- */ - public static final String SPN = "spn"; - - /** - * Prefer APN name. - *

Type: TEXT

- */ - public static final String APN = "apn"; - - /** - * Prefix of Integrated Circuit Card Identifier. - *

Type: TEXT

- */ - public static final String ICCID_PREFIX = "iccid_prefix"; - - /** - * User facing carrier name. + * A user facing carrier name. + * @see TelephonyManager#getAndroidCarrierNameForSubscription() *

Type: TEXT

*/ public static final String NAME = "carrier_name"; /** * A unique carrier id + * @see TelephonyManager#getAndroidCarrierIdForSubscription() *

Type: INTEGER

*/ public static final String CID = "carrier_id"; /** - * The {@code content://} URI for this table. + * Contains mappings between matching rules with carrier id for all carriers. + * @hide */ - public static final Uri CONTENT_URI = Uri.parse("content://carrier_identification"); + public static final class All implements BaseColumns { + /** + * Numeric operator ID (as String). {@code MCC + MNC} + *

Type: TEXT

+ */ + public static final String MCCMNC = "mccmnc"; + + /** + * Group id level 1 (as String). + *

Type: TEXT

+ */ + public static final String GID1 = "gid1"; + + /** + * Group id level 2 (as String). + *

Type: TEXT

+ */ + public static final String GID2 = "gid2"; + + /** + * Public Land Mobile Network name. + *

Type: TEXT

+ */ + public static final String PLMN = "plmn"; + + /** + * Prefix xpattern of IMSI (International Mobile Subscriber Identity). + *

Type: TEXT

+ */ + public static final String IMSI_PREFIX_XPATTERN = "imsi_prefix_xpattern"; + + /** + * Service Provider Name. + *

Type: TEXT

+ */ + public static final String SPN = "spn"; + + /** + * Prefer APN name. + *

Type: TEXT

+ */ + public static final String APN = "apn"; + + /** + * Prefix of Integrated Circuit Card Identifier. + *

Type: TEXT

+ */ + public static final String ICCID_PREFIX = "iccid_prefix"; + + /** + * The {@code content://} URI for this table. + */ + public static final Uri CONTENT_URI = Uri.parse("content://carrier_identification/all"); + } } }