[Settings] update the db list when back to UI
Bug: 271524675 Test: local test Change-Id: I26c7d64e6f040c62c9efb1438efe328f5744fa02
This commit is contained in:
@@ -101,7 +101,7 @@ public class InternetPreferenceController extends AbstractPreferenceController i
|
||||
mInternetUpdater = new InternetUpdater(context, lifecycle, this);
|
||||
mInternetType = mInternetUpdater.getInternetType();
|
||||
mLifecycleOwner = lifecycleOwner;
|
||||
mMobileNetworkRepository = MobileNetworkRepository.create(context, this);
|
||||
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
|
||||
@@ -156,14 +156,16 @@ public class InternetPreferenceController extends AbstractPreferenceController i
|
||||
/** @OnLifecycleEvent(ON_RESUME) */
|
||||
@OnLifecycleEvent(ON_RESUME)
|
||||
public void onResume() {
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner);
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner, this,
|
||||
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||
mMobileNetworkRepository.updateEntity();
|
||||
mSummaryHelper.register(true);
|
||||
}
|
||||
|
||||
/** @OnLifecycleEvent(ON_PAUSE) */
|
||||
@OnLifecycleEvent(ON_PAUSE)
|
||||
public void onPause() {
|
||||
mMobileNetworkRepository.removeRegister();
|
||||
mMobileNetworkRepository.removeRegister(this);
|
||||
mSummaryHelper.register(false);
|
||||
}
|
||||
|
||||
|
@@ -22,6 +22,7 @@ import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.UserManager;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.euicc.EuiccManager;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -87,7 +88,7 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
|
||||
mMetricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
|
||||
mUserManager = context.getSystemService(UserManager.class);
|
||||
mLifecycleOwner = lifecycleOwner;
|
||||
mMobileNetworkRepository = MobileNetworkRepository.create(context, this);
|
||||
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
|
||||
mIsAirplaneModeOn = mMobileNetworkRepository.isAirplaneModeOn();
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(this);
|
||||
@@ -96,13 +97,14 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
|
||||
|
||||
@OnLifecycleEvent(ON_RESUME)
|
||||
public void onResume() {
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner);
|
||||
update();
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner, this,
|
||||
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||
mMobileNetworkRepository.updateEntity();
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(ON_PAUSE)
|
||||
public void onPause() {
|
||||
mMobileNetworkRepository.removeRegister();
|
||||
mMobileNetworkRepository.removeRegister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -21,6 +21,7 @@ import static androidx.lifecycle.Lifecycle.Event;
|
||||
import android.content.Context;
|
||||
import android.os.UserManager;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -71,7 +72,7 @@ public class NetworkProviderCallsSmsController extends AbstractPreferenceControl
|
||||
mIsRtlMode = context.getResources().getConfiguration().getLayoutDirection()
|
||||
== View.LAYOUT_DIRECTION_RTL;
|
||||
mLifecycleOwner = lifecycleOwner;
|
||||
mMobileNetworkRepository = MobileNetworkRepository.create(context, this);
|
||||
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
@@ -79,13 +80,14 @@ public class NetworkProviderCallsSmsController extends AbstractPreferenceControl
|
||||
|
||||
@OnLifecycleEvent(Event.ON_RESUME)
|
||||
public void onResume() {
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner);
|
||||
update();
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner, this,
|
||||
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||
mMobileNetworkRepository.updateEntity();
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Event.ON_PAUSE)
|
||||
public void onPause() {
|
||||
mMobileNetworkRepository.removeRegister();
|
||||
mMobileNetworkRepository.removeRegister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -65,19 +65,20 @@ public class NetworkProviderSimListController extends AbstractPreferenceControll
|
||||
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
|
||||
mPreferences = new ArrayMap<>();
|
||||
mLifecycleOwner = lifecycleOwner;
|
||||
mMobileNetworkRepository = MobileNetworkRepository.create(context, this);
|
||||
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(ON_RESUME)
|
||||
public void onResume() {
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner);
|
||||
update();
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner, this,
|
||||
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||
mMobileNetworkRepository.updateEntity();
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(ON_PAUSE)
|
||||
public void onPause() {
|
||||
mMobileNetworkRepository.removeRegister();
|
||||
mMobileNetworkRepository.removeRegister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -52,7 +52,7 @@ public class ConvertToEsimPreferenceController extends TelephonyBasePreferenceCo
|
||||
LifecycleOwner lifecycleOwner, int subId) {
|
||||
super(context, key);
|
||||
mSubId = subId;
|
||||
mMobileNetworkRepository = MobileNetworkRepository.createBySubId(context, this, mSubId);
|
||||
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
|
||||
mLifecycleOwner = lifecycleOwner;
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(this);
|
||||
@@ -66,12 +66,13 @@ public class ConvertToEsimPreferenceController extends TelephonyBasePreferenceCo
|
||||
|
||||
@OnLifecycleEvent(ON_START)
|
||||
public void onStart() {
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner);
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner, this, mSubId);
|
||||
mMobileNetworkRepository.updateEntity();
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(ON_STOP)
|
||||
public void onStop() {
|
||||
mMobileNetworkRepository.removeRegister();
|
||||
mMobileNetworkRepository.removeRegister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -75,7 +75,7 @@ public abstract class DefaultSubscriptionController extends TelephonyBasePrefere
|
||||
mManager = context.getSystemService(SubscriptionManager.class);
|
||||
mIsRtlMode = context.getResources().getConfiguration().getLayoutDirection()
|
||||
== View.LAYOUT_DIRECTION_RTL;
|
||||
mMobileNetworkRepository = MobileNetworkRepository.create(context, this);
|
||||
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
|
||||
mLifecycleOwner = lifecycleOwner;
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(this);
|
||||
@@ -104,13 +104,13 @@ public abstract class DefaultSubscriptionController extends TelephonyBasePrefere
|
||||
|
||||
@OnLifecycleEvent(ON_RESUME)
|
||||
public void onResume() {
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner);
|
||||
updateEntries();
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner, this, getDefaultSubscriptionId());
|
||||
mMobileNetworkRepository.updateEntity();
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(ON_PAUSE)
|
||||
public void onPause() {
|
||||
mMobileNetworkRepository.removeRegister();
|
||||
mMobileNetworkRepository.removeRegister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -303,6 +303,4 @@ public abstract class DefaultSubscriptionController extends TelephonyBasePrefere
|
||||
updateEntries();
|
||||
refreshSummary(mPreference);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -58,7 +58,6 @@ public class MobileDataPreferenceController extends TelephonyTogglePreferenceCon
|
||||
private SwitchPreference mPreference;
|
||||
private TelephonyManager mTelephonyManager;
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
private MobileDataContentObserver mDataContentObserver;
|
||||
private FragmentManager mFragmentManager;
|
||||
@VisibleForTesting
|
||||
int mDialogType;
|
||||
@@ -79,9 +78,7 @@ public class MobileDataPreferenceController extends TelephonyTogglePreferenceCon
|
||||
super(context, key);
|
||||
mSubId = subId;
|
||||
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
|
||||
mDataContentObserver = new MobileDataContentObserver(new Handler(Looper.getMainLooper()));
|
||||
mDataContentObserver.setOnMobileDataChangedListener(() -> updateState(mPreference));
|
||||
mMobileNetworkRepository = MobileNetworkRepository.createBySubId(context, this, mSubId);
|
||||
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
|
||||
mLifecycleOwner = lifecycleOwner;
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(this);
|
||||
@@ -103,12 +100,13 @@ public class MobileDataPreferenceController extends TelephonyTogglePreferenceCon
|
||||
|
||||
@OnLifecycleEvent(ON_START)
|
||||
public void onStart() {
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner);
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner, this, mSubId);
|
||||
mMobileNetworkRepository.updateEntity();
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(ON_STOP)
|
||||
public void onStop() {
|
||||
mMobileNetworkRepository.removeRegister();
|
||||
mMobileNetworkRepository.removeRegister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -158,7 +158,7 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme
|
||||
MobileNetworkUtils.getSearchableSubscriptionId(context));
|
||||
Log.d(LOG_TAG, "display subId from getArguments(): " + mSubId);
|
||||
}
|
||||
mMobileNetworkRepository = MobileNetworkRepository.create(context, this);
|
||||
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
|
||||
mExecutor.execute(() -> {
|
||||
mSubscriptionInfoEntity = mMobileNetworkRepository.getSubInfoById(
|
||||
String.valueOf(mSubId));
|
||||
@@ -177,6 +177,8 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme
|
||||
new SmsDefaultSubscriptionController(context, KEY_SMS_PREF, getSettingsLifecycle(),
|
||||
this),
|
||||
new MobileDataPreferenceController(context, KEY_MOBILE_DATA_PREF,
|
||||
getSettingsLifecycle(), this, mSubId),
|
||||
new ConvertToEsimPreferenceController(context, KEY_CONVERT_TO_ESIM_PREF,
|
||||
getSettingsLifecycle(), this, mSubId));
|
||||
}
|
||||
|
||||
@@ -322,7 +324,8 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mMobileNetworkRepository.addRegister(this);
|
||||
mMobileNetworkRepository.addRegister(this, this, mSubId);
|
||||
mMobileNetworkRepository.updateEntity();
|
||||
// TODO: remove log after fixing b/182326102
|
||||
Log.d(LOG_TAG, "onResume() subId=" + mSubId);
|
||||
}
|
||||
@@ -350,7 +353,7 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
mMobileNetworkRepository.removeRegister();
|
||||
mMobileNetworkRepository.removeRegister(this);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -505,7 +508,7 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme
|
||||
break;
|
||||
} else if (entity.isDefaultSubscriptionSelection) {
|
||||
mSubscriptionInfoEntity = entity;
|
||||
Log.d(LOG_TAG, "Set subInfo to the default subInfo.");
|
||||
Log.d(LOG_TAG, "Set subInfo to default subInfo.");
|
||||
}
|
||||
}
|
||||
onSubscriptionDetailChanged();
|
||||
|
@@ -81,7 +81,7 @@ public class RoamingPreferenceController extends TelephonyTogglePreferenceContro
|
||||
super(context, key);
|
||||
mSubId = subId;
|
||||
mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
|
||||
mMobileNetworkRepository = MobileNetworkRepository.createBySubId(context, this, mSubId);
|
||||
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
|
||||
mLifecycleOwner = lifecycleOwner;
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(this);
|
||||
@@ -100,7 +100,8 @@ public class RoamingPreferenceController extends TelephonyTogglePreferenceContro
|
||||
|
||||
@OnLifecycleEvent(ON_START)
|
||||
public void onStart() {
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner);
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner, this, mSubId);
|
||||
mMobileNetworkRepository.updateEntity();
|
||||
if (mListener == null) {
|
||||
mListener = new GlobalSettingsChangeListener(mContext,
|
||||
Settings.Global.DATA_ROAMING) {
|
||||
@@ -126,7 +127,7 @@ public class RoamingPreferenceController extends TelephonyTogglePreferenceContro
|
||||
|
||||
@OnLifecycleEvent(ON_STOP)
|
||||
public void onStop() {
|
||||
mMobileNetworkRepository.removeRegister();
|
||||
mMobileNetworkRepository.removeRegister(this);
|
||||
stopMonitor();
|
||||
stopMonitorSubIdSpecific();
|
||||
}
|
||||
|
@@ -95,10 +95,11 @@ public class MobileNetworkSummaryControllerTest {
|
||||
doReturn(mSubscriptionManager).when(mContext).getSystemService(SubscriptionManager.class);
|
||||
doReturn(mEuiccManager).when(mContext).getSystemService(EuiccManager.class);
|
||||
doReturn(mUserManager).when(mContext).getSystemService(UserManager.class);
|
||||
mMobileNetworkRepository = MobileNetworkRepository.create(mContext, mMobileNetworkCallback);
|
||||
mMobileNetworkRepository = MobileNetworkRepository.getInstance(mContext);
|
||||
mLifecycleOwner = () -> mLifecycle;
|
||||
mLifecycle = new Lifecycle(mLifecycleOwner);
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner);
|
||||
mMobileNetworkRepository.addRegister(mLifecycleOwner, mMobileNetworkCallback,
|
||||
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||
|
||||
when(mTelephonyManager.getNetworkCountryIso()).thenReturn("");
|
||||
when(mSubscriptionManager.isActiveSubscriptionId(anyInt())).thenReturn(true);
|
||||
@@ -114,7 +115,7 @@ public class MobileNetworkSummaryControllerTest {
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
mMobileNetworkRepository.removeRegister();
|
||||
mMobileNetworkRepository.removeRegister(mMobileNetworkCallback);
|
||||
SubscriptionUtil.setActiveSubscriptionsForTesting(null);
|
||||
SubscriptionUtil.setAvailableSubscriptionsForTesting(null);
|
||||
}
|
||||
|
Reference in New Issue
Block a user