Merge "Adding zen duration preference" into pi-dev
diff --git a/res/values/bools.xml b/res/values/bools.xml
index 4665f2e..61a3c75 100644
--- a/res/values/bools.xml
+++ b/res/values/bools.xml
@@ -96,6 +96,9 @@
<!-- Whether device_administrators should be shown or not. -->
<bool name="config_show_device_administrators">true</bool>
+ <!-- Whether encryption_and_credentials_encryption_status should be shown or not. -->
+ <bool name="config_show_encryption_and_credentials_encryption_status">true</bool>
+
<!-- Whether premium_sms should be shown or not. -->
<bool name="config_show_premium_sms">true</bool>
@@ -153,6 +156,9 @@
<!-- Whether assist_and_voice_input should be shown or not. -->
<bool name="config_show_assist_and_voice_input">true</bool>
+ <!-- Whether reset_dashboard should be shown or not. -->
+ <bool name="config_show_reset_dashboard">true</bool>
+
<!-- Whether system_update_settings should be shown or not. -->
<bool name="config_show_system_update_settings">true</bool>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c84853f..185732d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1676,10 +1676,10 @@
<string name="bluetooth_max_connected_audio_devices_string">Maximum connected Bluetooth audio devices</string>
<!-- Bluetooth developer settings: Maximum number of connected audio devices -->
<string name="bluetooth_max_connected_audio_devices_dialog_title">Select maximum number of connected Bluetooth audio devices</string>
- <!-- Bluetooth developer settings: Checkbox title for enabling Bluetooth receiving AVDTP delay reports -->
- <string name="bluetooth_enable_avdtp_delay_reports">Enable Bluetooth AVDTP delay reports</string>
- <!-- Bluetooth developer settings: Summary of checkbox for enabling Bluetooth receiving AVDTP delay reports -->
- <string name="bluetooth_enable_avdtp_delay_reports_summary">Allow receiving Bluetooth AVDTP delay reports</string>
+ <!-- Bluetooth developer settings: Checkbox title for disabling Bluetooth receiving AVDTP delay reports -->
+ <string name="bluetooth_disable_avdtp_delay_reports">Disable Bluetooth AVDTP delay reports</string>
+ <!-- Bluetooth developer settings: Summary of checkbox for disabling Bluetooth receiving AVDTP delay reports -->
+ <string name="bluetooth_disable_avdtp_delay_reports_summary">Disallow receiving Bluetooth AVDTP delay reports</string>
<!-- Wifi Display settings. The title of the screen. [CHAR LIMIT=40] -->
<string name="wifi_display_settings_title">Cast</string>
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index 571f38e..282a5121 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -264,9 +264,9 @@
android:summary="@string/bluetooth_disable_inband_ringing_summary" />
<SwitchPreference
- android:key="bluetooth_enable_avdtp_delay_reports"
- android:title="@string/bluetooth_enable_avdtp_delay_reports"
- android:summary="@string/bluetooth_enable_avdtp_delay_reports_summary"/>
+ android:key="bluetooth_disable_avdtp_delay_reports"
+ android:title="@string/bluetooth_disable_avdtp_delay_reports"
+ android:summary="@string/bluetooth_disable_avdtp_delay_reports_summary"/>
<ListPreference
android:key="bluetooth_select_avrcp_version"
diff --git a/res/xml/system_dashboard_fragment.xml b/res/xml/system_dashboard_fragment.xml
index d8459dd..c3f15b9 100644
--- a/res/xml/system_dashboard_fragment.xml
+++ b/res/xml/system_dashboard_fragment.xml
@@ -46,7 +46,8 @@
android:summary="@string/reset_dashboard_summary"
android:icon="@drawable/ic_restore"
android:order="-50"
- android:fragment="com.android.settings.system.ResetDashboardFragment" />
+ android:fragment="com.android.settings.system.ResetDashboardFragment"
+ settings:controller="com.android.settings.system.ResetPreferenceController"/>
<!-- System updates -->
<Preference
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index f9c7847..0cbc539 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -105,6 +105,7 @@
import com.android.settings.notification.ZenAccessSettings;
import com.android.settings.notification.ZenModeAutomationSettings;
import com.android.settings.notification.ZenModeBehaviorSettings;
+import com.android.settings.notification.ZenModeBlockedEffectsSettings;
import com.android.settings.notification.ZenModeEventRuleSettings;
import com.android.settings.notification.ZenModeScheduleRuleSettings;
import com.android.settings.notification.ZenModeSettings;
@@ -220,6 +221,7 @@
ZenModeBehaviorSettings.class.getName(),
ZenModeScheduleRuleSettings.class.getName(),
ZenModeEventRuleSettings.class.getName(),
+ ZenModeBlockedEffectsSettings.class.getName(),
ProcessStatsUi.class.getName(),
AdvancedPowerUsageDetail.class.getName(),
ProcessStatsSummary.class.getName(),
diff --git a/src/com/android/settings/development/BluetoothDelayReportsPreferenceController.java b/src/com/android/settings/development/BluetoothDelayReportsPreferenceController.java
index 0858555..6c7a7dd 100644
--- a/src/com/android/settings/development/BluetoothDelayReportsPreferenceController.java
+++ b/src/com/android/settings/development/BluetoothDelayReportsPreferenceController.java
@@ -28,11 +28,11 @@
public class BluetoothDelayReportsPreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
- private static final String BLUETOOTH_ENABLE_AVDTP_DELAY_REPORT_KEY =
- "bluetooth_enable_avdtp_delay_reports";
+ private static final String BLUETOOTH_DISABLE_AVDTP_DELAY_REPORT_KEY =
+ "bluetooth_disable_avdtp_delay_reports";
@VisibleForTesting
- static final String BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY =
- "persist.bluetooth.enabledelayreports";
+ static final String BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY =
+ "persist.bluetooth.disabledelayreports";
public BluetoothDelayReportsPreferenceController(Context context) {
super(context);
@@ -40,22 +40,22 @@
@Override
public String getPreferenceKey() {
- return BLUETOOTH_ENABLE_AVDTP_DELAY_REPORT_KEY;
+ return BLUETOOTH_DISABLE_AVDTP_DELAY_REPORT_KEY;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
- final boolean isEnabled = (Boolean) newValue;
- SystemProperties.set(BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY,
- isEnabled ? "true" : "false");
+ final boolean isDisabled = (Boolean) newValue;
+ SystemProperties.set(BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY,
+ isDisabled ? "true" : "false");
return true;
}
@Override
public void updateState(Preference preference) {
- final boolean isEnabled = SystemProperties.getBoolean(
- BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
- ((SwitchPreference) mPreference).setChecked(isEnabled);
+ final boolean isDisabled = SystemProperties.getBoolean(
+ BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
+ ((SwitchPreference) mPreference).setChecked(isDisabled);
}
@Override
@@ -63,7 +63,7 @@
super.onDeveloperOptionsSwitchDisabled();
// the default setting for this preference is the disabled state
((SwitchPreference) mPreference).setChecked(false);
- SystemProperties.set(BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY, "false");
+ SystemProperties.set(BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY, "false");
}
}
diff --git a/src/com/android/settings/security/EncryptionStatusPreferenceController.java b/src/com/android/settings/security/EncryptionStatusPreferenceController.java
index 2341248..8125599 100644
--- a/src/com/android/settings/security/EncryptionStatusPreferenceController.java
+++ b/src/com/android/settings/security/EncryptionStatusPreferenceController.java
@@ -41,6 +41,12 @@
@Override
public int getAvailabilityStatus() {
+ if (TextUtils.equals(getPreferenceKey(), PREF_KEY_ENCRYPTION_DETAIL_PAGE) &&
+ !mContext.getResources().getBoolean(
+ R.bool.config_show_encryption_and_credentials_encryption_status)) {
+ return DISABLED_UNSUPPORTED;
+ }
+
return mUserManager.isAdminUser() ? AVAILABLE : DISABLED_FOR_USER;
}
diff --git a/src/com/android/settings/system/ResetPreferenceController.java b/src/com/android/settings/system/ResetPreferenceController.java
new file mode 100644
index 0000000..16f7ce3
--- /dev/null
+++ b/src/com/android/settings/system/ResetPreferenceController.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.system;
+
+import android.content.Context;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+public class ResetPreferenceController extends BasePreferenceController {
+
+ public ResetPreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return mContext.getResources().getBoolean(R.bool.config_show_reset_dashboard)
+ ? AVAILABLE
+ : DISABLED_UNSUPPORTED;
+ }
+}
diff --git a/tests/robotests/res/values-mcc999/config.xml b/tests/robotests/res/values-mcc999/config.xml
index 788c593..39620d8 100644
--- a/tests/robotests/res/values-mcc999/config.xml
+++ b/tests/robotests/res/values-mcc999/config.xml
@@ -34,6 +34,7 @@
<bool name="config_show_screen_locking_sounds">false</bool>
<bool name="config_show_touch_sounds">false</bool>
<bool name="config_show_device_administrators">false</bool>
+ <bool name="config_show_encryption_and_credentials_encryption_status">false</bool>
<bool name="config_show_premium_sms">false</bool>
<bool name="config_show_data_saver">false</bool>
<bool name="config_show_enabled_vr_listeners">false</bool>
@@ -54,6 +55,7 @@
<bool name="config_show_tts_settings_summary">false</bool>
<bool name="config_show_pointer_speed">false</bool>
<bool name="config_show_vibrate_input_devices">false</bool>
+ <bool name="config_show_reset_dashboard">false</bool>
<bool name="config_show_system_update_settings">false</bool>
<bool name="config_wifi_support_connected_mac_randomization">false</bool>
<bool name="config_show_device_model">false</bool>
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
index 522067b..dc492a9 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
@@ -44,23 +44,25 @@
import com.android.settings.dashboard.DashboardAdapter;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowCardView;
import com.android.settingslib.suggestions.SuggestionControllerMixin;
import com.android.settingslib.utils.IconCache;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = ShadowCardView.class)
public class SuggestionAdapterTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
@@ -143,7 +145,6 @@
.isEqualTo(R.layout.suggestion_tile_with_button);
}
- @Ignore
@Test
public void onBindViewHolder_shouldLog() {
final View view = spy(LayoutInflater.from(mContext).inflate(
@@ -164,7 +165,6 @@
mOneSuggestion.get(0).getId());
}
- @Ignore
@Test
public void onBindViewHolder_itemViewShouldHandleClick()
throws PendingIntent.CanceledException {
@@ -178,7 +178,6 @@
verify(suggestions.get(0).getPendingIntent()).send();
}
- @Ignore
@Test
public void onBindViewHolder_hasButton_buttonShouldHandleClick()
throws PendingIntent.CanceledException {
@@ -205,7 +204,6 @@
verify(pendingIntent).send();
}
- @Ignore
@Test
public void getSuggestions_shouldReturnSuggestionWhenMatch() {
final List<Suggestion> suggestions = makeSuggestions("pkg1");
@@ -214,7 +212,6 @@
assertThat(mSuggestionAdapter.getSuggestion(0)).isNotNull();
}
- @Ignore
@Test
public void onBindViewHolder_closeButtonShouldHandleClick()
throws PendingIntent.CanceledException {
@@ -236,7 +233,6 @@
verify(callback).onSuggestionClosed(suggestion);
}
- @Ignore
@Test
public void onBindViewHolder_iconNotTintable_shouldNotTintIcon()
throws PendingIntent.CanceledException {
@@ -263,7 +259,6 @@
verify(drawable, never()).setTint(anyInt());
}
- @Ignore
@Test
public void onBindViewHolder_iconTintable_shouldTintIcon()
throws PendingIntent.CanceledException {
@@ -296,7 +291,6 @@
verify(drawable).setTint(colorAccent);
}
- @Ignore
@Test
public void onBindViewHolder_closeButtonShouldHaveContentDescription()
throws PendingIntent.CanceledException {
@@ -310,7 +304,6 @@
.isNotNull();
}
- @Ignore
@Test
public void setCardLayout_twoCards_shouldSetCardWidthToHalfScreenMinusPadding() {
final List<Suggestion> suggestions = makeSuggestions("pkg1");
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothDelayReportsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothDelayReportsPreferenceControllerTest.java
index d529fc1..bdaad0a 100644
--- a/tests/robotests/src/com/android/settings/development/BluetoothDelayReportsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/BluetoothDelayReportsPreferenceControllerTest.java
@@ -16,7 +16,9 @@
package com.android.settings.development;
-import static com.android.settings.development.BluetoothDelayReportsPreferenceController.BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY;
+import static com.android.settings.development.BluetoothDelayReportsPreferenceController
+ .BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@@ -57,11 +59,11 @@
}
@Test
- public void onPreferenceChanged_settingEnabled_turnOnDelayReports() {
+ public void onPreferenceChanged_settingDisabled_turnOnDelayReports() {
mController.onPreferenceChange(mPreference, true /* new value */);
final boolean mode = SystemProperties.getBoolean(
- BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
+ BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
assertThat(mode).isTrue();
}
@@ -71,14 +73,14 @@
mController.onPreferenceChange(mPreference, false /* new value */);
final boolean mode = SystemProperties.getBoolean(
- BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
+ BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
assertThat(mode).isFalse();
}
@Test
- public void updateState_settingEnabled_preferenceShouldBeChecked() {
- SystemProperties.set(BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY,
+ public void updateState_settingDisabled_preferenceShouldBeChecked() {
+ SystemProperties.set(BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY,
Boolean.toString(true));
mController.updateState(mPreference);
@@ -87,7 +89,7 @@
@Test
public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
- SystemProperties.set(BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY,
+ SystemProperties.set(BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY,
Boolean.toString(false));
mController.updateState(mPreference);
@@ -99,10 +101,10 @@
mController.onDeveloperOptionsDisabled();
final boolean mode = SystemProperties.getBoolean(
- BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
+ BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
assertThat(mode).isFalse();
assertThat(mPreference.isEnabled()).isFalse();
assertThat(mPreference.isChecked()).isFalse();
}
-}
\ No newline at end of file
+}
diff --git a/tests/robotests/src/com/android/settings/security/EncryptionStatusPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/EncryptionStatusPreferenceControllerTest.java
index ee6d33a..2e6b703 100644
--- a/tests/robotests/src/com/android/settings/security/EncryptionStatusPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/EncryptionStatusPreferenceControllerTest.java
@@ -68,6 +68,23 @@
}
@Test
+ @Config(qualifiers = "mcc999")
+ public void isAvailable_notVisible_false() {
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void isAvailable_notVisible_butNotDetailPage_true() {
+ mController = new EncryptionStatusPreferenceController(mContext,
+ PREF_KEY_ENCRYPTION_SECURITY_PAGE);
+
+ UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+ Shadows.shadowOf(userManager).setIsAdminUser(true);
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
public void updateSummary_encrypted_shouldSayEncrypted() {
ShadowLockPatternUtils.setDeviceEncryptionEnabled(true);
diff --git a/tests/robotests/src/com/android/settings/system/ResetPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/system/ResetPreferenceControllerTest.java
new file mode 100644
index 0000000..3869903
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/system/ResetPreferenceControllerTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.system;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class ResetPreferenceControllerTest {
+
+ private static final String KEY_RESET_DASHBOARD = "reset_dashboard";
+
+ private Context mContext;
+ private ResetPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new ResetPreferenceController(mContext, KEY_RESET_DASHBOARD);
+ }
+
+ @Test
+ public void isAvailable_byDefault_true() {
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void isAvailable_ifNotVisible_false() {
+ assertThat(mController.isAvailable()).isFalse();
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowCardView.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowCardView.java
new file mode 100644
index 0000000..e349ee3
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowCardView.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.testutils.shadow;
+
+import android.content.Context;
+import android.support.v7.widget.CardView;
+import android.util.AttributeSet;
+
+import org.robolectric.annotation.Implements;
+import org.robolectric.shadows.ShadowFrameLayout;
+
+/**
+ * Shadow for CardView to get around view not implemented error.
+ */
+@Implements(CardView.class)
+public class ShadowCardView extends ShadowFrameLayout {
+
+ public void __constructor__(Context context, AttributeSet attrs, int defStyleAttr) {
+ // do nothing
+ }
+
+}