Merge "Clean up lifecycle in MobileNetworkSettings" into tm-dev am: 87f8135959 am: 635c506a92 am: 52a4269f9a am: 6c4476b59f

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/18591472

Change-Id: I33fd0a975c68a1dc49c5953986af1a16894c720b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Chaohui Wang
2022-05-25 10:35:12 +00:00
committed by Automerger Merge Worker
17 changed files with 38 additions and 74 deletions

View File

@@ -111,7 +111,7 @@ public class EnabledNetworkModePreferenceControllerTest {
mController = new EnabledNetworkModePreferenceController(mContext, KEY);
mockAllowedNetworkTypes(ALLOWED_ALL_NETWORK_TYPE);
mockAccessFamily(TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA);
mController.init(mLifecycle, SUB_ID);
mController.init(SUB_ID);
mPreference.setKey(mController.getPreferenceKey());
}
@@ -205,7 +205,7 @@ public class EnabledNetworkModePreferenceControllerTest {
public void updateState_5gWorldPhone_GlobalHasNr() {
mockAllowedNetworkTypes(ALLOWED_ALL_NETWORK_TYPE);
mockAccessFamily(TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA);
mController.init(mLifecycle, SUB_ID);
mController.init(SUB_ID);
mPersistableBundle.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
mController.updateState(mPreference);
@@ -221,7 +221,7 @@ public class EnabledNetworkModePreferenceControllerTest {
mockAllowedNetworkTypes(ALLOWED_ALL_NETWORK_TYPE);
mockEnabledNetworkMode(TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
mockAccessFamily(TelephonyManager.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
mController.init(mLifecycle, SUB_ID);
mController.init(SUB_ID);
// NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA = NR | LTE | RAF_TD_SCDMA | GSM | WCDMA
when(mTelephonyManager.getAllowedNetworkTypesForReason(
@@ -241,7 +241,7 @@ public class EnabledNetworkModePreferenceControllerTest {
mockEnabledNetworkMode(TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
mockAccessFamily(TelephonyManager.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
mockAllowedNetworkTypes(DISABLED_5G_NETWORK_TYPE);
mController.init(mLifecycle, SUB_ID);
mController.init(SUB_ID);
// NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA = NR | LTE | RAF_TD_SCDMA | GSM | WCDMA
when(mTelephonyManager.getAllowedNetworkTypesForReason(
@@ -261,7 +261,7 @@ public class EnabledNetworkModePreferenceControllerTest {
mockEnabledNetworkMode(TelephonyManagerConstants.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
mockAccessFamily(TelephonyManager.NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA);
mockAllowedNetworkTypes(DISABLED_5G_NETWORK_TYPE);
mController.init(mLifecycle, SUB_ID);
mController.init(SUB_ID);
// NETWORK_MODE_NR_LTE_TDSCDMA_GSM_WCDMA = NR | LTE | RAF_TD_SCDMA | GSM | WCDMA
when(mTelephonyManager.getAllowedNetworkTypesForReason(
@@ -281,7 +281,7 @@ public class EnabledNetworkModePreferenceControllerTest {
mockAccessFamily(TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA);
mockAllowedNetworkTypes(DISABLED_5G_NETWORK_TYPE);
mController.init(mLifecycle, SUB_ID);
mController.init(SUB_ID);
// NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA = LTE | CDMA | EVDO | GSM | WCDMA
when(mTelephonyManager.getAllowedNetworkTypesForReason(
@@ -304,7 +304,7 @@ public class EnabledNetworkModePreferenceControllerTest {
public void updateState_GlobalDisAllowed5g_GlobalWithoutNR() {
mockAccessFamily(TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA);
mockAllowedNetworkTypes(DISABLED_5G_NETWORK_TYPE);
mController.init(mLifecycle, SUB_ID);
mController.init(SUB_ID);
mPersistableBundle.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
// NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA = NR | LTE | CDMA | EVDO | GSM | WCDMA
@@ -324,7 +324,7 @@ public class EnabledNetworkModePreferenceControllerTest {
public void updateState_GlobalDisAllowed5g_SelectOnGlobal() {
mockAccessFamily(TelephonyManager.NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA);
mockAllowedNetworkTypes(DISABLED_5G_NETWORK_TYPE);
mController.init(mLifecycle, SUB_ID);
mController.init(SUB_ID);
mPersistableBundle.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
// NETWORK_MODE_NR_LTE_CDMA_EVDO_GSM_WCDMA = NR | LTE | CDMA | EVDO | GSM | WCDMA

View File

@@ -32,8 +32,6 @@ import androidx.preference.PreferenceScreen;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -48,8 +46,6 @@ public class DisabledSubscriptionControllerTest {
@Mock
private SubscriptionManager mSubscriptionManager;
@Mock
private Lifecycle mLifecycle;
private PreferenceScreen mScreen;
private PreferenceManager mPreferenceManager;
@@ -72,7 +68,7 @@ public class DisabledSubscriptionControllerTest {
mScreen.addPreference(mCategory);
mController = new DisabledSubscriptionController(mContext, KEY);
mController.init(mLifecycle, SUB_ID);
mController.init(SUB_ID);
}
@Test

View File

@@ -48,7 +48,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.widget.SettingsMainSwitchPreference;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.After;
import org.junit.Before;
@@ -67,8 +66,6 @@ public class MobileNetworkSwitchControllerTest {
private SubscriptionManager mSubscriptionManager;
@Mock
private SubscriptionInfo mSubscription;
@Mock
private Lifecycle mLifecycle;
private PreferenceScreen mScreen;
private PreferenceManager mPreferenceManager;
@@ -94,7 +91,7 @@ public class MobileNetworkSwitchControllerTest {
final String key = "prefKey";
mController = new MobileNetworkSwitchController(mContext, key);
mController.init(mLifecycle, mSubscription.getSubscriptionId());
mController.init(mSubscription.getSubscriptionId());
if (Looper.myLooper() == null) {
Looper.prepare();

View File

@@ -31,7 +31,6 @@ import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import androidx.lifecycle.Lifecycle;
import androidx.preference.SwitchPreference;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -62,8 +61,6 @@ public class AutoSelectPreferenceControllerTest {
private CarrierConfigCache mCarrierConfigCache;
@Mock
private ProgressDialog mProgressDialog;
@Mock
private Lifecycle mLifecycle;
private PersistableBundle mCarrierConfig;
private AutoSelectPreferenceController mController;
@@ -91,7 +88,7 @@ public class AutoSelectPreferenceControllerTest {
mController = new AutoSelectPreferenceController(mContext, "auto_select");
mController.mProgressDialog = mProgressDialog;
mController.mSwitchPreference = mSwitchPreference;
mController.init(mLifecycle, SUB_ID);
mController.init(SUB_ID);
}
@Test
@@ -139,6 +136,6 @@ public class AutoSelectPreferenceControllerTest {
when(mCarrierConfigCache.getConfigForSubId(SUB_ID)).thenReturn(null);
// Should not crash
mController.init(mLifecycle, SUB_ID);
mController.init(SUB_ID);
}
}

View File

@@ -29,7 +29,6 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import androidx.lifecycle.Lifecycle;
import androidx.preference.Preference;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -59,8 +58,6 @@ public class OpenNetworkSelectPagePreferenceControllerTest {
private ServiceState mServiceState;
@Mock
private SubscriptionInfo mSubscriptionInfo;
@Mock
private Lifecycle mLifecycle;
private PersistableBundle mCarrierConfig;
private OpenNetworkSelectPagePreferenceController mController;
@@ -99,7 +96,7 @@ public class OpenNetworkSelectPagePreferenceControllerTest {
super.updateState(mPreference);
}
};
mController.init(mLifecycle, SUB_ID);
mController.init(SUB_ID);
}
@Test