PhoneAccount -> SubId for use in TelephonyManager#line1Number
Since we do not want to expose SubIds in the app layer, we need a
wrapper to extra the subId from a PhoneAccount and return the value of
TelephonyManager#line1Number. TelecomManager exposes the method, this is
the implementation.
Bug: 19087382
Change-Id: I4cb293e83baebfd135a01e2ffd0a86b22a3d8917
diff --git a/src/com/android/server/telecom/TelecomService.java b/src/com/android/server/telecom/TelecomService.java
index 1743f0d..0e0f0a1 100644
--- a/src/com/android/server/telecom/TelecomService.java
+++ b/src/com/android/server/telecom/TelecomService.java
@@ -448,10 +448,7 @@
return false;
}
- int subId = SubscriptionManager.getDefaultVoiceSubId();
- if (accountHandle != null) {
- subId = mPhoneAccountRegistrar.getSubscriptionIdForPhoneAccount(accountHandle);
- }
+ int subId = mPhoneAccountRegistrar.getSubscriptionIdForPhoneAccount(accountHandle);
return !TextUtils.isEmpty(getTelephonyManager().getVoiceMailNumber(subId));
} catch (Exception e) {
Log.e(this, e, "getSubscriptionIdForPhoneAccount");
@@ -460,6 +457,25 @@
}
/**
+ * @see android.telecom.TelecomManager#getLine1Number
+ */
+ @Override
+ public String getLine1Number(PhoneAccountHandle accountHandle) {
+ enforceReadPermissionOrDefaultDialer();
+ try {
+ if (!isVisibleToCaller(accountHandle)) {
+ Log.w(this, "%s is not visible for the calling user", accountHandle);
+ return null;
+ }
+ int subId = mPhoneAccountRegistrar.getSubscriptionIdForPhoneAccount(accountHandle);
+ return getTelephonyManager().getLine1NumberForSubscriber(subId);
+ } catch (Exception e) {
+ Log.e(this, e, "getSubscriptionIdForPhoneAccount");
+ throw e;
+ }
+ }
+
+ /**
* @see android.telecom.TelecomManager#silenceRinger
*/
@Override