[Settings] Replacing SubscriptionManager#addOnSubscriptionsChangedListener API

Replace SubscriptionManager#addOnSubscriptionsChangedListener API in
order to compatible with legacy design.

Bug: 151838951
Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=SubscriptionsChangeListenerTest
Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=ActiveSubsciptionsListenerTest
Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=SimStatusDialogControllerTest
Change-Id: Ib98ce0dcbf18b6f48a6f267dd9e7be017d571157
This commit is contained in:
Bonian Chen
2020-03-24 11:46:03 +08:00
parent a3fccb9cc0
commit 073f483d86
5 changed files with 17 additions and 5 deletions

View File

@@ -266,6 +266,12 @@ public abstract class ActiveSubsciptionsListener
mCachedActiveSubscriptionInfo = null;
}
@VisibleForTesting
void registerForSubscriptionsChange() {
getSubscriptionManager().addOnSubscriptionsChangedListener(
mContext.getMainExecutor(), this);
}
private void monitorSubscriptionsChange(boolean on) {
if (on) {
if (!mCacheState.compareAndSet(STATE_NOT_LISTENING, STATE_PREPARING)) {
@@ -277,7 +283,7 @@ public abstract class ActiveSubsciptionsListener
}
mContext.registerReceiver(mSubscriptionChangeReceiver,
mSubscriptionChangeIntentFilter, null, new Handler(mLooper));
getSubscriptionManager().addOnSubscriptionsChangedListener(this);
registerForSubscriptionsChange();
mCacheState.compareAndSet(STATE_PREPARING, STATE_LISTENING);
return;
}

View File

@@ -67,7 +67,8 @@ public class SubscriptionsChangeListener extends ContentObserver {
}
public void start() {
mSubscriptionManager.addOnSubscriptionsChangedListener(mSubscriptionsChangedListener);
mSubscriptionManager.addOnSubscriptionsChangedListener(
mContext.getMainExecutor(), mSubscriptionsChangedListener);
mContext.getContentResolver()
.registerContentObserver(mAirplaneModeSettingUri, false, this);
final IntentFilter radioTechnologyChangedFilter = new IntentFilter(