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:
Naveen Kalla
2017-09-19 18:36:03 -07:00
parent 2d6ca03364
commit cac657fdbb
6 changed files with 82 additions and 75 deletions

View File

@@ -38,8 +38,8 @@
<!-- When true enable color temperature setting. -->
<bool name="config_enableColorTemperature">false</bool>
<!-- Whether to show TelphonyMonitor switch in Developer Options -->
<bool name="config_show_telephony_monitor">false</bool>
<!-- Whether to show Connectivity Monitor switch in Developer Options -->
<bool name="config_show_connectivity_monitor">false</bool>
<!-- Whether to show Camera HAL HDR+ switch in Developer Options -->
<bool name="config_show_camera_hal_hdrplus">false</bool>

View File

@@ -8247,8 +8247,14 @@
<!-- 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>
<!-- Toast message letting the user know the how to trigger telephony monitor -->
<string name="telephony_monitor_toast">To apply telephony monitor change, reboot device</string>
<!-- UI debug setting: title for ConnectivityMonitor switch [CHAR LIMIT=50] -->
<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] -->
<string name="camera_hal_hdrplus_switch">Camera HAL HDR+</string>

View File

@@ -159,9 +159,9 @@
android:entryValues="@array/select_logpersist_values" />
<SwitchPreference
android:key="telephony_monitor_switch"
android:title="@string/telephony_monitor_switch"
android:summary="@string/telephony_monitor_switch_summary"/>
android:key="connectivity_monitor_switch"
android:title="@string/connectivity_monitor_switch"
android:summary="@string/connectivity_monitor_switch_summary"/>
<SwitchPreference
android:key="camera_laser_sensor_switch"

View File

@@ -28,14 +28,14 @@ import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.R;
import com.android.settingslib.core.AbstractPreferenceController;
public class TelephonyMonitorPreferenceController extends AbstractPreferenceController implements
public class ConnectivityMonitorPreferenceController extends AbstractPreferenceController implements
PreferenceControllerMixin {
private static final String KEY_TELEPHONY_MONITOR_SWITCH = "telephony_monitor_switch";
private static final String KEY_CONNECTIVITY_MONITOR_SWITCH = "connectivity_monitor_switch";
@VisibleForTesting
static final String BUILD_TYPE = "ro.build.type";
@VisibleForTesting
static final String PROPERTY_TELEPHONY_MONITOR = "persist.radio.enable_tel_mon";
static final String PROPERTY_CONNECTIVITY_MONITOR = "persist.radio.enable_tel_mon";
@VisibleForTesting
static final String ENABLED_STATUS = "enabled";
@@ -48,7 +48,7 @@ public class TelephonyMonitorPreferenceController extends AbstractPreferenceCont
private SwitchPreference mPreference;
public TelephonyMonitorPreferenceController(Context context) {
public ConnectivityMonitorPreferenceController(Context context) {
super(context);
}
@@ -56,19 +56,19 @@ public class TelephonyMonitorPreferenceController extends AbstractPreferenceCont
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
if (isAvailable()) {
mPreference = (SwitchPreference) screen.findPreference(KEY_TELEPHONY_MONITOR_SWITCH);
mPreference.setChecked(isTelephonyMonitorEnabled());
mPreference = (SwitchPreference) screen.findPreference(KEY_CONNECTIVITY_MONITOR_SWITCH);
mPreference.setChecked(isConnectivityMonitorEnabled());
}
}
@Override
public String getPreferenceKey() {
return KEY_TELEPHONY_MONITOR_SWITCH;
return KEY_CONNECTIVITY_MONITOR_SWITCH;
}
@Override
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("eng"));
}
@@ -80,11 +80,11 @@ public class TelephonyMonitorPreferenceController extends AbstractPreferenceCont
@Override
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;
SystemProperties.set(PROPERTY_TELEPHONY_MONITOR,
SystemProperties.set(PROPERTY_CONNECTIVITY_MONITOR,
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();
return true;
}
@@ -101,14 +101,15 @@ public class TelephonyMonitorPreferenceController extends AbstractPreferenceCont
if (!isAvailable()) {
return false;
}
final boolean enabled = isTelephonyMonitorEnabled();
final boolean enabled = isConnectivityMonitorEnabled();
mPreference.setChecked(enabled);
return enabled;
}
private boolean isTelephonyMonitorEnabled() {
final String tmStatus = SystemProperties.get(PROPERTY_TELEPHONY_MONITOR, DISABLED_STATUS);
return ENABLED_STATUS.equals(tmStatus) || USER_ENABLED_STATUS.equals(tmStatus);
private boolean isConnectivityMonitorEnabled() {
final String cmStatus = SystemProperties.get(PROPERTY_CONNECTIVITY_MONITOR,
DISABLED_STATUS);
return ENABLED_STATUS.equals(cmStatus) || USER_ENABLED_STATUS.equals(cmStatus);
}
}

View File

@@ -330,7 +330,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private DevelopmentSwitchBarController mSwitchBarController;
private BugReportPreferenceController mBugReportController;
private BugReportInPowerPreferenceController mBugReportInPowerController;
private TelephonyMonitorPreferenceController mTelephonyMonitorController;
private ConnectivityMonitorPreferenceController mConnectivityMonitorController;
private CameraHalHdrplusPreferenceController mCameraHalHdrplusController;
private CameraLaserSensorPreferenceController mCameraLaserSensorController;
@@ -374,7 +374,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mBugReportController = new BugReportPreferenceController(getActivity());
mBugReportInPowerController = new BugReportInPowerPreferenceController(getActivity());
mTelephonyMonitorController = new TelephonyMonitorPreferenceController(getActivity());
mConnectivityMonitorController = new ConnectivityMonitorPreferenceController(getActivity());
mLogdSizeController = new LogdSizePreferenceController(getActivity());
mLogpersistController = new LogpersistPreferenceController(getActivity(), getLifecycle());
mWebViewAppPrefController = new WebViewAppPreferenceController(getActivity());
@@ -412,7 +412,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mBugReportController.displayPreference(preferenceScreen);
mBugReportInPowerController.displayPreference(preferenceScreen);
mTelephonyMonitorController.displayPreference(preferenceScreen);
mConnectivityMonitorController.displayPreference(preferenceScreen);
mLogdSizeController.displayPreference(preferenceScreen);
mLogpersistController.displayPreference(preferenceScreen);
mWebViewAppPrefController.displayPreference(preferenceScreen);
@@ -624,7 +624,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
}
mEnableAdbController.enablePreference(enabled);
mBugReportInPowerController.enablePreference(enabled);
mTelephonyMonitorController.enablePreference(enabled);
mConnectivityMonitorController.enablePreference(enabled);
mLogdSizeController.enablePreference(enabled);
mLogpersistController.enablePreference(enabled);
mWebViewAppPrefController.enablePreference(enabled);
@@ -774,7 +774,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
== PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}
mHaveDebugSettings |= mBugReportInPowerController.updatePreference();
mHaveDebugSettings |= mTelephonyMonitorController.updatePreference();
mHaveDebugSettings |= mConnectivityMonitorController.updatePreference();
mHaveDebugSettings |= mCameraHalHdrplusController.updatePreference();
mHaveDebugSettings |= mCameraLaserSensorController.updatePreference();
updateSwitchPreference(mKeepScreenOn, Settings.Global.getInt(cr,
@@ -2210,7 +2210,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
return true;
}
if (mTelephonyMonitorController.handlePreferenceTreeClick(preference)) {
if (mConnectivityMonitorController.handlePreferenceTreeClick(preference)) {
return true;
}

View File

@@ -40,7 +40,7 @@ import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class TelephonyMonitorPreferenceControllerTest {
public class ConnectivityMonitorPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
@@ -49,13 +49,13 @@ public class TelephonyMonitorPreferenceControllerTest {
@Mock
private SwitchPreference mPreference;
private TelephonyMonitorPreferenceController mController;
private ConnectivityMonitorPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
SettingsShadowSystemProperties.clear();
mController = new TelephonyMonitorPreferenceController(mContext);
mController = new ConnectivityMonitorPreferenceController(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
when(mPreference.getKey()).thenReturn(mController.getPreferenceKey());
}
@@ -63,10 +63,10 @@ public class TelephonyMonitorPreferenceControllerTest {
@Config(shadows = {SettingsShadowSystemProperties.class})
@Test
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);
SettingsShadowSystemProperties.set(
TelephonyMonitorPreferenceController.BUILD_TYPE, "userdebug");
ConnectivityMonitorPreferenceController.BUILD_TYPE, "userdebug");
assertThat(mController.isAvailable()).isTrue();
}
@@ -74,10 +74,10 @@ public class TelephonyMonitorPreferenceControllerTest {
@Config(shadows = {SettingsShadowSystemProperties.class})
@Test
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);
SettingsShadowSystemProperties.set(
TelephonyMonitorPreferenceController.BUILD_TYPE, "eng");
ConnectivityMonitorPreferenceController.BUILD_TYPE, "eng");
assertThat(mController.isAvailable()).isTrue();
}
@@ -85,10 +85,10 @@ public class TelephonyMonitorPreferenceControllerTest {
@Config(shadows = {SettingsShadowSystemProperties.class})
@Test
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);
SettingsShadowSystemProperties.set(
TelephonyMonitorPreferenceController.BUILD_TYPE, "user");
ConnectivityMonitorPreferenceController.BUILD_TYPE, "user");
assertThat(mController.isAvailable()).isFalse();
}
@@ -96,10 +96,10 @@ public class TelephonyMonitorPreferenceControllerTest {
@Config(shadows = {SettingsShadowSystemProperties.class})
@Test
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);
SettingsShadowSystemProperties.set(
TelephonyMonitorPreferenceController.BUILD_TYPE, "userdebug");
ConnectivityMonitorPreferenceController.BUILD_TYPE, "userdebug");
assertThat(mController.isAvailable()).isFalse();
}
@@ -107,10 +107,10 @@ public class TelephonyMonitorPreferenceControllerTest {
@Config(shadows = {SettingsShadowSystemProperties.class})
@Test
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);
SettingsShadowSystemProperties.set(
TelephonyMonitorPreferenceController.BUILD_TYPE, "eng");
ConnectivityMonitorPreferenceController.BUILD_TYPE, "eng");
assertThat(mController.isAvailable()).isFalse();
}
@@ -118,24 +118,24 @@ public class TelephonyMonitorPreferenceControllerTest {
@Config(shadows = {SettingsShadowSystemProperties.class})
@Test
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);
SettingsShadowSystemProperties.set(
TelephonyMonitorPreferenceController.BUILD_TYPE, "user");
ConnectivityMonitorPreferenceController.BUILD_TYPE, "user");
assertThat(mController.isAvailable()).isFalse();
}
@Config(shadows = {SettingsShadowSystemProperties.class})
@Test
public void displayPreference_telephonyMonitorEnabled_shouldCheckedPreference() {
when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
public void displayPreference_connectivityMonitorEnabled_shouldCheckedPreference() {
when(mContext.getResources().getBoolean(R.bool.config_show_connectivity_monitor))
.thenReturn(true);
SettingsShadowSystemProperties.set(
TelephonyMonitorPreferenceController.PROPERTY_TELEPHONY_MONITOR,
TelephonyMonitorPreferenceController.ENABLED_STATUS);
ConnectivityMonitorPreferenceController.PROPERTY_CONNECTIVITY_MONITOR,
ConnectivityMonitorPreferenceController.ENABLED_STATUS);
SettingsShadowSystemProperties.set(
TelephonyMonitorPreferenceController.BUILD_TYPE, "userdebug");
ConnectivityMonitorPreferenceController.BUILD_TYPE, "userdebug");
mController.displayPreference(mScreen);
@@ -144,14 +144,14 @@ public class TelephonyMonitorPreferenceControllerTest {
@Config(shadows = {SettingsShadowSystemProperties.class})
@Test
public void displayPreference_telephonyMonitorUserEnabled_shouldCheckedPreference() {
when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
public void displayPreference_connectivityMonitorUserEnabled_shouldCheckedPreference() {
when(mContext.getResources().getBoolean(R.bool.config_show_connectivity_monitor))
.thenReturn(true);
SettingsShadowSystemProperties.set(
TelephonyMonitorPreferenceController.PROPERTY_TELEPHONY_MONITOR,
TelephonyMonitorPreferenceController.USER_ENABLED_STATUS);
ConnectivityMonitorPreferenceController.PROPERTY_CONNECTIVITY_MONITOR,
ConnectivityMonitorPreferenceController.USER_ENABLED_STATUS);
SettingsShadowSystemProperties.set(
TelephonyMonitorPreferenceController.BUILD_TYPE, "userdebug");
ConnectivityMonitorPreferenceController.BUILD_TYPE, "userdebug");
mController.displayPreference(mScreen);
@@ -160,14 +160,14 @@ public class TelephonyMonitorPreferenceControllerTest {
@Config(shadows = {SettingsShadowSystemProperties.class})
@Test
public void displayPreference_telephonyMonitorDisabled_shouldUncheckedPreference() {
when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
public void displayPreference_connectivityMonitorDisabled_shouldUncheckedPreference() {
when(mContext.getResources().getBoolean(R.bool.config_show_connectivity_monitor))
.thenReturn(true);
SettingsShadowSystemProperties.set(
TelephonyMonitorPreferenceController.PROPERTY_TELEPHONY_MONITOR,
TelephonyMonitorPreferenceController.DISABLED_STATUS);
ConnectivityMonitorPreferenceController.PROPERTY_CONNECTIVITY_MONITOR,
ConnectivityMonitorPreferenceController.DISABLED_STATUS);
SettingsShadowSystemProperties.set(
TelephonyMonitorPreferenceController.BUILD_TYPE, "userdebug");
ConnectivityMonitorPreferenceController.BUILD_TYPE, "userdebug");
mController.displayPreference(mScreen);
@@ -176,14 +176,14 @@ public class TelephonyMonitorPreferenceControllerTest {
@Config(shadows = {SettingsShadowSystemProperties.class})
@Test
public void displayPreference_telephonyMonitorUserDisabled_shouldUncheckedPreference() {
when(mContext.getResources().getBoolean(R.bool.config_show_telephony_monitor))
public void displayPreference_connectivityMonitorUserDisabled_shouldUncheckedPreference() {
when(mContext.getResources().getBoolean(R.bool.config_show_connectivity_monitor))
.thenReturn(true);
SettingsShadowSystemProperties.set(
TelephonyMonitorPreferenceController.PROPERTY_TELEPHONY_MONITOR,
TelephonyMonitorPreferenceController.USER_DISABLED_STATUS);
ConnectivityMonitorPreferenceController.PROPERTY_CONNECTIVITY_MONITOR,
ConnectivityMonitorPreferenceController.USER_DISABLED_STATUS);
SettingsShadowSystemProperties.set(
TelephonyMonitorPreferenceController.BUILD_TYPE, "userdebug");
ConnectivityMonitorPreferenceController.BUILD_TYPE, "userdebug");
mController.displayPreference(mScreen);
@@ -192,34 +192,34 @@ public class TelephonyMonitorPreferenceControllerTest {
@Config(shadows = {SettingsShadowSystemProperties.class})
@Test
public void handlePreferenceTreeClick_preferenceChecked_shouldEnableTelephonyMonitor() {
public void handlePreferenceTreeClick_preferenceChecked_shouldEnableConnectivityMonitor() {
when(mPreference.isChecked()).thenReturn(true);
when(mContext.getResources().getString(R.string.telephony_monitor_toast))
.thenReturn("To apply telephony monitor change, reboot device");
when(mContext.getResources().getString(R.string.connectivity_monitor_toast))
.thenReturn("To apply connectivity monitor change, reboot device");
mController.handlePreferenceTreeClick(mPreference);
assertThat(TelephonyMonitorPreferenceController.USER_ENABLED_STATUS.equals(
assertThat(ConnectivityMonitorPreferenceController.USER_ENABLED_STATUS.equals(
SystemProperties.get(
TelephonyMonitorPreferenceController.PROPERTY_TELEPHONY_MONITOR,
TelephonyMonitorPreferenceController.DISABLED_STATUS))).isTrue();
ConnectivityMonitorPreferenceController.PROPERTY_CONNECTIVITY_MONITOR,
ConnectivityMonitorPreferenceController.DISABLED_STATUS))).isTrue();
}
@Config(shadows = {SettingsShadowSystemProperties.class})
@Test
public void handlePreferenceTreeClick_preferenceUnchecked_shouldDisableTelephonyMonitor() {
public void handlePreferenceTreeClick_preferenceUnchecked_shouldDisableConnectivityMonitor() {
when(mPreference.isChecked()).thenReturn(false);
when(mContext.getResources().getString(R.string.telephony_monitor_toast))
.thenReturn("To apply telephony monitor change, reboot device");
when(mContext.getResources().getString(R.string.connectivity_monitor_toast))
.thenReturn("To apply connectivity monitor change, reboot device");
mController.handlePreferenceTreeClick(mPreference);
assertThat(TelephonyMonitorPreferenceController.USER_DISABLED_STATUS.equals(
assertThat(ConnectivityMonitorPreferenceController.USER_DISABLED_STATUS.equals(
SystemProperties.get(
TelephonyMonitorPreferenceController.PROPERTY_TELEPHONY_MONITOR,
TelephonyMonitorPreferenceController.DISABLED_STATUS))).isTrue();
ConnectivityMonitorPreferenceController.PROPERTY_CONNECTIVITY_MONITOR,
ConnectivityMonitorPreferenceController.DISABLED_STATUS))).isTrue();
}
}