From 78c3f368c3a64197dee84df24547449220d36e2a Mon Sep 17 00:00:00 2001 From: Salvador Martinez Date: Mon, 9 Jul 2018 11:52:34 -0700 Subject: [PATCH 1/7] Fix incorrect method call to wifiManager in Tether In the WifiTetherApBandController the incorrect method was being called to check if the device is 5Ghz compatible. We were calling is5GhzBandSupported directly, but we were supposed to call isDualBandSupported instead. Test: robotests updated Bug: 110793581 Change-Id: I61d3ff10abedde6196b8e29591ebfd3272dbbcd9 --- .../WifiTetherApBandPreferenceController.java | 2 +- .../WifiTetherApBandPreferenceControllerTest.java | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java index 2624c736327..1eda72d7bae 100644 --- a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java +++ b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java @@ -103,7 +103,7 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen // 3: With Dual mode support we can't have AP_BAND_5GHZ - default to ANY if (!isDualMode && WifiConfiguration.AP_BAND_ANY == band) { return WifiConfiguration.AP_BAND_5GHZ; - } else if (!mWifiManager.is5GHzBandSupported() && WifiConfiguration.AP_BAND_5GHZ == band) { + } else if (!is5GhzBandSupported() && WifiConfiguration.AP_BAND_5GHZ == band) { return WifiConfiguration.AP_BAND_2GHZ; } else if (isDualMode && WifiConfiguration.AP_BAND_5GHZ == band) { return WifiConfiguration.AP_BAND_ANY; diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java index 8df62c3c02e..c9a9c0040ec 100644 --- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java @@ -104,6 +104,7 @@ public class WifiTetherApBandPreferenceControllerTest { @Test public void display_5GhzNotSupported_shouldDisable() { + when(mWifiManager.getCountryCode()).thenReturn("US"); when(mWifiManager.isDualBandSupported()).thenReturn(false); mController.displayPreference(mScreen); @@ -115,7 +116,8 @@ public class WifiTetherApBandPreferenceControllerTest { @Test public void changePreference_noDualModeWith5G_shouldUpdateValue() { - when(mWifiManager.is5GHzBandSupported()).thenReturn(true); + when(mWifiManager.getCountryCode()).thenReturn("US"); + when(mWifiManager.isDualBandSupported()).thenReturn(true); mController.displayPreference(mScreen); @@ -141,7 +143,8 @@ public class WifiTetherApBandPreferenceControllerTest { @Test public void changePreference_dualModeWith5G_shouldUpdateValue() { - when(mWifiManager.is5GHzBandSupported()).thenReturn(true); + when(mWifiManager.getCountryCode()).thenReturn("US"); + when(mWifiManager.isDualBandSupported()).thenReturn(true); when(mWifiManager.isDualModeSupported()).thenReturn(true); mController.displayPreference(mScreen); @@ -167,14 +170,16 @@ public class WifiTetherApBandPreferenceControllerTest { @Test public void updateDisplay_shouldUpdateValue() { + when(mWifiManager.getCountryCode()).thenReturn("US"); + when(mWifiManager.isDualBandSupported()).thenReturn(true); + // Set controller band index to 1 and verify is set. - when(mWifiManager.is5GHzBandSupported()).thenReturn(true); mController.displayPreference(mScreen); mController.onPreferenceChange(mPreference, "1"); assertThat(mController.getBandIndex()).isEqualTo(1); // Disable 5Ghz band - when(mWifiManager.is5GHzBandSupported()).thenReturn(false); + when(mWifiManager.isDualBandSupported()).thenReturn(false); // Call updateDisplay and verify it's changed. mController.updateDisplay(); From d7d1e8063aa692e09850a4b79f4903048b3380cc Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Mon, 9 Jul 2018 16:45:22 -0700 Subject: [PATCH 2/7] Fix NPE when querying AmbientDisply through ExternalSeting Bug: 110403709 Test: manual Change-Id: I5c037b010e296cbd011f8c141932e6befd341c99 --- ...playNotificationsPreferenceController.java | 16 ++++++++++----- .../PickupGesturePreferenceController.java | 20 +++++++++++-------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java b/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java index cae56715107..b3c182252f7 100644 --- a/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java +++ b/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java @@ -68,7 +68,7 @@ public class AmbientDisplayNotificationsPreferenceController extends @Override public boolean isChecked() { - return mConfig.pulseOnNotificationEnabled(MY_USER); + return getAmbientConfig().pulseOnNotificationEnabled(MY_USER); } @Override @@ -79,14 +79,20 @@ public class AmbientDisplayNotificationsPreferenceController extends @Override public int getAvailabilityStatus() { - if (mConfig == null) { - mConfig = new AmbientDisplayConfiguration(mContext); - } - return mConfig.pulseOnNotificationAvailable() ? AVAILABLE : UNSUPPORTED_ON_DEVICE; + return getAmbientConfig().pulseOnNotificationAvailable() + ? AVAILABLE : UNSUPPORTED_ON_DEVICE; } @Override public boolean isSliceable() { return TextUtils.equals(getPreferenceKey(), "ambient_display_notification"); } + + private AmbientDisplayConfiguration getAmbientConfig() { + if (mConfig == null) { + mConfig = new AmbientDisplayConfiguration(mContext); + } + + return mConfig; + } } diff --git a/src/com/android/settings/gestures/PickupGesturePreferenceController.java b/src/com/android/settings/gestures/PickupGesturePreferenceController.java index 430361c1707..53a4447cbe0 100644 --- a/src/com/android/settings/gestures/PickupGesturePreferenceController.java +++ b/src/com/android/settings/gestures/PickupGesturePreferenceController.java @@ -62,17 +62,13 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll @Override public int getAvailabilityStatus() { - if (mAmbientConfig == null) { - mAmbientConfig = new AmbientDisplayConfiguration(mContext); - } - // No hardware support for Pickup Gesture - if (!mAmbientConfig.dozePulsePickupSensorAvailable()) { + if (!getAmbientConfig().dozePulsePickupSensorAvailable()) { return UNSUPPORTED_ON_DEVICE; } // Can't change Pickup Gesture when AOD is enabled. - if (!mAmbientConfig.ambientDisplayAvailable()) { + if (!getAmbientConfig().ambientDisplayAvailable()) { return DISABLED_DEPENDENT_SETTING; } @@ -91,7 +87,7 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll @Override public boolean isChecked() { - return mAmbientConfig.pulseOnPickupEnabled(mUserId); + return getAmbientConfig().pulseOnPickupEnabled(mUserId); } @Override @@ -112,6 +108,14 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll @VisibleForTesting boolean pulseOnPickupCanBeModified() { - return mAmbientConfig.pulseOnPickupCanBeModified(mUserId); + return getAmbientConfig().pulseOnPickupCanBeModified(mUserId); + } + + private AmbientDisplayConfiguration getAmbientConfig() { + if (mAmbientConfig == null) { + mAmbientConfig = new AmbientDisplayConfiguration(mContext); + } + + return mAmbientConfig; } } From 9c75b6513eba034e3081e7f0ab24d777318d4c40 Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Tue, 10 Jul 2018 09:46:32 -0700 Subject: [PATCH 3/7] Update airplane mode pref key so it's sliceable. Bug: 110403709 Test: rebuild slice db Change-Id: I16e13ec67705754fc55d8c797f94e407f617722c --- res/xml/network_and_internet.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/xml/network_and_internet.xml b/res/xml/network_and_internet.xml index 6eda0b09669..0d130e06b81 100644 --- a/res/xml/network_and_internet.xml +++ b/res/xml/network_and_internet.xml @@ -68,7 +68,7 @@ settings:useAdminDisabledSummary="true" /> Date: Tue, 10 Jul 2018 10:20:43 -0700 Subject: [PATCH 4/7] Fixed various strings & limits Fixes: 111170847 Fixes: 111137762 Fixes: 111174545 Fixes: 111174330 Fixes: 111174332 Fixes: 111173644 Test: builds Change-Id: Ia39fe7b70a1bb5ac6f71c8244268aab51deed0ee --- res/values/strings.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 2d80b855dd2..01ca294e2bd 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -879,26 +879,26 @@ Screen lock - + Face added - + Tap to set up face authentication - + Face authentication Cancel - + Unlock with your face Use your face to authenticate Use your face to unlock your phone, authorize purchases, or sign in to apps. - Use you + Use your face to unlock your phone or approve purchases.\n\nNote: You can\u2019t use your face to unlock this device. For more information, contact your organization\u2019s admin. Use your face to unlock your phone, authorize purchases, or sign in to apps - You can add up to %d fingerprints + You can add up to %d faces You\u2019ve added the maximum number of faces From b0eab98754735c567f683993f718079072117a6b Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Tue, 10 Jul 2018 11:25:18 -0700 Subject: [PATCH 5/7] Update auto brightness pref summary to show on/off Change-Id: I7914957cc9dbffcc12e34fc714bb9c37783a4f33 Fixes: 109885418 Test: robotests --- res/values/strings.xml | 6 +- res/xml/display_settings.xml | 2 +- .../AutoBrightnessPreferenceController.java | 8 +++ ...utoBrightnessPreferenceControllerTest.java | 61 ++++++++++++------- 4 files changed, 52 insertions(+), 25 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index b88c6118a8e..a17a0654299 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -2568,9 +2568,9 @@ Adjust the brightness of the screen Adaptive brightness - - Optimize brightness level for available light - + + On + Off Preferred brightness is very low diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml index bbf2883c4fb..0686bdb1bf8 100644 --- a/res/xml/display_settings.xml +++ b/res/xml/display_settings.xml @@ -42,7 +42,7 @@ diff --git a/src/com/android/settings/display/AutoBrightnessPreferenceController.java b/src/com/android/settings/display/AutoBrightnessPreferenceController.java index 3661056667b..3b7a076f0f3 100644 --- a/src/com/android/settings/display/AutoBrightnessPreferenceController.java +++ b/src/com/android/settings/display/AutoBrightnessPreferenceController.java @@ -21,6 +21,7 @@ import android.content.Context; import android.provider.Settings; import android.text.TextUtils; +import com.android.settings.R; import com.android.settings.core.TogglePreferenceController; @@ -59,4 +60,11 @@ public class AutoBrightnessPreferenceController extends TogglePreferenceControll public boolean isSliceable() { return TextUtils.equals(getPreferenceKey(), "auto_brightness"); } + + @Override + public CharSequence getSummary() { + return mContext.getText(isChecked() + ? R.string.auto_brightness_summary_on + : R.string.auto_brightness_summary_off); + } } \ No newline at end of file diff --git a/tests/robotests/src/com/android/settings/display/AutoBrightnessPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AutoBrightnessPreferenceControllerTest.java index 188cb92a646..5ceb70f2f86 100644 --- a/tests/robotests/src/com/android/settings/display/AutoBrightnessPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/display/AutoBrightnessPreferenceControllerTest.java @@ -25,6 +25,7 @@ import android.content.ContentResolver; import android.content.Context; import android.provider.Settings; +import com.android.settings.R; import com.android.settings.testutils.SettingsRobolectricTestRunner; import org.junit.Before; @@ -52,50 +53,68 @@ public class AutoBrightnessPreferenceControllerTest { } @Test - public void testOnPreferenceChange_TurnOnAuto_ReturnAuto() { + public void onPreferenceChange_TurnOnAuto_ReturnAuto() { mController.onPreferenceChange(null, true); final int mode = Settings.System.getInt(mContentResolver, SCREEN_BRIGHTNESS_MODE, - SCREEN_BRIGHTNESS_MODE_MANUAL); + SCREEN_BRIGHTNESS_MODE_MANUAL); assertThat(mode).isEqualTo(SCREEN_BRIGHTNESS_MODE_AUTOMATIC); } @Test - public void testOnPreferenceChange_TurnOffAuto_ReturnManual() { + public void onPreferenceChange_TurnOffAuto_ReturnManual() { mController.onPreferenceChange(null, false); final int mode = Settings.System.getInt(mContentResolver, SCREEN_BRIGHTNESS_MODE, - SCREEN_BRIGHTNESS_MODE_AUTOMATIC); + SCREEN_BRIGHTNESS_MODE_AUTOMATIC); assertThat(mode).isEqualTo(SCREEN_BRIGHTNESS_MODE_MANUAL); } @Test - public void testSetValue_updatesCorrectly() { - boolean newValue = true; - Settings.System.putInt(mContentResolver, SCREEN_BRIGHTNESS_MODE, - SCREEN_BRIGHTNESS_MODE_MANUAL); + public void setChecked_updatesCorrectly() { + mController.setChecked(true); - mController.setChecked(newValue); - boolean updatedValue = Settings.System.getInt(mContentResolver, SCREEN_BRIGHTNESS_MODE, -1) - != SCREEN_BRIGHTNESS_MODE_MANUAL; + assertThat(mController.isChecked()).isTrue(); - assertThat(updatedValue).isEqualTo(newValue); + mController.setChecked(false); + + assertThat(mController.isChecked()).isFalse(); } @Test - public void testGetValue_correctValueReturned() { + public void isChecked_no() { Settings.System.putInt(mContentResolver, SCREEN_BRIGHTNESS_MODE, - SCREEN_BRIGHTNESS_MODE_AUTOMATIC); + SCREEN_BRIGHTNESS_MODE_MANUAL); - int newValue = mController.isChecked() ? - SCREEN_BRIGHTNESS_MODE_AUTOMATIC - : SCREEN_BRIGHTNESS_MODE_MANUAL; - - assertThat(newValue).isEqualTo(SCREEN_BRIGHTNESS_MODE_AUTOMATIC); + assertThat(mController.isChecked()).isFalse(); } @Test - public void isSliceableCorrectKey_returnsTrue() { + public void isChecked_yes() { + Settings.System.putInt(mContentResolver, SCREEN_BRIGHTNESS_MODE, + SCREEN_BRIGHTNESS_MODE_AUTOMATIC); + + assertThat(mController.isChecked()).isTrue(); + } + + @Test + public void getSummary_settingOn_shouldReturnOnSummary() { + mController.setChecked(true); + + assertThat(mController.getSummary()) + .isEqualTo(mContext.getText(R.string.auto_brightness_summary_on)); + } + + @Test + public void getSummary_settingOff_shouldReturnOffSummary() { + mController.setChecked(false); + + assertThat(mController.getSummary()) + .isEqualTo(mContext.getText(R.string.auto_brightness_summary_off)); + } + + @Test + public void isSliceable_correctKey_returnsTrue() { final AutoBrightnessPreferenceController controller = new AutoBrightnessPreferenceController(mContext, "auto_brightness"); @@ -103,7 +122,7 @@ public class AutoBrightnessPreferenceControllerTest { } @Test - public void isSliceableIncorrectKey_returnsFalse() { + public void isSliceable_incorrectKey_returnsFalse() { final AutoBrightnessPreferenceController controller = new AutoBrightnessPreferenceController(mContext, "bad_key"); assertThat(controller.isSliceable()).isFalse(); From af129e4f6b335fb9b3b5431b7d3b185c2a6eca0c Mon Sep 17 00:00:00 2001 From: jackqdyulei Date: Tue, 10 Jul 2018 11:26:35 -0700 Subject: [PATCH 6/7] Remove DeviceProfilesSettings It's not used anymore since we have a bt detail page. Change-Id: Ib2ecfabf544913701ca613048e9f37e297ffff18 Fixes: 111305587 Test: robo still pass --- res/layout/device_profiles_settings.xml | 69 --- res/values/dimens.xml | 1 - res/values/strings.xml | 8 - res/values/styles.xml | 7 - .../bluetooth/DeviceProfilesSettings.java | 434 ------------------ .../bluetooth/DeviceProfilesSettingsTest.java | 204 -------- 6 files changed, 723 deletions(-) delete mode 100644 res/layout/device_profiles_settings.xml delete mode 100644 src/com/android/settings/bluetooth/DeviceProfilesSettings.java delete mode 100644 tests/robotests/src/com/android/settings/bluetooth/DeviceProfilesSettingsTest.java diff --git a/res/layout/device_profiles_settings.xml b/res/layout/device_profiles_settings.xml deleted file mode 100644 index 260fa0587be..00000000000 --- a/res/layout/device_profiles_settings.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 981893d1562..02d31827f59 100755 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -185,7 +185,6 @@ 8dip 20dp - 32 24dp 21dp 16dp diff --git a/res/values/strings.xml b/res/values/strings.xml index d799ea544bd..8aba6463b43 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -268,10 +268,6 @@ Disconnect %1$s? Broadcasting - - Disable profile? - - This will disable:<br><b>%1$s</b><br><br>From:<br><b>%2$s</b> @@ -1592,8 +1588,6 @@ Device settings Paired device - - Name Internet connection @@ -1608,8 +1602,6 @@ %1$s wants to access your contacts and call history. %1$s wants to pair with Bluetooth. When connected, it will have access to your contacts and call history. - - Paired devices Available devices diff --git a/res/values/styles.xml b/res/values/styles.xml index 37219d6c2d7..e7d11642289 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -157,13 +157,6 @@ start - -