[Settings] update the db list when back to UI

Bug: 271524675
Test: local test
Change-Id: I26c7d64e6f040c62c9efb1438efe328f5744fa02
This commit is contained in:
Zoey Chen
2023-03-16 18:40:59 +00:00
parent b9f6bb7958
commit db02f10b07
10 changed files with 49 additions and 40 deletions

View File

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