Merge "Removed reference to RadioAccessFamily"

This commit is contained in:
Treehugger Robot
2020-01-09 02:09:10 +00:00
committed by Gerrit Code Review
9 changed files with 303 additions and 129 deletions

View File

@@ -25,7 +25,6 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -45,6 +44,7 @@ import androidx.preference.ListPreference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
@@ -171,12 +171,12 @@ public class EnabledNetworkModePreferenceControllerTest {
public void updateState_updateByNetworkMode() {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
TelephonyManager.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
mController.updateState(mPreference);
assertThat(mPreference.getValue()).isEqualTo(
String.valueOf(TelephonyManager.NETWORK_MODE_TDSCDMA_GSM_WCDMA));
String.valueOf(TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA));
assertThat(mPreference.getSummary()).isEqualTo("3G");
}
@@ -184,12 +184,12 @@ public class EnabledNetworkModePreferenceControllerTest {
public void updateState_updateByNetworkMode_useDefaultValue() {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);
TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA);
mController.updateState(mPreference);
assertThat(mPreference.getValue()).isEqualTo(
String.valueOf(TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA));
String.valueOf(TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA));
}
/**
@@ -392,27 +392,27 @@ public class EnabledNetworkModePreferenceControllerTest {
@Test
public void onPreferenceChange_updateSuccess() {
doReturn(true).when(mTelephonyManager).setPreferredNetworkType(SUB_ID,
TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);
TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA);
mController.onPreferenceChange(mPreference,
String.valueOf(TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA));
String.valueOf(TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA));
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID, 0)).isEqualTo(
TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);
TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA);
}
@Test
public void onPreferenceChange_updateFail() {
doReturn(false).when(mTelephonyManager).setPreferredNetworkType(SUB_ID,
TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);
TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA);
mController.onPreferenceChange(mPreference,
String.valueOf(TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA));
String.valueOf(TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA));
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID, 0)).isNotEqualTo(
TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);
TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA);
}
@Test
@@ -421,24 +421,24 @@ public class EnabledNetworkModePreferenceControllerTest {
doReturn(mPreference).when(screen).findPreference(KEY);
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
TelephonyManager.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
mController.displayPreference(screen);
mController.updateState(mPreference);
mLifecycle.handleLifecycleEvent(ON_START);
assertThat(Integer.parseInt(mPreference.getValue())).isEqualTo(
TelephonyManager.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
assertThat(mPreference.getSummary()).isEqualTo("3G");
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
TelephonyManager.NETWORK_MODE_GSM_ONLY);
TelephonyManagerConstants.NETWORK_MODE_GSM_ONLY);
final Uri uri = Settings.Global.getUriFor(Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID);
mContext.getContentResolver().notifyChange(uri, null);
assertThat(Integer.parseInt(mPreference.getValue())).isEqualTo(
TelephonyManager.NETWORK_MODE_GSM_ONLY);
TelephonyManagerConstants.NETWORK_MODE_GSM_ONLY);
assertThat(mPreference.getSummary()).isEqualTo("2G");
}
}

View File

@@ -41,6 +41,7 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import com.android.internal.telephony.PhoneConstants;
import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
import org.junit.Before;
import org.junit.Test;
@@ -181,7 +182,7 @@ public class MobileNetworkUtilsTest {
Settings.Global.putInt(mContext.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);
TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA);
assertThat(MobileNetworkUtils.isCdmaOptions(mContext, SUB_ID_1)).isTrue();
}
@@ -255,7 +256,7 @@ public class MobileNetworkUtilsTest {
Settings.Global.putInt(mContext.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM);
TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_GSM);
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
}
@@ -266,7 +267,7 @@ public class MobileNetworkUtilsTest {
Settings.Global.putInt(mContext.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA);
TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA);
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
}
@@ -277,7 +278,7 @@ public class MobileNetworkUtilsTest {
Settings.Global.putInt(mContext.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
TelephonyManager.NETWORK_MODE_LTE_TDSCDMA);
TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA);
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
}
@@ -288,7 +289,7 @@ public class MobileNetworkUtilsTest {
Settings.Global.putInt(mContext.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_WCDMA);
TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_WCDMA);
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
}
@@ -299,7 +300,7 @@ public class MobileNetworkUtilsTest {
Settings.Global.putInt(mContext.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA);
TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA);
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
}
@@ -310,7 +311,7 @@ public class MobileNetworkUtilsTest {
Settings.Global.putInt(mContext.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA);
TelephonyManagerConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA);
assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
}

View File

@@ -37,6 +37,7 @@ import androidx.fragment.app.FragmentManager;
import androidx.preference.ListPreference;
import com.android.settings.R;
import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
import org.junit.Before;
import org.junit.Test;
@@ -127,12 +128,12 @@ public class PreferredNetworkModePreferenceControllerTest {
public void updateState_updateByNetworkMode() {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
TelephonyManager.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA);
mController.updateState(mPreference);
assertThat(mPreference.getValue()).isEqualTo(
String.valueOf(TelephonyManager.NETWORK_MODE_TDSCDMA_GSM_WCDMA));
String.valueOf(TelephonyManagerConstants.NETWORK_MODE_TDSCDMA_GSM_WCDMA));
assertThat(mPreference.getSummary()).isEqualTo(
mContext.getString(R.string.preferred_network_mode_tdscdma_gsm_wcdma_summary));
}
@@ -140,26 +141,26 @@ public class PreferredNetworkModePreferenceControllerTest {
@Test
public void onPreferenceChange_updateSuccess() {
doReturn(true).when(mTelephonyManager).setPreferredNetworkType(SUB_ID,
TelephonyManager.NETWORK_MODE_LTE_TDSCDMA);
TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA);
mController.onPreferenceChange(mPreference,
String.valueOf(TelephonyManager.NETWORK_MODE_LTE_TDSCDMA));
String.valueOf(TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA));
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID, 0)).isEqualTo(
TelephonyManager.NETWORK_MODE_LTE_TDSCDMA);
TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA);
}
@Test
public void onPreferenceChange_updateFail() {
doReturn(false).when(mTelephonyManager).setPreferredNetworkType(SUB_ID,
TelephonyManager.NETWORK_MODE_LTE_TDSCDMA);
TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA);
mController.onPreferenceChange(mPreference,
String.valueOf(TelephonyManager.NETWORK_MODE_LTE_TDSCDMA));
String.valueOf(TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA));
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID, 0)).isNotEqualTo(
TelephonyManager.NETWORK_MODE_LTE_TDSCDMA);
TelephonyManagerConstants.NETWORK_MODE_LTE_TDSCDMA);
}
}

View File

@@ -33,6 +33,8 @@ import android.telephony.TelephonyManager;
import androidx.preference.ListPreference;
import androidx.preference.PreferenceManager;
import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -118,7 +120,7 @@ public class CdmaSystemSelectPreferenceControllerTest {
mTelephonyManager).getCdmaRoamingMode();
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID,
TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA);
TelephonyManagerConstants.NETWORK_MODE_LTE_GSM_WCDMA);
mController.updateState(mPreference);