Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8c4e6c6 authored by Nancy Chen's avatar Nancy Chen Committed by Natiq Ahmed
Browse files

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
parent 018bf7a7
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -478,10 +478,7 @@ public class TelecomService extends Service {
                    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");
@@ -489,6 +486,25 @@ public class TelecomService extends Service {
            }
        }

        /**
         * @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
         */