Merge "Make VideoPreference not important for talkback." into pi-dev
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceController.java b/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceController.java
index 05b5a8a..e422bdc 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceController.java
@@ -46,7 +46,7 @@
@VisibleForTesting
Preference mPreference;
private LocalBluetoothManager mLocalManager;
- private LocalBluetoothAdapter mLocalAdapter;
+ protected LocalBluetoothAdapter mLocalAdapter;
/**
* Constructor exclusively used for Slice.
@@ -77,8 +77,10 @@
@Override
public void onStart() {
- mContext.registerReceiver(mReceiver,
- new IntentFilter(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED));
+ final IntentFilter intentFilter = new IntentFilter();
+ intentFilter.addAction(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED);
+ intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
+ mContext.registerReceiver(mReceiver, intentFilter);
}
@Override
@@ -93,7 +95,7 @@
@Override
public void updateState(Preference preference) {
- updateDeviceName(preference);
+ updatePreferenceState(preference);
}
@Override
@@ -129,7 +131,7 @@
*
* @param preference to set the summary for
*/
- protected void updateDeviceName(final Preference preference) {
+ protected void updatePreferenceState(final Preference preference) {
preference.setSelectable(false);
preference.setSummary(getSummary());
}
@@ -150,8 +152,10 @@
if (TextUtils.equals(action, BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED)) {
if (mPreference != null && mLocalAdapter != null && mLocalAdapter.isEnabled()) {
- updateDeviceName(mPreference);
+ updatePreferenceState(mPreference);
}
+ } else if (TextUtils.equals(action, BluetoothAdapter.ACTION_STATE_CHANGED)) {
+ updatePreferenceState(mPreference);
}
}
};
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceController.java b/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceController.java
index 21f0487..d6221ef 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceController.java
@@ -58,8 +58,9 @@
}
@Override
- protected void updateDeviceName(final Preference preference) {
+ protected void updatePreferenceState(final Preference preference) {
preference.setSummary(getSummary());
+ preference.setVisible(mLocalAdapter != null && mLocalAdapter.isEnabled());
}
@Override
diff --git a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
index 94ef978..4dd483a 100644
--- a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
@@ -24,6 +24,7 @@
import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support.annotation.VisibleForTesting;
+import android.text.TextUtils;
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.R;
@@ -74,7 +75,18 @@
if (mAmbientConfig == null) {
mAmbientConfig = new AmbientDisplayConfiguration(mContext);
}
- return mAmbientConfig.pulseOnDoubleTapAvailable() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+
+ // No hardware support for Double Tap
+ if (!mAmbientConfig.doubleTapSensorAvailable()) {
+ return UNSUPPORTED_ON_DEVICE;
+ }
+
+ // Can't change Double Tap when AOD is enabled.
+ if (!mAmbientConfig.ambientDisplayAvailable()) {
+ return DISABLED_DEPENDENT_SETTING;
+ }
+
+ return AVAILABLE;
}
@Override
diff --git a/src/com/android/settings/gestures/PickupGesturePreferenceController.java b/src/com/android/settings/gestures/PickupGesturePreferenceController.java
index d50df19..d0f247e 100644
--- a/src/com/android/settings/gestures/PickupGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/PickupGesturePreferenceController.java
@@ -25,6 +25,7 @@
import android.os.UserHandle;
import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
+import android.text.TextUtils;
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.R;
@@ -68,7 +69,18 @@
if (mAmbientConfig == null) {
mAmbientConfig = new AmbientDisplayConfiguration(mContext);
}
- return mAmbientConfig.pulseOnPickupAvailable() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+
+ // No hardware support for Pickup Gesture
+ if (!mAmbientConfig.dozePulsePickupSensorAvailable()) {
+ return UNSUPPORTED_ON_DEVICE;
+ }
+
+ // Can't change Pickup Gesture when AOD is enabled.
+ if (!mAmbientConfig.ambientDisplayAvailable()) {
+ return DISABLED_DEPENDENT_SETTING;
+ }
+
+ return AVAILABLE;
}
@Override
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceControllerTest.java
index 1d37883..1c61553 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceControllerTest.java
@@ -70,7 +70,7 @@
@Test
public void testUpdateDeviceName_showSummaryWithDeviceName() {
- mController.updateDeviceName(mPreference);
+ mController.updatePreferenceState(mPreference);
final CharSequence summary = mPreference.getSummary();
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceControllerTest.java
index 65eae2c..607842a 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceControllerTest.java
@@ -71,11 +71,13 @@
PREF_KEY));
mController.setFragment(mFragment);
doReturn(DEVICE_NAME).when(mController).getDeviceName();
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+ mController.displayPreference(mScreen);
}
@Test
public void testUpdateDeviceName_showSummaryWithDeviceName() {
- mController.updateDeviceName(mPreference);
+ mController.updatePreferenceState(mPreference);
final CharSequence summary = mPreference.getSummary();
@@ -94,10 +96,24 @@
@Test
public void displayPreference_shouldFindPreferenceWithMatchingPrefKey() {
- when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
-
- mController.displayPreference(mScreen);
-
assertThat(mController.mPreference.getKey()).isEqualTo(mController.getPreferenceKey());
}
+
+ @Test
+ public void updatePreferenceState_whenBTisOnPreferenceShouldBeVisible() {
+ when(mLocalAdapter.isEnabled()).thenReturn(true);
+
+ mController.updatePreferenceState(mPreference);
+
+ assertThat(mPreference.isVisible()).isTrue();
+ }
+
+ @Test
+ public void updatePreferenceState_whenBTisOffPreferenceShouldBeHide() {
+ when(mLocalAdapter.isEnabled()).thenReturn(false);
+
+ mController.updatePreferenceState(mPreference);
+
+ assertThat(mPreference.isVisible()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
index cc9347d..63a1027 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
@@ -16,6 +16,10 @@
package com.android.settings.gestures;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.when;
@@ -61,20 +65,6 @@
}
@Test
- public void isAvailable_configIsTrue_shouldReturnTrue() {
- when(mAmbientDisplayConfiguration.pulseOnDoubleTapAvailable()).thenReturn(true);
-
- assertThat(mController.isAvailable()).isTrue();
- }
-
- @Test
- public void isAvailable_configIsFalse_shouldReturnFalse() {
- when(mAmbientDisplayConfiguration.pulseOnDoubleTapAvailable()).thenReturn(false);
-
- assertThat(mController.isAvailable()).isFalse();
- }
-
- @Test
public void testIsChecked_configIsSet_shouldReturnTrue() {
// Set the setting to be enabled.
when(mAmbientDisplayConfiguration.pulseOnDoubleTapEnabled(anyInt())).thenReturn(true);
@@ -162,4 +152,31 @@
when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(false);
assertThat(mController.canHandleClicks()).isTrue();
}
+
+ @Test
+ public void getAvailabilityStatus_aodNotSupported_UNSUPPORTED_ON_DEVICE() {
+ when(mAmbientDisplayConfiguration.doubleTapSensorAvailable()).thenReturn(false);
+ when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(false);
+ final int availabilityStatus = mController.getAvailabilityStatus();
+
+ assertThat(availabilityStatus).isEqualTo(UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_aodOn_DISABLED_DEPENDENT_SETTING() {
+ when(mAmbientDisplayConfiguration.doubleTapSensorAvailable()).thenReturn(true);
+ when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(false);
+ final int availabilityStatus = mController.getAvailabilityStatus();
+
+ assertThat(availabilityStatus).isEqualTo(DISABLED_DEPENDENT_SETTING);
+ }
+
+ @Test
+ public void getAvailabilityStatus_aodSupported_aodOff_AVAILABLE() {
+ when(mAmbientDisplayConfiguration.doubleTapSensorAvailable()).thenReturn(true);
+ when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(true);
+ final int availabilityStatus = mController.getAvailabilityStatus();
+
+ assertThat(availabilityStatus).isEqualTo(AVAILABLE);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
index 6aa451c..98c32ad 100644
--- a/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
@@ -16,6 +16,10 @@
package com.android.settings.gestures;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.doReturn;
@@ -62,20 +66,6 @@
}
@Test
- public void isAvailable_configIsTrue_shouldReturnTrue() {
- when(mAmbientDisplayConfiguration.pulseOnPickupAvailable()).thenReturn(true);
-
- assertThat(mController.isAvailable()).isTrue();
- }
-
- @Test
- public void isAvailable_configIsFalse_shouldReturnFalse() {
- when(mAmbientDisplayConfiguration.pulseOnPickupAvailable()).thenReturn(false);
-
- assertThat(mController.isAvailable()).isFalse();
- }
-
- @Test
public void testIsChecked_configIsSet_shouldReturnTrue() {
// Set the setting to be enabled.
when(mAmbientDisplayConfiguration.pulseOnPickupEnabled(anyInt())).thenReturn(true);
@@ -153,4 +143,31 @@
assertThat(PickupGesturePreferenceController.isSuggestionComplete(mContext, prefs))
.isTrue();
}
+
+ @Test
+ public void getAvailabilityStatus_aodNotSupported_UNSUPPORTED_ON_DEVICE() {
+ when(mAmbientDisplayConfiguration.dozePulsePickupSensorAvailable()).thenReturn(false);
+ when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(false);
+ final int availabilityStatus = mController.getAvailabilityStatus();
+
+ assertThat(availabilityStatus).isEqualTo(UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_aodOn_DISABLED_DEPENDENT_SETTING() {
+ when(mAmbientDisplayConfiguration.dozePulsePickupSensorAvailable()).thenReturn(true);
+ when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(false);
+ final int availabilityStatus = mController.getAvailabilityStatus();
+
+ assertThat(availabilityStatus).isEqualTo(DISABLED_DEPENDENT_SETTING);
+ }
+
+ @Test
+ public void getAvailabilityStatus_aodSupported_aodOff_AVAILABLE() {
+ when(mAmbientDisplayConfiguration.dozePulsePickupSensorAvailable()).thenReturn(true);
+ when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(true);
+ final int availabilityStatus = mController.getAvailabilityStatus();
+
+ assertThat(availabilityStatus).isEqualTo(AVAILABLE);
+ }
}