[Settings] Do not creat multiple database
Bug: 254405469 Test: manual Change-Id: I96ea77899270439a87569bd1676d38b52dd36650
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 = new MobileNetworkRepository(context, this);
|
||||
mMobileNetworkRepository = MobileNetworkRepository.create(context, this);
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
|
||||
@@ -163,7 +163,6 @@ public class InternetPreferenceController extends AbstractPreferenceController i
|
||||
/** @OnLifecycleEvent(ON_PAUSE) */
|
||||
@OnLifecycleEvent(ON_PAUSE)
|
||||
public void onPause() {
|
||||
mMobileNetworkRepository.removeRegister();
|
||||
mSummaryHelper.register(false);
|
||||
}
|
||||
|
||||
@@ -203,22 +202,38 @@ public class InternetPreferenceController extends AbstractPreferenceController i
|
||||
@VisibleForTesting
|
||||
void updateCellularSummary() {
|
||||
CharSequence summary = null;
|
||||
for (SubscriptionInfoEntity subInfo : mSubInfoEntityList) {
|
||||
if (subInfo.isSubscriptionVisible && subInfo.isActiveDataSubscriptionId) {
|
||||
summary = subInfo.uniqueName;
|
||||
break;
|
||||
} else if (subInfo.isDefaultDataSubscription) {
|
||||
summary = mContext.getString(
|
||||
R.string.mobile_data_temp_using, subInfo.uniqueName);
|
||||
SubscriptionInfoEntity activeSubInfo = null;
|
||||
SubscriptionInfoEntity defaultSubInfo = null;
|
||||
|
||||
for (SubscriptionInfoEntity subInfo : getSubscriptionInfoList()) {
|
||||
if (subInfo.isActiveDataSubscriptionId) {
|
||||
activeSubInfo = subInfo;
|
||||
}
|
||||
if (subInfo.isDefaultDataSubscription) {
|
||||
defaultSubInfo = subInfo;
|
||||
}
|
||||
}
|
||||
|
||||
if (summary == null) {
|
||||
if (activeSubInfo == null) {
|
||||
return;
|
||||
}
|
||||
activeSubInfo = activeSubInfo.isSubscriptionVisible ? activeSubInfo : defaultSubInfo;
|
||||
|
||||
if (activeSubInfo.equals(defaultSubInfo)) {
|
||||
// DDS is active
|
||||
summary = activeSubInfo.uniqueName;
|
||||
} else {
|
||||
summary = mContext.getString(
|
||||
R.string.mobile_data_temp_using, activeSubInfo.uniqueName);
|
||||
}
|
||||
|
||||
mPreference.setSummary(summary);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected List<SubscriptionInfoEntity> getSubscriptionInfoList() {
|
||||
return mSubInfoEntityList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAvailableSubInfoChanged(List<SubscriptionInfoEntity> subInfoEntityList) {
|
||||
if ((mSubInfoEntityList != null &&
|
||||
|
Reference in New Issue
Block a user