Add a boolean flag to show or hide the device name in About device.

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
This commit is contained in:
Prabir Pradhan
2018-07-25 13:55:56 -07:00
parent f24b749ec0
commit 7758fcc6dd
4 changed files with 22 additions and 1 deletions

View 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 -->

View 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

View 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">

View 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;
@@ -79,6 +82,17 @@ public class DeviceNamePreferenceControllerTest {
mController.setLocalBluetoothManager(mBluetoothManager);
}
@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);