Merge "Read default confirm credentials title from policy"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 3764b95..4e6f303 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -630,6 +630,10 @@
<activity android:name="Settings$KeyboardLayoutPickerActivity"
android:label="@string/keyboard_layout_picker_title"
android:clearTaskOnLaunch="true">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.KEYBOARD_LAYOUT_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1607,33 +1611,35 @@
android:value="true" />
</activity>
- <activity-alias android:name=".suggestion.ChooseLockGeneric"
- android:icon="@drawable/ic_settings_security"
- android:targetActivity=".ChooseLockGeneric">
+ <activity android:name=".Settings$ScreenLockSuggestionActivity"
+ android:icon="@drawable/ic_settings_security">
<intent-filter android:priority="1">
<action android:name="android.intent.action.MAIN" />
<category android:name="com.android.settings.suggested.category.LOCK_SCREEN" />
</intent-filter>
+ <meta-data android:name="com.android.settings.dismiss"
+ android:value="0,30" />
<meta-data android:name="com.android.settings.title"
android:resource="@string/suggested_lock_settings_title" />
<meta-data android:name="com.android.settings.summary"
android:resource="@string/suggested_lock_settings_summary" />
- </activity-alias>
+ </activity>
- <activity-alias android:name=".suggestion.FingerprintEnrollIntroduction"
- android:icon="@drawable/ic_settings_security"
- android:targetActivity=".fingerprint.FingerprintEnrollIntroduction">
+ <activity android:name=".Settings$FingerprintEnrollSuggestionActivity"
+ android:icon="@drawable/ic_settings_security">
<intent-filter android:priority="2">
<action android:name="android.intent.action.MAIN" />
<category android:name="com.android.settings.suggested.category.LOCK_SCREEN" />
</intent-filter>
+ <meta-data android:name="com.android.settings.dismiss"
+ android:value="0,30" />
<meta-data android:name="com.android.settings.require_feature"
android:value="android.hardware.fingerprint" />
<meta-data android:name="com.android.settings.title"
android:resource="@string/suggested_lock_settings_title" />
<meta-data android:name="com.android.settings.summary"
android:resource="@string/suggested_lock_settings_summary" />
- </activity-alias>
+ </activity>
<activity android:name="ChooseLockGeneric$InternalActivity" android:exported="false"
android:label="@string/lockpassword_choose_lock_generic_header"
diff --git a/res/drawable/accessibility_screen_magnification_background.xml b/res/drawable/accessibility_screen_magnification_background.xml
new file mode 100644
index 0000000..e22cfec
--- /dev/null
+++ b/res/drawable/accessibility_screen_magnification_background.xml
@@ -0,0 +1,31 @@
+<!--
+ ~ 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
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="360dp"
+ android:height="184dp"
+ android:viewportWidth="360"
+ android:viewportHeight="184">
+
+ <path
+ android:fillColor="#E9F0F9"
+ android:pathData="M 0 0 H 360 V 184 H 0 V 0 Z" />
+ <path
+ android:fillColor="#444445"
+ android:pathData="M217.6,179h-75.1c-5,0-9-4-9-9V14c0-5,4-9,9-9h75.1c5,0,9,4,9,9V170C226.6,174.9,222.5,179,217.6,179z" />
+ <path
+ android:fillColor="#000000"
+ android:pathData="M 180 9.6 C 181.1045695 9.6 182 10.4954305003 182 11.6 C 182 12.7045694997 181.1045695 13.6 180 13.6 C 178.8954305 13.6 178 12.7045694997 178 11.6 C 178 10.4954305003 178.8954305 9.6 180 9.6 Z" />
+</vector>
diff --git a/res/layout/preference_importance_slider.xml b/res/layout/preference_importance_slider.xml
index 0099384..677a32b 100644
--- a/res/layout/preference_importance_slider.xml
+++ b/res/layout/preference_importance_slider.xml
@@ -23,35 +23,11 @@
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:orientation="vertical"
android:clickable="false"
- android:focusable="false"
- android:paddingTop="8dip"
- android:paddingBottom="8dip">
-
- <TextView
- android:id="@android:id/title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
- android:textColor="?android:attr/textColorPrimary"
- android:ellipsize="marquee"
- android:fadingEdge="horizontal" />
-
- <TextView
- android:id="@android:id/summary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignStart="@android:id/title"
- android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
- android:textColor="?android:attr/textColorSecondary"
- android:maxLines="10"
- android:minLines="2" />
+ android:focusable="false" >
<FrameLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="6dp">
+ android:layout_height="wrap_content" >
<ImageView
android:id="@+id/low_importance"
@@ -82,5 +58,4 @@
android:tint="@color/importance_icon_tint" />
</FrameLayout>
-
</LinearLayout>
diff --git a/res/layout/text_description_preference.xml b/res/layout/text_description_preference.xml
index d71f078..6b8594b 100644
--- a/res/layout/text_description_preference.xml
+++ b/res/layout/text_description_preference.xml
@@ -13,11 +13,10 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/summary"
- android:layout_width="fill_parent"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.Material.Body1"
android:padding="16dip" />
diff --git a/res/layout/video_preference.xml b/res/layout/video_preference.xml
new file mode 100644
index 0000000..a6fde76
--- /dev/null
+++ b/res/layout/video_preference.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/video_background"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <VideoView
+ android:id="@+id/video"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/res/raw/accessibility_screen_magnification.mp4 b/res/raw/accessibility_screen_magnification.mp4
new file mode 100644
index 0000000..1e60fc5
--- /dev/null
+++ b/res/raw/accessibility_screen_magnification.mp4
Binary files differ
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 30aa52f..12bdfaa 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -268,4 +268,11 @@
<!-- Accessibility, Font size -->
<dimen name="font_size_preview_height">240dp</dimen>
+
+ <!-- Accessibility, Screen magnification. These values are meant to be relative values and the actual layout value will be set programmatically. -->
+ <dimen name="screen_magnification_video_background_width">750dp</dimen>
+ <dimen name="screen_magnification_video_background_height">383dp</dimen>
+ <dimen name="screen_magnification_video_width">170dp</dimen>
+ <dimen name="screen_magnification_video_height">311dp</dimen>
+ <dimen name="screen_magnification_video_margin_top">40dp</dimen>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 399db32..bc2076a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3765,8 +3765,6 @@
<string name="accessibility_global_gesture_preference_summary_off">Off</string>
<!-- Description for the preference screen to enable the global geture taht turns on accessibility. [CHAR LIMIT=none] -->
<string name="accessibility_global_gesture_preference_description">When this feature is turned on, you can quickly enable accessibility features in two steps:\n\nStep 1: Press and hold the power button until you hear a sound or feel a vibration.\n\nStep 2: Touch and hold two fingers until you hear audio confirmation.\n\nIf the device has multiple users, using this shortcut on the lock screen temporarily enables accessibility until the device is unlocked.</string>
- <!-- Title for the accessibility preference to enable large text. [CHAR LIMIT=35] -->
- <string name="accessibility_toggle_large_text_preference_title">Large text</string>
<!-- Title for the accessibility preference to high contrast text. [CHAR LIMIT=35] -->
<string name="accessibility_toggle_high_text_contrast_preference_title">High contrast text</string>
<!-- Title for the accessibility preference to enable screen magnification. [CHAR LIMIT=35] -->
@@ -5841,6 +5839,9 @@
<!-- [CHAR LIMIT=100] Notification importance slider title -->
<string name="notification_importance_title">Importance</string>
+ <!-- [CHAR LIMIT=100] Notification Importance slider: unset importance level description -->
+ <string name="notification_importance_none">Not set</string>
+
<!-- [CHAR LIMIT=100] Notification Importance slider: blocked importance level description -->
<string name="notification_importance_blocked">Blocked: Never show these notifications</string>
@@ -5856,6 +5857,9 @@
<!-- [CHAR LIMIT=100] Notification Importance slider: max importance level description -->
<string name="notification_importance_max">Urgent: Peek onto the screen and make sound</string>
+ <!-- [CHAR LIMIT=60] Notification importance reset button -->
+ <string name="importance_reset">Reset</string>
+
<!-- Default Apps > Default notification assistant -->
<string name="default_notification_assistant">Notification assistant</string>
@@ -7020,6 +7024,18 @@
<!-- No default home set summary [CHAR LIMIT=NONE] -->
<string name="no_default_home">No default Home</string>
+ <!-- Title of the preference controlling whether the device encryption password/PIN/Pattern must be entered before being able to start the device. [CHAR LIMIT=60]-->
+ <string name="lockpattern_settings_require_cred_before_startup">Secure start-up</string>
+
+ <!-- Summary of the preference controlling whether the device encryption *pattern* must be entered before being able to start the device. [CHAR LIMIT=NONE]-->
+ <string name="lockpattern_settings_require_pattern_before_startup_summary">Require pattern to start up your device. While off, this device can\'t receive calls, messages, notifications, or alarms.</string>
+
+ <!-- Summary of the preference controlling whether the device encryption *PIN* must be entered before being able to start the device. [CHAR LIMIT=NONE]-->
+ <string name="lockpattern_settings_require_pin_before_startup_summary">Require PIN to start up your device. While off, this device can\'t receive calls, messages, notifications, or alarms.</string>
+
+ <!-- Summary of the preference controlling whether the device encryption *password* must be entered before being able to start the device. [CHAR LIMIT=NONE]-->
+ <string name="lockpattern_settings_require_password_before_startup_summary">Require password to start up your device. While off, this device can\'t receive calls, messages, notifications, or alarms.</string>
+
<!-- Title for suggestion adding more fingerprints [CHAR LIMIT=30] -->
<string name="suggestion_additional_fingerprints">Additional Fingerprints</string>
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 54a5a17..a59fbdc 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -43,17 +43,16 @@
android:key="font_size_preference_screen"
android:title="@string/title_font_size"/>
+ <com.android.settings.display.ScreenZoomPreference
+ android:key="screen_zoom"
+ android:title="@string/screen_zoom_title"/>
+
<PreferenceScreen
android:fragment="com.android.settings.accessibility.ToggleAutoclickPreferenceFragment"
android:key="autoclick_preference_screen"
android:title="@string/accessibility_autoclick_preference_title"/>
<SwitchPreference
- android:key="toggle_large_text_preference"
- android:title="@string/accessibility_toggle_large_text_preference_title"
- android:persistent="false"/>
-
- <SwitchPreference
android:key="toggle_high_text_contrast_preference"
android:title="@string/accessibility_toggle_high_text_contrast_preference_title"
android:summary="@string/experimental_preference"
diff --git a/res/xml/app_notification_settings.xml b/res/xml/app_notification_settings.xml
index 3141af8..d48cf93 100644
--- a/res/xml/app_notification_settings.xml
+++ b/res/xml/app_notification_settings.xml
@@ -22,6 +22,47 @@
<Preference
android:key="app_settings"
android:title="@string/app_notification_preferences"
- android:persistent="false" />
+ android:order="1" />
+
+ <!-- Apps without topics -->
+ <!-- Importance -->
+ <Preference
+ android:key="importance_title"
+ android:title="@string/notification_importance_title"
+ android:order="2" />
+ <com.android.settings.notification.ImportanceSeekBarPreference
+ android:key="importance"
+ android:order="3"/>
+
+ <com.android.settings.applications.LayoutPreference
+ android:key="importance_reset_button"
+ android:layout="@layout/two_buttons_panel"
+ android:order="4" />
+
+ <!-- Sensitive -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="sensitive"
+ android:title="@string/app_notification_sensitive_title"
+ android:summary="@string/app_notification_sensitive_summary"
+ android:order="5" />
+
+ <!-- Bypass DND -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="bypass_dnd"
+ android:title="@string/app_notification_override_dnd_title"
+ android:summary="@string/app_notification_override_dnd_summary"
+ android:order="6" />
+
+ <!-- Apps with topics -->
+ <!-- Block -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="block"
+ android:title="@string/app_notification_block_title"
+ android:summary="@string/app_notification_block_summary"
+ android:order="7" />
+ <PreferenceCategory
+ android:key="categories"
+ android:title="@string/notification_topic_categories"
+ android:order="8" />
</PreferenceScreen>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 1780765..0543ac1 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -91,14 +91,11 @@
android:summary="@string/tap_to_wake_summary"
android:persistent="false" />
- <DropDownPreference
+ <PreferenceScreen
android:key="font_size"
android:title="@string/title_font_size"
- settings:keywords="@string/keywords_display_font_size"
- android:persistent="false"
- android:summary="%s"
- android:entries="@array/entries_font_size"
- android:entryValues="@array/entryvalues_font_size" />
+ android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
+ settings:keywords="@string/keywords_display_font_size" />
<com.android.settings.display.ScreenZoomPreference
android:key="screen_zoom"
diff --git a/res/xml/security_settings_chooser.xml b/res/xml/security_settings_chooser.xml
index af7bfeb..dd8ae55 100644
--- a/res/xml/security_settings_chooser.xml
+++ b/res/xml/security_settings_chooser.xml
@@ -15,23 +15,20 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
android:title="@string/security_settings_title">
<PreferenceCategory
android:key="security_category"
android:title="@string/lock_settings_title">
- <PreferenceScreen
+ <com.android.settings.GearPreference
android:key="unlock_set_or_change"
android:title="@string/unlock_set_unlock_launch_picker_title"
android:summary="@string/unlock_set_unlock_mode_none"
+ settings:keywords="@string/keywords_lockscreen"
android:persistent="false"/>
- <com.android.settings.SingleLineSummaryPreference
- android:key="owner_info_settings"
- android:title="@string/owner_info_settings_title"
- android:summary="@string/owner_info_settings_summary"/>
-
</PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/security_settings_lockscreen.xml b/res/xml/security_settings_lockscreen.xml
index fde0446..a5aa767 100644
--- a/res/xml/security_settings_lockscreen.xml
+++ b/res/xml/security_settings_lockscreen.xml
@@ -29,12 +29,6 @@
settings:keywords="@string/keywords_lockscreen"
android:persistent="false"/>
- <com.android.settings.SingleLineSummaryPreference
- android:key="owner_info_settings"
- android:enabled="false"
- android:title="@string/owner_info_settings_title"
- android:summary="@string/owner_info_settings_summary"/>
-
</PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/security_settings_password.xml b/res/xml/security_settings_password.xml
index a6fe1a4..d96ca4b 100644
--- a/res/xml/security_settings_password.xml
+++ b/res/xml/security_settings_password.xml
@@ -22,30 +22,13 @@
android:key="security_category"
android:title="@string/lock_settings_title">
- <PreferenceScreen
+ <com.android.settings.GearPreference
android:key="unlock_set_or_change"
android:title="@string/unlock_set_unlock_launch_picker_title"
android:summary="@string/unlock_set_unlock_mode_password"
settings:keywords="@string/keywords_lockscreen"
android:persistent="false"/>
- <com.android.settings.RestrictedListPreference
- android:key="lock_after_timeout"
- android:title="@string/lock_after_timeout"
- android:summary="@string/lock_after_timeout_summary"
- android:entries="@array/lock_after_timeout_entries"
- android:entryValues="@array/lock_after_timeout_values"
- android:persistent="false"/>
-
- <SwitchPreference
- android:key="power_button_instantly_locks"
- android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
-
- <com.android.settings.SingleLineSummaryPreference
- android:key="owner_info_settings"
- android:title="@string/owner_info_settings_title"
- android:summary="@string/owner_info_settings_summary"/>
-
</PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/security_settings_password_sub.xml b/res/xml/security_settings_password_sub.xml
new file mode 100644
index 0000000..0fa3731
--- /dev/null
+++ b/res/xml/security_settings_password_sub.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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
+ -->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:title="@string/settings_label">
+
+ <com.android.settings.RestrictedListPreference
+ android:key="lock_after_timeout"
+ android:title="@string/lock_after_timeout"
+ android:summary="@string/lock_after_timeout_summary"
+ android:entries="@array/lock_after_timeout_entries"
+ android:entryValues="@array/lock_after_timeout_values"
+ android:persistent="false"/>
+
+ <SwitchPreference
+ android:key="power_button_instantly_locks"
+ android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
+
+ <com.android.settings.SingleLineSummaryPreference
+ android:key="owner_info_settings"
+ android:title="@string/owner_info_settings_title"
+ android:summary="@string/owner_info_settings_summary"/>
+
+ <SwitchPreference
+ android:key="require_cred_before_startup"
+ android:title="@string/lockpattern_settings_require_cred_before_startup"
+ android:summary="@string/lockpattern_settings_require_password_before_startup_summary"/>
+
+
+</PreferenceScreen>
diff --git a/res/xml/security_settings_pattern.xml b/res/xml/security_settings_pattern.xml
index f8c4bd9..d3fd97d 100644
--- a/res/xml/security_settings_pattern.xml
+++ b/res/xml/security_settings_pattern.xml
@@ -22,34 +22,13 @@
android:key="security_category"
android:title="@string/lock_settings_title">
- <PreferenceScreen
+ <com.android.settings.GearPreference
android:key="unlock_set_or_change"
android:title="@string/unlock_set_unlock_launch_picker_title"
android:summary="@string/unlock_set_unlock_mode_pattern"
settings:keywords="@string/keywords_lockscreen"
android:persistent="false"/>
- <SwitchPreference
- android:key="visiblepattern"
- android:title="@string/lockpattern_settings_enable_visible_pattern_title"/>
-
- <com.android.settings.RestrictedListPreference
- android:key="lock_after_timeout"
- android:title="@string/lock_after_timeout"
- android:summary="@string/lock_after_timeout_summary"
- android:entries="@array/lock_after_timeout_entries"
- android:entryValues="@array/lock_after_timeout_values"
- android:persistent="false"/>
-
- <SwitchPreference
- android:key="power_button_instantly_locks"
- android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
-
- <com.android.settings.SingleLineSummaryPreference
- android:key="owner_info_settings"
- android:title="@string/owner_info_settings_title"
- android:summary="@string/owner_info_settings_summary"/>
-
</PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/security_settings_pattern_sub.xml b/res/xml/security_settings_pattern_sub.xml
new file mode 100644
index 0000000..adaaca6
--- /dev/null
+++ b/res/xml/security_settings_pattern_sub.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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
+ -->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:title="@string/settings_label">
+
+ <SwitchPreference
+ android:key="visiblepattern"
+ android:title="@string/lockpattern_settings_enable_visible_pattern_title"/>
+
+ <com.android.settings.RestrictedListPreference
+ android:key="lock_after_timeout"
+ android:title="@string/lock_after_timeout"
+ android:summary="@string/lock_after_timeout_summary"
+ android:entries="@array/lock_after_timeout_entries"
+ android:entryValues="@array/lock_after_timeout_values"
+ android:persistent="false"/>
+
+ <SwitchPreference
+ android:key="power_button_instantly_locks"
+ android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
+
+ <com.android.settings.SingleLineSummaryPreference
+ android:key="owner_info_settings"
+ android:title="@string/owner_info_settings_title"
+ android:summary="@string/owner_info_settings_summary"/>
+
+ <SwitchPreference
+ android:key="require_cred_before_startup"
+ android:title="@string/lockpattern_settings_require_cred_before_startup"
+ android:summary="@string/lockpattern_settings_require_pattern_before_startup_summary"/>
+
+
+</PreferenceScreen>
diff --git a/res/xml/security_settings_pin.xml b/res/xml/security_settings_pin.xml
index abab140..ba19c43 100644
--- a/res/xml/security_settings_pin.xml
+++ b/res/xml/security_settings_pin.xml
@@ -22,30 +22,13 @@
android:key="security_category"
android:title="@string/lock_settings_title">
- <PreferenceScreen
+ <com.android.settings.GearPreference
android:key="unlock_set_or_change"
android:title="@string/unlock_set_unlock_launch_picker_title"
android:summary="@string/unlock_set_unlock_mode_pin"
settings:keywords="@string/keywords_lockscreen"
android:persistent="false"/>
- <com.android.settings.RestrictedListPreference
- android:key="lock_after_timeout"
- android:title="@string/lock_after_timeout"
- android:summary="@string/lock_after_timeout_summary"
- android:entries="@array/lock_after_timeout_entries"
- android:entryValues="@array/lock_after_timeout_values"
- android:persistent="false"/>
-
- <SwitchPreference
- android:key="power_button_instantly_locks"
- android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
-
- <com.android.settings.SingleLineSummaryPreference
- android:key="owner_info_settings"
- android:title="@string/owner_info_settings_title"
- android:summary="@string/owner_info_settings_summary"/>
-
</PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/security_settings_pin_sub.xml b/res/xml/security_settings_pin_sub.xml
new file mode 100644
index 0000000..6dff551
--- /dev/null
+++ b/res/xml/security_settings_pin_sub.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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
+ -->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:title="@string/settings_label">
+
+ <com.android.settings.RestrictedListPreference
+ android:key="lock_after_timeout"
+ android:title="@string/lock_after_timeout"
+ android:summary="@string/lock_after_timeout_summary"
+ android:entries="@array/lock_after_timeout_entries"
+ android:entryValues="@array/lock_after_timeout_values"
+ android:persistent="false"/>
+
+ <SwitchPreference
+ android:key="power_button_instantly_locks"
+ android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
+
+ <com.android.settings.SingleLineSummaryPreference
+ android:key="owner_info_settings"
+ android:title="@string/owner_info_settings_title"
+ android:summary="@string/owner_info_settings_summary"/>
+
+ <SwitchPreference
+ android:key="require_cred_before_startup"
+ android:title="@string/lockpattern_settings_require_cred_before_startup"
+ android:summary="@string/lockpattern_settings_require_pin_before_startup_summary"/>
+
+
+</PreferenceScreen>
diff --git a/res/xml/security_settings_slide_sub.xml b/res/xml/security_settings_slide_sub.xml
new file mode 100644
index 0000000..1efb370
--- /dev/null
+++ b/res/xml/security_settings_slide_sub.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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
+ -->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:title="@string/settings_label">
+
+ <com.android.settings.SingleLineSummaryPreference
+ android:key="owner_info_settings"
+ android:title="@string/owner_info_settings_title"
+ android:summary="@string/owner_info_settings_summary"/>
+
+</PreferenceScreen>
diff --git a/res/xml/topic_notification_settings.xml b/res/xml/topic_notification_settings.xml
index d5f28b3..2f15500 100644
--- a/res/xml/topic_notification_settings.xml
+++ b/res/xml/topic_notification_settings.xml
@@ -19,26 +19,31 @@
android:key="topic_notification_settings">
<!-- Importance -->
+ <Preference
+ android:key="importance_title"
+ android:title="@string/notification_importance_title"
+ android:order="1" />
<com.android.settings.notification.ImportanceSeekBarPreference
android:key="importance"
- android:title="@string/notification_importance_title"
- android:order="1"
- android:persistent="false" />
+ android:order="2" />
- <!-- Bypass DND -->
- <SwitchPreference
- android:key="bypass_dnd"
- android:title="@string/app_notification_override_dnd_title"
- android:summary="@string/app_notification_override_dnd_summary"
- android:order="2"
- android:persistent="false" />
+ <com.android.settings.applications.LayoutPreference
+ android:key="importance_reset_button"
+ android:order="3"
+ android:layout="@layout/two_buttons_panel" />
<!-- Sensitive -->
- <SwitchPreference
+ <com.android.settingslib.RestrictedSwitchPreference
android:key="sensitive"
android:title="@string/app_notification_sensitive_title"
android:summary="@string/app_notification_sensitive_summary"
- android:order="4"
- android:persistent="false" />
+ android:order="4" />
+
+ <!-- Bypass DND -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="bypass_dnd"
+ android:title="@string/app_notification_override_dnd_title"
+ android:summary="@string/app_notification_override_dnd_summary"
+ android:order="5" />
</PreferenceScreen>
diff --git a/src/com/android/settings/ChooseLockGeneric.java b/src/com/android/settings/ChooseLockGeneric.java
index d2eae7e..03a3fef 100644
--- a/src/com/android/settings/ChooseLockGeneric.java
+++ b/src/com/android/settings/ChooseLockGeneric.java
@@ -24,11 +24,9 @@
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.admin.DevicePolicyManager;
-import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.content.pm.PackageManager;
import android.hardware.fingerprint.Fingerprint;
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintManager.RemovalCallback;
@@ -39,6 +37,7 @@
import android.security.KeyStore;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
+import android.text.TextUtils;
import android.util.EventLog;
import android.util.Log;
import android.view.View;
@@ -106,6 +105,7 @@
private boolean mEncryptionRequestDisabled;
private boolean mRequirePassword;
private boolean mForFingerprint = false;
+ private boolean mForChangeCredRequiredForBoot = false;
private String mUserPassword;
private LockPatternUtils mLockPatternUtils;
private FingerprintManager mFingerprintManager;
@@ -159,6 +159,8 @@
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
mForFingerprint = getActivity().getIntent().getBooleanExtra(
ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false);
+ mForChangeCredRequiredForBoot = getArguments() != null && getArguments().getBoolean(
+ ChooseLockSettingsHelper.EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT);
if (savedInstanceState != null) {
mPasswordConfirmed = savedInstanceState.getBoolean(PASSWORD_CONFIRMED);
@@ -185,6 +187,10 @@
if (mPasswordConfirmed) {
updatePreferencesOrFinish();
+ if (mForChangeCredRequiredForBoot) {
+ maybeEnableEncryption(mLockPatternUtils.getKeyguardStoredPasswordQuality(
+ mUserId), false);
+ }
} else if (!mWaitingForConfirmation) {
ChooseLockSettingsHelper helper =
new ChooseLockSettingsHelper(this.getActivity(), this);
@@ -240,6 +246,9 @@
// Get the intent that the encryption interstitial should start for creating
// the new unlock method.
Intent unlockMethodIntent = getIntentForUnlockMethod(quality, disabled);
+ unlockMethodIntent.putExtra(
+ ChooseLockSettingsHelper.EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT,
+ mForChangeCredRequiredForBoot);
final Context context = getActivity();
// If accessibility is enabled and the user hasn't seen this dialog before, set the
// default state to agree with that which is compatible with accessibility
@@ -252,6 +261,11 @@
mForFingerprint);
startActivityForResult(intent, ENABLE_ENCRYPTION_REQUEST);
} else {
+ if (mForChangeCredRequiredForBoot) {
+ // Welp, couldn't change it. Oh well.
+ finish();
+ return;
+ }
mRequirePassword = false; // device encryption not enabled or not device owner.
updateUnlockMethodAndFinish(quality, disabled);
}
@@ -265,17 +279,27 @@
mPasswordConfirmed = true;
mUserPassword = data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
updatePreferencesOrFinish();
+ if (mForChangeCredRequiredForBoot) {
+ if (!TextUtils.isEmpty(mUserPassword)) {
+ maybeEnableEncryption(
+ mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId), false);
+ } else {
+ finish();
+ }
+ }
} else if (requestCode == CHOOSE_LOCK_REQUEST
|| requestCode == ENABLE_ENCRYPTION_REQUEST) {
if (resultCode != RESULT_CANCELED) {
getActivity().setResult(resultCode, data);
- disableScreenLockSuggestion();
finish();
}
} else {
getActivity().setResult(Activity.RESULT_CANCELED);
finish();
}
+ if (requestCode == Activity.RESULT_CANCELED && mForChangeCredRequiredForBoot) {
+ finish();
+ }
}
@Override
@@ -548,30 +572,9 @@
getActivity().setResult(Activity.RESULT_OK);
} else {
removeAllFingerprintTemplatesAndFinish();
- disableScreenLockSuggestion();
}
}
- private void disableScreenLockSuggestion() {
- final ComponentName suggestionChooseLock = new ComponentName("com.android.settings",
- "com.android.settings.suggestion.ChooseLockGeneric");
- disableComponent(suggestionChooseLock);
- PackageManager pm = getContext().getPackageManager();
- if (pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
- final ComponentName suggestionFingerprint = new ComponentName(
- "com.android.settings",
- "com.android.settings.suggestion.FingerprintEnrollIntroduction");
- disableComponent(suggestionFingerprint);
- }
- }
-
- private void disableComponent(ComponentName componentName) {
- getContext().getPackageManager().setComponentEnabledSetting(
- componentName,
- PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
- PackageManager.DONT_KILL_APP);
- }
-
private Intent getIntentForUnlockMethod(int quality, boolean disabled) {
Intent intent = null;
final Context context = getActivity();
diff --git a/src/com/android/settings/ChooseLockPassword.java b/src/com/android/settings/ChooseLockPassword.java
index 2fd012e..212aa0c 100644
--- a/src/com/android/settings/ChooseLockPassword.java
+++ b/src/com/android/settings/ChooseLockPassword.java
@@ -267,6 +267,19 @@
mUserId));
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(getActivity());
+
+ if (intent.getBooleanExtra(
+ ChooseLockSettingsHelper.EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT, false)) {
+ SaveAndFinishWorker w = new SaveAndFinishWorker();
+ final boolean required = getActivity().getIntent().getBooleanExtra(
+ EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
+ String current = intent.getStringExtra(
+ ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
+ w.setBlocking(true);
+ w.setListener(this);
+ w.start(mChooseLockSettingsHelper.utils(), required,
+ false, 0, current, current, mRequestedQuality, mUserId);
+ }
}
@Override
@@ -641,9 +654,11 @@
setNextEnabled(false);
mSaveAndFinishWorker = new SaveAndFinishWorker();
+ mSaveAndFinishWorker.setListener(this);
+
getFragmentManager().beginTransaction().add(mSaveAndFinishWorker,
FRAGMENT_TAG_SAVE_AND_FINISH).commit();
- mSaveAndFinishWorker.setListener(this);
+ getFragmentManager().executePendingTransactions();
final boolean required = getActivity().getIntent().getBooleanExtra(
EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
diff --git a/src/com/android/settings/ChooseLockPattern.java b/src/com/android/settings/ChooseLockPattern.java
index 960ec1a..8aa9532 100644
--- a/src/com/android/settings/ChooseLockPattern.java
+++ b/src/com/android/settings/ChooseLockPattern.java
@@ -371,6 +371,19 @@
Intent intent = getActivity().getIntent();
// Only take this argument into account if it belongs to the current profile.
mUserId = Utils.getUserIdFromBundle(getActivity(), intent.getExtras());
+
+ if (intent.getBooleanExtra(
+ ChooseLockSettingsHelper.EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT, false)) {
+ SaveAndFinishWorker w = new SaveAndFinishWorker();
+ final boolean required = getActivity().getIntent().getBooleanExtra(
+ EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
+ String current = intent.getStringExtra(
+ ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
+ w.setBlocking(true);
+ w.setListener(this);
+ w.start(mChooseLockSettingsHelper.utils(), required,
+ false, 0, LockPatternUtils.stringToPattern(current), current, mUserId);
+ }
}
@Override
@@ -642,9 +655,11 @@
setRightButtonEnabled(false);
mSaveAndFinishWorker = new SaveAndFinishWorker();
+ mSaveAndFinishWorker.setListener(this);
+
getFragmentManager().beginTransaction().add(mSaveAndFinishWorker,
FRAGMENT_TAG_SAVE_AND_FINISH).commit();
- mSaveAndFinishWorker.setListener(this);
+ getFragmentManager().executePendingTransactions();
final boolean required = getActivity().getIntent().getBooleanExtra(
EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
diff --git a/src/com/android/settings/ChooseLockSettingsHelper.java b/src/com/android/settings/ChooseLockSettingsHelper.java
index 1035ef1..dda8da2 100644
--- a/src/com/android/settings/ChooseLockSettingsHelper.java
+++ b/src/com/android/settings/ChooseLockSettingsHelper.java
@@ -33,6 +33,7 @@
public static final String EXTRA_KEY_CHALLENGE = "challenge";
public static final String EXTRA_KEY_CHALLENGE_TOKEN = "hw_auth_token";
public static final String EXTRA_KEY_FOR_FINGERPRINT = "for_fingerprint";
+ public static final String EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT = "for_cred_req_boot";
private LockPatternUtils mLockPatternUtils;
diff --git a/src/com/android/settings/CustomDialogPreference.java b/src/com/android/settings/CustomDialogPreference.java
index edd5416..383163f 100644
--- a/src/com/android/settings/CustomDialogPreference.java
+++ b/src/com/android/settings/CustomDialogPreference.java
@@ -29,7 +29,8 @@
private CustomPreferenceDialogFragment mFragment;
- public CustomDialogPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ public CustomDialogPreference(Context context, AttributeSet attrs, int defStyleAttr,
+ int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index 31e8d89..5e7407b 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -17,7 +17,6 @@
package com.android.settings;
import android.app.Activity;
-import android.app.ActivityManagerNative;
import android.app.UiModeManager;
import android.app.admin.DevicePolicyManager;
import android.content.ContentResolver;
@@ -29,7 +28,6 @@
import android.hardware.SensorManager;
import android.os.Build;
import android.os.Bundle;
-import android.os.RemoteException;
import android.os.SystemProperties;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
@@ -44,6 +42,7 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.internal.view.RotationPolicy;
+import com.android.settings.accessibility.ToggleFontSizePreferenceFragment;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
@@ -85,7 +84,7 @@
private static final String KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE
= "camera_double_tap_power_gesture";
- private DropDownPreference mFontSizePref;
+ private Preference mFontSizePref;
private final Configuration mCurConfig = new Configuration();
@@ -121,8 +120,7 @@
mScreenTimeoutPreference = (RestrictedListPreference) findPreference(KEY_SCREEN_TIMEOUT);
- mFontSizePref = (DropDownPreference) findPreference(KEY_FONT_SIZE);
- mFontSizePref.setOnPreferenceChangeListener(this);
+ mFontSizePref = findPreference(KEY_FONT_SIZE);
if (isAutomaticBrightnessAvailable(getResources())) {
mAutoBrightnessPreference = (SwitchPreference) findPreference(KEY_AUTO_BRIGHTNESS);
@@ -339,37 +337,6 @@
}
}
- int floatToIndex(float val) {
- String[] indices = getResources().getStringArray(R.array.entryvalues_font_size);
- float lastVal = Float.parseFloat(indices[0]);
- for (int i=1; i<indices.length; i++) {
- float thisVal = Float.parseFloat(indices[i]);
- if (val < (lastVal + (thisVal-lastVal)*.5f)) {
- return i-1;
- }
- lastVal = thisVal;
- }
- return indices.length-1;
- }
-
- public void readFontSizePreference(ListPreference pref) {
- try {
- mCurConfig.updateFrom(ActivityManagerNative.getDefault().getConfiguration());
- } catch (RemoteException e) {
- Log.w(TAG, "Unable to retrieve font size");
- }
-
- // mark the appropriate item in the preferences list
- int index = floatToIndex(mCurConfig.fontScale);
- pref.setValueIndex(index);
-
- // report the current size in the summary text
- final Resources res = getResources();
- String[] fontSizeNames = res.getStringArray(R.array.entries_font_size);
- pref.setSummary(String.format(res.getString(R.string.summary_font_size),
- fontSizeNames[index]));
- }
-
@Override
public void onResume() {
super.onResume();
@@ -384,7 +351,7 @@
}
private void updateState() {
- readFontSizePreference(mFontSizePref);
+ updateFontSizeSummary();
updateScreenSaverSummary();
// Update auto brightness if it is available.
@@ -433,13 +400,13 @@
}
}
- public void writeFontSizePreference(Object objValue) {
- try {
- mCurConfig.fontScale = Float.parseFloat(objValue.toString());
- ActivityManagerNative.getDefault().updatePersistentConfiguration(mCurConfig);
- } catch (RemoteException e) {
- Log.w(TAG, "Unable to save font size");
- }
+ private void updateFontSizeSummary() {
+ final Resources res = mFontSizePref.getContext().getResources();
+ final String[] entries = res.getStringArray(R.array.entries_font_size);
+ final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
+ final int index = ToggleFontSizePreferenceFragment.fontSizeValueToIndex(
+ res.getConfiguration().fontScale, strEntryValues);
+ mFontSizePref.setSummary(entries[index]);
}
@Override
@@ -454,9 +421,6 @@
Log.e(TAG, "could not persist screen timeout setting", e);
}
}
- if (KEY_FONT_SIZE.equals(key)) {
- writeFontSizePreference(objValue);
- }
if (preference == mAutoBrightnessPreference) {
boolean auto = (Boolean) objValue;
Settings.System.putInt(getContentResolver(), SCREEN_BRIGHTNESS_MODE,
diff --git a/src/com/android/settings/GearPreference.java b/src/com/android/settings/GearPreference.java
new file mode 100644
index 0000000..a8c1e9d
--- /dev/null
+++ b/src/com/android/settings/GearPreference.java
@@ -0,0 +1,59 @@
+/*
+ * 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;
+
+import android.content.Context;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.util.AttributeSet;
+import android.view.View;
+
+/**
+ * A preference with a Gear on the side
+ */
+public class GearPreference extends Preference implements View.OnClickListener {
+
+ private OnGearClickListener mOnGearClickListener;
+
+ public GearPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setWidgetLayoutResource(R.layout.preference_widget_settings);
+ }
+
+ public void setOnGearClickListener(OnGearClickListener l) {
+ mOnGearClickListener = l;
+ }
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder holder) {
+ super.onBindViewHolder(holder);
+ holder.findViewById(R.id.settings_button).setOnClickListener(this);
+ }
+
+ @Override
+ public void onClick(View v) {
+ if (v.getId() == R.id.settings_button) {
+ if (mOnGearClickListener != null) {
+ mOnGearClickListener.onGearClick(this);
+ }
+ }
+ }
+
+ public interface OnGearClickListener {
+ void onGearClick(GearPreference p);
+ }
+}
diff --git a/src/com/android/settings/OwnerInfoSettings.java b/src/com/android/settings/OwnerInfoSettings.java
index 7fffb11..cad0693 100644
--- a/src/com/android/settings/OwnerInfoSettings.java
+++ b/src/com/android/settings/OwnerInfoSettings.java
@@ -75,8 +75,8 @@
mLockPatternUtils.setOwnerInfoEnabled(!TextUtils.isEmpty(info), mUserId);
mLockPatternUtils.setOwnerInfo(info, mUserId);
- if (getTargetFragment() instanceof SecuritySettings) {
- ((SecuritySettings) getTargetFragment()).updateOwnerInfo();
+ if (getTargetFragment() instanceof SecuritySettings.SecuritySubSettings) {
+ ((SecuritySettings.SecuritySubSettings) getTargetFragment()).updateOwnerInfo();
}
}
}
diff --git a/src/com/android/settings/RestrictedListPreference.java b/src/com/android/settings/RestrictedListPreference.java
index 35ee30d..77af19e 100644
--- a/src/com/android/settings/RestrictedListPreference.java
+++ b/src/com/android/settings/RestrictedListPreference.java
@@ -146,11 +146,10 @@
ImageView padlock = (ImageView) root.findViewById(R.id.restricted_lock_icon);
if (isRestrictedForEntry(entry)) {
text.setEnabled(false);
+ text.setChecked(false);
padlock.setVisibility(View.VISIBLE);
} else {
- if (position == mSelectedIndex) {
- text.setChecked(true);
- }
+ text.setChecked(position == mSelectedIndex);
text.setEnabled(true);
padlock.setVisibility(View.GONE);
}
diff --git a/src/com/android/settings/SaveChosenLockWorkerBase.java b/src/com/android/settings/SaveChosenLockWorkerBase.java
index 4d8964a..128bd99 100644
--- a/src/com/android/settings/SaveChosenLockWorkerBase.java
+++ b/src/com/android/settings/SaveChosenLockWorkerBase.java
@@ -20,6 +20,7 @@
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.os.UserManager;
import com.android.internal.widget.LockPatternUtils;
@@ -39,6 +40,8 @@
protected boolean mWasSecureBefore;
protected int mUserId;
+ private boolean mBlocking;
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -67,14 +70,20 @@
mUtils.setSeparateProfileChallengeEnabled(mUserId, true);
mWasSecureBefore = mUtils.isSecure(mUserId);
- mUtils.setCredentialRequiredToDecrypt(credentialRequired);
+ if (UserManager.get(getContext()).getUserInfo(mUserId).isPrimary()) {
+ mUtils.setCredentialRequiredToDecrypt(credentialRequired);
+ }
mFinished = false;
mResultData = null;
}
protected void start() {
- new Task().execute();
+ if (mBlocking) {
+ finish(saveAndVerifyInBackground());
+ } else {
+ new Task().execute();
+ }
}
/**
@@ -91,6 +100,10 @@
}
}
+ public void setBlocking(boolean blocking) {
+ mBlocking = blocking;
+ }
+
private class Task extends AsyncTask<Void, Void, Intent> {
@Override
protected Intent doInBackground(Void... params){
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 415f4d3..3e873d4 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -28,7 +28,6 @@
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
import android.content.res.Resources;
-import android.hardware.fingerprint.Fingerprint;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
import android.os.PersistableBundle;
@@ -55,7 +54,6 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.RestrictedListPreference;
import com.android.settings.TrustAgentUtils.TrustAgentComponentInfo;
-import com.android.settings.fingerprint.FingerprintEnrollIntroduction;
import com.android.settings.fingerprint.FingerprintSettings;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Index;
@@ -77,7 +75,8 @@
* Gesture lock pattern settings.
*/
public class SecuritySettings extends SettingsPreferenceFragment
- implements OnPreferenceChangeListener, DialogInterface.OnClickListener, Indexable {
+ implements OnPreferenceChangeListener, DialogInterface.OnClickListener, Indexable,
+ GearPreference.OnGearClickListener {
private static final String TAG = "SecuritySettings";
private static final String TRUST_AGENT_CLICK_INTENT = "trust_agent_click_intent";
@@ -87,11 +86,8 @@
// Lock Settings
private static final String KEY_UNLOCK_SET_OR_CHANGE = "unlock_set_or_change";
private static final String KEY_UNLOCK_SET_OR_CHANGE_PROFILE = "profile_challenge";
- private static final String KEY_VISIBLE_PATTERN = "visiblepattern";
private static final String KEY_SECURITY_CATEGORY = "security_category";
private static final String KEY_DEVICE_ADMIN_CATEGORY = "device_admin_category";
- private static final String KEY_LOCK_AFTER_TIMEOUT = "lock_after_timeout";
- private static final String KEY_OWNER_INFO_SETTINGS = "owner_info_settings";
private static final String KEY_ADVANCED_SECURITY = "advanced_security";
private static final String KEY_MANAGE_TRUST_AGENTS = "manage_trust_agents";
@@ -105,16 +101,14 @@
private static final String KEY_RESET_CREDENTIALS = "credentials_reset";
private static final String KEY_CREDENTIALS_INSTALL = "credentials_install";
private static final String KEY_TOGGLE_INSTALL_APPLICATIONS = "toggle_install_applications";
- private static final String KEY_POWER_INSTANTLY_LOCKS = "power_button_instantly_locks";
private static final String KEY_CREDENTIALS_MANAGER = "credentials_management";
private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive";
private static final String KEY_TRUST_AGENT = "trust_agent";
private static final String KEY_SCREEN_PINNING = "screen_pinning_settings";
// These switch preferences need special handling since they're not all stored in Settings.
- private static final String SWITCH_PREFERENCE_KEYS[] = { KEY_LOCK_AFTER_TIMEOUT,
- KEY_VISIBLE_PATTERN, KEY_POWER_INSTANTLY_LOCKS, KEY_SHOW_PASSWORD,
- KEY_TOGGLE_INSTALL_APPLICATIONS };
+ private static final String SWITCH_PREFERENCE_KEYS[] = {
+ KEY_SHOW_PASSWORD, KEY_TOGGLE_INSTALL_APPLICATIONS };
// Only allow one trust agent on the platform.
private static final boolean ONLY_ONE_TRUST_AGENT = true;
@@ -127,9 +121,6 @@
private ChooseLockSettingsHelper mChooseLockSettingsHelper;
private LockPatternUtils mLockPatternUtils;
- private RestrictedListPreference mLockAfter;
-
- private SwitchPreference mVisiblePattern;
private SwitchPreference mShowPassword;
@@ -138,12 +129,10 @@
private RestrictedSwitchPreference mToggleAppInstallation;
private DialogInterface mWarnInstallApps;
- private SwitchPreference mPowerButtonInstantlyLocks;
private boolean mIsAdmin;
private Intent mTrustAgentClickIntent;
- private Preference mOwnerInfoPref;
private int mProfileChallengeUserId;
@@ -232,25 +221,14 @@
}
}
+ Preference unlockSetOrChange = findPreference(KEY_UNLOCK_SET_OR_CHANGE);
+ if (unlockSetOrChange instanceof GearPreference) {
+ ((GearPreference) unlockSetOrChange).setOnGearClickListener(this);
+ }
+
// Add options for device encryption
mIsAdmin = mUm.isAdminUser();
- mOwnerInfoPref = findPreference(KEY_OWNER_INFO_SETTINGS);
- if (mOwnerInfoPref != null) {
- mOwnerInfoPref.setEnabled(!mLockPatternUtils.isLockScreenDisabled(MY_USER_ID)
- && !mLockPatternUtils.isDeviceOwnerInfoEnabled());
-
- if (mOwnerInfoPref.isEnabled()) {
- mOwnerInfoPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- @Override
- public boolean onPreferenceClick(Preference preference) {
- OwnerInfoSettings.show(SecuritySettings.this);
- return true;
- }
- });
- }
- }
-
if (mIsAdmin) {
if (LockPatternUtils.isDeviceEncryptionEnabled()) {
// The device is currently encrypted.
@@ -269,28 +247,6 @@
addTrustAgentSettings(securityCategory);
}
- // lock after preference
- mLockAfter = (RestrictedListPreference) root.findPreference(KEY_LOCK_AFTER_TIMEOUT);
- if (mLockAfter != null) {
- setupLockAfterPreference();
- updateLockAfterPreferenceSummary();
- }
-
- // visible pattern
- mVisiblePattern = (SwitchPreference) root.findPreference(KEY_VISIBLE_PATTERN);
-
- // lock instantly on power key press
- mPowerButtonInstantlyLocks = (SwitchPreference) root.findPreference(
- KEY_POWER_INSTANTLY_LOCKS);
- Preference trustAgentPreference = root.findPreference(KEY_TRUST_AGENT);
- if (mPowerButtonInstantlyLocks != null &&
- trustAgentPreference != null &&
- trustAgentPreference.getTitle().length() > 0) {
- mPowerButtonInstantlyLocks.setSummary(getString(
- R.string.lockpattern_settings_power_button_instantly_locks_summary,
- trustAgentPreference.getTitle()));
- }
-
// Append the rest of the settings
addPreferencesFromResource(R.xml.security_settings_misc);
@@ -522,6 +478,13 @@
}
@Override
+ public void onGearClick(GearPreference p) {
+ if (KEY_UNLOCK_SET_OR_CHANGE.equals(p.getKey())) {
+ startFragment(this, SecuritySubSettings.class.getName(), 0, 0, null);
+ }
+ }
+
+ @Override
public void onDestroy() {
super.onDestroy();
if (mWarnInstallApps != null) {
@@ -529,105 +492,6 @@
}
}
- private void setupLockAfterPreference() {
- // Compatible with pre-Froyo
- long currentTimeout = Settings.Secure.getLong(getContentResolver(),
- Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, 5000);
- mLockAfter.setValue(String.valueOf(currentTimeout));
- mLockAfter.setOnPreferenceChangeListener(this);
- final EnforcedAdmin admin = RestrictedLockUtils.checkIfMaximumTimeToLockIsSet(
- getActivity());
- if (admin != null) {
- final long adminTimeout = (mDPM != null ? mDPM.getMaximumTimeToLock(null) : 0);
- final long displayTimeout = Math.max(0,
- Settings.System.getInt(getContentResolver(), SCREEN_OFF_TIMEOUT, 0));
- if (adminTimeout > 0) {
- // This setting is a slave to display timeout when a device policy is enforced.
- // As such, maxLockTimeout = adminTimeout - displayTimeout.
- // If there isn't enough time, shows "immediately" setting.
- disableUnusableTimeouts(Math.max(0, adminTimeout - displayTimeout), admin);
- }
- }
- }
-
- private void updateLockAfterPreferenceSummary() {
- final String summary;
- if (mLockAfter.isDisabledByAdmin()) {
- summary = getString(R.string.disabled_by_policy_title);
- } else {
- // Update summary message with current value
- long currentTimeout = Settings.Secure.getLong(getContentResolver(),
- Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, 5000);
- final CharSequence[] entries = mLockAfter.getEntries();
- final CharSequence[] values = mLockAfter.getEntryValues();
- int best = 0;
- for (int i = 0; i < values.length; i++) {
- if (mLockAfter.isRestrictedForEntry(entries[i])) {
- break;
- }
- long timeout = Long.valueOf(values[i].toString());
- if (currentTimeout >= timeout) {
- best = i;
- }
- }
-
- Preference preference = getPreferenceScreen().findPreference(KEY_TRUST_AGENT);
- if (preference != null && preference.getTitle().length() > 0) {
- if (Long.valueOf(values[best].toString()) == 0) {
- summary = getString(R.string.lock_immediately_summary_with_exception,
- preference.getTitle());
- } else {
- summary = getString(R.string.lock_after_timeout_summary_with_exception,
- entries[best], preference.getTitle());
- }
- } else {
- summary = getString(R.string.lock_after_timeout_summary, entries[best]);
- }
- }
- mLockAfter.setSummary(summary);
- }
-
- private void disableUnusableTimeouts(long maxTimeout, EnforcedAdmin admin) {
- final CharSequence[] entries = mLockAfter.getEntries();
- final CharSequence[] values = mLockAfter.getEntryValues();
- long maxTimeoutSelectable = 0;
- int maxTimeoutEntryIndex = -1;
- for (int i = 0; i < values.length; i++) {
- long timeout = Long.parseLong(values[i].toString());
- if (timeout > maxTimeout) {
- break;
- }
- maxTimeoutSelectable = timeout;
- maxTimeoutEntryIndex = i;
- }
- // If there are no possible options for the user, then set this preference as
- // disabled by admin, otherwise remove the padlock in case it was set earlier.
- if (maxTimeoutSelectable == 0) {
- mLockAfter.setDisabledByAdmin(admin);
- return;
- } else {
- mLockAfter.setDisabledByAdmin(null);
- }
-
- mLockAfter.clearRestrictedItems();
- // Set all the entries after the maximum selectable timeout as disabled by admin.
- for (int i = maxTimeoutEntryIndex + 1; i < values.length; i++) {
- mLockAfter.addRestrictedItem(
- new RestrictedItem(entries[i], values[i], admin));
- }
-
- final int userPreference = Integer.valueOf(mLockAfter.getValue());
- if (userPreference <= maxTimeout) {
- mLockAfter.setValue(String.valueOf(userPreference));
- } else if (maxTimeoutSelectable == maxTimeout) {
- mLockAfter.setValue(String.valueOf(maxTimeout));
- } else {
- // There will be no highlighted selection since nothing in the list matches
- // maxTimeout. The user can still select anything less than maxTimeout.
- // TODO: maybe append maxTimeout to the list and mark selected.
- }
- }
-
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
@@ -645,15 +509,6 @@
createPreferenceHierarchy();
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
- if (mVisiblePattern != null) {
- mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled(
- MY_USER_ID));
- }
- if (mPowerButtonInstantlyLocks != null) {
- mPowerButtonInstantlyLocks.setChecked(lockPatternUtils.getPowerButtonInstantlyLocks(
- MY_USER_ID));
- }
-
if (mShowPassword != null) {
mShowPassword.setChecked(Settings.System.getInt(getContentResolver(),
Settings.System.TEXT_SHOW_PASSWORD, 1) != 0);
@@ -662,20 +517,6 @@
if (mResetCredentials != null) {
mResetCredentials.setEnabled(!mKeyStore.isEmpty());
}
-
- updateOwnerInfo();
- }
-
- public void updateOwnerInfo() {
- if (mOwnerInfoPref != null) {
- if (mLockPatternUtils.isDeviceOwnerInfoEnabled()) {
- mOwnerInfoPref.setSummary(R.string.disabled_by_administrator_summary);
- } else {
- mOwnerInfoPref.setSummary(mLockPatternUtils.isOwnerInfoEnabled(MY_USER_ID)
- ? mLockPatternUtils.getOwnerInfo(MY_USER_ID)
- : getString(R.string.owner_info_settings_summary));
- }
- }
}
@Override
@@ -728,20 +569,7 @@
boolean result = true;
final String key = preference.getKey();
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
- if (KEY_LOCK_AFTER_TIMEOUT.equals(key)) {
- int timeout = Integer.parseInt((String) value);
- try {
- Settings.Secure.putInt(getContentResolver(),
- Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, timeout);
- } catch (NumberFormatException e) {
- Log.e("SecuritySettings", "could not persist lockAfter timeout setting", e);
- }
- updateLockAfterPreferenceSummary();
- } else if (KEY_VISIBLE_PATTERN.equals(key)) {
- lockPatternUtils.setVisiblePatternEnabled((Boolean) value, MY_USER_ID);
- } else if (KEY_POWER_INSTANTLY_LOCKS.equals(key)) {
- mLockPatternUtils.setPowerButtonInstantlyLocks((Boolean) value, MY_USER_ID);
- } else if (KEY_SHOW_PASSWORD.equals(key)) {
+ if (KEY_SHOW_PASSWORD.equals(key)) {
Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD,
((Boolean) value) ? 1 : 0);
lockPatternUtils.setVisiblePasswordEnabled((Boolean) value, MY_USER_ID);
@@ -823,6 +651,12 @@
result.add(sir);
}
+ sir = new SearchIndexableResource(context);
+ sir.xmlResId = SecuritySubSettings.getResIdForLockUnlockSubScreen(context,
+ lockPatternUtils);
+ sir.className = SecuritySubSettings.class.getName();
+ result.add(sir);
+
// Append the rest of the settings
sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.security_settings_misc;
@@ -924,8 +758,304 @@
keys.add(KEY_MANAGE_TRUST_AGENTS);
}
+ if (!SecuritySubSettings.canChangeRequireCredentialBeforeStartup(context)) {
+ keys.add(SecuritySubSettings.KEY_REQUIRE_CRED_BEFORE_STARTUP);
+ }
+
return keys;
}
}
+ public static class SecuritySubSettings extends SettingsPreferenceFragment
+ implements OnPreferenceChangeListener {
+
+ private static final String KEY_VISIBLE_PATTERN = "visiblepattern";
+ private static final String KEY_LOCK_AFTER_TIMEOUT = "lock_after_timeout";
+ private static final String KEY_OWNER_INFO_SETTINGS = "owner_info_settings";
+ private static final String KEY_POWER_INSTANTLY_LOCKS = "power_button_instantly_locks";
+ private static final String KEY_REQUIRE_CRED_BEFORE_STARTUP = "require_cred_before_startup";
+
+ public static final int REQUEST_CHANGE_REQUIRE_CRED_FOR_START = 2;
+
+ // These switch preferences need special handling since they're not all stored in Settings.
+ private static final String SWITCH_PREFERENCE_KEYS[] = { KEY_LOCK_AFTER_TIMEOUT,
+ KEY_VISIBLE_PATTERN, KEY_POWER_INSTANTLY_LOCKS, KEY_REQUIRE_CRED_BEFORE_STARTUP };
+
+ private RestrictedListPreference mLockAfter;
+ private SwitchPreference mVisiblePattern;
+ private SwitchPreference mPowerButtonInstantlyLocks;
+ private Preference mOwnerInfoPref;
+
+ private LockPatternUtils mLockPatternUtils;
+ private DevicePolicyManager mDPM;
+
+ @Override
+ protected int getMetricsCategory() {
+ return MetricsEvent.SECURITY;
+ }
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ mLockPatternUtils = new LockPatternUtils(getContext());
+ mDPM = getContext().getSystemService(DevicePolicyManager.class);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ createPreferenceHierarchy();
+
+ final LockPatternUtils lockPatternUtils = mLockPatternUtils;
+ if (mVisiblePattern != null) {
+ mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled(
+ MY_USER_ID));
+ }
+ if (mPowerButtonInstantlyLocks != null) {
+ mPowerButtonInstantlyLocks.setChecked(lockPatternUtils.getPowerButtonInstantlyLocks(
+ MY_USER_ID));
+ }
+
+ updateOwnerInfo();
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+
+ createPreferenceHierarchy();
+ }
+
+ private void createPreferenceHierarchy() {
+ PreferenceScreen root = getPreferenceScreen();
+ if (root != null) {
+ root.removeAll();
+ }
+ root = null;
+
+ final int resid = getResIdForLockUnlockSubScreen(getActivity(),
+ new LockPatternUtils(getContext()));
+ addPreferencesFromResource(resid);
+
+ // lock after preference
+ mLockAfter = (RestrictedListPreference) findPreference(KEY_LOCK_AFTER_TIMEOUT);
+ if (mLockAfter != null) {
+ setupLockAfterPreference();
+ updateLockAfterPreferenceSummary();
+ }
+
+ // visible pattern
+ mVisiblePattern = (SwitchPreference) findPreference(KEY_VISIBLE_PATTERN);
+
+ // lock instantly on power key press
+ mPowerButtonInstantlyLocks = (SwitchPreference) findPreference(
+ KEY_POWER_INSTANTLY_LOCKS);
+ Preference trustAgentPreference = findPreference(KEY_TRUST_AGENT);
+ if (mPowerButtonInstantlyLocks != null &&
+ trustAgentPreference != null &&
+ trustAgentPreference.getTitle().length() > 0) {
+ mPowerButtonInstantlyLocks.setSummary(getString(
+ R.string.lockpattern_settings_power_button_instantly_locks_summary,
+ trustAgentPreference.getTitle()));
+ }
+
+ mOwnerInfoPref = findPreference(KEY_OWNER_INFO_SETTINGS);
+ if (mOwnerInfoPref != null) {
+ mOwnerInfoPref.setEnabled(!mLockPatternUtils.isLockScreenDisabled(MY_USER_ID)
+ && !mLockPatternUtils.isDeviceOwnerInfoEnabled());
+
+ if (mOwnerInfoPref.isEnabled()) {
+ mOwnerInfoPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ OwnerInfoSettings.show(SecuritySubSettings.this);
+ return true;
+ }
+ });
+ }
+ }
+
+ Preference requireCredForStartup = findPreference(KEY_REQUIRE_CRED_BEFORE_STARTUP);
+ if (requireCredForStartup instanceof SwitchPreference) {
+ ((SwitchPreference) requireCredForStartup).setChecked(
+ mLockPatternUtils.isCredentialRequiredToDecrypt(false));
+ if (!canChangeRequireCredentialBeforeStartup(getContext())) {
+ removePreference(KEY_REQUIRE_CRED_BEFORE_STARTUP);
+ }
+ }
+
+ for (int i = 0; i < SWITCH_PREFERENCE_KEYS.length; i++) {
+ final Preference pref = findPreference(SWITCH_PREFERENCE_KEYS[i]);
+ if (pref != null) pref.setOnPreferenceChangeListener(this);
+ }
+ }
+
+ static boolean canChangeRequireCredentialBeforeStartup(Context context) {
+ DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
+ return UserManager.get(context).isAdminUser()
+ && LockPatternUtils.isDeviceEncryptionEnabled()
+ && !dpm.getDoNotAskCredentialsOnBoot();
+ }
+
+ private void setupLockAfterPreference() {
+ // Compatible with pre-Froyo
+ long currentTimeout = Settings.Secure.getLong(getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, 5000);
+ mLockAfter.setValue(String.valueOf(currentTimeout));
+ mLockAfter.setOnPreferenceChangeListener(this);
+ final EnforcedAdmin admin = RestrictedLockUtils.checkIfMaximumTimeToLockIsSet(
+ getActivity());
+ if (admin != null) {
+ final long adminTimeout = (mDPM != null ? mDPM.getMaximumTimeToLock(null) : 0);
+ final long displayTimeout = Math.max(0,
+ Settings.System.getInt(getContentResolver(), SCREEN_OFF_TIMEOUT, 0));
+ if (adminTimeout > 0) {
+ // This setting is a slave to display timeout when a device policy is enforced.
+ // As such, maxLockTimeout = adminTimeout - displayTimeout.
+ // If there isn't enough time, shows "immediately" setting.
+ disableUnusableTimeouts(Math.max(0, adminTimeout - displayTimeout), admin);
+ }
+ }
+ }
+
+ private void updateLockAfterPreferenceSummary() {
+ final String summary;
+ if (mLockAfter.isDisabledByAdmin()) {
+ summary = getString(R.string.disabled_by_policy_title);
+ } else {
+ // Update summary message with current value
+ long currentTimeout = Settings.Secure.getLong(getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, 5000);
+ final CharSequence[] entries = mLockAfter.getEntries();
+ final CharSequence[] values = mLockAfter.getEntryValues();
+ int best = 0;
+ for (int i = 0; i < values.length; i++) {
+ if (mLockAfter.isRestrictedForEntry(entries[i])) {
+ break;
+ }
+ long timeout = Long.valueOf(values[i].toString());
+ if (currentTimeout >= timeout) {
+ best = i;
+ }
+ }
+
+ Preference preference = findPreference(KEY_TRUST_AGENT);
+ if (preference != null && preference.getTitle().length() > 0) {
+ if (Long.valueOf(values[best].toString()) == 0) {
+ summary = getString(R.string.lock_immediately_summary_with_exception,
+ preference.getTitle());
+ } else {
+ summary = getString(R.string.lock_after_timeout_summary_with_exception,
+ entries[best], preference.getTitle());
+ }
+ } else {
+ summary = getString(R.string.lock_after_timeout_summary, entries[best]);
+ }
+ }
+ mLockAfter.setSummary(summary);
+ }
+
+ private void disableUnusableTimeouts(long maxTimeout, EnforcedAdmin admin) {
+ final CharSequence[] entries = mLockAfter.getEntries();
+ final CharSequence[] values = mLockAfter.getEntryValues();
+ long maxTimeoutSelectable = 0;
+ int maxTimeoutEntryIndex = -1;
+ for (int i = 0; i < values.length; i++) {
+ long timeout = Long.parseLong(values[i].toString());
+ if (timeout > maxTimeout) {
+ break;
+ }
+ maxTimeoutSelectable = timeout;
+ maxTimeoutEntryIndex = i;
+ }
+ // If there are no possible options for the user, then set this preference as
+ // disabled by admin, otherwise remove the padlock in case it was set earlier.
+ if (maxTimeoutSelectable == 0) {
+ mLockAfter.setDisabledByAdmin(admin);
+ return;
+ } else {
+ mLockAfter.setDisabledByAdmin(null);
+ }
+
+ mLockAfter.clearRestrictedItems();
+ // Set all the entries after the maximum selectable timeout as disabled by admin.
+ for (int i = maxTimeoutEntryIndex + 1; i < values.length; i++) {
+ mLockAfter.addRestrictedItem(
+ new RestrictedItem(entries[i], values[i], admin));
+ }
+
+ final int userPreference = Integer.valueOf(mLockAfter.getValue());
+ if (userPreference <= maxTimeout) {
+ mLockAfter.setValue(String.valueOf(userPreference));
+ } else if (maxTimeoutSelectable == maxTimeout) {
+ mLockAfter.setValue(String.valueOf(maxTimeout));
+ } else {
+ // There will be no highlighted selection since nothing in the list matches
+ // maxTimeout. The user can still select anything less than maxTimeout.
+ // TODO: maybe append maxTimeout to the list and mark selected.
+ }
+ }
+
+ public void updateOwnerInfo() {
+ if (mOwnerInfoPref != null) {
+ if (mLockPatternUtils.isDeviceOwnerInfoEnabled()) {
+ mOwnerInfoPref.setSummary(R.string.disabled_by_administrator_summary);
+ } else {
+ mOwnerInfoPref.setSummary(mLockPatternUtils.isOwnerInfoEnabled(MY_USER_ID)
+ ? mLockPatternUtils.getOwnerInfo(MY_USER_ID)
+ : getString(R.string.owner_info_settings_summary));
+ }
+ }
+ }
+
+ private static int getResIdForLockUnlockSubScreen(Context context,
+ LockPatternUtils lockPatternUtils) {
+ if (lockPatternUtils.isSecure(MY_USER_ID)) {
+ switch (lockPatternUtils.getKeyguardStoredPasswordQuality(MY_USER_ID)) {
+ case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
+ return R.xml.security_settings_pattern_sub;
+ case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
+ case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
+ return R.xml.security_settings_pin_sub;
+ case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC:
+ case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
+ case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX:
+ return R.xml.security_settings_password_sub;
+ }
+ } else if (!lockPatternUtils.isLockScreenDisabled(MY_USER_ID)) {
+ return R.xml.security_settings_slide_sub;
+ }
+ return 0;
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object value) {
+ String key = preference.getKey();
+ if (KEY_POWER_INSTANTLY_LOCKS.equals(key)) {
+ mLockPatternUtils.setPowerButtonInstantlyLocks((Boolean) value, MY_USER_ID);
+ } else if (KEY_LOCK_AFTER_TIMEOUT.equals(key)) {
+ int timeout = Integer.parseInt((String) value);
+ try {
+ Settings.Secure.putInt(getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, timeout);
+ } catch (NumberFormatException e) {
+ Log.e("SecuritySettings", "could not persist lockAfter timeout setting", e);
+ }
+ updateLockAfterPreferenceSummary();
+ } else if (KEY_VISIBLE_PATTERN.equals(key)) {
+ mLockPatternUtils.setVisiblePatternEnabled((Boolean) value, MY_USER_ID);
+ } else if (KEY_REQUIRE_CRED_BEFORE_STARTUP.equals(key)) {
+ Bundle extras = new Bundle();
+ extras.putBoolean(
+ ChooseLockSettingsHelper.EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT, true);
+ startFragment(this,
+ "com.android.settings.ChooseLockGeneric$ChooseLockGenericFragment",
+ R.string.lock_settings_picker_title, REQUEST_CHANGE_REQUIRE_CRED_FOR_START,
+ extras);
+ return false;
+ }
+ return true;
+ }
+ }
}
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 5d2468e..494fd3b 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -17,6 +17,7 @@
package com.android.settings;
import com.android.settings.applications.AppOpsSummary;
+import com.android.settings.fingerprint.FingerprintEnrollIntroduction;
import com.android.settings.fingerprint.FingerprintSettings;
/**
@@ -129,6 +130,10 @@
public static class ZenModeAutomationSuggestionActivity extends SettingsActivity { /* empty */ }
public static class WallpaperSuggestionActivity extends SettingsActivity { /* empty */ }
public static class FingerprintSuggestionActivity extends FingerprintSettings { /* empty */ }
+ public static class FingerprintEnrollSuggestionActivity extends FingerprintEnrollIntroduction {
+ /* empty */
+ }
+ public static class ScreenLockSuggestionActivity extends ChooseLockGeneric { /* empty */ }
// Categories.
public static class WirelessSettings extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/SettingsLicenseActivity.java b/src/com/android/settings/SettingsLicenseActivity.java
index 52b48bb..aa2e8dd 100644
--- a/src/com/android/settings/SettingsLicenseActivity.java
+++ b/src/com/android/settings/SettingsLicenseActivity.java
@@ -21,6 +21,7 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
+import android.os.StrictMode;
import android.os.SystemProperties;
import android.text.TextUtils;
import android.util.Log;
@@ -65,11 +66,14 @@
intent.setPackage("com.android.htmlviewer");
try {
+ StrictMode.disableDeathOnFileUriExposure();
startActivity(intent);
finish();
} catch (ActivityNotFoundException e) {
Log.e(TAG, "Failed to find viewer", e);
showErrorAndFinish();
+ } finally {
+ StrictMode.enableDeathOnFileUriExposure();
}
}
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 1ca32d8..5ce5cfc 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -71,15 +71,11 @@
public class AccessibilitySettings extends SettingsPreferenceFragment implements DialogCreatable,
Preference.OnPreferenceChangeListener, Indexable {
- private static final float LARGE_FONT_SCALE = 1.3f;
-
// Preference categories
private static final String SERVICES_CATEGORY = "services_category";
private static final String SYSTEM_CATEGORY = "system_category";
// Preferences
- private static final String TOGGLE_LARGE_TEXT_PREFERENCE =
- "toggle_large_text_preference";
private static final String TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE =
"toggle_high_text_contrast_preference";
private static final String TOGGLE_INVERSION_PREFERENCE =
@@ -127,8 +123,6 @@
private final Map<String, String> mLongPressTimeoutValuetoTitleMap = new HashMap<>();
- private final Configuration mCurConfig = new Configuration();
-
private final Handler mHandler = new Handler();
private final Runnable mUpdateRunnable = new Runnable() {
@@ -185,7 +179,6 @@
private PreferenceCategory mServicesCategory;
private PreferenceCategory mSystemsCategory;
- private SwitchPreference mToggleLargeTextPreference;
private SwitchPreference mToggleHighTextContrastPreference;
private SwitchPreference mTogglePowerButtonEndsCallPreference;
private SwitchPreference mToggleLockScreenRotationPreference;
@@ -274,10 +267,7 @@
@Override
public boolean onPreferenceTreeClick(Preference preference) {
- if (mToggleLargeTextPreference == preference) {
- handleToggleLargeTextPreferenceClick();
- return true;
- } else if (mToggleHighTextContrastPreference == preference) {
+ if (mToggleHighTextContrastPreference == preference) {
handleToggleTextContrastPreferenceClick();
return true;
} else if (mTogglePowerButtonEndsCallPreference == preference) {
@@ -302,15 +292,6 @@
return super.onPreferenceTreeClick(preference);
}
- private void handleToggleLargeTextPreferenceClick() {
- try {
- mCurConfig.fontScale = mToggleLargeTextPreference.isChecked() ? LARGE_FONT_SCALE : 1;
- ActivityManagerNative.getDefault().updatePersistentConfiguration(mCurConfig);
- } catch (RemoteException re) {
- /* ignore */
- }
- }
-
private void handleToggleTextContrastPreferenceClick() {
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
@@ -368,10 +349,6 @@
mServicesCategory = (PreferenceCategory) findPreference(SERVICES_CATEGORY);
mSystemsCategory = (PreferenceCategory) findPreference(SYSTEM_CATEGORY);
- // Large text.
- mToggleLargeTextPreference =
- (SwitchPreference) findPreference(TOGGLE_LARGE_TEXT_PREFERENCE);
-
// Text contrast.
mToggleHighTextContrastPreference =
(SwitchPreference) findPreference(TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE);
@@ -564,14 +541,6 @@
}
private void updateSystemPreferences() {
- // Large text.
- try {
- mCurConfig.updateFrom(ActivityManagerNative.getDefault().getConfiguration());
- } catch (RemoteException re) {
- /* ignore */
- }
- mToggleLargeTextPreference.setChecked(mCurConfig.fontScale == LARGE_FONT_SCALE);
-
// Text contrast.
mToggleHighTextContrastPreference.setChecked(
Settings.Secure.getInt(getContentResolver(),
@@ -658,7 +627,7 @@
final Resources res = getContext().getResources();
final String[] entries = res.getStringArray(R.array.entries_font_size);
final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
- final int index = ToggleFontSizePreferenceFragment.floatToIndex(
+ final int index = ToggleFontSizePreferenceFragment.fontSizeValueToIndex(
res.getConfiguration().fontScale, strEntryValues);
pref.setSummary(entries[index]);
}
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
index 052f6fb..eaab57d 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
@@ -188,7 +188,7 @@
final Resources res = getContext().getResources();
final String[] entries = res.getStringArray(R.array.entries_font_size);
final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
- final int index = ToggleFontSizePreferenceFragment.floatToIndex(
+ final int index = ToggleFontSizePreferenceFragment.fontSizeValueToIndex(
res.getConfiguration().fontScale, strEntryValues);
pref.setSummary(entries[index]);
}
diff --git a/src/com/android/settings/accessibility/ToggleFontSizePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFontSizePreferenceFragment.java
index 4a8cd32..1c5d8dc 100644
--- a/src/com/android/settings/accessibility/ToggleFontSizePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFontSizePreferenceFragment.java
@@ -48,7 +48,7 @@
final Configuration origConfig = res.getConfiguration();
mEntries = res.getStringArray(R.array.entries_font_size);
final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
- mInitialIndex = floatToIndex(origConfig.fontScale, strEntryValues);
+ mInitialIndex = fontSizeValueToIndex(origConfig.fontScale, strEntryValues);
mValues = new float[strEntryValues.length];
for (int i = 0; i < strEntryValues.length; ++i) {
mValues[i] = Float.parseFloat(strEntryValues[i]);
@@ -86,7 +86,7 @@
* Utility function that returns the index in a string array with which the represented value is
* the closest to a given float value.
*/
- static int floatToIndex(float val, String[] indices) {
+ public static int fontSizeValueToIndex(float val, String[] indices) {
float lastVal = Float.parseFloat(indices[0]);
for (int i=1; i<indices.length; i++) {
float thisVal = Float.parseFloat(indices[i]);
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index 80719b2..041fed8 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -16,15 +16,111 @@
package com.android.settings.accessibility;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Point;
+import android.os.Bundle;
import android.provider.Settings;
+import android.media.MediaPlayer;
+import android.media.MediaPlayer.OnPreparedListener;
+import android.net.Uri;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.view.Display;
+import android.view.Gravity;
+import android.view.WindowManager;
+import android.widget.MediaController;
+import android.widget.RelativeLayout;
+import android.widget.VideoView;
import com.android.internal.logging.MetricsProto.MetricsEvent;
+import com.android.settings.R;
import com.android.settings.widget.ToggleSwitch;
import com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
public class ToggleScreenMagnificationPreferenceFragment
extends ToggleFeaturePreferenceFragment {
+ protected class VideoPreference extends Preference {
+ public VideoPreference(Context context) {
+ super(context);
+ }
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder view) {
+ super.onBindViewHolder(view);
+ view.setDividerAllowedAbove(false);
+ view.setDividerAllowedBelow(false);
+ final RelativeLayout background =
+ (RelativeLayout) view.findViewById(R.id.video_background);
+ final VideoView videoView = (VideoView) view.findViewById(R.id.video);
+
+ // Hacky adjustment for using VideoView in recycle view and positioning
+ // it on the background image
+ Resources res = getPrefContext().getResources();
+ final int backgroundWidth = res.getDimensionPixelSize(
+ R.dimen.screen_magnification_video_background_width);
+ final int backgroundHeight = res.getDimensionPixelSize(
+ R.dimen.screen_magnification_video_background_height);
+ final int videoWidth = res.getDimensionPixelSize(
+ R.dimen.screen_magnification_video_width);
+ final int videoHeight = res.getDimensionPixelSize(
+ R.dimen.screen_magnification_video_height);
+ final int videoMarginTop = res.getDimensionPixelSize(
+ R.dimen.screen_magnification_video_margin_top);
+ final int screenWidth = getScreenWidth(getPrefContext());
+
+ RelativeLayout.LayoutParams videoLp = new RelativeLayout.LayoutParams(
+ screenWidth * videoWidth / backgroundWidth,
+ screenWidth * videoHeight / backgroundWidth);
+ videoLp.setMargins(0, screenWidth * videoMarginTop / backgroundWidth, 0, 0);
+ videoView.setLayoutParams(videoLp);
+
+ RelativeLayout.LayoutParams backgroundLp = new RelativeLayout.LayoutParams(
+ screenWidth,
+ screenWidth * backgroundHeight / backgroundWidth);
+ background.setLayoutParams(backgroundLp);
+ background.setBackgroundResource(
+ R.drawable.accessibility_screen_magnification_background);
+ background.setGravity(Gravity.CENTER_HORIZONTAL);
+
+ // Loop the video.
+ videoView.setOnPreparedListener(new OnPreparedListener() {
+ @Override
+ public void onPrepared(MediaPlayer mediaPlayer) {
+ mediaPlayer.setLooping(true);
+ }
+ });
+
+ videoView.setVideoURI(Uri.parse(String.format("%s://%s/%s",
+ ContentResolver.SCHEME_ANDROID_RESOURCE,
+ getPrefContext().getPackageName(),
+ R.raw.accessibility_screen_magnification)));
+ videoView.setMediaController(new MediaController(getPrefContext()));
+ videoView.start();
+ }
+ }
+
+ protected VideoPreference mVideoPreference;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mVideoPreference = new VideoPreference(getPrefContext());
+ mVideoPreference.setSelectable(false);
+ mVideoPreference.setPersistent(false);
+ mVideoPreference.setLayoutResource(R.layout.video_preference);
+
+ final PreferenceScreen preferenceScreen = getPreferenceManager().getPreferenceScreen();
+ preferenceScreen.setOrderingAsAdded(false);
+ mVideoPreference.setOrder(0);
+ mSummaryPreference.setOrder(1);
+ preferenceScreen.addPreference(mVideoPreference);
+ }
+
@Override
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
// Do nothing.
@@ -34,7 +130,7 @@
protected void onInstallSwitchBarToggleSwitch() {
super.onInstallSwitchBarToggleSwitch();
mToggleSwitch.setOnBeforeCheckedChangeListener(new OnBeforeCheckedChangeListener() {
- @Override
+ @Override
public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
mSwitchBar.setCheckedInternal(checked);
getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, checked);
@@ -72,4 +168,12 @@
protected int getMetricsCategory() {
return MetricsEvent.ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION;
}
+
+ private static int getScreenWidth(Context context) {
+ WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ Display display = wm.getDefaultDisplay();
+ Point size = new Point();
+ display.getSize(size);
+ return size.x;
+ }
}
diff --git a/src/com/android/settings/dashboard/SuggestionsChecks.java b/src/com/android/settings/dashboard/SuggestionsChecks.java
index fde7bc1..d465942 100644
--- a/src/com/android/settings/dashboard/SuggestionsChecks.java
+++ b/src/com/android/settings/dashboard/SuggestionsChecks.java
@@ -18,6 +18,7 @@
import android.app.IWallpaperManager;
import android.app.IWallpaperManager.Stub;
import android.app.IWallpaperManagerCallback;
+import android.app.KeyguardManager;
import android.app.NotificationManager;
import android.content.Context;
import android.hardware.fingerprint.FingerprintManager;
@@ -26,7 +27,9 @@
import android.os.RemoteException;
import android.os.ServiceManager;
import com.android.ims.ImsManager;
+import com.android.settings.Settings.FingerprintEnrollSuggestionActivity;
import com.android.settings.Settings.FingerprintSuggestionActivity;
+import com.android.settings.Settings.ScreenLockSuggestionActivity;
import com.android.settings.Settings.WallpaperSuggestionActivity;
import com.android.settings.Settings.WifiCallingSuggestionActivity;
import com.android.settings.Settings.ZenModeAutomationSuggestionActivity;
@@ -55,10 +58,18 @@
return isWifiCallingUnavailableOrEnabled();
} else if (className.equals(FingerprintSuggestionActivity.class.getName())) {
return isNotSingleFingerprintEnrolled();
+ } else if (className.equals(ScreenLockSuggestionActivity.class.getName())
+ || className.equals(FingerprintEnrollSuggestionActivity.class.getName())) {
+ return isDeviceSecured();
}
return false;
}
+ private boolean isDeviceSecured() {
+ KeyguardManager km = mContext.getSystemService(KeyguardManager.class);
+ return km.isKeyguardSecure();
+ }
+
private boolean isNotSingleFingerprintEnrolled() {
FingerprintManager manager = mContext.getSystemService(FingerprintManager.class);
return manager == null || manager.getEnrolledFingerprints().size() != 1;
diff --git a/src/com/android/settings/datausage/CellDataPreference.java b/src/com/android/settings/datausage/CellDataPreference.java
index fa333f1..d64bef4 100644
--- a/src/com/android/settings/datausage/CellDataPreference.java
+++ b/src/com/android/settings/datausage/CellDataPreference.java
@@ -48,7 +48,7 @@
private static final String TAG = "CellDataPreference";
- public int mSubId;
+ public int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
public boolean mChecked;
public boolean mMultiSimDialog;
private TelephonyManager mTelephonyManager;
@@ -65,8 +65,10 @@
mTelephonyManager = TelephonyManager.from(getContext());
mChecked = state.mChecked;
mMultiSimDialog = state.mMultiSimDialog;
- mSubId = state.mSubId;
- setKey(getKey() + mSubId);
+ if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ mSubId = state.mSubId;
+ setKey(getKey() + mSubId);
+ }
notifyChanged();
}
@@ -110,7 +112,6 @@
@Override
protected void performClick(View view) {
- super.performClick(view);
MetricsLogger.action(getContext(), MetricsEvent.ACTION_CELL_DATA_TOGGLE, !mChecked);
if (mChecked) {
// disabling data; show confirmation dialog which eventually
diff --git a/src/com/android/settings/datausage/DataUsageSummary.java b/src/com/android/settings/datausage/DataUsageSummary.java
index e1936ed..3195641 100644
--- a/src/com/android/settings/datausage/DataUsageSummary.java
+++ b/src/com/android/settings/datausage/DataUsageSummary.java
@@ -138,6 +138,7 @@
TemplatePreferenceCategory category = (TemplatePreferenceCategory)
inflatePreferences(R.xml.data_usage_cellular);
category.setTemplate(getNetworkTemplate(subId), subId, services);
+ category.pushTemplates(services);
}
private void addWifiSection() {
diff --git a/src/com/android/settings/localepicker/LocaleListEditor.java b/src/com/android/settings/localepicker/LocaleListEditor.java
index 24e5e53..8161036 100644
--- a/src/com/android/settings/localepicker/LocaleListEditor.java
+++ b/src/com/android/settings/localepicker/LocaleListEditor.java
@@ -155,7 +155,7 @@
final MenuItem menuItem =
menu.add(Menu.NONE, MENU_ID_REMOVE, 0, R.string.locale_remove_menu);
menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT);
- menuItem.setIcon(android.R.drawable.ic_menu_delete);
+ menuItem.setIcon(R.drawable.ic_delete);
super.onCreateOptionsMenu(menu, inflater);
mMenu = menu;
}
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index f3e95ab..626e5a4 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -22,8 +22,7 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
-import android.service.notification.NotificationListenerService;
-import android.support.v14.preference.SwitchPreference;
+import android.service.notification.NotificationListenerService.Ranking;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
import android.support.v7.preference.Preference.OnPreferenceClickListener;
@@ -37,7 +36,12 @@
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.applications.AppInfoBase;
+import com.android.settings.applications.LayoutPreference;
import com.android.settings.notification.NotificationBackend.AppRow;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedSwitchPreference;
+import com.android.settingslib.RestrictedPreference;
+
import java.util.List;
@@ -54,7 +58,7 @@
= new Intent(Intent.ACTION_MAIN)
.addCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES);
- private SwitchPreference mBlock;
+ private RestrictedSwitchPreference mBlock;
private PreferenceCategory mCategories;
private AppRow mAppRow;
@@ -75,7 +79,16 @@
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.app_notification_settings);
- getPreferenceScreen().setOrderingAsAdded(true);
+ mCategories = (PreferenceCategory) findPreference(KEY_CATEGORIES);
+ mBlock = (RestrictedSwitchPreference) findPreference(KEY_BLOCK);
+ mImportance = (ImportanceSeekBarPreference) findPreference(KEY_IMPORTANCE);
+ mImportanceReset = (LayoutPreference) findPreference(KEY_IMPORTANCE_RESET);
+ mImportanceTitle = findPreference(KEY_IMPORTANCE_TITLE);
+ mPriority =
+ (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BYPASS_DND);
+ mSensitive =
+ (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_SENSITIVE);
+
mAppRow = mBackend.loadAppRow(mPm, mPkgInfo);
// load settings intent
@@ -86,18 +99,17 @@
// Add topics
List<Notification.Topic> topics = mBackend.getTopics(mPkg, mUid);
if (topics.size() <= 1) {
- setupImportancePref(mAppRow, null, mAppRow.appImportance);
- setupPriorityPref(null, mAppRow.appBypassDnd);
- setupSensitivePref(null, mAppRow.appSensitive);
+ removeAppPrefs();
+ setupImportancePrefs(mAppRow.systemApp, mAppRow.appImportance);
+ setupPriorityPref(mAppRow.appBypassDnd);
+ setupSensitivePref(mAppRow.appSensitive);
} else {
+ removeTopicPrefs();
setupBlockSwitch();
- mCategories = new PreferenceCategory(getPrefContext());
- mCategories.setKey(KEY_CATEGORIES);
- mCategories.setTitle(R.string.notification_topic_categories);
- mCategories.setOrderingAsAdded(true);
- getPreferenceScreen().addPreference(mCategories);
for (Notification.Topic topic : topics) {
- Preference topicPreference = new Preference(getPrefContext());
+ RestrictedPreference topicPreference = new RestrictedPreference(getPrefContext());
+ topicPreference.setDisabledByAdmin(
+ RestrictedLockUtils.checkIfApplicationIsSuspended(mContext, mPkg, mUserId));
topicPreference.setKey(topic.getId());
topicPreference.setTitle(topic.getLabel());
// Create intent for this preference.
@@ -132,20 +144,30 @@
@Override
protected void updateDependents(int progress) {
- updateDependents(progress == NotificationListenerService.Ranking.IMPORTANCE_NONE);
+ updateDependents(progress == Ranking.IMPORTANCE_NONE);
+ }
+
+ private void removeTopicPrefs() {
+ setVisible(mImportance, false);
+ setVisible(mImportanceReset, false);
+ setVisible(mImportanceTitle, false);
+ setVisible(mPriority, false);
+ setVisible(mSensitive, false);
+ }
+
+ private void removeAppPrefs() {
+ setVisible(mBlock, false);
+ setVisible(mCategories, false);
}
private void updateDependents(boolean banned) {
- if (mBlock != null) {
- mBlock.setEnabled(!mAppRow.systemApp);
- }
- if (mCategories != null) {
- setVisible(mCategories, !banned);
- }
+ mBlock.setEnabled(!mAppRow.systemApp);
+ mCategories.setEnabled(!banned);
}
private void setupBlockSwitch() {
- mBlock = new SwitchPreference(getPrefContext());
+ mBlock.setDisabledByAdmin(
+ RestrictedLockUtils.checkIfApplicationIsSuspended(mContext, mPkg, mUserId));
mBlock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
@@ -153,17 +175,13 @@
if (banned) {
MetricsLogger.action(getActivity(), MetricsEvent.ACTION_BAN_APP_NOTES, mPkg);
}
- final boolean success = mBackend.setNotificationsBanned(mPkg, mUid, banned);
+ final boolean success = mBackend.setNotificationsBanned(mPkg, mUid, banned);
if (success) {
updateDependents(banned);
}
return success;
}
});
- mBlock.setKey(KEY_BLOCK);
- mBlock.setTitle(R.string.app_notification_block_title);
- mBlock.setSummary(R.string.app_notification_block_summary);
- getPreferenceScreen().addPreference(mBlock);
mBlock.setChecked(mAppRow.banned);
updateDependents(mAppRow.banned);
}
diff --git a/src/com/android/settings/notification/ImportanceSeekBarPreference.java b/src/com/android/settings/notification/ImportanceSeekBarPreference.java
index 920fcc3..aff9688 100644
--- a/src/com/android/settings/notification/ImportanceSeekBarPreference.java
+++ b/src/com/android/settings/notification/ImportanceSeekBarPreference.java
@@ -20,12 +20,10 @@
import com.android.settings.SeekBarPreference;
import android.content.Context;
-import android.service.notification.NotificationListenerService;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.SeekBar;
-import android.widget.TextView;
/**
* A slider preference that controls notification importance.
@@ -35,8 +33,6 @@
private static final String TAG = "ImportanceSeekBarPref";
private Callback mCallback;
- private TextView mSummaryTextView;
- private String mSummary;
private int mMinProgress;
private boolean mSystemApp;
@@ -64,6 +60,7 @@
public void setMinimumProgress(int minProgress) {
mMinProgress = minProgress;
+ notifyChanged();
}
public void setSystemApp(boolean systemApp) {
@@ -74,17 +71,12 @@
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
- mSummaryTextView = (TextView) view.findViewById(com.android.internal.R.id.summary);
if (mSystemApp) {
((ImageView) view.findViewById(R.id.low_importance)).getDrawable().setTint(
getContext().getColor(R.color.importance_disabled_tint));
}
- }
-
- @Override
- public void setProgress(int progress) {
- mSummary = getProgressSummary(progress);
- super.setProgress(progress);
+ view.setDividerAllowedAbove(false);
+ view.setDividerAllowedBelow(false);
}
@Override
@@ -94,37 +86,11 @@
seekBar.setProgress(mMinProgress);
progress = mMinProgress;
}
- mSummary = getProgressSummary(progress);
- if (mSummaryTextView != null) {
- mSummaryTextView.setText(mSummary);
- }
if (fromTouch) {
mCallback.onImportanceChanged(progress);
}
}
- @Override
- public CharSequence getSummary() {
- return mSummary;
- }
-
- private String getProgressSummary(int progress) {
- switch (progress) {
- case NotificationListenerService.Ranking.IMPORTANCE_NONE:
- return getContext().getString(R.string.notification_importance_blocked);
- case NotificationListenerService.Ranking.IMPORTANCE_LOW:
- return getContext().getString(R.string.notification_importance_low);
- case NotificationListenerService.Ranking.IMPORTANCE_DEFAULT:
- return getContext().getString(R.string.notification_importance_default);
- case NotificationListenerService.Ranking.IMPORTANCE_HIGH:
- return getContext().getString(R.string.notification_importance_high);
- case NotificationListenerService.Ranking.IMPORTANCE_MAX:
- return getContext().getString(R.string.notification_importance_max);
- default:
- return "";
- }
- }
-
public interface Callback {
void onImportanceChanged(int progress);
}
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index a669d95..740f8c1 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -19,6 +19,9 @@
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.applications.AppInfoBase;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedSwitchPreference;
+import com.android.settings.applications.LayoutPreference;
import android.app.Notification;
import android.content.Context;
@@ -27,34 +30,45 @@
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
+import android.os.UserHandle;
import android.provider.Settings;
import android.service.notification.NotificationListenerService.Ranking;
-import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.text.TextUtils;
import android.util.Log;
+import android.view.View;
+import android.widget.Button;
import android.widget.Toast;
+import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
abstract public class NotificationSettingsBase extends SettingsPreferenceFragment {
private static final String TAG = "NotifiSettingsBase";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
protected static final String ARG_PACKAGE_INFO = "arg_info";
+ protected static final String ARG_TOPIC = "arg_topic";
protected static final String KEY_BYPASS_DND = "bypass_dnd";
protected static final String KEY_SENSITIVE = "sensitive";
protected static final String KEY_IMPORTANCE = "importance";
+ protected static final String KEY_IMPORTANCE_TITLE = "importance_title";
+ protected static final String KEY_IMPORTANCE_RESET = "importance_reset_button";
protected PackageManager mPm;
protected final NotificationBackend mBackend = new NotificationBackend();
protected Context mContext;
protected boolean mCreated;
protected int mUid;
+ protected int mUserId;
protected String mPkg;
protected PackageInfo mPkgInfo;
+ protected Notification.Topic mTopic;
protected ImportanceSeekBarPreference mImportance;
- protected SwitchPreference mPriority;
- protected SwitchPreference mSensitive;
+ protected Preference mImportanceTitle;
+ protected LayoutPreference mImportanceReset;
+ protected RestrictedSwitchPreference mPriority;
+ protected RestrictedSwitchPreference mSensitive;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
@@ -94,6 +108,7 @@
toastAndFinish();
return;
}
+ mUserId = UserHandle.getUserId(mUid);
if (DEBUG) Log.d(TAG, "Load details for pkg=" + mPkg + " uid=" + mUid);
mPkgInfo = args != null && args.containsKey(ARG_PACKAGE_INFO)
@@ -107,75 +122,116 @@
toastAndFinish();
return;
}
+
+ // Will be null for app wide settings.
+ mTopic = args != null && args.containsKey(ARG_TOPIC)
+ ? (Notification.Topic) args.getParcelable(ARG_TOPIC) : null;
}
@Override
public void onResume() {
super.onResume();
- if (mUid != -1 && getPackageManager().getPackagesForUid(mUid) == null) {
+ if ((mUid != -1 && getPackageManager().getPackagesForUid(mUid) == null)) {
// App isn't around anymore, must have been removed.
finish();
+ return;
+ }
+ EnforcedAdmin admin = RestrictedLockUtils.checkIfApplicationIsSuspended(
+ mContext, mPkg, mUserId);
+ if (mImportance != null) {
+ mImportance.setDisabledByAdmin(admin);
+ }
+ if (mPriority != null) {
+ mPriority.setDisabledByAdmin(admin);
+ }
+ if (mSensitive != null) {
+ mSensitive.setDisabledByAdmin(admin);
}
}
- protected void setupImportancePref(final NotificationBackend.AppRow appRow,
- final Notification.Topic topic, int importance) {
- if (mImportance == null) {
- mImportance = new ImportanceSeekBarPreference(getPrefContext());
- mImportance.setTitle(R.string.notification_importance_title);
- mImportance.setKey(KEY_IMPORTANCE);
- getPreferenceScreen().addPreference(mImportance);
+ protected void setupImportancePrefs(boolean isSystemApp, int importance) {
+ mImportance.setDisabledByAdmin(
+ RestrictedLockUtils.checkIfApplicationIsSuspended(mContext, mPkg, mUserId));
+ if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
+ mImportance.setVisible(false);
+ mImportanceReset.setVisible(false);
+ mImportanceTitle.setOnPreferenceClickListener(showEditableImportance);
+ } else {
+ mImportanceTitle.setOnPreferenceClickListener(null);
}
- mImportance.setSystemApp(appRow.systemApp);
+
+ mImportanceTitle.setSummary(getProgressSummary(importance));
+ mImportance.setSystemApp(isSystemApp);
mImportance.setMinimumProgress(
- appRow.systemApp ? Ranking.IMPORTANCE_LOW : Ranking.IMPORTANCE_NONE);
+ isSystemApp ? Ranking.IMPORTANCE_LOW : Ranking.IMPORTANCE_NONE);
mImportance.setMax(Ranking.IMPORTANCE_MAX);
- // TODO: stop defaulting to 'normal' in the UI when there are mocks for this scenario.
- importance = importance == Ranking.IMPORTANCE_UNSPECIFIED
- ? Ranking.IMPORTANCE_DEFAULT
- : importance;
mImportance.setProgress(importance);
mImportance.setCallback(new ImportanceSeekBarPreference.Callback() {
@Override
public void onImportanceChanged(int progress) {
- mBackend.setImportance(appRow.pkg, appRow.uid, topic, progress);
+ mBackend.setImportance(mPkg, mUid, mTopic, progress);
+ mImportanceTitle.setSummary(getProgressSummary(progress));
updateDependents(progress);
}
});
+
+ Button button = (Button) mImportanceReset.findViewById(R.id.left_button);
+ button.setText(R.string.importance_reset);
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mBackend.setImportance(mPkg, mUid, mTopic, Ranking.IMPORTANCE_UNSPECIFIED);
+ mImportanceReset.setVisible(false);
+ mImportance.setVisible(false);
+ mImportanceTitle.setOnPreferenceClickListener(showEditableImportance);
+ mImportanceTitle.setSummary(getProgressSummary(Ranking.IMPORTANCE_UNSPECIFIED));
+ updateDependents(Ranking.IMPORTANCE_UNSPECIFIED);
+ }
+ });
+ mImportanceReset.findViewById(R.id.right_button).setVisibility(View.INVISIBLE);
}
- protected void setupPriorityPref(final Notification.Topic topic, boolean priority) {
- if (mPriority == null) {
- mPriority = new SwitchPreference(getPrefContext());
- mPriority.setTitle(R.string.app_notification_override_dnd_title);
- mPriority.setSummary(R.string.app_notification_override_dnd_summary);
- mPriority.setKey(KEY_BYPASS_DND);
- getPreferenceScreen().addPreference(mPriority);
+ private String getProgressSummary(int progress) {
+ switch (progress) {
+ case Ranking.IMPORTANCE_NONE:
+ return mContext.getString(R.string.notification_importance_blocked);
+ case Ranking.IMPORTANCE_LOW:
+ return mContext.getString(R.string.notification_importance_low);
+ case Ranking.IMPORTANCE_DEFAULT:
+ return mContext.getString(R.string.notification_importance_default);
+ case Ranking.IMPORTANCE_HIGH:
+ return mContext.getString(R.string.notification_importance_high);
+ case Ranking.IMPORTANCE_MAX:
+ return mContext.getString(R.string.notification_importance_max);
+ case Ranking.IMPORTANCE_UNSPECIFIED:
+ return mContext.getString(R.string.notification_importance_none);
+ default:
+ return "";
}
+ }
+
+ protected void setupPriorityPref(boolean priority) {
+ mPriority.setDisabledByAdmin(
+ RestrictedLockUtils.checkIfApplicationIsSuspended(mContext, mPkg, mUserId));
mPriority.setChecked(priority);
mPriority.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean bypassZenMode = (Boolean) newValue;
- return mBackend.setBypassZenMode(mPkgInfo.packageName, mUid, topic, bypassZenMode);
+ return mBackend.setBypassZenMode(mPkgInfo.packageName, mUid, mTopic, bypassZenMode);
}
});
}
- protected void setupSensitivePref(final Notification.Topic topic, boolean sensitive) {
- if (mSensitive == null) {
- mSensitive = new SwitchPreference(getPrefContext());
- mSensitive.setTitle(R.string.app_notification_sensitive_title);
- mSensitive.setSummary(R.string.app_notification_sensitive_summary);
- mSensitive.setKey(KEY_SENSITIVE);
- getPreferenceScreen().addPreference(mSensitive);
- }
+ protected void setupSensitivePref(boolean sensitive) {
+ mSensitive.setDisabledByAdmin(
+ RestrictedLockUtils.checkIfApplicationIsSuspended(mContext, mPkg, mUserId));
mSensitive.setChecked(sensitive);
mSensitive.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean sensitive = (Boolean) newValue;
- return mBackend.setSensitive(mPkgInfo.packageName, mUid, topic, sensitive);
+ return mBackend.setSensitive(mPkgInfo.packageName, mUid, mTopic, sensitive);
}
});
}
@@ -214,4 +270,18 @@
}
return null;
}
+
+ private Preference.OnPreferenceClickListener showEditableImportance =
+ new Preference.OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ mBackend.setImportance(mPkg, mUid, mTopic, Ranking.IMPORTANCE_DEFAULT);
+ mImportance.setProgress(Ranking.IMPORTANCE_DEFAULT);
+ mImportanceTitle.setSummary(getProgressSummary(Ranking.IMPORTANCE_DEFAULT));
+ mImportance.setVisible(true);
+ mImportanceReset.setVisible(true);
+ mImportanceTitle.setOnPreferenceClickListener(null);
+ return true;
+ }
+ };
}
diff --git a/src/com/android/settings/notification/TopicNotificationSettings.java b/src/com/android/settings/notification/TopicNotificationSettings.java
index 96104e4..bbbcade 100644
--- a/src/com/android/settings/notification/TopicNotificationSettings.java
+++ b/src/com/android/settings/notification/TopicNotificationSettings.java
@@ -20,33 +20,19 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.AppHeader;
import com.android.settings.R;
-import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.applications.AppInfoBase;
+import com.android.settings.applications.LayoutPreference;
import com.android.settings.notification.NotificationBackend.TopicRow;
+import com.android.settingslib.RestrictedSwitchPreference;
-import android.app.Notification;
import android.app.NotificationManager;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.UserHandle;
import android.provider.Settings;
-import android.service.notification.NotificationListenerService;
import android.service.notification.NotificationListenerService.Ranking;
-import android.support.v14.preference.SwitchPreference;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.Preference.OnPreferenceChangeListener;
-import android.util.Log;
-import android.widget.Toast;
/** These settings are per topic, so should not be returned in global search results. */
public class TopicNotificationSettings extends NotificationSettingsBase {
private static final String TAG = "TopicNotiSettings";
-
- protected static final String ARG_TOPIC = "arg_topic";
-
private TopicRow mTopicRow;
private boolean mDndVisualEffectsSuppressed;
@@ -71,25 +57,23 @@
NotificationManager.from(mContext).getNotificationPolicy();
mDndVisualEffectsSuppressed = policy == null ? false : policy.suppressedVisualEffects != 0;
- Bundle args = getArguments();
- final Notification.Topic topic = args != null && args.containsKey(ARG_TOPIC)
- ? (Notification.Topic) args.getParcelable(ARG_TOPIC) : null;
- if (topic == null) {
+ if (mTopic == null) {
toastAndFinish();
return;
}
addPreferencesFromResource(R.xml.topic_notification_settings);
- mTopicRow = mBackend.loadTopicRow(mPm, mPkgInfo, topic);
+ mTopicRow = mBackend.loadTopicRow(mPm, mPkgInfo, mTopic);
mImportance = (ImportanceSeekBarPreference) findPreference(KEY_IMPORTANCE);
- setupImportancePref(mTopicRow, mTopicRow.topic, mTopicRow.importance);
+ mImportanceReset = (LayoutPreference) findPreference(KEY_IMPORTANCE_RESET);
+ mImportanceTitle = findPreference(KEY_IMPORTANCE_TITLE);
+ mPriority = (RestrictedSwitchPreference) findPreference(KEY_BYPASS_DND);
+ mSensitive = (RestrictedSwitchPreference) findPreference(KEY_SENSITIVE);
- mPriority = (SwitchPreference) findPreference(KEY_BYPASS_DND);
- setupPriorityPref(mTopicRow.topic, mTopicRow.priority);
-
- mSensitive = (SwitchPreference) findPreference(KEY_SENSITIVE);
- setupSensitivePref(mTopicRow.topic, mTopicRow.sensitive);
+ setupImportancePrefs(mTopicRow.systemApp, mTopicRow.importance);
+ setupPriorityPref(mTopicRow.priority);
+ setupSensitivePref(mTopicRow.sensitive);
updateDependents(mTopicRow.importance);
}
@@ -101,13 +85,19 @@
final boolean lockscreenNotificationsEnabled = getLockscreenNotificationsEnabled();
final boolean allowPrivate = getLockscreenAllowPrivateNotifications();
-
- setVisible(mPriority, importance > NotificationListenerService.Ranking.IMPORTANCE_DEFAULT
+ setVisible(mPriority, checkCanBeVisible(Ranking.IMPORTANCE_DEFAULT, importance)
&& !mDndVisualEffectsSuppressed);
- setVisible(mSensitive, (importance > NotificationListenerService.Ranking.IMPORTANCE_LOW)
+ setVisible(mSensitive, checkCanBeVisible(Ranking.IMPORTANCE_LOW, importance)
&& lockscreenSecure && lockscreenNotificationsEnabled && allowPrivate);
}
+ protected boolean checkCanBeVisible(int minImportanceVisible, int importance) {
+ if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
+ return true;
+ }
+ return importance > minImportanceVisible;
+ }
+
private boolean getLockscreenNotificationsEnabled() {
return Settings.Secure.getInt(getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;