Merge "Fix tests" 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 13e1364..ab8c011 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7026,8 +7026,8 @@
<!-- [CHAR LIMIT=20] Accessibility string for current zen mode and selected exit condition. A template that simply concatenates existing mode string and the current condition description. -->
<string name="zen_mode_and_condition"><xliff:g id="zen_mode" example="Priority interruptions only">%1$s</xliff:g>. <xliff:g id="exit_condition" example="For one hour">%2$s</xliff:g></string>
- <!-- Sound settings screen, summary format of do not disturb when on. [CHAR LIMIT=NONE] -->
- <string name="zen_mode_sound_summary_on">On / <xliff:g name="dnd_summary" example="No sound except alarms and media">%1$s</xliff:g></string>
+ <!-- Sound settings screen, summary format of do not disturb when on with extra info. [CHAR LIMIT=NONE] -->
+ <string name="zen_mode_sound_summary_on_with_info">On / <xliff:g name="dnd_summary" example="No sound except alarms and media">%1$s</xliff:g></string>
<!-- Sound settings screen, summary format of do not disturb when off with extra information. [CHAR LIMIT=NONE] -->
<string name="zen_mode_sound_summary_off_with_info">Off / <xliff:g name="dnd_summary" example="1 rule can turn on automatically">%1$s</xliff:g></string>
@@ -7035,6 +7035,9 @@
<!-- Sound settings screen, summary format of do not disturb when off with no extra information. [CHAR LIMIT=NONE] -->
<string name="zen_mode_sound_summary_off">Off</string>
+ <!-- Sound settings screen, summary format of do not disturb when on with no extra information. [CHAR LIMIT=NONE] -->
+ <string name="zen_mode_sound_summary_on">On</string>
+
<!-- Summary for the Sound Do not Disturb option when at least one automatic rules is enabled. [CHAR LIMIT=NONE]-->
<plurals name="zen_mode_sound_summary_summary_off_info">
<item quantity="one">1 rule can turn on automatically</item>
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/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index fdb5cc6..557d624 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -23,6 +23,7 @@
import android.content.Context;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
+import android.service.notification.ZenModeConfig;
import android.support.annotation.VisibleForTesting;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -122,9 +123,15 @@
int zenMode = NotificationManager.from(mContext).getZenMode();
if (zenMode != Settings.Global.ZEN_MODE_OFF) {
- Policy policy = NotificationManager.from(mContext).getNotificationPolicy();
- return mContext.getString(R.string.zen_mode_sound_summary_on,
- getBehaviorSettingSummary(policy, zenMode));
+ ZenModeConfig config = NotificationManager.from(mContext).getZenModeConfig();
+ String description = ZenModeConfig.getDescription(mContext, true, config);
+
+ if (description == null) {
+ return mContext.getString(R.string.zen_mode_sound_summary_on);
+ } else {
+ return mContext.getString(R.string.zen_mode_sound_summary_on_with_info,
+ description);
+ }
} else {
final int count = getEnabledAutomaticRulesCount();
if (count > 0) {
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/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