summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jin Jeong <jinjeong@google.com> 2024-11-21 00:16:54 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-11-21 00:16:54 +0000
commit97b52e98f56e55f730fc67be4ea57e8940e8de54 (patch)
treee6eb7d6c62eb3e0f5428f79fcf2b6417b2d03cc5
parentf2ac6aec40284d3c89b86abeeb8471f9cff45e6b (diff)
parent6fdfb791b04755a926b5907a48c9ecc96d6fa13b (diff)
Merge "New System Api: getCarrierId using carrierIdentifier" into main
-rw-r--r--core/api/system-current.txt1
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java33
-rw-r--r--telephony/java/com/android/internal/telephony/ITelephony.aidl11
3 files changed, 45 insertions, 0 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index e225bb4199e3..d971f8bf3bed 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -16196,6 +16196,7 @@ package android.telephony {
method @Nullable @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public android.content.ComponentName getAndUpdateDefaultRespondViaMessageApplication();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void getCallForwarding(int, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyManager.CallForwardingInfoCallback);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void getCallWaitingStatus(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>);
+ method @FlaggedApi("com.android.internal.telephony.flags.carrier_id_from_carrier_identifier") @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @WorkerThread public int getCarrierIdFromCarrierIdentifier(@NonNull android.service.carrier.CarrierIdentifier);
method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int);
method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.List<java.lang.String> getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int);
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index e22d75e4dfe3..ad5d42ad5a68 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -19599,4 +19599,37 @@ public class TelephonyManager {
throw ex.rethrowAsRuntimeException();
}
}
+
+ /**
+ * Returns carrier id maps to the passing CarrierIdentifier.
+ * To recognize a carrier (including MVNO) as a first-class identity,
+ * Android assigns each carrier with a canonical integer a.k.a. carrier id.
+ * The carrier ID is an Android platform-wide identifier for a carrier.
+ * AOSP maintains carrier ID assignments in
+ * <a href="https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/master/assets/latest_carrier_id/carrier_list.textpb">here</a>
+ *
+ * @param carrierIdentifier {@link CarrierIdentifier}
+ *
+ * @return Carrier id. Return {@link #UNKNOWN_CARRIER_ID} if the carrier cannot be identified.
+ * @throws UnsupportedOperationException If the device does not have
+ * {@link PackageManager#FEATURE_TELEPHONY_SUBSCRIPTION}.
+ *
+ * @hide
+ */
+ @FlaggedApi(Flags.FLAG_CARRIER_ID_FROM_CARRIER_IDENTIFIER)
+ @SystemApi
+ @WorkerThread
+ @RequiresFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION)
+ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ public int getCarrierIdFromCarrierIdentifier(@NonNull CarrierIdentifier carrierIdentifier) {
+ try {
+ ITelephony service = getITelephony();
+ if (service != null) {
+ return service.getCarrierIdFromIdentifier(carrierIdentifier);
+ }
+ } catch (RemoteException ex) {
+ // This could happen if binder process crashes.
+ }
+ return UNKNOWN_CARRIER_ID;
+ }
}
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index d22e9fa20101..294c93c8e493 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -3519,4 +3519,15 @@ interface ITelephony {
* @hide
*/
void setNtnSmsSupported(boolean ntnSmsSupported);
+
+ /**
+ * Returns carrier id maps to the passing {@link CarrierIdentifier}.
+ *
+ * @param {@link CarrierIdentifier}.
+ *
+ * @return carrier id from passing {@link CarrierIdentifier} or {@link #UNKNOWN_CARRIER_ID}
+ * if the carrier cannot be identified
+ * @hide
+ */
+ int getCarrierIdFromIdentifier(in CarrierIdentifier carrierIdentifier);
}