Rename TelephonyMonitor to ConnectivityMonitor
TelephonyMonitor can be extended to catch WIFI and GPS issues. Bug: 38422753 Test: Unit tests and manual testing Change-Id: I71f9cf75fdc792452dd35a3581ef0f5fcc0c1ab0
This commit is contained in:
@@ -38,8 +38,8 @@
|
|||||||
<!-- When true enable color temperature setting. -->
|
<!-- When true enable color temperature setting. -->
|
||||||
<bool name="config_enableColorTemperature">false</bool>
|
<bool name="config_enableColorTemperature">false</bool>
|
||||||
|
|
||||||
<!-- Whether to show TelphonyMonitor switch in Developer Options -->
|
<!-- Whether to show Connectivity Monitor switch in Developer Options -->
|
||||||
<bool name="config_show_telephony_monitor">false</bool>
|
<bool name="config_show_connectivity_monitor">false</bool>
|
||||||
|
|
||||||
<!-- Whether to show Camera HAL HDR+ switch in Developer Options -->
|
<!-- Whether to show Camera HAL HDR+ switch in Developer Options -->
|
||||||
<bool name="config_show_camera_hal_hdrplus">false</bool>
|
<bool name="config_show_camera_hal_hdrplus">false</bool>
|
||||||
|
@@ -8247,8 +8247,14 @@
|
|||||||
<!-- Toast message letting the user know the color temperature setting is not immediate -->
|
<!-- Toast message letting the user know the color temperature setting is not immediate -->
|
||||||
<string name="color_temperature_toast">To apply color change, turn off screen</string>
|
<string name="color_temperature_toast">To apply color change, turn off screen</string>
|
||||||
|
|
||||||
<!-- Toast message letting the user know the how to trigger telephony monitor -->
|
<!-- UI debug setting: title for ConnectivityMonitor switch [CHAR LIMIT=50] -->
|
||||||
<string name="telephony_monitor_toast">To apply telephony monitor change, reboot device</string>
|
<string name="connectivity_monitor_switch">Connectivity Monitor</string>
|
||||||
|
|
||||||
|
<!-- UI debug setting: summary for switch of ConnectivityMonitor [CHAR LIMIT=500] -->
|
||||||
|
<string name="connectivity_monitor_switch_summary">ConnectivityMonitor will collect logs when it detects a connectivity problem and prompt notification to user to file a bug</string>
|
||||||
|
|
||||||
|
<!-- Toast message letting the user know the how to apply connectivity monitor change -->
|
||||||
|
<string name="connectivity_monitor_toast">To apply connectivity monitor change, reboot device</string>
|
||||||
|
|
||||||
<!-- Title for Camera HAL HDR+ switch [CHAR LIMIT=50] -->
|
<!-- Title for Camera HAL HDR+ switch [CHAR LIMIT=50] -->
|
||||||
<string name="camera_hal_hdrplus_switch">Camera HAL HDR+</string>
|
<string name="camera_hal_hdrplus_switch">Camera HAL HDR+</string>
|
||||||
|
@@ -159,9 +159,9 @@
|
|||||||
android:entryValues="@array/select_logpersist_values" />
|
android:entryValues="@array/select_logpersist_values" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="telephony_monitor_switch"
|
android:key="connectivity_monitor_switch"
|
||||||
android:title="@string/telephony_monitor_switch"
|
android:title="@string/connectivity_monitor_switch"
|
||||||
android:summary="@string/telephony_monitor_switch_summary"/>
|
android:summary="@string/connectivity_monitor_switch_summary"/>
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="camera_laser_sensor_switch"
|
android:key="camera_laser_sensor_switch"
|
||||||
|
@@ -28,14 +28,14 @@ import com.android.settings.core.PreferenceControllerMixin;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
|
||||||
public class TelephonyMonitorPreferenceController extends AbstractPreferenceController implements
|
public class ConnectivityMonitorPreferenceController extends AbstractPreferenceController implements
|
||||||
PreferenceControllerMixin {
|
PreferenceControllerMixin {
|
||||||
|
|
||||||
private static final String KEY_TELEPHONY_MONITOR_SWITCH = "telephony_monitor_switch";
|
private static final String KEY_CONNECTIVITY_MONITOR_SWITCH = "connectivity_monitor_switch";
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String BUILD_TYPE = "ro.build.type";
|
static final String BUILD_TYPE = "ro.build.type";
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String PROPERTY_TELEPHONY_MONITOR = "persist.radio.enable_tel_mon";
|
static final String PROPERTY_CONNECTIVITY_MONITOR = "persist.radio.enable_tel_mon";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String ENABLED_STATUS = "enabled";
|
static final String ENABLED_STATUS = "enabled";
|
||||||
@@ -48,7 +48,7 @@ public class TelephonyMonitorPreferenceController extends AbstractPreferenceCont
|
|||||||
|
|
||||||
private SwitchPreference mPreference;
|
private SwitchPreference mPreference;
|
||||||
|
|
||||||
public TelephonyMonitorPreferenceController(Context context) {
|
public ConnectivityMonitorPreferenceController(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,19 +56,19 @@ public class TelephonyMonitorPreferenceController extends AbstractPreferenceCont
|
|||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
if (isAvailable()) {
|
if (isAvailable()) {
|
||||||
mPreference = (SwitchPreference) screen.findPreference(KEY_TELEPHONY_MONITOR_SWITCH);
|
mPreference = (SwitchPreference) screen.findPreference(KEY_CONNECTIVITY_MONITOR_SWITCH);
|
||||||
mPreference.setChecked(isTelephonyMonitorEnabled());
|
mPreference.setChecked(isConnectivityMonitorEnabled());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPreferenceKey() {
|
public String getPreferenceKey() {
|
||||||
return KEY_TELEPHONY_MONITOR_SWITCH;
|
return KEY_CONNECTIVITY_MONITOR_SWITCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
return mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor) &&
|
return mContext.getResources().getBoolean(R.bool.config_show_connectivity_monitor) &&
|
||||||
(SystemProperties.get(BUILD_TYPE).equals("userdebug") ||
|
(SystemProperties.get(BUILD_TYPE).equals("userdebug") ||
|
||||||
SystemProperties.get(BUILD_TYPE).equals("eng"));
|
SystemProperties.get(BUILD_TYPE).equals("eng"));
|
||||||
}
|
}
|
||||||
@@ -80,11 +80,11 @@ public class TelephonyMonitorPreferenceController extends AbstractPreferenceCont
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||||
if (KEY_TELEPHONY_MONITOR_SWITCH.equals(preference.getKey())) {
|
if (KEY_CONNECTIVITY_MONITOR_SWITCH.equals(preference.getKey())) {
|
||||||
final SwitchPreference switchPreference = (SwitchPreference) preference;
|
final SwitchPreference switchPreference = (SwitchPreference) preference;
|
||||||
SystemProperties.set(PROPERTY_TELEPHONY_MONITOR,
|
SystemProperties.set(PROPERTY_CONNECTIVITY_MONITOR,
|
||||||
switchPreference.isChecked() ? USER_ENABLED_STATUS : USER_DISABLED_STATUS);
|
switchPreference.isChecked() ? USER_ENABLED_STATUS : USER_DISABLED_STATUS);
|
||||||
Toast.makeText(mContext, R.string.telephony_monitor_toast,
|
Toast.makeText(mContext, R.string.connectivity_monitor_toast,
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -101,14 +101,15 @@ public class TelephonyMonitorPreferenceController extends AbstractPreferenceCont
|
|||||||
if (!isAvailable()) {
|
if (!isAvailable()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final boolean enabled = isTelephonyMonitorEnabled();
|
final boolean enabled = isConnectivityMonitorEnabled();
|
||||||
mPreference.setChecked(enabled);
|
mPreference.setChecked(enabled);
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isTelephonyMonitorEnabled() {
|
private boolean isConnectivityMonitorEnabled() {
|
||||||
final String tmStatus = SystemProperties.get(PROPERTY_TELEPHONY_MONITOR, DISABLED_STATUS);
|
final String cmStatus = SystemProperties.get(PROPERTY_CONNECTIVITY_MONITOR,
|
||||||
return ENABLED_STATUS.equals(tmStatus) || USER_ENABLED_STATUS.equals(tmStatus);
|
DISABLED_STATUS);
|
||||||
|
return ENABLED_STATUS.equals(cmStatus) || USER_ENABLED_STATUS.equals(cmStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -330,7 +330,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
private DevelopmentSwitchBarController mSwitchBarController;
|
private DevelopmentSwitchBarController mSwitchBarController;
|
||||||
private BugReportPreferenceController mBugReportController;
|
private BugReportPreferenceController mBugReportController;
|
||||||
private BugReportInPowerPreferenceController mBugReportInPowerController;
|
private BugReportInPowerPreferenceController mBugReportInPowerController;
|
||||||
private TelephonyMonitorPreferenceController mTelephonyMonitorController;
|
private ConnectivityMonitorPreferenceController mConnectivityMonitorController;
|
||||||
private CameraHalHdrplusPreferenceController mCameraHalHdrplusController;
|
private CameraHalHdrplusPreferenceController mCameraHalHdrplusController;
|
||||||
private CameraLaserSensorPreferenceController mCameraLaserSensorController;
|
private CameraLaserSensorPreferenceController mCameraLaserSensorController;
|
||||||
|
|
||||||
@@ -374,7 +374,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
|
|
||||||
mBugReportController = new BugReportPreferenceController(getActivity());
|
mBugReportController = new BugReportPreferenceController(getActivity());
|
||||||
mBugReportInPowerController = new BugReportInPowerPreferenceController(getActivity());
|
mBugReportInPowerController = new BugReportInPowerPreferenceController(getActivity());
|
||||||
mTelephonyMonitorController = new TelephonyMonitorPreferenceController(getActivity());
|
mConnectivityMonitorController = new ConnectivityMonitorPreferenceController(getActivity());
|
||||||
mLogdSizeController = new LogdSizePreferenceController(getActivity());
|
mLogdSizeController = new LogdSizePreferenceController(getActivity());
|
||||||
mLogpersistController = new LogpersistPreferenceController(getActivity(), getLifecycle());
|
mLogpersistController = new LogpersistPreferenceController(getActivity(), getLifecycle());
|
||||||
mWebViewAppPrefController = new WebViewAppPreferenceController(getActivity());
|
mWebViewAppPrefController = new WebViewAppPreferenceController(getActivity());
|
||||||
@@ -412,7 +412,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
|
|
||||||
mBugReportController.displayPreference(preferenceScreen);
|
mBugReportController.displayPreference(preferenceScreen);
|
||||||
mBugReportInPowerController.displayPreference(preferenceScreen);
|
mBugReportInPowerController.displayPreference(preferenceScreen);
|
||||||
mTelephonyMonitorController.displayPreference(preferenceScreen);
|
mConnectivityMonitorController.displayPreference(preferenceScreen);
|
||||||
mLogdSizeController.displayPreference(preferenceScreen);
|
mLogdSizeController.displayPreference(preferenceScreen);
|
||||||
mLogpersistController.displayPreference(preferenceScreen);
|
mLogpersistController.displayPreference(preferenceScreen);
|
||||||
mWebViewAppPrefController.displayPreference(preferenceScreen);
|
mWebViewAppPrefController.displayPreference(preferenceScreen);
|
||||||
@@ -624,7 +624,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
}
|
}
|
||||||
mEnableAdbController.enablePreference(enabled);
|
mEnableAdbController.enablePreference(enabled);
|
||||||
mBugReportInPowerController.enablePreference(enabled);
|
mBugReportInPowerController.enablePreference(enabled);
|
||||||
mTelephonyMonitorController.enablePreference(enabled);
|
mConnectivityMonitorController.enablePreference(enabled);
|
||||||
mLogdSizeController.enablePreference(enabled);
|
mLogdSizeController.enablePreference(enabled);
|
||||||
mLogpersistController.enablePreference(enabled);
|
mLogpersistController.enablePreference(enabled);
|
||||||
mWebViewAppPrefController.enablePreference(enabled);
|
mWebViewAppPrefController.enablePreference(enabled);
|
||||||
@@ -774,7 +774,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
== PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
|
== PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
|
||||||
}
|
}
|
||||||
mHaveDebugSettings |= mBugReportInPowerController.updatePreference();
|
mHaveDebugSettings |= mBugReportInPowerController.updatePreference();
|
||||||
mHaveDebugSettings |= mTelephonyMonitorController.updatePreference();
|
mHaveDebugSettings |= mConnectivityMonitorController.updatePreference();
|
||||||
mHaveDebugSettings |= mCameraHalHdrplusController.updatePreference();
|
mHaveDebugSettings |= mCameraHalHdrplusController.updatePreference();
|
||||||
mHaveDebugSettings |= mCameraLaserSensorController.updatePreference();
|
mHaveDebugSettings |= mCameraLaserSensorController.updatePreference();
|
||||||
updateSwitchPreference(mKeepScreenOn, Settings.Global.getInt(cr,
|
updateSwitchPreference(mKeepScreenOn, Settings.Global.getInt(cr,
|
||||||
@@ -2210,7 +2210,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTelephonyMonitorController.handlePreferenceTreeClick(preference)) {
|
if (mConnectivityMonitorController.handlePreferenceTreeClick(preference)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,7 +40,7 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||||
public class TelephonyMonitorPreferenceControllerTest {
|
public class ConnectivityMonitorPreferenceControllerTest {
|
||||||
|
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@@ -49,13 +49,13 @@ public class TelephonyMonitorPreferenceControllerTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private SwitchPreference mPreference;
|
private SwitchPreference mPreference;
|
||||||
|
|
||||||
private TelephonyMonitorPreferenceController mController;
|
private ConnectivityMonitorPreferenceController mController;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
SettingsShadowSystemProperties.clear();
|
SettingsShadowSystemProperties.clear();
|
||||||
mController = new TelephonyMonitorPreferenceController(mContext);
|
mController = new ConnectivityMonitorPreferenceController(mContext);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
when(mPreference.getKey()).thenReturn(mController.getPreferenceKey());
|
when(mPreference.getKey()).thenReturn(mController.getPreferenceKey());
|
||||||
}
|
}
|
||||||
@@ -63,10 +63,10 @@ public class TelephonyMonitorPreferenceControllerTest {
|
|||||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||||
@Test
|
@Test
|
||||||
public void isAvailable_trueShowFlagWithUserdebugBuild_shouldReturnTrue() {
|
public void isAvailable_trueShowFlagWithUserdebugBuild_shouldReturnTrue() {
|
||||||
when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
|
when(mContext.getResources().getBoolean(R.bool.config_show_connectivity_monitor))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
SettingsShadowSystemProperties.set(
|
SettingsShadowSystemProperties.set(
|
||||||
TelephonyMonitorPreferenceController.BUILD_TYPE, "userdebug");
|
ConnectivityMonitorPreferenceController.BUILD_TYPE, "userdebug");
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
}
|
}
|
||||||
@@ -74,10 +74,10 @@ public class TelephonyMonitorPreferenceControllerTest {
|
|||||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||||
@Test
|
@Test
|
||||||
public void isAvailable_trueShowFlagWithEngBuild_shouldReturnTrue() {
|
public void isAvailable_trueShowFlagWithEngBuild_shouldReturnTrue() {
|
||||||
when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
|
when(mContext.getResources().getBoolean(R.bool.config_show_connectivity_monitor))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
SettingsShadowSystemProperties.set(
|
SettingsShadowSystemProperties.set(
|
||||||
TelephonyMonitorPreferenceController.BUILD_TYPE, "eng");
|
ConnectivityMonitorPreferenceController.BUILD_TYPE, "eng");
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
}
|
}
|
||||||
@@ -85,10 +85,10 @@ public class TelephonyMonitorPreferenceControllerTest {
|
|||||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||||
@Test
|
@Test
|
||||||
public void isAvailable_trueShowFlagWithUserBuild_shouldReturnFalse() {
|
public void isAvailable_trueShowFlagWithUserBuild_shouldReturnFalse() {
|
||||||
when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
|
when(mContext.getResources().getBoolean(R.bool.config_show_connectivity_monitor))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
SettingsShadowSystemProperties.set(
|
SettingsShadowSystemProperties.set(
|
||||||
TelephonyMonitorPreferenceController.BUILD_TYPE, "user");
|
ConnectivityMonitorPreferenceController.BUILD_TYPE, "user");
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
assertThat(mController.isAvailable()).isFalse();
|
||||||
}
|
}
|
||||||
@@ -96,10 +96,10 @@ public class TelephonyMonitorPreferenceControllerTest {
|
|||||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||||
@Test
|
@Test
|
||||||
public void isAvailable_falseShowFlagWithUserdebugBuild_shouldReturnFalse() {
|
public void isAvailable_falseShowFlagWithUserdebugBuild_shouldReturnFalse() {
|
||||||
when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
|
when(mContext.getResources().getBoolean(R.bool.config_show_connectivity_monitor))
|
||||||
.thenReturn(false);
|
.thenReturn(false);
|
||||||
SettingsShadowSystemProperties.set(
|
SettingsShadowSystemProperties.set(
|
||||||
TelephonyMonitorPreferenceController.BUILD_TYPE, "userdebug");
|
ConnectivityMonitorPreferenceController.BUILD_TYPE, "userdebug");
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
assertThat(mController.isAvailable()).isFalse();
|
||||||
}
|
}
|
||||||
@@ -107,10 +107,10 @@ public class TelephonyMonitorPreferenceControllerTest {
|
|||||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||||
@Test
|
@Test
|
||||||
public void isAvailable_falseShowFlagWithEngBuild_shouldReturnFalse() {
|
public void isAvailable_falseShowFlagWithEngBuild_shouldReturnFalse() {
|
||||||
when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
|
when(mContext.getResources().getBoolean(R.bool.config_show_connectivity_monitor))
|
||||||
.thenReturn(false);
|
.thenReturn(false);
|
||||||
SettingsShadowSystemProperties.set(
|
SettingsShadowSystemProperties.set(
|
||||||
TelephonyMonitorPreferenceController.BUILD_TYPE, "eng");
|
ConnectivityMonitorPreferenceController.BUILD_TYPE, "eng");
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
assertThat(mController.isAvailable()).isFalse();
|
||||||
}
|
}
|
||||||
@@ -118,24 +118,24 @@ public class TelephonyMonitorPreferenceControllerTest {
|
|||||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||||
@Test
|
@Test
|
||||||
public void isAvailable_falseShowFlagWithUserBuild_shouldReturnFalse() {
|
public void isAvailable_falseShowFlagWithUserBuild_shouldReturnFalse() {
|
||||||
when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
|
when(mContext.getResources().getBoolean(R.bool.config_show_connectivity_monitor))
|
||||||
.thenReturn(false);
|
.thenReturn(false);
|
||||||
SettingsShadowSystemProperties.set(
|
SettingsShadowSystemProperties.set(
|
||||||
TelephonyMonitorPreferenceController.BUILD_TYPE, "user");
|
ConnectivityMonitorPreferenceController.BUILD_TYPE, "user");
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
assertThat(mController.isAvailable()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||||
@Test
|
@Test
|
||||||
public void displayPreference_telephonyMonitorEnabled_shouldCheckedPreference() {
|
public void displayPreference_connectivityMonitorEnabled_shouldCheckedPreference() {
|
||||||
when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
|
when(mContext.getResources().getBoolean(R.bool.config_show_connectivity_monitor))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
SettingsShadowSystemProperties.set(
|
SettingsShadowSystemProperties.set(
|
||||||
TelephonyMonitorPreferenceController.PROPERTY_TELEPHONY_MONITOR,
|
ConnectivityMonitorPreferenceController.PROPERTY_CONNECTIVITY_MONITOR,
|
||||||
TelephonyMonitorPreferenceController.ENABLED_STATUS);
|
ConnectivityMonitorPreferenceController.ENABLED_STATUS);
|
||||||
SettingsShadowSystemProperties.set(
|
SettingsShadowSystemProperties.set(
|
||||||
TelephonyMonitorPreferenceController.BUILD_TYPE, "userdebug");
|
ConnectivityMonitorPreferenceController.BUILD_TYPE, "userdebug");
|
||||||
|
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
|
||||||
@@ -144,14 +144,14 @@ public class TelephonyMonitorPreferenceControllerTest {
|
|||||||
|
|
||||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||||
@Test
|
@Test
|
||||||
public void displayPreference_telephonyMonitorUserEnabled_shouldCheckedPreference() {
|
public void displayPreference_connectivityMonitorUserEnabled_shouldCheckedPreference() {
|
||||||
when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
|
when(mContext.getResources().getBoolean(R.bool.config_show_connectivity_monitor))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
SettingsShadowSystemProperties.set(
|
SettingsShadowSystemProperties.set(
|
||||||
TelephonyMonitorPreferenceController.PROPERTY_TELEPHONY_MONITOR,
|
ConnectivityMonitorPreferenceController.PROPERTY_CONNECTIVITY_MONITOR,
|
||||||
TelephonyMonitorPreferenceController.USER_ENABLED_STATUS);
|
ConnectivityMonitorPreferenceController.USER_ENABLED_STATUS);
|
||||||
SettingsShadowSystemProperties.set(
|
SettingsShadowSystemProperties.set(
|
||||||
TelephonyMonitorPreferenceController.BUILD_TYPE, "userdebug");
|
ConnectivityMonitorPreferenceController.BUILD_TYPE, "userdebug");
|
||||||
|
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
|
||||||
@@ -160,14 +160,14 @@ public class TelephonyMonitorPreferenceControllerTest {
|
|||||||
|
|
||||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||||
@Test
|
@Test
|
||||||
public void displayPreference_telephonyMonitorDisabled_shouldUncheckedPreference() {
|
public void displayPreference_connectivityMonitorDisabled_shouldUncheckedPreference() {
|
||||||
when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
|
when(mContext.getResources().getBoolean(R.bool.config_show_connectivity_monitor))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
SettingsShadowSystemProperties.set(
|
SettingsShadowSystemProperties.set(
|
||||||
TelephonyMonitorPreferenceController.PROPERTY_TELEPHONY_MONITOR,
|
ConnectivityMonitorPreferenceController.PROPERTY_CONNECTIVITY_MONITOR,
|
||||||
TelephonyMonitorPreferenceController.DISABLED_STATUS);
|
ConnectivityMonitorPreferenceController.DISABLED_STATUS);
|
||||||
SettingsShadowSystemProperties.set(
|
SettingsShadowSystemProperties.set(
|
||||||
TelephonyMonitorPreferenceController.BUILD_TYPE, "userdebug");
|
ConnectivityMonitorPreferenceController.BUILD_TYPE, "userdebug");
|
||||||
|
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
|
||||||
@@ -176,14 +176,14 @@ public class TelephonyMonitorPreferenceControllerTest {
|
|||||||
|
|
||||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||||
@Test
|
@Test
|
||||||
public void displayPreference_telephonyMonitorUserDisabled_shouldUncheckedPreference() {
|
public void displayPreference_connectivityMonitorUserDisabled_shouldUncheckedPreference() {
|
||||||
when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
|
when(mContext.getResources().getBoolean(R.bool.config_show_connectivity_monitor))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
SettingsShadowSystemProperties.set(
|
SettingsShadowSystemProperties.set(
|
||||||
TelephonyMonitorPreferenceController.PROPERTY_TELEPHONY_MONITOR,
|
ConnectivityMonitorPreferenceController.PROPERTY_CONNECTIVITY_MONITOR,
|
||||||
TelephonyMonitorPreferenceController.USER_DISABLED_STATUS);
|
ConnectivityMonitorPreferenceController.USER_DISABLED_STATUS);
|
||||||
SettingsShadowSystemProperties.set(
|
SettingsShadowSystemProperties.set(
|
||||||
TelephonyMonitorPreferenceController.BUILD_TYPE, "userdebug");
|
ConnectivityMonitorPreferenceController.BUILD_TYPE, "userdebug");
|
||||||
|
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
|
||||||
@@ -192,34 +192,34 @@ public class TelephonyMonitorPreferenceControllerTest {
|
|||||||
|
|
||||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||||
@Test
|
@Test
|
||||||
public void handlePreferenceTreeClick_preferenceChecked_shouldEnableTelephonyMonitor() {
|
public void handlePreferenceTreeClick_preferenceChecked_shouldEnableConnectivityMonitor() {
|
||||||
when(mPreference.isChecked()).thenReturn(true);
|
when(mPreference.isChecked()).thenReturn(true);
|
||||||
|
|
||||||
when(mContext.getResources().getString(R.string.telephony_monitor_toast))
|
when(mContext.getResources().getString(R.string.connectivity_monitor_toast))
|
||||||
.thenReturn("To apply telephony monitor change, reboot device");
|
.thenReturn("To apply connectivity monitor change, reboot device");
|
||||||
|
|
||||||
mController.handlePreferenceTreeClick(mPreference);
|
mController.handlePreferenceTreeClick(mPreference);
|
||||||
|
|
||||||
assertThat(TelephonyMonitorPreferenceController.USER_ENABLED_STATUS.equals(
|
assertThat(ConnectivityMonitorPreferenceController.USER_ENABLED_STATUS.equals(
|
||||||
SystemProperties.get(
|
SystemProperties.get(
|
||||||
TelephonyMonitorPreferenceController.PROPERTY_TELEPHONY_MONITOR,
|
ConnectivityMonitorPreferenceController.PROPERTY_CONNECTIVITY_MONITOR,
|
||||||
TelephonyMonitorPreferenceController.DISABLED_STATUS))).isTrue();
|
ConnectivityMonitorPreferenceController.DISABLED_STATUS))).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||||
@Test
|
@Test
|
||||||
public void handlePreferenceTreeClick_preferenceUnchecked_shouldDisableTelephonyMonitor() {
|
public void handlePreferenceTreeClick_preferenceUnchecked_shouldDisableConnectivityMonitor() {
|
||||||
when(mPreference.isChecked()).thenReturn(false);
|
when(mPreference.isChecked()).thenReturn(false);
|
||||||
|
|
||||||
when(mContext.getResources().getString(R.string.telephony_monitor_toast))
|
when(mContext.getResources().getString(R.string.connectivity_monitor_toast))
|
||||||
.thenReturn("To apply telephony monitor change, reboot device");
|
.thenReturn("To apply connectivity monitor change, reboot device");
|
||||||
|
|
||||||
mController.handlePreferenceTreeClick(mPreference);
|
mController.handlePreferenceTreeClick(mPreference);
|
||||||
|
|
||||||
assertThat(TelephonyMonitorPreferenceController.USER_DISABLED_STATUS.equals(
|
assertThat(ConnectivityMonitorPreferenceController.USER_DISABLED_STATUS.equals(
|
||||||
SystemProperties.get(
|
SystemProperties.get(
|
||||||
TelephonyMonitorPreferenceController.PROPERTY_TELEPHONY_MONITOR,
|
ConnectivityMonitorPreferenceController.PROPERTY_CONNECTIVITY_MONITOR,
|
||||||
TelephonyMonitorPreferenceController.DISABLED_STATUS))).isTrue();
|
ConnectivityMonitorPreferenceController.DISABLED_STATUS))).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user