Merge "[Settings] Replacing SubscriptionManager#addOnSubscriptionsChangedListener API" into rvc-dev
This commit is contained in:
@@ -268,7 +268,8 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
|
|||||||
PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
|
PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
|
||||||
| PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
|
| PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
|
||||||
| PhoneStateListener.LISTEN_SERVICE_STATE);
|
| PhoneStateListener.LISTEN_SERVICE_STATE);
|
||||||
mSubscriptionManager.addOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);
|
mSubscriptionManager.addOnSubscriptionsChangedListener(
|
||||||
|
mContext.getMainExecutor(), mOnSubscriptionsChangedListener);
|
||||||
registerImsRegistrationCallback(mSubscriptionInfo.getSubscriptionId());
|
registerImsRegistrationCallback(mSubscriptionInfo.getSubscriptionId());
|
||||||
|
|
||||||
if (mShowLatestAreaInfo) {
|
if (mShowLatestAreaInfo) {
|
||||||
|
@@ -266,6 +266,12 @@ public abstract class ActiveSubsciptionsListener
|
|||||||
mCachedActiveSubscriptionInfo = null;
|
mCachedActiveSubscriptionInfo = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void registerForSubscriptionsChange() {
|
||||||
|
getSubscriptionManager().addOnSubscriptionsChangedListener(
|
||||||
|
mContext.getMainExecutor(), this);
|
||||||
|
}
|
||||||
|
|
||||||
private void monitorSubscriptionsChange(boolean on) {
|
private void monitorSubscriptionsChange(boolean on) {
|
||||||
if (on) {
|
if (on) {
|
||||||
if (!mCacheState.compareAndSet(STATE_NOT_LISTENING, STATE_PREPARING)) {
|
if (!mCacheState.compareAndSet(STATE_NOT_LISTENING, STATE_PREPARING)) {
|
||||||
@@ -277,7 +283,7 @@ public abstract class ActiveSubsciptionsListener
|
|||||||
}
|
}
|
||||||
mContext.registerReceiver(mSubscriptionChangeReceiver,
|
mContext.registerReceiver(mSubscriptionChangeReceiver,
|
||||||
mSubscriptionChangeIntentFilter, null, new Handler(mLooper));
|
mSubscriptionChangeIntentFilter, null, new Handler(mLooper));
|
||||||
getSubscriptionManager().addOnSubscriptionsChangedListener(this);
|
registerForSubscriptionsChange();
|
||||||
mCacheState.compareAndSet(STATE_PREPARING, STATE_LISTENING);
|
mCacheState.compareAndSet(STATE_PREPARING, STATE_LISTENING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -67,7 +67,8 @@ public class SubscriptionsChangeListener extends ContentObserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
mSubscriptionManager.addOnSubscriptionsChangedListener(mSubscriptionsChangedListener);
|
mSubscriptionManager.addOnSubscriptionsChangedListener(
|
||||||
|
mContext.getMainExecutor(), mSubscriptionsChangedListener);
|
||||||
mContext.getContentResolver()
|
mContext.getContentResolver()
|
||||||
.registerContentObserver(mAirplaneModeSettingUri, false, this);
|
.registerContentObserver(mAirplaneModeSettingUri, false, this);
|
||||||
final IntentFilter radioTechnologyChangedFilter = new IntentFilter(
|
final IntentFilter radioTechnologyChangedFilter = new IntentFilter(
|
||||||
|
@@ -108,6 +108,10 @@ public class ActiveSubsciptionsListenerTest {
|
|||||||
private ActiveSubsciptionsListenerImpl(Looper looper, Context context) {
|
private ActiveSubsciptionsListenerImpl(Looper looper, Context context) {
|
||||||
super(looper, context);
|
super(looper, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void registerForSubscriptionsChange() {}
|
||||||
|
|
||||||
public void onChanged() {}
|
public void onChanged() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -83,7 +83,7 @@ public class SubscriptionsChangeListenerTest {
|
|||||||
initListener(false);
|
initListener(false);
|
||||||
verify(contentResolver, never()).registerContentObserver(any(Uri.class), anyBoolean(),
|
verify(contentResolver, never()).registerContentObserver(any(Uri.class), anyBoolean(),
|
||||||
any(ContentObserver.class));
|
any(ContentObserver.class));
|
||||||
verify(mSubscriptionManager, never()).addOnSubscriptionsChangedListener(any());
|
verify(mSubscriptionManager, never()).addOnSubscriptionsChangedListener(any(), any());
|
||||||
verify(mContext, never()).registerReceiver(any(), any());
|
verify(mContext, never()).registerReceiver(any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ public class SubscriptionsChangeListenerTest {
|
|||||||
initListener(true);
|
initListener(true);
|
||||||
final ArgumentCaptor<SubscriptionManager.OnSubscriptionsChangedListener> captor =
|
final ArgumentCaptor<SubscriptionManager.OnSubscriptionsChangedListener> captor =
|
||||||
ArgumentCaptor.forClass(SubscriptionManager.OnSubscriptionsChangedListener.class);
|
ArgumentCaptor.forClass(SubscriptionManager.OnSubscriptionsChangedListener.class);
|
||||||
verify(mSubscriptionManager).addOnSubscriptionsChangedListener(captor.capture());
|
verify(mSubscriptionManager).addOnSubscriptionsChangedListener(any(), captor.capture());
|
||||||
captor.getValue().onSubscriptionsChanged();
|
captor.getValue().onSubscriptionsChanged();
|
||||||
verify(mClient).onSubscriptionsChanged();
|
verify(mClient).onSubscriptionsChanged();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user