diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-09-05 23:35:47 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-09-05 23:35:47 +0000 |
commit | 9576e6f5046d4c310f9fae51fdbb6571928a271b (patch) | |
tree | 8681251ea63fce950e17aa774c5a2301dd7cda40 | |
parent | 892883806f8d916f037ecc125ac7bc66090f6c81 (diff) | |
parent | ad80f594d4dec7d9ef4775abbdde12d53a5876f4 (diff) | |
download | Telephony-pie-qpr1-s1-release.tar.gz |
Merge cherrypicks of [4948448, 4948511, 4948299, 4947854, 4947306, 4946150, 4948531, 4946116, 4948532] into pi-qpr1-releaseandroid-9.0.0_r30android-9.0.0_r22android-9.0.0_r21android-9.0.0_r20android-9.0.0_r19android-9.0.0_r16pie-qpr1-s3-releasepie-qpr1-s2-releasepie-qpr1-s1-releasepie-qpr1-release
Change-Id: I0da058074593bf706f43d8d6389a8e30bb46b09a
-rw-r--r-- | src/com/android/services/telephony/TelecomAccountRegistry.java | 86 |
1 files changed, 71 insertions, 15 deletions
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java index 6c8dcaa6b..642af8569 100644 --- a/src/com/android/services/telephony/TelecomAccountRegistry.java +++ b/src/com/android/services/telephony/TelecomAccountRegistry.java @@ -107,9 +107,31 @@ final class TelecomAccountRegistry { } /** - * Registers the specified account with Telecom as a PhoneAccountHandle. + * Trigger re-registration of this account. */ + public void reRegisterPstnPhoneAccount() { + PhoneAccount newAccount = buildPstnPhoneAccount(mIsEmergency, mIsDummy); + if (!newAccount.equals(mAccount)) { + Log.i(this, "reRegisterPstnPhoneAccount: subId: " + getSubId() + + " - re-register due to account change."); + mTelecomManager.registerPhoneAccount(newAccount); + mAccount = newAccount; + } else { + Log.i(this, "reRegisterPstnPhoneAccount: subId: " + getSubId() + " - no change"); + } + } + private PhoneAccount registerPstnPhoneAccount(boolean isEmergency, boolean isDummyAccount) { + PhoneAccount account = buildPstnPhoneAccount(mIsEmergency, mIsDummy); + // Register with Telecom and put into the account entry. + mTelecomManager.registerPhoneAccount(account); + return account; + } + + /** + * Registers the specified account with Telecom as a PhoneAccountHandle. + */ + private PhoneAccount buildPstnPhoneAccount(boolean isEmergency, boolean isDummyAccount) { String dummyPrefix = isDummyAccount ? "Dummy " : ""; // Build the Phone account handle. @@ -312,9 +334,6 @@ final class TelecomAccountRegistry { .setGroupId(groupId) .build(); - // Register with Telecom and put into the account entry. - mTelecomManager.registerPhoneAccount(account); - return account; } @@ -322,6 +341,10 @@ final class TelecomAccountRegistry { return mAccount != null ? mAccount.getAccountHandle() : null; } + public int getSubId() { + return mPhone.getSubId(); + } + /** * Determines from carrier configuration whether pausing of IMS video calls is supported. * @@ -579,19 +602,27 @@ final class TelecomAccountRegistry { } }; - private final BroadcastReceiver mUserSwitchedReceiver = new BroadcastReceiver() { + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - Log.i(this, "User changed, re-registering phone accounts."); + if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) { + Log.i(this, "User changed, re-registering phone accounts."); - int userHandleId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0); - UserHandle currentUserHandle = new UserHandle(userHandleId); - mIsPrimaryUser = UserManager.get(mContext).getPrimaryUser().getUserHandle() - .equals(currentUserHandle); + int userHandleId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0); + UserHandle currentUserHandle = new UserHandle(userHandleId); + mIsPrimaryUser = UserManager.get(mContext).getPrimaryUser().getUserHandle() + .equals(currentUserHandle); - // Any time the user changes, re-register the accounts. - tearDownAccounts(); - setupAccounts(); + // Any time the user changes, re-register the accounts. + tearDownAccounts(); + setupAccounts(); + } else if (CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED.equals( + intent.getAction())) { + Log.i(this, "Carrier-config changed, checking for phone account updates."); + int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, + SubscriptionManager.INVALID_SUBSCRIPTION_ID); + handleCarrierConfigChange(subId); + } } }; @@ -814,8 +845,10 @@ final class TelecomAccountRegistry { // Listen for user switches. When the user switches, we need to ensure that if the current // use is not the primary user we disable video calling. - mContext.registerReceiver(mUserSwitchedReceiver, - new IntentFilter(Intent.ACTION_USER_SWITCHED)); + IntentFilter filter = new IntentFilter(); + filter.addAction(Intent.ACTION_USER_SWITCHED); + filter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED); + mContext.registerReceiver(mReceiver, filter); // Listen to the RTT system setting so that we update it when the user flips it. ContentObserver rttUiSettingObserver = new ContentObserver( @@ -951,4 +984,27 @@ final class TelecomAccountRegistry { mAccounts.clear(); } } + + /** + * Handles changes to the carrier configuration which may impact a phone account. There are + * some extras defined in the {@link PhoneAccount} which are based on carrier config options. + * Only checking for carrier config changes when the subscription is configured runs the risk of + * missing carrier config changes which happen later. + * @param subId The subid the carrier config changed for, if applicable. Will be + * {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID} if not specified. + */ + private void handleCarrierConfigChange(int subId) { + if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { + return; + } + synchronized (mAccountsLock) { + for (AccountEntry entry : mAccounts) { + if (entry.getSubId() == subId) { + Log.d(this, "handleCarrierConfigChange: subId=%d, accountSubId=%d", subId, + entry.getSubId()); + entry.reRegisterPstnPhoneAccount(); + } + } + } + } } |