summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Shuo Qian <shuoq@google.com> 2019-10-30 16:25:42 -0700
committer sqian <shuoq@google.com> 2019-11-01 11:11:46 -0700
commit8fe529bce284bd0df1a3200f5b156cef86609b63 (patch)
treea53f03c2bf2c35e5f33d09d021b96c14ab33e32c
parent3d8a0ce48992c77b67e27f1fc079a3fdb648b9b3 (diff)
Make getSubIdForPhoneAccountHandle Public
Clean up getSubIdForPhoneAccountHandle without checking CAPABILITY_SIM_SUBSCRIPTION Test: Treehugger Bug: 143235201 Change-Id: I563760d0e68cbcae597ccd297f184ee9efdf3367 Merged-In: I563760d0e68cbcae597ccd297f184ee9efdf3367 (cherry picked from commit 9ac2d6b08be97a2d8c20bbc57632605712167bd4)
-rw-r--r--api/current.txt1
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java22
-rw-r--r--telephony/java/com/android/internal/telephony/ITelephony.aidl6
3 files changed, 24 insertions, 5 deletions
diff --git a/api/current.txt b/api/current.txt
index c818205e56f1..80acaee8b53c 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -45021,6 +45021,7 @@ package android.telephony {
method @Nullable public CharSequence getSimSpecificCarrierIdName();
method public int getSimState();
method public int getSimState(int);
+ method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int getSubIdForPhoneAccountHandle(@NonNull android.telecom.PhoneAccountHandle);
method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public String getSubscriberId();
method public int getSupportedModemCount();
method @Nullable public String getTypeAllocationCode();
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index c9440a66ab96..e62041ddf55c 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -9448,16 +9448,28 @@ public class TelephonyManager {
return returnValue;
}
- private int getSubIdForPhoneAccountHandle(PhoneAccountHandle phoneAccountHandle) {
+ /**
+ * Returns the subscription ID for the given phone account handle.
+ *
+ * @param phoneAccountHandle the phone account handle for outgoing calls
+ * @return subscription ID for the given phone account handle; or
+ * {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID}
+ * if not available; or throw a SecurityException if the caller doesn't have the
+ * permission.
+ */
+ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
+ public int getSubIdForPhoneAccountHandle(@NonNull PhoneAccountHandle phoneAccountHandle) {
int retval = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
try {
- ITelecomService service = getTelecomService();
+ ITelephony service = getITelephony();
if (service != null) {
- retval = getSubIdForPhoneAccount(service.getPhoneAccount(phoneAccountHandle));
+ retval = service.getSubIdForPhoneAccountHandle(
+ phoneAccountHandle, mContext.getOpPackageName());
}
- } catch (RemoteException e) {
+ } catch (RemoteException ex) {
+ Log.e(TAG, "getSubIdForPhoneAccountHandle RemoteException", ex);
+ ex.rethrowAsRuntimeException();
}
-
return retval;
}
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index db0eac287423..414693ef6362 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -1309,6 +1309,12 @@ interface ITelephony {
int getSubIdForPhoneAccount(in PhoneAccount phoneAccount);
/**
+ * Returns the subscription ID associated with the specified PhoneAccountHandle.
+ */
+ int getSubIdForPhoneAccountHandle(in PhoneAccountHandle phoneAccountHandle,
+ String callingPackage);
+
+ /**
* Returns the PhoneAccountHandle associated with a subscription ID.
*/
PhoneAccountHandle getPhoneAccountHandleForSubscriptionId(int subscriptionId);