OSDN Git Service

Add a boolean flag to show or hide the device name in About device.
authorPrabir Pradhan <prabirmsp@google.com>
Wed, 25 Jul 2018 20:55:56 +0000 (13:55 -0700)
committerPrabir Pradhan <prabirmsp@google.com>
Thu, 26 Jul 2018 00:06:21 +0000 (17:06 -0700)
The following boolean flag is added:
config_show_device_name

When set to false, the device name will not be shown in System > About
Device.

Bug: 111653180
Test: Updated robotests
Change-Id: Id9610e2009604c9d9693428adff01adc7d606565

res/values/bools.xml
src/com/android/settings/deviceinfo/DeviceNamePreferenceController.java
tests/robotests/res/values-mcc999/config.xml
tests/robotests/src/com/android/settings/deviceinfo/DeviceNamePreferenceControllerTest.java

index b406605..08bb08c 100644 (file)
@@ -32,6 +32,9 @@
          Can be overridden for specific product builds. -->
     <bool name="auto_confirm_bluetooth_activation_dialog">false</bool>
 
+    <!-- Whether the device name is shown in About device or not -->
+    <bool name="config_show_device_name">true</bool>
+
     <!-- Whether to show a preference item for the manual in About phone -->
     <bool name="config_show_manual">false</bool>
     <!-- Whether to show a preference item for regulatory information in About phone -->
index 0d4df99..558e7cb 100644 (file)
@@ -27,6 +27,7 @@ import android.text.SpannedString;
 
 import com.android.settings.bluetooth.BluetoothLengthDeviceNameFilter;
 import com.android.settings.core.BasePreferenceController;
+import com.android.settings.R;
 import com.android.settings.widget.ValidatedEditTextPreference;
 import com.android.settings.wifi.tether.WifiDeviceNameTextValidator;
 import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
@@ -90,7 +91,9 @@ public class DeviceNamePreferenceController extends BasePreferenceController
 
     @Override
     public int getAvailabilityStatus() {
-        return AVAILABLE;
+        return mContext.getResources().getBoolean(R.bool.config_show_device_name)
+                ? AVAILABLE
+                : UNSUPPORTED_ON_DEVICE;
     }
 
     @Override
index 2d95b65..6d82451 100644 (file)
@@ -61,6 +61,7 @@
     <bool name="config_show_wifi_ip_address">false</bool>
     <bool name="config_show_wifi_mac_address">false</bool>
     <bool name="config_disable_uninstall_update">true</bool>
+    <bool name="config_show_device_name">false</bool>
 
     <!-- List of a11y components on the device allowed to be enabled by Settings Slices -->
     <string-array name="config_settings_slices_accessibility_components" translatable="false">
index 0e6bf8d..68b48a8 100644 (file)
@@ -16,6 +16,8 @@
 
 package com.android.settings.deviceinfo;
 
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
 import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.eq;
@@ -41,6 +43,7 @@ import org.mockito.Answers;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowApplication;
 
 import androidx.preference.PreferenceScreen;
@@ -80,6 +83,17 @@ public class DeviceNamePreferenceControllerTest {
     }
 
     @Test
+    public void getAvailibilityStatus_availableByDefault() {
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+    }
+
+    @Test
+    @Config(qualifiers = "mcc999")
+    public void getAvailabilityStatus_unsupportedWhenSet() {
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+    }
+
+    @Test
     public void constructor_defaultDeviceNameIsModelName() {
         assertThat(mController.getSummary()).isEqualTo(Build.MODEL);
     }