Merge "Clean up ConditionalCards"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 8cad8a4..aa98c62 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -59,6 +59,7 @@
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.STATUS_BAR" />
<uses-permission android:name="android.permission.MANAGE_USB" />
+ <uses-permission android:name="android.permission.MANAGE_DEBUGGING" />
<uses-permission android:name="android.permission.SET_POINTER_SPEED" />
<uses-permission android:name="android.permission.SET_KEYBOARD_LAYOUT" />
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
@@ -80,6 +81,8 @@
<uses-permission android:name="android.permission.OVERRIDE_WIFI_CONFIG" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.MANAGE_FINGERPRINT" />
+ <uses-permission android:name="android.permission.USE_BIOMETRIC" />
+ <uses-permission android:name="android.permission.USE_BIOMETRIC_INTERNAL" />
<uses-permission android:name="android.permission.USER_ACTIVITY" />
<uses-permission android:name="android.permission.CHANGE_APP_IDLE_STATE" />
<uses-permission android:name="android.permission.PEERS_MAC_ADDRESS"/>
@@ -1451,7 +1454,7 @@
<!-- Lock screen settings -->
<activity android:name=".password.ConfirmDeviceCredentialActivity"
android:exported="true"
- android:theme="@android:style/Theme.NoDisplay">
+ android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter android:priority="1">
<action android:name="android.app.action.CONFIRM_DEVICE_CREDENTIAL" />
<action android:name="android.app.action.CONFIRM_FRP_CREDENTIAL" />
@@ -1524,6 +1527,15 @@
android:exported="false"
android:screenOrientation="portrait"/>
+ <activity android:name=".biometrics.BiometricEnrollActivity"
+ android:exported="true"
+ android:theme="@style/GlifTheme.Light">
+ <intent-filter>
+ <action android:name="android.settings.BIOMETRIC_ENROLL" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
<activity android:name=".biometrics.fingerprint.FingerprintSettings" android:exported="false"/>
<activity android:name=".biometrics.fingerprint.FingerprintEnrollFindSensor" android:exported="false"/>
<activity android:name=".biometrics.fingerprint.FingerprintEnrollEnrolling" android:exported="false"/>
diff --git a/res/anim/confirm_credential_biometric_transition_enter.xml b/res/anim/confirm_credential_biometric_transition_enter.xml
new file mode 100644
index 0000000..56f3593
--- /dev/null
+++ b/res/anim/confirm_credential_biometric_transition_enter.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2018 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shareInterpolator="false"
+ android:zAdjustment="top">
+ <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
+ android:interpolator="@android:interpolator/linear_out_slow_in"
+ android:duration="350"/>
+</set>
\ No newline at end of file
diff --git a/res/anim/confirm_credential_biometric_transition_exit.xml b/res/anim/confirm_credential_biometric_transition_exit.xml
new file mode 100644
index 0000000..debdce2
--- /dev/null
+++ b/res/anim/confirm_credential_biometric_transition_exit.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2018 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shareInterpolator="false"
+ android:zAdjustment="top">
+ <alpha android:fromAlpha="1.0" android:toAlpha="0.0"
+ android:interpolator="@android:interpolator/linear_out_slow_in"
+ android:duration="350" />
+</set>
\ No newline at end of file
diff --git a/res/drawable/ic_fingerprint_error.xml b/res/drawable/ic_fingerprint_error.xml
deleted file mode 100644
index c9363bc..0000000
--- a/res/drawable/ic_fingerprint_error.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<!--
- ~ Copyright (C) 2015 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="32dp"
- android:height="32dp"
- android:viewportWidth="32.0"
- android:viewportHeight="32.0">
- <path
- android:fillColor="?android:attr/colorError"
- android:pathData="M15.99,2.5C8.53,2.5 2.5,8.54 2.5,16.0s6.03,13.5 13.49,13.5S29.5,23.46 29.5,16.0S23.45,2.5 15.99,2.5zM16.0,26.8c-5.97,0.0 -10.8,-4.83 -10.8,-10.8S10.03,5.2 16.0,5.2S26.8,10.03 26.8,16.0S21.97,26.8 16.0,26.8z"/>
- <path
- android:fillColor="?android:attr/colorError"
- android:pathData="M14.65,20.05l2.7,0.0l0.0,2.7l-2.7,0.0z"/>
- <path
- android:fillColor="?android:attr/colorError"
- android:pathData="M14.65,9.25l2.7,0.0l0.0,8.1l-2.7,0.0z"/>
-</vector>
diff --git a/res/layout-land/confirm_lock_password.xml b/res/layout-land/confirm_lock_password.xml
index 218192c..a6a85d3 100644
--- a/res/layout-land/confirm_lock_password.xml
+++ b/res/layout-land/confirm_lock_password.xml
@@ -87,14 +87,6 @@
</LinearLayout>
- <ImageView
- android:id="@+id/fingerprintIcon"
- android:layout_gravity="end|bottom"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginBottom="28dp"
- android:layout_marginEnd="20dp"
- android:visibility="gone"/>
</FrameLayout>
</LinearLayout>
diff --git a/res/layout-land/confirm_lock_pattern.xml b/res/layout-land/confirm_lock_pattern.xml
index 81f257e..b0a0a96 100644
--- a/res/layout-land/confirm_lock_pattern.xml
+++ b/res/layout-land/confirm_lock_pattern.xml
@@ -108,14 +108,6 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
-
- <ImageView
- android:id="@+id/fingerprintIcon"
- android:layout_gravity="center_vertical"
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:visibility="gone"/>
</LinearLayout>
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
diff --git a/res/layout-land/confirm_lock_pattern_normal.xml b/res/layout-land/confirm_lock_pattern_normal.xml
index 9c90d6f..158d343 100644
--- a/res/layout-land/confirm_lock_pattern_normal.xml
+++ b/res/layout-land/confirm_lock_pattern_normal.xml
@@ -85,14 +85,6 @@
android:layout_marginEnd="?attr/suwMarginSides"
android:layout_marginBottom="24dp"
android:gravity="center_vertical"/>
-
- <ImageView
- android:id="@+id/fingerprintIcon"
- android:layout_gravity="center_horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:contentDescription="@string/confirm_fingerprint_icon_content_description"
- android:visibility="gone"/>
</LinearLayout>
</ScrollView>
diff --git a/res/layout/confirm_lock_password_base.xml b/res/layout/confirm_lock_password_base.xml
index 05e90d2..1e42fbe 100644
--- a/res/layout/confirm_lock_password_base.xml
+++ b/res/layout/confirm_lock_password_base.xml
@@ -89,19 +89,5 @@
</LinearLayout>
- <View android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"/>
-
- <ImageView
- android:id="@+id/fingerprintIcon"
- android:layout_gravity="center_horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_marginBottom="24dp"
- android:contentDescription="@string/confirm_fingerprint_icon_content_description"
- android:visibility="gone"/>
-
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
</FrameLayout>
diff --git a/res/layout/confirm_lock_password_normal.xml b/res/layout/confirm_lock_password_normal.xml
index 05bd4a0..0b516ca 100644
--- a/res/layout/confirm_lock_password_normal.xml
+++ b/res/layout/confirm_lock_password_normal.xml
@@ -70,16 +70,6 @@
android:layout_height="0dp"
android:layout_weight="1" />
- <ImageView
- android:id="@+id/fingerprintIcon"
- android:layout_gravity="center_horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_marginBottom="24dp"
- android:contentDescription="@string/confirm_fingerprint_icon_content_description"
- android:visibility="gone"/>
-
<Button
android:id="@+id/cancelButton"
style="@style/SuwGlifButton.Secondary"
diff --git a/res/layout/confirm_lock_pattern_base.xml b/res/layout/confirm_lock_pattern_base.xml
index e6b7887..f841391 100644
--- a/res/layout/confirm_lock_pattern_base.xml
+++ b/res/layout/confirm_lock_pattern_base.xml
@@ -97,15 +97,6 @@
android:layout_marginEnd="12dp"
android:gravity="center_vertical"/>
- <ImageView
- android:id="@+id/fingerprintIcon"
- android:layout_gravity="center_horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_marginBottom="24dp"
- android:contentDescription="@string/confirm_fingerprint_icon_content_description"
- android:visibility="gone"/>
</LinearLayout>
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
diff --git a/res/layout/confirm_lock_pattern_normal_base.xml b/res/layout/confirm_lock_pattern_normal_base.xml
index 6773ec0..bfabf99 100644
--- a/res/layout/confirm_lock_pattern_normal_base.xml
+++ b/res/layout/confirm_lock_pattern_normal_base.xml
@@ -90,16 +90,6 @@
android:layout_marginTop="12dp"
android:gravity="center_vertical"/>
- <ImageView
- android:id="@+id/fingerprintIcon"
- android:layout_gravity="center_horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginHorizontal="?attr/suwMarginSides"
- android:layout_marginBottom="24dp"
- android:contentDescription="@string/confirm_fingerprint_icon_content_description"
- android:visibility="gone"/>
-
<Button
android:id="@+id/cancelButton"
style="@style/SuwGlifButton.Secondary"
diff --git a/res/layout/homepage_slice_tile.xml b/res/layout/homepage_slice_tile.xml
index 7cb8407..28cdfb1 100644
--- a/res/layout/homepage_slice_tile.xml
+++ b/res/layout/homepage_slice_tile.xml
@@ -24,9 +24,9 @@
<androidx.slice.widget.SliceView
android:id="@+id/slice_view"
android:layout_width="match_parent"
- android:layout_height="@dimen/homepage_slice_card_max_height"
- android:layout_marginBottom="@dimen/homepage_card_bottom_margin"
- android:layout_marginTop="@dimen/homepage_card_top_margin"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/homepage_card_vertical_margin"
+ android:layout_marginTop="@dimen/homepage_card_vertical_margin"
android:paddingStart="@dimen/homepage_card_padding_start"
android:paddingEnd="@dimen/homepage_card_padding_end"/>
diff --git a/res/layout/network_request_dialog_title.xml b/res/layout/network_request_dialog_title.xml
new file mode 100644
index 0000000..fa01085
--- /dev/null
+++ b/res/layout/network_request_dialog_title.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingEnd="?android:attr/dialogPreferredPadding"
+ android:orientation="horizontal"
+ android:background="?android:attr/selectableItemBackground"
+ android:minHeight="?android:attr/listPreferredItemHeightSmall">
+
+ <TextView
+ android:id="@+id/network_request_title_text"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:paddingLeft="16dip"
+ android:layout_weight="1"
+ android:textSize="18sp"
+ android:gravity="center_vertical"
+ style="@style/info_label"/>
+
+ <ProgressBar
+ android:id="@+id/network_request_title_progress"
+ style="?android:attr/progressBarStyleSmallTitle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_marginStart="16dip"
+ android:minWidth="32dp"
+ android:text="@string/progress_scanning"/>
+</LinearLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 5f0097a..9b33388 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -327,17 +327,10 @@
<!-- Homepage cards size and padding -->
<dimen name="homepage_card_corner_radius">8dp</dimen>
<dimen name="homepage_card_elevation">2dp</dimen>
- <dimen name="homepage_card_top_margin">6dp</dimen>
- <dimen name="homepage_card_bottom_margin">6dp</dimen>
+ <dimen name="homepage_card_vertical_margin">6dp</dimen>
<dimen name="homepage_card_side_margin">16dp</dimen>
<dimen name="homepage_card_padding_start">16dp</dimen>
<dimen name="homepage_card_padding_end">16dp</dimen>
- <dimen name="homepage_card_padding_top">6dp</dimen>
- <dimen name="homepage_card_padding_bottom">6dp</dimen>
-
- <!-- Slice cards maximum height (4 rows + show more)
- MODE_LARGE height(3 rows + show more) 240dp + two lines text(1 row) 60dp = 300dp -->
- <dimen name="homepage_slice_card_max_height">300dp</dimen>
<!-- Signal icon in NetworkSelectSetting -->
<dimen name="signal_strength_icon_size">24dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 56dbc6b..0f3b18d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1051,9 +1051,6 @@
<!-- Button to confirm the last removing the last fingerprint. [CHAR LIMIT=20]-->
<string name="fingerprint_last_delete_confirm">Yes, remove</string>
- <!-- Content description for the fingerprint icon when the user is prompted to enter his credentials. Not shown on the screen. [CHAR LIMIT=NONE] -->
- <string name="confirm_fingerprint_icon_content_description">Use your fingerprint to continue.</string>
-
<!-- Title of the preferences category for preference items to control encryption -->
<string name="crypt_keeper_settings_title">Encryption</string>
@@ -3709,6 +3706,10 @@
<!-- About phone settings screen, Safety Legal dialog title until the link is fully loaded -->
<string name="settings_safetylegal_activity_loading">Loading\u2026</string>
+ <!-- ConfirmDeviceCredential settings-->
+ <!-- Button text shown on BiometricPrompt (system dialog that asks for biometric authentication) giving the user the option to use an alternate form of authentication (Pin/Pattern/Pass) [CHAR LIMIT=30] -->
+ <string name="confirm_device_credential_use_alternate_method">Use alternate method</string>
+
<!-- Lock Pattern settings -->
<!-- Header on first screen of choose password/PIN flow [CHAR LIMIT=40] -->
<string name="lockpassword_choose_your_screen_lock_header">Set screen lock</string>
@@ -3771,8 +3772,8 @@
<string name="lockpassword_confirm_your_password_generic_profile">Enter your work password to continue</string>
<!-- This string shows up on a screen where a user can enter a pattern that
- unlocks their device. This is an extra security measure that's required for them to
- continue. [CHAR LIMIT=100] -->
+ unlocks their device. This is an extra security measure that's required for them to
+ continue. [CHAR LIMIT=100] -->
<string name="lockpassword_strong_auth_required_device_pattern">For added security, use your device pattern</string>
<!-- This string shows up on a screen where a user can enter a PIN that unlocks their device.
This is an extra security measure that's required for them to continue. [CHAR LIMIT=100]
@@ -7185,20 +7186,26 @@
<string name="zen_mode_behavior_alarms_only">No sound except alarms and media</string>
<!-- Do not disturb: Title for the zen mode automation option in Settings. [CHAR LIMIT=40] -->
- <string name="zen_mode_automation_settings_title">Turn on automatically</string>
+ <string name="zen_mode_automation_settings_title">Schedules</string>
<!-- Do not disturb: Title for the zen mode automatic rules page in settings. [CHAR LIMIT=30] -->
- <string name="zen_mode_automation_settings_page_title">Automatic rules</string>
+ <string name="zen_mode_automation_settings_page_title">Do Not Disturb</string>
<!-- Do not disturb: Title for a specific zen mode automatic rule in settings. [CHAR LIMIT=30] -->
<string name="zen_mode_automatic_rule_settings_page_title">Automatic rule</string>
+ <!-- Do not disturb: Title do not disturb settings representing automatic (scheduled) do not disturb rules. [CHAR LIMIT=30] -->
+ <string name="zen_mode_schedule_category_title">Schedule</string>
+
<!-- Do not disturb: Title for the zen mode automation option Suggestion. [CHAR LIMIT=46] -->
<string name="zen_mode_automation_suggestion_title">Silence phone at certain times</string>
<!-- Do not disturb: Summary for the zen mode automation option Suggestion. [CHAR LIMIT=55] -->
<string name="zen_mode_automation_suggestion_summary">Set Do Not Disturb rules</string>
+ <!-- Do not disturb: Header for the Do Not Disturb automatic rules. [CHAR LIMIT=55] -->
+ <string name="zen_mode_schedule_title">Schedule</string>
+
<!-- Do not disturb: Switch toggle to toggle whether to use an automatic dnd rule or not [CHAR LIMIT=40] -->
<string name="zen_mode_use_automatic_rule">Use rule</string>
@@ -7221,10 +7228,10 @@
<string name="zen_mode_visual_signals_settings_subtitle">Allow visual signals</string>
<!-- Do not disturb: zen settings screens category title [CHAR LIMIT=100] -->
- <string name="zen_mode_settings_category">When Do Not Disturb is turned on</string>
+ <string name="zen_mode_settings_category">When Do Not Disturb is on</string>
- <!-- Do not disturb: restrict notifications title [CHAR LIMIT=60] -->
- <string name="zen_mode_restrict_notifications_title">Notifications</string>
+ <!-- Do not disturb: restrict notifications title [CHAR LIMIT=80] -->
+ <string name="zen_mode_restrict_notifications_title">Notification restrictions</string>
<!-- Do not disturb: Mute notifications option [CHAR LIMIT=60] -->
<string name="zen_mode_restrict_notifications_mute">No sound from notifications</string>
<!-- Do not disturb:Mute notifications summary [CHAR LIMIT=NONE] -->
@@ -7356,15 +7363,15 @@
<item quantity="other"><xliff:g id="on_count" example="3">%d</xliff:g> rules can turn on automatically</item>
</plurals>
- <!-- Do not disturb settings, category header [CHAR LIMIT=100]-->
- <string name="zen_category_behavior">Behavior</string>
- <!-- Do not disturb settings, category header [CHAR LIMIT=100]-->
+ <!-- Do not disturb settings, category header [CHAR LIMIT=120]-->
+ <string name="zen_category_behavior">Mute phone, but allow exceptions</string>
+ <!-- Do not disturb settings, exceptions to dnd title [CHAR LIMIT=100]-->
<string name="zen_category_exceptions">Exceptions</string>
<!-- Do not disturb settings, category header [CHAR LIMIT=100]-->
<string name="zen_category_schedule">Schedule</string>
- <!-- Do not disturb settings, sound and vibrations title [CHAR LIMIT=100]-->
- <string name="zen_sound_title">Sound & vibration</string>
+ <!-- Do not disturb settings, sound and vibrations exceptions title [CHAR LIMIT=100]-->
+ <string name="zen_sound_title">See all exceptions</string>
<!-- Do not disturb settings, sound and vibrations screen footer [CHAR LIMIT=NONE]-->
<string name="zen_sound_footer">When Do Not Disturb is on, sound and vibration will be muted, except for the items you allow above.</string>
<!-- Do not disturb settings, sound and vibrations screen category [CHAR LIMIT=100]-->
@@ -7816,8 +7823,8 @@
<!-- [CHAR LIMIT=100] Zen mode settings: Warning text for invalid zen rule names -->
<string name="zen_mode_rule_name_warning">Rule name already in use</string>
- <!-- [CHAR LIMIT=40] Zen mode settings: Add rule menu option name -->
- <string name="zen_mode_add_rule">Add rule</string>
+ <!-- [CHAR LIMIT=40] Zen mode settings: Add another automatic zen rule option name-->
+ <string name="zen_mode_add_rule">Add more</string>
<!-- [CHAR LIMIT=40] Zen mode settings: Add event-based rule, set rule name title -->
<string name="zen_mode_add_event_rule">Add event rule</string>
@@ -7942,6 +7949,9 @@
<!-- [CHAR LIMIT=20] Zen mode settings: Messages option -->
<string name="zen_mode_messages">Messages</string>
+ <!-- Do not disturb settings, messages, events and reminders footer [CHAR LIMIT=NONE]-->
+ <string name="zen_mode_messages_footer">When Do Not Disturb is on, incoming text messages are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.</string>
+
<!-- [CHAR LIMIT=40] Zen mode settings: Allow messages toggle title -->
<string name="zen_mode_messages_title">Allow messages</string>
@@ -7978,42 +7988,36 @@
<!-- [CHAR LIMIT=40] Zen mode settings: Calls or messages option value: None -->
<string name="zen_mode_from_none">None</string>
- <!-- [CHAR LIMIT=50] Zen mode settings: Alarms option -->
- <string name="zen_mode_alarms">Alarms</string>
+ <!-- [CHAR LIMIT=80] Zen mode settings: Allow alarms option -->
+ <string name="zen_mode_alarms">Allow alarms</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Alarms option (ie: sound from alarm clock) -->
<string name="zen_mode_alarms_list">alarms</string>
- <!-- [CHAR LIMIT=50] Zen mode settings: Media option -->
- <string name="zen_mode_media">Media</string>
+ <!-- [CHAR LIMIT=80] Zen mode settings: Allow media (sound from video) to bypass dnd -->
+ <string name="zen_mode_media">Allow media</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Media (ie: sound from video) -->
<string name="zen_mode_media_list">media</string>
- <!-- [CHAR LIMIT=50] Zen mode settings: System option which includes sounds such as touch sounds -->
- <string name="zen_mode_system">Touch sounds</string>
+ <!-- [CHAR LIMIT=80] Zen mode settings: allow touch sounds to bypass DND -->
+ <string name="zen_mode_system">Allow touch sounds</string>
<!-- [CHAR LIMIT=50] Zen mode settings: System sounds (ie: touch sounds) -->
<string name="zen_mode_system_list">touch sounds</string>
- <!-- [CHAR LIMIT=50] Zen mode settings: Reminders option -->
- <string name="zen_mode_reminders">Reminders</string>
+ <!-- [CHAR LIMIT=80] Zen mode settings: Allow reminder notifications/sounds to bypass DND -->
+ <string name="zen_mode_reminders">Allow reminders</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Reminders (ie: calendar reminders are allowed to bypass dnd) -->
<string name="zen_mode_reminders_list">reminders</string>
- <!-- [CHAR LIMIT=70] Zen mode settings: Allow reminders toggle title -->
- <string name="zen_mode_reminders_title">Allow reminders</string>
-
- <!-- [CHAR LIMIT=50] Zen mode settings: Events option -->
- <string name="zen_mode_events">Events</string>
+ <!-- [CHAR LIMIT=80] Zen mode settings: Allow event notifications/sounds to bypass DND -->
+ <string name="zen_mode_events">Allow events</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Events (ie: calendar events) -->
<string name="zen_mode_events_list">events</string>
- <!-- [CHAR LIMIT=70] Zen mode settings: Allow events toggle title -->
- <string name="zen_mode_events_title">Allow events</string>
-
<!-- [CHAR LIMIT=50] Zen mode settings: All callers summary -->
<string name="zen_mode_all_callers">anyone</string>
@@ -8371,9 +8375,6 @@
<!-- Explanation that the app that will NEVER be launched to open web links to domains that it understands -->
<string name="app_link_open_never">Don’t open in this app</string>
- <!-- Fingerprint hint message when finger was not recognized.-->
- <string name="fingerprint_not_recognized">Not recognized</string>
-
<!-- Title for Default Apps settings [CHAR LIMIT=30] -->
<string name="default_apps_title">Default</string>
@@ -10269,7 +10270,9 @@
<!-- See less items in contextual homepage [CHAR LIMIT=30]-->
<string name="see_less">See less</string>
- <!-- Summary for connected devices count in connected device slice. [CHAR LIMIT=NONE] -->
+ <!-- Title for Network connection request Dialog [CHAR LIMIT=30] -->
+ <string name="network_connection_request_dialog_title">Choose device</string>
+
<plurals name="show_connected_devices">
<item quantity="one"><xliff:g id="number_device_count">%1$d</xliff:g> device connected</item>
<item quantity="other"><xliff:g id="number_device_count">%1$d</xliff:g> devices connected</item>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index fa7b1d7..83971b6 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -455,8 +455,8 @@
</style>
<style name="ContextualCardStyle">
- <item name="android:layout_marginTop">@dimen/homepage_card_top_margin</item>
- <item name="android:layout_marginBottom">@dimen/homepage_card_bottom_margin</item>
+ <item name="android:layout_marginTop">@dimen/homepage_card_vertical_margin</item>
+ <item name="android:layout_marginBottom">@dimen/homepage_card_vertical_margin</item>
<item name="android:layout_marginStart">@dimen/homepage_card_side_margin</item>
<item name="android:layout_marginEnd">@dimen/homepage_card_side_margin</item>
<item name="cardCornerRadius">@dimen/homepage_card_corner_radius</item>
diff --git a/res/xml/usb_details_fragment.xml b/res/xml/usb_details_fragment.xml
index 4efad6d..5c1efcf 100644
--- a/res/xml/usb_details_fragment.xml
+++ b/res/xml/usb_details_fragment.xml
@@ -36,9 +36,4 @@
<PreferenceCategory
android:key="usb_details_power_role"/>
- <!-- Empty category for spacing -->
- <PreferenceCategory
- android:key="usb_details_space"
- settings:allowDividerAbove="false"/>
-
</PreferenceScreen>
diff --git a/res/xml/zen_mode_automation_settings.xml b/res/xml/zen_mode_automation_settings.xml
index 99826ea..dade454 100644
--- a/res/xml/zen_mode_automation_settings.xml
+++ b/res/xml/zen_mode_automation_settings.xml
@@ -19,9 +19,9 @@
android:key="zen_mode_automation_settings_page"
android:title="@string/zen_mode_automation_settings_page_title" >
-
<PreferenceCategory
- android:key="zen_mode_automatic_rules">
+ android:key="zen_mode_automatic_rules"
+ android:title="@string/zen_mode_schedule_title">
<!-- Rules added at runtime -->
</PreferenceCategory>
diff --git a/res/xml/zen_mode_calls_settings.xml b/res/xml/zen_mode_calls_settings.xml
index 2da022c..74b6986 100644
--- a/res/xml/zen_mode_calls_settings.xml
+++ b/res/xml/zen_mode_calls_settings.xml
@@ -17,6 +17,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="zen_mode_calls_settings_page"
android:title="@string/zen_mode_calls" >
diff --git a/res/xml/zen_mode_messages_settings.xml b/res/xml/zen_mode_messages_settings.xml
new file mode 100644
index 0000000..4ca6c92
--- /dev/null
+++ b/res/xml/zen_mode_messages_settings.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:key="zen_mode_messages_settings_page"
+ android:title="@string/zen_mode_messages" >
+
+ <PreferenceCategory
+ android:title="@string/zen_mode_settings_category"
+ android:key="zen_mode_settings_category_messages">
+ <!-- Messages -->
+ <ListPreference
+ android:key="zen_mode_messages"
+ android:title="@string/zen_mode_messages_title"
+ android:entries="@array/zen_mode_contacts_entries"
+ android:entryValues="@array/zen_mode_contacts_values"/>
+
+ <Preference
+ android:key="zen_mode_starred_contacts_messages"
+ android:title="@string/zen_mode_starred_contacts_title"/>
+ </PreferenceCategory>
+
+ <com.android.settingslib.widget.FooterPreference/>
+
+</PreferenceScreen>
diff --git a/res/xml/zen_mode_msg_event_reminder_settings.xml b/res/xml/zen_mode_msg_event_reminder_settings.xml
deleted file mode 100644
index 8fc6b47..0000000
--- a/res/xml/zen_mode_msg_event_reminder_settings.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:key="zen_mode_msg_event_reminder_settings_page"
- android:title="@string/zen_msg_event_reminder_title" >
-
- <PreferenceCategory
- android:title="@string/zen_mode_settings_category"
- android:key="zen_mode_settings_category_msg_event_reminder">
- <!-- Messages -->
- <ListPreference
- android:key="zen_mode_messages"
- android:title="@string/zen_mode_messages_title"
- android:entries="@array/zen_mode_contacts_entries"
- android:entryValues="@array/zen_mode_contacts_values"/>
-
- <Preference
- android:key="zen_mode_starred_contacts_messages"
- android:title="@string/zen_mode_starred_contacts_title"/>
-
- <!-- Reminders -->
- <SwitchPreference
- android:key="zen_mode_reminders"
- android:title="@string/zen_mode_reminders_title"/>
-
- <!-- Events -->
- <SwitchPreference
- android:key="zen_mode_events"
- android:title="@string/zen_mode_events_title"/>
- </PreferenceCategory>
-
- <com.android.settingslib.widget.FooterPreference />
-
-</PreferenceScreen>
diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml
index b8af650..1966484 100644
--- a/res/xml/zen_mode_settings.xml
+++ b/res/xml/zen_mode_settings.xml
@@ -25,62 +25,59 @@
<PreferenceCategory
android:key="zen_mode_settings_category_behavior"
android:title="@string/zen_category_behavior">
- <!-- sound vibration -->
+ <!-- Calls -->
+ <Preference
+ android:key="zen_mode_behavior_calls"
+ android:title="@string/zen_mode_calls_title"
+ android:fragment="com.android.settings.notification.ZenModeCallsSettings" />
+
+ <!-- Messages -->
+ <Preference
+ android:key="zen_mode_behavior_messages"
+ android:title="@string/zen_mode_messages_title"
+ android:fragment="com.android.settings.notification.ZenModeMessagesSettings" />
+
+ <!-- Alarms -->
+ <SwitchPreference
+ android:key="zen_mode_behavior_alarms"
+ android:title="@string/zen_mode_alarms"/>
+
+ <!-- All sounds -->
<Preference
android:key="zen_sound_vibration_settings"
android:title="@string/zen_sound_title"
- android:fragment="com.android.settings.notification.ZenModeSoundVibrationSettings"/>
-
- <!-- What to block (effects) -->
- <Preference
- android:key="zen_mode_block_effects_settings"
- android:title="@string/zen_mode_restrict_notifications_title"
- android:fragment="com.android.settings.notification.ZenModeRestrictNotificationsSettings" />
+ android:fragment="com.android.settings.notification.ZenModeSoundVibrationSettings"
+ android:icon="@drawable/ic_chevron_right_24dp"/>
</PreferenceCategory>
- <PreferenceCategory
- android:key="zen_mode_settings_category_exceptions"
- android:title="@string/zen_category_exceptions">
- <Preference
- android:key="zen_mode_calls_settings"
- android:title="@string/zen_mode_calls"
- android:fragment="com.android.settings.notification.ZenModeCallsSettings" />
- <Preference
- android:key="zen_mode_msg_event_reminder_settings"
- android:title="@string/zen_msg_event_reminder_title"
- android:fragment="com.android.settings.notification.ZenModeMsgEventReminderSettings" />
+ <!-- What to block (effects) -->
+ <Preference
+ android:key="zen_mode_block_effects_settings"
+ android:title="@string/zen_mode_restrict_notifications_title"
+ android:fragment="com.android.settings.notification.ZenModeRestrictNotificationsSettings"
+ settings:allowDividerAbove="true"/>
- </PreferenceCategory>
+ <!-- DND duration settings -->
+ <com.android.settings.notification.ZenDurationDialogPreference
+ android:key="zen_mode_duration_settings"
+ android:title="@string/zen_mode_duration_settings_title"
+ android:widgetLayout="@null"/>
- <PreferenceCategory
- android:key="zen_mode_settings_category_schedule"
- android:title="@string/zen_category_schedule">
- <!-- DND duration settings -->
- <com.android.settings.notification.ZenDurationDialogPreference
- android:key="zen_mode_duration_settings"
- android:title="@string/zen_mode_duration_settings_title"
- android:widgetLayout="@null"/>
-
- <!-- Automatic rules -->
- <Preference
- android:key="zen_mode_automation_settings"
- android:title="@string/zen_mode_automation_settings_title"
- android:fragment="com.android.settings.notification.ZenModeAutomationSettings" />
- </PreferenceCategory>
+ <!-- Automatic rules -->
+ <Preference
+ android:key="zen_mode_automation_settings"
+ android:title="@string/zen_mode_automation_settings_title"
+ android:fragment="com.android.settings.notification.ZenModeAutomationSettings"/>
<!-- Turn on DND button -->
- <!-- Layout preference doesn't obey allowDividerAbove, so put it in a PreferenceCategory -->
- <PreferenceCategory
- android:key="zen_mode_settings_button_category">
- <com.android.settings.applications.LayoutPreference
- android:key="zen_mode_settings_button_container"
- android:selectable="false"
- android:layout="@layout/zen_mode_settings_button" />
- </PreferenceCategory>
+ <com.android.settings.applications.LayoutPreference
+ android:key="zen_mode_settings_button_container"
+ android:selectable="false"
+ android:layout="@layout/zen_mode_settings_button"
+ settings:allowDividerAbove="true"
+ settings:allowDividerBelow="true"/>
- <PreferenceCategory
- android:key="zen_mode_footer_container">
- <com.android.settingslib.widget.FooterPreference />
- </PreferenceCategory>
+ <!-- Footer that shows if user is put into alarms only or total silence mode by an app -->
+ <com.android.settingslib.widget.FooterPreference/>
</PreferenceScreen>
diff --git a/res/xml/zen_mode_sound_vibration_settings.xml b/res/xml/zen_mode_sound_vibration_settings.xml
index b3b8139..3d1da2f 100644
--- a/res/xml/zen_mode_sound_vibration_settings.xml
+++ b/res/xml/zen_mode_sound_vibration_settings.xml
@@ -18,11 +18,24 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:key="zen_mode_sound_vibration_settings_page"
- android:title="@string/zen_sound_title" >
+ android:title="@string/zen_category_exceptions" >
<PreferenceCategory
android:title="@string/zen_mode_settings_category"
android:key="zen_mode_settings_category_sound_vibration">
+
+ <!-- Calls -->
+ <Preference
+ android:key="zen_mode_calls_settings"
+ android:title="@string/zen_mode_calls_title"
+ android:fragment="com.android.settings.notification.ZenModeCallsSettings" />
+
+ <!-- Messages -->
+ <Preference
+ android:key="zen_mode_messages_settings"
+ android:title="@string/zen_mode_messages_title"
+ android:fragment="com.android.settings.notification.ZenModeMessagesSettings" />
+
<!-- Alarms -->
<SwitchPreference
android:key="zen_mode_alarms"
@@ -37,6 +50,18 @@
<SwitchPreference
android:key="zen_mode_system"
android:title="@string/zen_mode_system"/>
+
+ <!-- Reminders -->
+ <SwitchPreference
+ android:key="zen_mode_reminders"
+ android:title="@string/zen_mode_reminders"/>
+
+ <!-- Events -->
+ <SwitchPreference
+ android:key="zen_mode_events"
+ android:title="@string/zen_mode_events"/>
+
+ <!-- TODO: beverlyt, add "Allow apps to override" -->
</PreferenceCategory>
<com.android.settingslib.widget.FooterPreference/>
diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
new file mode 100644
index 0000000..ee35945
--- /dev/null
+++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.biometrics;
+
+import android.app.settings.SettingsEnums;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+
+import com.android.settings.biometrics.face.FaceEnrollIntroduction;
+import com.android.settings.biometrics.fingerprint.FingerprintEnrollIntroduction;
+import com.android.settings.core.InstrumentedActivity;
+
+/**
+ * Trampoline activity launched by the {@code android.settings.BIOMETRIC_ENROLL} action which
+ * shows the user an appropriate enrollment flow depending on the device's biometric hardware.
+ * This activity must only allow enrollment of biometrics that can be used by
+ * {@link android.hardware.biometrics.BiometricPrompt}.
+ */
+public class BiometricEnrollActivity extends InstrumentedActivity {
+
+ private static final String SETTINGS_PACKAGE = "com.android.settings";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ final PackageManager pm = getApplicationContext().getPackageManager();
+ final Intent intent = new Intent();
+
+ // This logic may have to be modified on devices with multiple biometrics.
+ if (pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
+ intent.setClassName(SETTINGS_PACKAGE, FingerprintEnrollIntroduction.class.getName());
+ } else if (pm.hasSystemFeature(PackageManager.FEATURE_FACE)) {
+ intent.setClassName(SETTINGS_PACKAGE, FaceEnrollIntroduction.class.getName());
+ }
+
+ startActivity(intent);
+ finish();
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.BIOMETRIC_ENROLL_ACTIVITY;
+ }
+}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintUiHelper.java b/src/com/android/settings/biometrics/fingerprint/FingerprintUiHelper.java
deleted file mode 100644
index 012f802..0000000
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintUiHelper.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2015 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.biometrics.fingerprint;
-
-import android.hardware.fingerprint.FingerprintManager;
-import android.os.CancellationSignal;
-import android.view.View;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.android.settings.R;
-import com.android.settings.Utils;
-
-/**
- * Small helper class to manage text/icon around fingerprint authentication UI.
- */
-public class FingerprintUiHelper extends FingerprintManager.AuthenticationCallback {
-
- private static final long ERROR_TIMEOUT = 1300;
-
- private ImageView mIcon;
- private TextView mErrorTextView;
- private CancellationSignal mCancellationSignal;
- private int mUserId;
-
- private Callback mCallback;
- private FingerprintManager mFingerprintManager;
-
- public FingerprintUiHelper(ImageView icon, TextView errorTextView, Callback callback,
- int userId) {
- mFingerprintManager = Utils.getFingerprintManagerOrNull(icon.getContext());
- mIcon = icon;
- mErrorTextView = errorTextView;
- mCallback = callback;
- mUserId = userId;
- }
-
- public void startListening() {
- if (mFingerprintManager != null && mFingerprintManager.isHardwareDetected()
- && mFingerprintManager.getEnrolledFingerprints(mUserId).size() > 0) {
- mCancellationSignal = new CancellationSignal();
- mFingerprintManager.setActiveUser(mUserId);
- mFingerprintManager.authenticate(
- null, mCancellationSignal, 0 /* flags */, this, null, mUserId);
- setFingerprintIconVisibility(true);
- mIcon.setImageResource(R.drawable.ic_fingerprint);
- }
- }
-
- public void stopListening() {
- if (mCancellationSignal != null) {
- mCancellationSignal.cancel();
- mCancellationSignal = null;
- }
- }
-
- public boolean isListening() {
- return mCancellationSignal != null && !mCancellationSignal.isCanceled();
- }
-
- private void setFingerprintIconVisibility(boolean visible) {
- mIcon.setVisibility(visible ? View.VISIBLE : View.GONE);
- mCallback.onFingerprintIconVisibilityChanged(visible);
- }
-
- @Override
- public void onAuthenticationError(int errMsgId, CharSequence errString) {
- if (errMsgId == FingerprintManager.FINGERPRINT_ERROR_CANCELED) {
- // Only happens if we get preempted by another activity. Ignored.
- return;
- }
- showError(errString);
- setFingerprintIconVisibility(false);
- }
-
- @Override
- public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) {
- showError(helpString);
- }
-
- @Override
- public void onAuthenticationFailed() {
- showError(mIcon.getResources().getString(
- R.string.fingerprint_not_recognized));
- }
-
- @Override
- public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
- mIcon.setImageResource(R.drawable.ic_fingerprint_success);
- mCallback.onAuthenticated();
- }
-
- private void showError(CharSequence error) {
- if (!isListening()) {
- return;
- }
-
- mIcon.setImageResource(R.drawable.ic_fingerprint_error);
- mErrorTextView.setText(error);
- mErrorTextView.removeCallbacks(mResetErrorTextRunnable);
- mErrorTextView.postDelayed(mResetErrorTextRunnable, ERROR_TIMEOUT);
- }
-
- private Runnable mResetErrorTextRunnable = new Runnable() {
- @Override
- public void run() {
- mErrorTextView.setText("");
- mIcon.setImageResource(R.drawable.ic_fingerprint);
- }
- };
-
- public interface Callback {
- void onAuthenticated();
- void onFingerprintIconVisibilityChanged(boolean visible);
- }
-}
diff --git a/src/com/android/settings/development/ClearAdbKeysPreferenceController.java b/src/com/android/settings/development/ClearAdbKeysPreferenceController.java
index ce23e3f..e1fda67 100644
--- a/src/com/android/settings/development/ClearAdbKeysPreferenceController.java
+++ b/src/com/android/settings/development/ClearAdbKeysPreferenceController.java
@@ -17,7 +17,7 @@
package com.android.settings.development;
import android.content.Context;
-import android.hardware.usb.IUsbManager;
+import android.debug.IAdbManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
@@ -42,7 +42,7 @@
@VisibleForTesting
static final String RO_ADB_SECURE_PROPERTY_KEY = "ro.adb.secure";
- private final IUsbManager mUsbManager;
+ private final IAdbManager mAdbManager;
private final DevelopmentSettingsDashboardFragment mFragment;
public ClearAdbKeysPreferenceController(Context context,
@@ -50,7 +50,7 @@
super(context);
mFragment = fragment;
- mUsbManager = IUsbManager.Stub.asInterface(ServiceManager.getService(Context.USB_SERVICE));
+ mAdbManager = IAdbManager.Stub.asInterface(ServiceManager.getService(Context.ADB_SERVICE));
}
@Override
@@ -94,7 +94,7 @@
public void onClearAdbKeysConfirmed() {
try {
- mUsbManager.clearUsbDebuggingKeys();
+ mAdbManager.clearDebuggingKeys();
} catch (RemoteException e) {
Log.e(TAG, "Unable to clear adb keys", e);
}
diff --git a/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProvider.java b/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProvider.java
index 6fe1204..59c9ba9 100644
--- a/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProvider.java
+++ b/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProvider.java
@@ -26,6 +26,7 @@
import com.android.settings.intelligence.ContextualCardProto.ContextualCardList;
import com.android.settings.wifi.WifiSlice;
+import com.google.android.settings.intelligence.libs.contextualcards.ContextualCardCategory;
import com.google.android.settings.intelligence.libs.contextualcards.ContextualCardProvider;
/** Provides dynamic card for SettingsIntelligence. */
@@ -40,16 +41,19 @@
ContextualCard.newBuilder()
.setSliceUri(WifiSlice.WIFI_URI.toString())
.setCardName(KEY_WIFI)
+ .setCategory(ContextualCardCategory.IMPORTANT)
.build();
final ContextualCard batteryInfoCard =
ContextualCard.newBuilder()
.setSliceUri(BatterySlice.BATTERY_CARD_URI.toString())
.setCardName(BatterySlice.PATH_BATTERY_INFO)
+ .setCategory(ContextualCardCategory.DEFAULT)
.build();
final ContextualCard connectedDeviceCard =
ContextualCard.newBuilder()
.setSliceUri(ConnectedDeviceSlice.CONNECTED_DEVICE_URI.toString())
.setCardName(ConnectedDeviceSlice.PATH_CONNECTED_DEVICE)
+ .setCategory(ContextualCardCategory.IMPORTANT)
.build();
final ContextualCardList cards = ContextualCardList.newBuilder()
.addCard(wifiCard)
diff --git a/src/com/android/settings/homepage/contextualcards/slices/ConnectedDeviceSlice.java b/src/com/android/settings/homepage/contextualcards/slices/ConnectedDeviceSlice.java
index 83a6af5..54cd82f 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/ConnectedDeviceSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/ConnectedDeviceSlice.java
@@ -95,8 +95,6 @@
private static final Comparator<CachedBluetoothDevice> COMPARATOR
= Comparator.naturalOrder();
- private static final int DEFAULT_EXPANDED_ROW_COUNT = 4;
-
private static final String TAG = "ConnectedDeviceSlice";
private final Context mContext;
@@ -162,13 +160,6 @@
for (ListBuilder.RowBuilder rowBuilder : rows) {
listBuilder.addRow(rowBuilder);
}
-
- // Only show "see more" button when the number of data row is more than or equal to 4.
- // TODO(b/118465996): SHOW MORE button won't work properly when having two data rows
- if (rows.size() >= DEFAULT_EXPANDED_ROW_COUNT) {
- listBuilder.setSeeMoreAction(primaryActionIntent);
- }
-
return listBuilder.build();
}
diff --git a/src/com/android/settings/notification/ZenModeAlarmsPreferenceController.java b/src/com/android/settings/notification/ZenModeAlarmsPreferenceController.java
index 96495df..67d9e93 100644
--- a/src/com/android/settings/notification/ZenModeAlarmsPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeAlarmsPreferenceController.java
@@ -21,19 +21,20 @@
import android.provider.Settings;
import android.util.Log;
-import androidx.preference.Preference;
-import androidx.preference.SwitchPreference;
-
import com.android.internal.logging.nano.MetricsProto;
import com.android.settingslib.core.lifecycle.Lifecycle;
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+
public class ZenModeAlarmsPreferenceController extends
AbstractZenModePreferenceController implements Preference.OnPreferenceChangeListener {
- protected static final String KEY = "zen_mode_alarms";
+ private final String KEY;
- public ZenModeAlarmsPreferenceController(Context context, Lifecycle lifecycle) {
- super(context, KEY, lifecycle);
+ public ZenModeAlarmsPreferenceController(Context context, Lifecycle lifecycle, String key) {
+ super(context, key, lifecycle);
+ KEY = key;
}
@Override
diff --git a/src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceController.java b/src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceController.java
deleted file mode 100644
index 0dba4d6..0000000
--- a/src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceController.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2017 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.notification;
-
-import android.content.Context;
-
-import androidx.preference.Preference;
-
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-public class ZenModeBehaviorCallsPreferenceController extends
- AbstractZenModePreferenceController implements PreferenceControllerMixin {
-
- protected static final String KEY_BEHAVIOR_SETTINGS = "zen_mode_calls_settings";
- private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
-
- public ZenModeBehaviorCallsPreferenceController(Context context, Lifecycle lifecycle) {
- super(context, KEY_BEHAVIOR_SETTINGS, lifecycle);
- mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY_BEHAVIOR_SETTINGS;
- }
-
- @Override
- public boolean isAvailable() {
- return true;
- }
-
- @Override
- public void updateState(Preference preference) {
- super.updateState(preference);
-
- preference.setSummary(mSummaryBuilder.getCallsSettingSummary(getPolicy()));
- }
-}
diff --git a/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceController.java b/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceController.java
deleted file mode 100644
index 2046244..0000000
--- a/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceController.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2017 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.notification;
-
-import android.content.Context;
-
-import androidx.preference.Preference;
-
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-public class ZenModeBehaviorMsgEventReminderPreferenceController extends
- AbstractZenModePreferenceController implements PreferenceControllerMixin {
-
- protected static final String KEY_BEHAVIOR_SETTINGS = "zen_mode_msg_event_reminder_settings";
- private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
-
- public ZenModeBehaviorMsgEventReminderPreferenceController(Context context,
- Lifecycle lifecycle) {
- super(context, KEY_BEHAVIOR_SETTINGS, lifecycle);
- mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY_BEHAVIOR_SETTINGS;
- }
-
- @Override
- public boolean isAvailable() {
- return true;
- }
-
- @Override
- public void updateState(Preference preference) {
- super.updateState(preference);
-
- preference.setSummary(mSummaryBuilder.getMsgEventReminderSettingSummary(getPolicy()));
- }
-}
diff --git a/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceController.java b/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceController.java
deleted file mode 100644
index 425f770..0000000
--- a/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceController.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.notification;
-
-import android.content.Context;
-
-import androidx.preference.Preference;
-
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-public class ZenModeBehaviorSoundPreferenceController extends
- AbstractZenModePreferenceController implements PreferenceControllerMixin {
-
- protected static final String KEY_BEHAVIOR_SETTINGS = "zen_sound_vibration_settings";
- private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
-
- public ZenModeBehaviorSoundPreferenceController(Context context, Lifecycle lifecycle) {
- super(context, KEY_BEHAVIOR_SETTINGS, lifecycle);
- mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY_BEHAVIOR_SETTINGS;
- }
-
- @Override
- public boolean isAvailable() {
- return true;
- }
-
- @Override
- public void updateState(Preference preference) {
- super.updateState(preference);
-
- preference.setSummary(mSummaryBuilder.getSoundSettingSummary(getPolicy()));
- }
-}
diff --git a/src/com/android/settings/notification/ZenModeCallsPreferenceController.java b/src/com/android/settings/notification/ZenModeCallsPreferenceController.java
index 3f689d7..5bacafb 100644
--- a/src/com/android/settings/notification/ZenModeCallsPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeCallsPreferenceController.java
@@ -16,36 +16,29 @@
package com.android.settings.notification;
-import android.app.NotificationManager;
import android.content.Context;
-import android.provider.Settings;
-import android.text.TextUtils;
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.ListPreference;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.lifecycle.Lifecycle;
-public class ZenModeCallsPreferenceController extends AbstractZenModePreferenceController implements
- Preference.OnPreferenceChangeListener {
+import androidx.preference.Preference;
- protected static final String KEY = "zen_mode_calls";
- private final ZenModeBackend mBackend;
- private ListPreference mPreference;
- private final String[] mListValues;
+public class ZenModeCallsPreferenceController extends
+ AbstractZenModePreferenceController implements PreferenceControllerMixin {
- public ZenModeCallsPreferenceController(Context context, Lifecycle lifecycle) {
- super(context, KEY, lifecycle);
- mBackend = ZenModeBackend.getInstance(context);
- mListValues = context.getResources().getStringArray(R.array.zen_mode_contacts_values);
+ private final String KEY_BEHAVIOR_SETTINGS;
+ private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
+
+ public ZenModeCallsPreferenceController(Context context, Lifecycle lifecycle,
+ String key) {
+ super(context, key, lifecycle);
+ KEY_BEHAVIOR_SETTINGS = key;
+ mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
}
@Override
public String getPreferenceKey() {
- return KEY;
+ return KEY_BEHAVIOR_SETTINGS;
}
@Override
@@ -54,54 +47,9 @@
}
@Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- mPreference = (ListPreference) screen.findPreference(KEY);
- }
-
- @Override
public void updateState(Preference preference) {
super.updateState(preference);
- updateFromContactsValue(preference);
- }
- @Override
- public boolean onPreferenceChange(Preference preference, Object selectedContactsFrom) {
- mBackend.saveSenders(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS,
- ZenModeBackend.getSettingFromPrefKey(selectedContactsFrom.toString()));
- updateFromContactsValue(preference);
- return true;
- }
-
- private void updateFromContactsValue(Preference preference) {
- mPreference = (ListPreference) preference;
- switch (getZenMode()) {
- case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
- case Settings.Global.ZEN_MODE_ALARMS:
- mPreference.setEnabled(false);
- mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
- mPreference.setSummary(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE));
- break;
- default:
- preference.setEnabled(true);
- preference.setSummary(mBackend.getContactsSummary(
- NotificationManager.Policy.PRIORITY_CATEGORY_CALLS));
-
- final String currentVal = ZenModeBackend.getKeyFromSetting(
- mBackend.getPriorityCallSenders());
- mPreference.setValue(mListValues[getIndexOfSendersValue(currentVal)]);
- }
- }
-
- @VisibleForTesting
- protected int getIndexOfSendersValue(String currentVal) {
- int index = 3; // defaults to "none" based on R.array.zen_mode_contacts_values
- for (int i = 0; i < mListValues.length; i++) {
- if (TextUtils.equals(currentVal, mListValues[i])) {
- return i;
- }
- }
-
- return index;
+ preference.setSummary(mSummaryBuilder.getCallsSettingSummary(getPolicy()));
}
}
diff --git a/src/com/android/settings/notification/ZenModeCallsSettings.java b/src/com/android/settings/notification/ZenModeCallsSettings.java
index 6ba53b5..fa77bb0 100644
--- a/src/com/android/settings/notification/ZenModeCallsSettings.java
+++ b/src/com/android/settings/notification/ZenModeCallsSettings.java
@@ -43,7 +43,7 @@
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
Lifecycle lifecycle) {
List<AbstractPreferenceController> controllers = new ArrayList<>();
- controllers.add(new ZenModeCallsPreferenceController(context, lifecycle));
+ controllers.add(new ZenModePriorityCallsPreferenceController(context, lifecycle));
controllers.add(new ZenModeStarredContactsPreferenceController(context, lifecycle,
PRIORITY_CATEGORY_CALLS, "zen_mode_starred_contacts_callers"));
controllers.add(new ZenModeRepeatCallersPreferenceController(context, lifecycle,
diff --git a/src/com/android/settings/notification/ZenModeMessagesPreferenceController.java b/src/com/android/settings/notification/ZenModeMessagesPreferenceController.java
index 321d94e..19ee809 100644
--- a/src/com/android/settings/notification/ZenModeMessagesPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeMessagesPreferenceController.java
@@ -1,31 +1,38 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.android.settings.notification;
-import android.app.NotificationManager;
import android.content.Context;
-import android.provider.Settings;
-import android.text.TextUtils;
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.ListPreference;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.lifecycle.Lifecycle;
-public class ZenModeMessagesPreferenceController extends AbstractZenModePreferenceController
- implements Preference.OnPreferenceChangeListener {
+import androidx.preference.Preference;
- protected static final String KEY = "zen_mode_messages";
+public class ZenModeMessagesPreferenceController extends
+ AbstractZenModePreferenceController implements PreferenceControllerMixin {
- private final ZenModeBackend mBackend;
- private ListPreference mPreference;
- private final String[] mListValues;
+ private final String KEY;
+ private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
- public ZenModeMessagesPreferenceController(Context context, Lifecycle lifecycle) {
- super(context, KEY, lifecycle);
- mBackend = ZenModeBackend.getInstance(context);
- mListValues = context.getResources().getStringArray(R.array.zen_mode_contacts_values);
+ public ZenModeMessagesPreferenceController(Context context, Lifecycle lifecycle, String key) {
+ super(context, key, lifecycle);
+ KEY = key;
+ mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
}
@Override
@@ -39,54 +46,8 @@
}
@Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- mPreference = (ListPreference) screen.findPreference(KEY);
- }
-
- @Override
public void updateState(Preference preference) {
super.updateState(preference);
- updateFromContactsValue(preference);
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object selectedContactsFrom) {
- mBackend.saveSenders(NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES,
- ZenModeBackend.getSettingFromPrefKey(selectedContactsFrom.toString()));
- updateFromContactsValue(preference);
- return true;
- }
-
- private void updateFromContactsValue(Preference preference) {
- mPreference = (ListPreference) preference;
- switch (getZenMode()) {
- case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
- case Settings.Global.ZEN_MODE_ALARMS:
- mPreference.setEnabled(false);
- mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
- mPreference.setSummary(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE));
- break;
- default:
- preference.setEnabled(true);
- preference.setSummary(mBackend.getContactsSummary(
- NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
-
- final String currentVal = ZenModeBackend.getKeyFromSetting(
- mBackend.getPriorityMessageSenders());
- mPreference.setValue(mListValues[getIndexOfSendersValue(currentVal)]);
- }
- }
-
- @VisibleForTesting
- protected int getIndexOfSendersValue(String currentVal) {
- int index = 3; // defaults to "none" based on R.array.zen_mode_contacts_values
- for (int i = 0; i < mListValues.length; i++) {
- if (TextUtils.equals(currentVal, mListValues[i])) {
- return i;
- }
- }
-
- return index;
+ // TODO: (b/111475013 - beverlyt) set messages summary
}
}
diff --git a/src/com/android/settings/notification/ZenModeMsgEventReminderSettings.java b/src/com/android/settings/notification/ZenModeMessagesSettings.java
similarity index 75%
rename from src/com/android/settings/notification/ZenModeMsgEventReminderSettings.java
rename to src/com/android/settings/notification/ZenModeMessagesSettings.java
index 0e6747a..e09d583 100644
--- a/src/com/android/settings/notification/ZenModeMsgEventReminderSettings.java
+++ b/src/com/android/settings/notification/ZenModeMessagesSettings.java
@@ -33,7 +33,7 @@
import java.util.List;
@SearchIndexable
-public class ZenModeMsgEventReminderSettings extends ZenModeSettingsBase implements Indexable {
+public class ZenModeMessagesSettings extends ZenModeSettingsBase implements Indexable {
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
@@ -43,19 +43,17 @@
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
Lifecycle lifecycle) {
List<AbstractPreferenceController> controllers = new ArrayList<>();
- controllers.add(new ZenModeEventsPreferenceController(context, lifecycle));
- controllers.add(new ZenModeRemindersPreferenceController(context, lifecycle));
- controllers.add(new ZenModeMessagesPreferenceController(context, lifecycle));
+ controllers.add(new ZenModePriorityMessagesPreferenceController(context, lifecycle));
controllers.add(new ZenModeStarredContactsPreferenceController(context, lifecycle,
PRIORITY_CATEGORY_MESSAGES, "zen_mode_starred_contacts_messages"));
- controllers.add(new ZenModeBehaviorFooterPreferenceController(context, lifecycle,
- R.string.zen_msg_event_reminder_footer));
+ controllers.add(new ZenModeBehaviorFooterPreferenceController(
+ context, lifecycle, R.string.zen_mode_messages_footer));
return controllers;
}
@Override
protected int getPreferenceScreenResId() {
- return R.xml.zen_mode_msg_event_reminder_settings;
+ return R.xml.zen_mode_messages_settings;
}
@Override
@@ -66,7 +64,7 @@
/**
* For Search.
*/
- public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
@@ -75,14 +73,15 @@
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.zen_mode_msg_event_reminder_settings;
+ sir.xmlResId = R.xml.zen_mode_messages_settings;
result.add(sir);
return result;
}
- @Override
- public List<AbstractPreferenceController> createPreferenceControllers(Context context) {
- return buildPreferenceControllers(context, null);
- }
- };
+ @Override
+ public List<AbstractPreferenceController> createPreferenceControllers(
+ Context context) {
+ return buildPreferenceControllers(context, null);
+ }
+ };
}
diff --git a/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java b/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java
new file mode 100644
index 0000000..44b6c24
--- /dev/null
+++ b/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification;
+
+import android.app.NotificationManager;
+import android.content.Context;
+import android.provider.Settings;
+import android.text.TextUtils;
+
+import com.android.settings.R;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+public class ZenModePriorityCallsPreferenceController extends AbstractZenModePreferenceController
+ implements Preference.OnPreferenceChangeListener {
+
+ protected static final String KEY = "zen_mode_calls";
+ private final ZenModeBackend mBackend;
+ private ListPreference mPreference;
+ private final String[] mListValues;
+
+ public ZenModePriorityCallsPreferenceController(Context context, Lifecycle lifecycle) {
+ super(context, KEY, lifecycle);
+ mBackend = ZenModeBackend.getInstance(context);
+ mListValues = context.getResources().getStringArray(R.array.zen_mode_contacts_values);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = (ListPreference) screen.findPreference(KEY);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ updateFromContactsValue(preference);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object selectedContactsFrom) {
+ mBackend.saveSenders(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS,
+ ZenModeBackend.getSettingFromPrefKey(selectedContactsFrom.toString()));
+ updateFromContactsValue(preference);
+ return true;
+ }
+
+ private void updateFromContactsValue(Preference preference) {
+ mPreference = (ListPreference) preference;
+ switch (getZenMode()) {
+ case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
+ case Settings.Global.ZEN_MODE_ALARMS:
+ mPreference.setEnabled(false);
+ mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
+ mPreference.setSummary(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE));
+ break;
+ default:
+ preference.setEnabled(true);
+ preference.setSummary(mBackend.getContactsSummary(
+ NotificationManager.Policy.PRIORITY_CATEGORY_CALLS));
+
+ final String currentVal = ZenModeBackend.getKeyFromSetting(
+ mBackend.getPriorityCallSenders());
+ mPreference.setValue(mListValues[getIndexOfSendersValue(currentVal)]);
+ }
+ }
+
+ @VisibleForTesting
+ protected int getIndexOfSendersValue(String currentVal) {
+ int index = 3; // defaults to "none" based on R.array.zen_mode_contacts_values
+ for (int i = 0; i < mListValues.length; i++) {
+ if (TextUtils.equals(currentVal, mListValues[i])) {
+ return i;
+ }
+ }
+
+ return index;
+ }
+}
diff --git a/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java b/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java
new file mode 100644
index 0000000..56829a7
--- /dev/null
+++ b/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification;
+
+import android.app.NotificationManager;
+import android.content.Context;
+import android.provider.Settings;
+import android.text.TextUtils;
+
+import com.android.settings.R;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+public class ZenModePriorityMessagesPreferenceController extends AbstractZenModePreferenceController
+ implements Preference.OnPreferenceChangeListener {
+
+ protected static final String KEY = "zen_mode_messages";
+ private final ZenModeBackend mBackend;
+ private ListPreference mPreference;
+ private final String[] mListValues;
+
+ public ZenModePriorityMessagesPreferenceController(Context context, Lifecycle lifecycle) {
+ super(context, KEY, lifecycle);
+ mBackend = ZenModeBackend.getInstance(context);
+ mListValues = context.getResources().getStringArray(R.array.zen_mode_contacts_values);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = (ListPreference) screen.findPreference(KEY);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ updateFromContactsValue(preference);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object selectedContactsFrom) {
+ mBackend.saveSenders(NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES,
+ ZenModeBackend.getSettingFromPrefKey(selectedContactsFrom.toString()));
+ updateFromContactsValue(preference);
+ return true;
+ }
+
+ private void updateFromContactsValue(Preference preference) {
+ mPreference = (ListPreference) preference;
+ switch (getZenMode()) {
+ case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
+ case Settings.Global.ZEN_MODE_ALARMS:
+ mPreference.setEnabled(false);
+ mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
+ mPreference.setSummary(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE));
+ break;
+ default:
+ preference.setEnabled(true);
+ preference.setSummary(mBackend.getContactsSummary(
+ NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
+
+ final String currentVal = ZenModeBackend.getKeyFromSetting(
+ mBackend.getPriorityMessageSenders());
+ mPreference.setValue(mListValues[getIndexOfSendersValue(currentVal)]);
+ }
+ }
+
+ @VisibleForTesting
+ protected int getIndexOfSendersValue(String currentVal) {
+ int index = 3; // defaults to "none" based on R.array.zen_mode_contacts_values
+ for (int i = 0; i < mListValues.length; i++) {
+ if (TextUtils.equals(currentVal, mListValues[i])) {
+ return i;
+ }
+ }
+
+ return index;
+ }
+}
diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index 9cd3107..3a270d2 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -82,9 +82,12 @@
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
Lifecycle lifecycle, FragmentManager fragmentManager) {
List<AbstractPreferenceController> controllers = new ArrayList<>();
- controllers.add(new ZenModeBehaviorMsgEventReminderPreferenceController(context, lifecycle));
- controllers.add(new ZenModeBehaviorSoundPreferenceController(context, lifecycle));
- controllers.add(new ZenModeBehaviorCallsPreferenceController(context, lifecycle));
+ controllers.add(new ZenModeCallsPreferenceController(context, lifecycle,
+ "zen_mode_behavior_calls"));
+ controllers.add(new ZenModeMessagesPreferenceController(context, lifecycle,
+ "zen_mode_behavior_messages"));
+ controllers.add(new ZenModeAlarmsPreferenceController(context, lifecycle,
+ "zen_mode_behavior_alarms"));
controllers.add(new ZenModeBlockedEffectsPreferenceController(context, lifecycle));
controllers.add(new ZenModeDurationPreferenceController(context, lifecycle));
controllers.add(new ZenModeAutomationPreferenceController(context));
diff --git a/src/com/android/settings/notification/ZenModeSoundVibrationSettings.java b/src/com/android/settings/notification/ZenModeSoundVibrationSettings.java
index 32ff2d1..df92446 100644
--- a/src/com/android/settings/notification/ZenModeSoundVibrationSettings.java
+++ b/src/com/android/settings/notification/ZenModeSoundVibrationSettings.java
@@ -16,6 +16,8 @@
package com.android.settings.notification;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES;
+
import android.content.Context;
import android.provider.SearchIndexableResource;
@@ -41,9 +43,16 @@
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
Lifecycle lifecycle) {
List<AbstractPreferenceController> controllers = new ArrayList<>();
- controllers.add(new ZenModeAlarmsPreferenceController(context, lifecycle));
+ controllers.add(new ZenModeCallsPreferenceController(context, lifecycle,
+ "zen_mode_calls_settings"));
+ controllers.add(new ZenModeMessagesPreferenceController(context, lifecycle,
+ "zen_mode_messages_settings"));
+ controllers.add(new ZenModeAlarmsPreferenceController(context, lifecycle,
+ "zen_mode_alarms"));
controllers.add(new ZenModeMediaPreferenceController(context, lifecycle));
controllers.add(new ZenModeSystemPreferenceController(context, lifecycle));
+ controllers.add(new ZenModeRemindersPreferenceController(context, lifecycle));
+ controllers.add(new ZenModeEventsPreferenceController(context, lifecycle));
controllers.add(new ZenModeBehaviorFooterPreferenceController(context, lifecycle,
R.string.zen_sound_footer));
return controllers;
diff --git a/src/com/android/settings/password/BiometricFragment.java b/src/com/android/settings/password/BiometricFragment.java
new file mode 100644
index 0000000..6e1ae10
--- /dev/null
+++ b/src/com/android/settings/password/BiometricFragment.java
@@ -0,0 +1,198 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.password;
+
+import android.app.settings.SettingsEnums;
+import android.content.DialogInterface;
+import android.hardware.biometrics.BiometricConstants;
+import android.hardware.biometrics.BiometricPrompt;
+import android.hardware.biometrics.BiometricPrompt.AuthenticationCallback;
+import android.hardware.biometrics.BiometricPrompt.AuthenticationResult;
+import android.os.Bundle;
+import android.os.CancellationSignal;
+import android.os.Handler;
+import android.os.Looper;
+
+import com.android.settings.core.InstrumentedFragment;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import java.util.concurrent.Executor;
+
+/**
+ * A fragment that wraps the BiometricPrompt and manages its lifecycle.
+ */
+public class BiometricFragment extends InstrumentedFragment {
+
+ private static final String KEY_TITLE = "title";
+ private static final String KEY_SUBTITLE = "subtitle";
+ private static final String KEY_DESCRIPTION = "description";
+ private static final String KEY_NEGATIVE_TEXT = "negative_text";
+
+ // Re-set by the application. Should be done upon orientation changes, etc
+ private Executor mClientExecutor;
+ private AuthenticationCallback mClientCallback;
+
+ // Created/Initialized once and retained
+ private final Handler mHandler = new Handler(Looper.getMainLooper());
+ private PromptInfo mPromptInfo;
+ private BiometricPrompt mBiometricPrompt;
+ private CancellationSignal mCancellationSignal;
+
+ private AuthenticationCallback mAuthenticationCallback =
+ new AuthenticationCallback() {
+ @Override
+ public void onAuthenticationError(int error, @NonNull CharSequence message) {
+ mClientExecutor.execute(() -> {
+ mClientCallback.onAuthenticationError(error, message);
+ });
+ cleanup();
+ }
+
+ @Override
+ public void onAuthenticationSucceeded(AuthenticationResult result) {
+ mClientExecutor.execute(() -> {
+ mClientCallback.onAuthenticationSucceeded(result);
+ });
+ cleanup();
+ }
+ };
+
+ private final DialogInterface.OnClickListener mNegativeButtonListener =
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ mAuthenticationCallback.onAuthenticationError(
+ BiometricConstants.BIOMETRIC_ERROR_NEGATIVE_BUTTON,
+ mPromptInfo.getNegativeButtonText());
+ }
+ };
+
+ public static BiometricFragment newInstance(PromptInfo info) {
+ BiometricFragment biometricFragment = new BiometricFragment();
+ biometricFragment.setArguments(info.getBundle());
+ return biometricFragment;
+ }
+
+ public void setCallbacks(Executor executor, AuthenticationCallback callback) {
+ mClientExecutor = executor;
+ mClientCallback = callback;
+ }
+
+ public void cancel() {
+ if (mCancellationSignal != null) {
+ mCancellationSignal.cancel();
+ }
+ cleanup();
+ }
+
+ private void cleanup() {
+ if (getActivity() != null) {
+ getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();
+ }
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setRetainInstance(true);
+
+ mPromptInfo = new PromptInfo(getArguments());
+ mBiometricPrompt = new BiometricPrompt.Builder(getContext())
+ .setTitle(mPromptInfo.getTitle())
+ .setUseDefaultTitle() // use default title if title is null/empty
+ .setSubtitle(mPromptInfo.getSubtitle())
+ .setDescription(mPromptInfo.getDescription())
+ .setNegativeButton(mPromptInfo.getNegativeButtonText(), mClientExecutor,
+ mNegativeButtonListener)
+ .build();
+ mCancellationSignal = new CancellationSignal();
+
+ // TODO: CC doesn't use crypto for now
+ mBiometricPrompt.authenticate(mCancellationSignal, mClientExecutor,
+ mAuthenticationCallback);
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.BIOMETRIC_FRAGMENT;
+ }
+
+ /**
+ * A simple wrapper for BiometricPrompt.PromptInfo. Since we want to manage the lifecycle
+ * of BiometricPrompt correctly, the information needs to be stored in here.
+ */
+ static class PromptInfo {
+ private final Bundle mBundle;
+
+ private PromptInfo(Bundle bundle) {
+ mBundle = bundle;
+ }
+
+ Bundle getBundle() {
+ return mBundle;
+ }
+
+ public CharSequence getTitle() {
+ return mBundle.getCharSequence(KEY_TITLE);
+ }
+
+ public CharSequence getSubtitle() {
+ return mBundle.getCharSequence(KEY_SUBTITLE);
+ }
+
+ public CharSequence getDescription() {
+ return mBundle.getCharSequence(KEY_DESCRIPTION);
+ }
+
+ public CharSequence getNegativeButtonText() {
+ return mBundle.getCharSequence(KEY_NEGATIVE_TEXT);
+ }
+
+ public static class Builder {
+ private final Bundle mBundle = new Bundle();
+
+ public Builder setTitle(@NonNull CharSequence title) {
+ mBundle.putCharSequence(KEY_TITLE, title);
+ return this;
+ }
+
+ public Builder setSubtitle(@Nullable CharSequence subtitle) {
+ mBundle.putCharSequence(KEY_SUBTITLE, subtitle);
+ return this;
+ }
+
+ public Builder setDescription(@Nullable CharSequence description) {
+ mBundle.putCharSequence(KEY_DESCRIPTION, description);
+ return this;
+ }
+
+ public Builder setNegativeButtonText(@NonNull CharSequence text) {
+ mBundle.putCharSequence(KEY_NEGATIVE_TEXT, text);
+ return this;
+ }
+
+ public PromptInfo build() {
+ return new PromptInfo(mBundle);
+ }
+ }
+ }
+}
+
diff --git a/src/com/android/settings/password/ChooseLockSettingsHelper.java b/src/com/android/settings/password/ChooseLockSettingsHelper.java
index 3c83f07..d5182b3 100644
--- a/src/com/android/settings/password/ChooseLockSettingsHelper.java
+++ b/src/com/android/settings/password/ChooseLockSettingsHelper.java
@@ -78,7 +78,13 @@
* @see Activity#onActivityResult(int, int, android.content.Intent)
*/
public boolean launchConfirmationActivity(int request, CharSequence title) {
- return launchConfirmationActivity(request, title, null, null, false, false);
+ return launchConfirmationActivity(
+ request /* request */,
+ title /* title */,
+ null /* header */,
+ null /* description */,
+ false /* returnCredentials */,
+ false /* external */);
}
/**
@@ -91,7 +97,13 @@
* @see Activity#onActivityResult(int, int, android.content.Intent)
*/
public boolean launchConfirmationActivity(int request, CharSequence title, boolean returnCredentials) {
- return launchConfirmationActivity(request, title, null, null, returnCredentials, false);
+ return launchConfirmationActivity(
+ request /* request */,
+ title /* title */,
+ null /* header */,
+ null /* description */,
+ returnCredentials /* returnCredentials */,
+ false /* external */);
}
/**
@@ -106,8 +118,16 @@
*/
public boolean launchConfirmationActivity(int request, CharSequence title,
boolean returnCredentials, int userId) {
- return launchConfirmationActivity(request, title, null, null,
- returnCredentials, false, false, 0, Utils.enforceSameOwner(mActivity, userId));
+ return launchConfirmationActivity(
+ request /* request */,
+ title /* title */,
+ null /* header */,
+ null /* description */,
+ returnCredentials /* returnCredentials */,
+ false /* external */,
+ false /* hasChallenge */,
+ 0 /* challenge */,
+ Utils.enforceSameOwner(mActivity, userId) /* userId */);
}
/**
@@ -127,8 +147,16 @@
boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
@Nullable CharSequence header, @Nullable CharSequence description,
boolean returnCredentials, boolean external) {
- return launchConfirmationActivity(request, title, header, description,
- returnCredentials, external, false, 0, Utils.getCredentialOwnerUserId(mActivity));
+ return launchConfirmationActivity(
+ request /* request */,
+ title /* title */,
+ header /* header */,
+ description /* description */,
+ returnCredentials /* returnCredentials */,
+ external /* external */,
+ false /* hasChallenge */,
+ 0 /* challenge */,
+ Utils.getCredentialOwnerUserId(mActivity) /* userId */);
}
/**
@@ -149,8 +177,16 @@
boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
@Nullable CharSequence header, @Nullable CharSequence description,
boolean returnCredentials, boolean external, int userId) {
- return launchConfirmationActivity(request, title, header, description,
- returnCredentials, external, false, 0, Utils.enforceSameOwner(mActivity, userId));
+ return launchConfirmationActivity(
+ request /* request */,
+ title /* title */,
+ header /* header */,
+ description /* description */,
+ returnCredentials /* returnCredentials */,
+ external /* external */,
+ false /* hasChallenge */,
+ 0 /* challenge */,
+ Utils.enforceSameOwner(mActivity, userId) /* userId */);
}
/**
@@ -166,8 +202,16 @@
public boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
@Nullable CharSequence header, @Nullable CharSequence description,
long challenge) {
- return launchConfirmationActivity(request, title, header, description,
- true, false, true, challenge, Utils.getCredentialOwnerUserId(mActivity));
+ return launchConfirmationActivity(
+ request /* request */,
+ title /* title */,
+ header /* header */,
+ description /* description */,
+ true /* returnCredentials */,
+ false /* external */,
+ true /* hasChallenge */,
+ challenge /* challenge */,
+ Utils.getCredentialOwnerUserId(mActivity) /* userId */);
}
/**
@@ -184,8 +228,16 @@
public boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
@Nullable CharSequence header, @Nullable CharSequence description,
long challenge, int userId) {
- return launchConfirmationActivity(request, title, header, description,
- true, false, true, challenge, Utils.enforceSameOwner(mActivity, userId));
+ return launchConfirmationActivity(
+ request /* request */,
+ title /* title */,
+ header /* header */,
+ description /* description */,
+ true /* returnCredentials */,
+ false /* external */,
+ true /* hasChallenge */,
+ challenge /* challenge */,
+ Utils.enforceSameOwner(mActivity, userId) /* userId */);
}
/**
@@ -205,8 +257,16 @@
public boolean launchConfirmationActivityWithExternalAndChallenge(int request,
@Nullable CharSequence title, @Nullable CharSequence header,
@Nullable CharSequence description, boolean external, long challenge, int userId) {
- return launchConfirmationActivity(request, title, header, description, false,
- external, true, challenge, Utils.enforceSameOwner(mActivity, userId));
+ return launchConfirmationActivity(
+ request /* request */,
+ title /* title */,
+ header /* header */,
+ description /* description */,
+ false /* returnCredentials */,
+ external /* external */,
+ true /* hasChallenge */,
+ challenge /* challenge */,
+ Utils.enforceSameOwner(mActivity, userId) /* userId */);
}
/**
@@ -219,31 +279,69 @@
@Nullable CharSequence description, int userId) {
final Bundle extras = new Bundle();
extras.putBoolean(EXTRA_ALLOW_ANY_USER, true);
- return launchConfirmationActivity(request, title, header, description, false,
- false, true, 0, userId, extras);
+ return launchConfirmationActivity(
+ request /* request */,
+ title /* title */,
+ header /* header */,
+ description /* description */,
+ false /* returnCredentials */,
+ false /* external */,
+ true /* hasChallenge */,
+ 0 /* challenge */,
+ userId /* userId */,
+ extras /* extras */);
}
private boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
@Nullable CharSequence header, @Nullable CharSequence description,
boolean returnCredentials, boolean external, boolean hasChallenge,
long challenge, int userId) {
- return launchConfirmationActivity(request, title, header, description, returnCredentials,
- external, hasChallenge, challenge, userId, null /* alternateButton */, null);
+ return launchConfirmationActivity(
+ request /* request */,
+ title /* title */,
+ header /* header */,
+ description /* description */,
+ returnCredentials /* returnCredentials */,
+ external /* external */,
+ hasChallenge /* hasChallenge */,
+ challenge /* challenge */,
+ userId /* userId */,
+ null /* alternateButton */,
+ null /* extras */);
}
private boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
@Nullable CharSequence header, @Nullable CharSequence description,
boolean returnCredentials, boolean external, boolean hasChallenge,
long challenge, int userId, Bundle extras) {
- return launchConfirmationActivity(request, title, header, description, returnCredentials,
- external, hasChallenge, challenge, userId, null /* alternateButton */, extras);
+ return launchConfirmationActivity(
+ request /* request */,
+ title /* title */,
+ header /* header */,
+ description /* description */,
+ returnCredentials /* returnCredentials */,
+ external /* external */,
+ hasChallenge /* hasChallenge */,
+ challenge /* challenge */,
+ userId /* userId */,
+ null /* alternateButton */,
+ extras /* extras */);
}
public boolean launchFrpConfirmationActivity(int request, @Nullable CharSequence header,
@Nullable CharSequence description, @Nullable CharSequence alternateButton) {
- return launchConfirmationActivity(request, null /* title */, header, description,
- false /* returnCredentials */, true /* external */, false /* hasChallenge */,
- 0 /* challenge */, LockPatternUtils.USER_FRP, alternateButton, null);
+ return launchConfirmationActivity(
+ request /* request */,
+ null /* title */,
+ header /* header */,
+ description /* description */,
+ false /* returnCredentials */,
+ true /* external */,
+ false /* hasChallenge */,
+ 0 /* challenge */,
+ LockPatternUtils.USER_FRP /* userId */,
+ alternateButton /* alternateButton */,
+ null /* extras */);
}
private boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
@@ -285,11 +383,11 @@
intent.putExtra(ConfirmDeviceCredentialBaseFragment.TITLE_TEXT, title);
intent.putExtra(ConfirmDeviceCredentialBaseFragment.HEADER_TEXT, header);
intent.putExtra(ConfirmDeviceCredentialBaseFragment.DETAILS_TEXT, message);
- intent.putExtra(ConfirmDeviceCredentialBaseFragment.ALLOW_FP_AUTHENTICATION, external);
// TODO: Remove dark theme and show_cancel_button options since they are no longer used
intent.putExtra(ConfirmDeviceCredentialBaseFragment.DARK_THEME, false);
intent.putExtra(ConfirmDeviceCredentialBaseFragment.SHOW_CANCEL_BUTTON, false);
intent.putExtra(ConfirmDeviceCredentialBaseFragment.SHOW_WHEN_LOCKED, external);
+ intent.putExtra(ConfirmDeviceCredentialBaseFragment.USE_FADE_ANIMATION, external);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_RETURN_CREDENTIALS, returnCredentials);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, hasChallenge);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge);
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index f5b3b05..f68c04a 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -22,21 +22,40 @@
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.Intent;
+import android.hardware.biometrics.BiometricConstants;
+import android.hardware.biometrics.BiometricManager;
+import android.hardware.biometrics.BiometricPrompt;
+import android.hardware.biometrics.BiometricPrompt.AuthenticationCallback;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
+import androidx.annotation.NonNull;
+import androidx.fragment.app.FragmentActivity;
+
import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.R;
import com.android.settings.Utils;
+import java.util.concurrent.Executor;
+
/**
* Launch this when you want to confirm the user is present by asking them to enter their
* PIN/password/pattern.
*/
-public class ConfirmDeviceCredentialActivity extends Activity {
+public class ConfirmDeviceCredentialActivity extends FragmentActivity {
public static final String TAG = ConfirmDeviceCredentialActivity.class.getSimpleName();
+ // The normal flow that apps go through
+ private static final int CREDENTIAL_NORMAL = 1;
+ // Unlocks the managed profile when the primary profile is unlocked
+ private static final int CREDENTIAL_MANAGED = 2;
+
+ private static final String TAG_BIOMETRIC_FRAGMENT = "fragment";
+
public static class InternalActivity extends ConfirmDeviceCredentialActivity {
}
@@ -60,57 +79,217 @@
return intent;
}
+ private BiometricManager mBiometricManager;
+ private BiometricFragment mBiometricFragment;
+ private DevicePolicyManager mDevicePolicyManager;
+ private LockPatternUtils mLockPatternUtils;
+ private UserManager mUserManager;
+ private ChooseLockSettingsHelper mChooseLockSettingsHelper;
+ private Handler mHandler = new Handler(Looper.getMainLooper());
+
+ private String mTitle;
+ private String mDetails;
+ private int mUserId;
+ private int mEffectiveUserId;
+ private int mCredentialMode;
+ private boolean mGoingToBackground;
+
+ private Executor mExecutor = (runnable -> {
+ mHandler.post(runnable);
+ });
+
+ private AuthenticationCallback mAuthenticationCallback = new AuthenticationCallback() {
+ public void onAuthenticationError(int errorCode, @NonNull CharSequence errString) {
+ if (!mGoingToBackground) {
+ if (errorCode == BiometricPrompt.BIOMETRIC_ERROR_USER_CANCELED) {
+ finish();
+ } else {
+ // All other errors go to some version of CC
+ showConfirmCredentials();
+ }
+ }
+
+ }
+
+ public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {
+ setResult(Activity.RESULT_OK);
+ finish();
+ }
+ };
+
@Override
- public void onCreate(Bundle savedInstanceState) {
+ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ mBiometricManager = getSystemService(BiometricManager.class);
+ mDevicePolicyManager = getSystemService(DevicePolicyManager.class);
+ mUserManager = UserManager.get(this);
+ mLockPatternUtils = new LockPatternUtils(this);
+
Intent intent = getIntent();
- String title = intent.getStringExtra(KeyguardManager.EXTRA_TITLE);
- String details = intent.getStringExtra(KeyguardManager.EXTRA_DESCRIPTION);
+ mTitle = intent.getStringExtra(KeyguardManager.EXTRA_TITLE);
+ mDetails = intent.getStringExtra(KeyguardManager.EXTRA_DESCRIPTION);
String alternateButton = intent.getStringExtra(
KeyguardManager.EXTRA_ALTERNATE_BUTTON_LABEL);
boolean frp = KeyguardManager.ACTION_CONFIRM_FRP_CREDENTIAL.equals(intent.getAction());
- int userId = UserHandle.myUserId();
+ mUserId = UserHandle.myUserId();
+ mEffectiveUserId = mUserManager.getCredentialOwnerProfile(mUserId);
if (isInternalActivity()) {
try {
- userId = Utils.getUserIdFromBundle(this, intent.getExtras());
+ mUserId = Utils.getUserIdFromBundle(this, intent.getExtras());
} catch (SecurityException se) {
Log.e(TAG, "Invalid intent extra", se);
}
}
- final boolean isManagedProfile = UserManager.get(this).isManagedProfile(userId);
+ final boolean isManagedProfile = UserManager.get(this).isManagedProfile(mUserId);
// if the client app did not hand in a title and we are about to show the work challenge,
// check whether there is a policy setting the organization name and use that as title
- if ((title == null) && isManagedProfile) {
- title = getTitleFromOrganizationName(userId);
+ if ((mTitle == null) && isManagedProfile) {
+ mTitle = getTitleFromOrganizationName(mUserId);
}
- ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this);
+ mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this);
final LockPatternUtils lockPatternUtils = new LockPatternUtils(this);
- boolean launched;
+
+ boolean launchedBiometric = false;
+ boolean launchedCDC = false;
// If the target is a managed user and user key not unlocked yet, we will force unlock
// tied profile so it will enable work mode and unlock managed profile, when personal
// challenge is unlocked.
if (frp) {
- launched = helper.launchFrpConfirmationActivity(0, title, details, alternateButton);
+ launchedCDC = mChooseLockSettingsHelper.launchFrpConfirmationActivity(
+ 0, mTitle, mDetails, alternateButton);
} else if (isManagedProfile && isInternalActivity()
- && !lockPatternUtils.isSeparateProfileChallengeEnabled(userId)) {
+ && !lockPatternUtils.isSeparateProfileChallengeEnabled(mUserId)) {
+ mCredentialMode = CREDENTIAL_MANAGED;
+ if (isBiometricAllowed()) {
+ showBiometricPrompt();
+ launchedBiometric = true;
+ } else {
+ showConfirmCredentials();
+ }
+ } else {
+ mCredentialMode = CREDENTIAL_NORMAL;
+ if (isBiometricAllowed()) {
+ // Don't need to check if biometrics / pin/pattern/pass are enrolled. It will go to
+ // onAuthenticationError and do the right thing automatically.
+ showBiometricPrompt();
+ launchedBiometric = true;
+ } else {
+ showConfirmCredentials();
+ }
+ }
+
+ if (launchedCDC) {
+ finish();
+ } else if (launchedBiometric) {
+ // Keep this activity alive until BiometricPrompt goes away
+ } else {
+ Log.d(TAG, "No pattern, password or PIN set.");
+ setResult(Activity.RESULT_OK);
+ finish();
+ }
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ // Translucent activity that is "visible", so it doesn't complain about finish()
+ // not being called before onResume().
+ setVisible(true);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ if (!isChangingConfigurations()) {
+ mGoingToBackground = true;
+ if (mBiometricFragment != null) {
+ mBiometricFragment.cancel();
+ }
+ finish();
+ } else {
+ mGoingToBackground = false;
+ }
+ }
+
+ // User could be locked while Effective user is unlocked even though the effective owns the
+ // credential. Otherwise, biometric can't unlock fbe/keystore through
+ // verifyTiedProfileChallenge. In such case, we also wanna show the user message that
+ // biometric is disabled due to device restart.
+ private boolean isStrongAuthRequired() {
+ return !mLockPatternUtils.isBiometricAllowedForUser(mEffectiveUserId)
+ || !mUserManager.isUserUnlocked(mUserId);
+ }
+
+ private boolean isBiometricDisabledByAdmin() {
+ final int disabledFeatures =
+ mDevicePolicyManager.getKeyguardDisabledFeatures(null, mEffectiveUserId);
+ return (disabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_BIOMETRICS) != 0;
+ }
+
+ private boolean isBiometricAllowed() {
+ return !isStrongAuthRequired() && !isBiometricDisabledByAdmin();
+ }
+
+ private void showBiometricPrompt() {
+ mBiometricManager.setActiveUser(mUserId);
+
+ mBiometricFragment = (BiometricFragment) getSupportFragmentManager()
+ .findFragmentByTag(TAG_BIOMETRIC_FRAGMENT);
+ boolean newFragment = false;
+
+ if (mBiometricFragment == null) {
+ final BiometricFragment.PromptInfo info = new BiometricFragment.PromptInfo.Builder()
+ .setTitle(mTitle)
+ .setSubtitle(mDetails)
+ .setNegativeButtonText(getResources()
+ .getString(R.string.confirm_device_credential_use_alternate_method))
+ .build();
+ mBiometricFragment = BiometricFragment.newInstance(info);
+ newFragment = true;
+ }
+ mBiometricFragment.setCallbacks(mExecutor, mAuthenticationCallback);
+
+ if (newFragment) {
+ getSupportFragmentManager().beginTransaction()
+ .add(mBiometricFragment, TAG_BIOMETRIC_FRAGMENT).commit();
+ }
+ }
+
+ /**
+ * Shows ConfirmDeviceCredentials for normal apps.
+ */
+ private void showConfirmCredentials() {
+ boolean launched = false;
+ if (mCredentialMode == CREDENTIAL_MANAGED) {
// We set the challenge as 0L, so it will force to unlock managed profile when it
// unlocks primary profile screen lock, by calling verifyTiedProfileChallenge()
- launched = helper.launchConfirmationActivityWithExternalAndChallenge(
- 0 /* request code */, null /* title */, title, details, true /* isExternal */,
- 0L /* challenge */, userId);
- } else {
- launched = helper.launchConfirmationActivity(0 /* request code */, null /* title */,
- title, details, false /* returnCredentials */, true /* isExternal */, userId);
+ launched = mChooseLockSettingsHelper
+ .launchConfirmationActivityWithExternalAndChallenge(
+ 0 /* request code */, null /* title */, mTitle, mDetails,
+ true /* isExternal */, 0L /* challenge */, mUserId);
+ } else if (mCredentialMode == CREDENTIAL_NORMAL){
+ launched = mChooseLockSettingsHelper.launchConfirmationActivity(
+ 0 /* request code */, null /* title */,
+ mTitle, mDetails, false /* returnCredentials */, true /* isExternal */,
+ mUserId);
}
if (!launched) {
- Log.d(TAG, "No pattern, password or PIN set.");
+ Log.d(TAG, "No pin/pattern/pass set");
setResult(Activity.RESULT_OK);
}
finish();
}
+ @Override
+ public void finish() {
+ super.finish();
+ // Finish without animation since the activity is just there so we can launch
+ // BiometricPrompt.
+ overridePendingTransition(R.anim.confirm_credential_biometric_transition_enter, 0);
+ }
+
private boolean isInternalActivity() {
return this instanceof ConfirmDeviceCredentialActivity.InternalActivity;
}
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
index cae3ae6..c00f9ab 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
@@ -140,6 +140,15 @@
}
}
+ @Override
+ public void finish() {
+ super.finish();
+ if (getIntent().getBooleanExtra(
+ ConfirmDeviceCredentialBaseFragment.USE_FADE_ANIMATION, false)) {
+ overridePendingTransition(0, R.anim.confirm_credential_biometric_transition_exit);
+ }
+ }
+
public void prepareEnterAnimation() {
getFragment().prepareEnterAnimation();
}
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java b/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
index a9542e5..9b677aa 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
@@ -53,26 +53,24 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.Utils;
-import com.android.settings.biometrics.fingerprint.FingerprintUiHelper;
import com.android.settings.core.InstrumentedFragment;
/**
* Base fragment to be shared for PIN/Pattern/Password confirmation fragments.
*/
-public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFragment
- implements FingerprintUiHelper.Callback {
+public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFragment {
public static final String PACKAGE = "com.android.settings";
public static final String TITLE_TEXT = PACKAGE + ".ConfirmCredentials.title";
public static final String HEADER_TEXT = PACKAGE + ".ConfirmCredentials.header";
public static final String DETAILS_TEXT = PACKAGE + ".ConfirmCredentials.details";
- public static final String ALLOW_FP_AUTHENTICATION =
- PACKAGE + ".ConfirmCredentials.allowFpAuthentication";
public static final String DARK_THEME = PACKAGE + ".ConfirmCredentials.darkTheme";
public static final String SHOW_CANCEL_BUTTON =
PACKAGE + ".ConfirmCredentials.showCancelButton";
public static final String SHOW_WHEN_LOCKED =
PACKAGE + ".ConfirmCredentials.showWhenLocked";
+ public static final String USE_FADE_ANIMATION =
+ PACKAGE + ".ConfirmCredentials.useFadeAnimation";
protected static final int USER_TYPE_PRIMARY = 1;
protected static final int USER_TYPE_MANAGED_PROFILE = 2;
@@ -81,10 +79,8 @@
/** Time we wait before clearing a wrong input attempt (e.g. pattern) and the error message. */
protected static final long CLEAR_WRONG_ATTEMPT_TIMEOUT_MS = 3000;
- private FingerprintUiHelper mFingerprintHelper;
protected boolean mReturnCredentials = false;
protected Button mCancelButton;
- protected ImageView mFingerprintIcon;
protected int mEffectiveUserId;
protected int mUserId;
protected UserManager mUserManager;
@@ -123,9 +119,7 @@
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mCancelButton = (Button) view.findViewById(R.id.cancelButton);
- mFingerprintIcon = (ImageView) view.findViewById(R.id.fingerprintIcon);
- mFingerprintHelper = new FingerprintUiHelper(
- mFingerprintIcon, view.findViewById(R.id.errorText), this, mUserId);
+
boolean showCancelButton = getActivity().getIntent().getBooleanExtra(
SHOW_CANCEL_BUTTON, false);
boolean hasAlternateButton = mFrp && !TextUtils.isEmpty(mFrpAlternateButtonText);
@@ -153,29 +147,16 @@
}
}
- private boolean isFingerprintDisabledByAdmin() {
- final int disabledFeatures =
- mDevicePolicyManager.getKeyguardDisabledFeatures(null, mEffectiveUserId);
- return (disabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT) != 0;
- }
-
// User could be locked while Effective user is unlocked even though the effective owns the
// credential. Otherwise, fingerprint can't unlock fbe/keystore through
// verifyTiedProfileChallenge. In such case, we also wanna show the user message that
// fingerprint is disabled due to device restart.
protected boolean isStrongAuthRequired() {
return mFrp
- || !mLockPatternUtils.isFingerprintAllowedForUser(mEffectiveUserId)
+ || !mLockPatternUtils.isBiometricAllowedForUser(mEffectiveUserId)
|| !mUserManager.isUserUnlocked(mUserId);
}
- private boolean isFingerprintAllowed() {
- return !mReturnCredentials
- && getActivity().getIntent().getBooleanExtra(ALLOW_FP_AUTHENTICATION, false)
- && !isStrongAuthRequired()
- && !isFingerprintDisabledByAdmin();
- }
-
@Override
public void onResume() {
super.onResume();
@@ -183,13 +164,6 @@
}
protected void refreshLockScreen() {
- if (isFingerprintAllowed()) {
- mFingerprintHelper.startListening();
- } else {
- if (mFingerprintHelper.isListening()) {
- mFingerprintHelper.stopListening();
- }
- }
updateErrorMessage(mLockPatternUtils.getCurrentFailedPasswordAttempts(mEffectiveUserId));
}
@@ -214,28 +188,10 @@
@Override
public void onPause() {
super.onPause();
- if (mFingerprintHelper.isListening()) {
- mFingerprintHelper.stopListening();
- }
- }
-
- @Override
- public void onAuthenticated() {
- // Check whether we are still active.
- if (getActivity() != null && getActivity().isResumed()) {
- TrustManager trustManager =
- (TrustManager) getActivity().getSystemService(Context.TRUST_SERVICE);
- trustManager.setDeviceLockedForUser(mEffectiveUserId, false);
- authenticationSucceeded();
- checkForPendingIntent();
- }
}
protected abstract void authenticationSucceeded();
- @Override
- public void onFingerprintIconVisibilityChanged(boolean visible) {
- }
public void prepareEnterAnimation() {
}
diff --git a/src/com/android/settings/password/ConfirmLockPassword.java b/src/com/android/settings/password/ConfirmLockPassword.java
index 38561fb..d380fc9 100644
--- a/src/com/android/settings/password/ConfirmLockPassword.java
+++ b/src/com/android/settings/password/ConfirmLockPassword.java
@@ -105,7 +105,6 @@
private CountDownTimer mCountdownTimer;
private boolean mIsAlpha;
private InputMethodManager mImm;
- private boolean mUsingFingerprint = false;
private AppearAnimationUtils mAppearAnimationUtils;
private DisappearAnimationUtils mDisappearAnimationUtils;
@@ -243,7 +242,6 @@
mCancelButton.setAlpha(0f);
mPasswordEntry.setAlpha(0f);
mErrorTextView.setAlpha(0f);
- mFingerprintIcon.setAlpha(0f);
}
private View[] getActiveViews() {
@@ -255,9 +253,6 @@
}
result.add(mPasswordEntry);
result.add(mErrorTextView);
- if (mFingerprintIcon.getVisibility() == View.VISIBLE) {
- result.add(mFingerprintIcon);
- }
return result.toArray(new View[] {});
}
@@ -303,17 +298,12 @@
mCredentialCheckResultTracker.setResult(true, new Intent(), 0, mEffectiveUserId);
}
- @Override
- public void onFingerprintIconVisibilityChanged(boolean visible) {
- mUsingFingerprint = visible;
- }
-
private void updatePasswordEntry() {
final boolean isLockedOut =
mLockPatternUtils.getLockoutAttemptDeadline(mEffectiveUserId) != 0;
mPasswordEntry.setEnabled(!isLockedOut);
mPasswordEntryInputDisabler.setInputEnabled(!isLockedOut);
- if (isLockedOut || mUsingFingerprint) {
+ if (isLockedOut) {
mImm.hideSoftInputFromWindow(mPasswordEntry.getWindowToken(), 0 /*flags*/);
} else {
mPasswordEntry.scheduleShowSoftInput();
diff --git a/src/com/android/settings/password/ConfirmLockPattern.java b/src/com/android/settings/password/ConfirmLockPattern.java
index 84db540..95a0aca 100644
--- a/src/com/android/settings/password/ConfirmLockPattern.java
+++ b/src/com/android/settings/password/ConfirmLockPattern.java
@@ -231,7 +231,6 @@
mCancelButton.setAlpha(0f);
mLockPatternView.setAlpha(0f);
mDetailsTextView.setAlpha(0f);
- mFingerprintIcon.setAlpha(0f);
}
private int getDefaultDetails() {
@@ -265,9 +264,6 @@
}
result.add(row);
}
- if (mFingerprintIcon.getVisibility() == View.VISIBLE) {
- result.add(new ArrayList<Object>(Collections.singletonList(mFingerprintIcon)));
- }
Object[][] resultArr = new Object[result.size()][cellStates[0].length];
for (int i = 0; i < result.size(); i++) {
ArrayList<Object> row = result.get(i);
@@ -377,16 +373,6 @@
}
}
- @Override
- public void onFingerprintIconVisibilityChanged(boolean visible) {
- if (mLeftSpacerLandscape != null && mRightSpacerLandscape != null) {
-
- // In landscape, adjust spacing depending on fingerprint icon visibility.
- mLeftSpacerLandscape.setVisibility(visible ? View.GONE : View.VISIBLE);
- mRightSpacerLandscape.setVisibility(visible ? View.GONE : View.VISIBLE);
- }
- }
-
/**
* The pattern listener that responds according to a user confirming
* an existing lock pattern.
diff --git a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
new file mode 100644
index 0000000..9aac509
--- /dev/null
+++ b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import androidx.appcompat.app.AlertDialog;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settingslib.wifi.AccessPoint;
+import java.util.ArrayList;
+import java.util.List;
+
+public class NetworkRequestDialogFragment extends InstrumentedDialogFragment implements
+ DialogInterface.OnClickListener {
+
+ private List<AccessPoint> mAccessPointList;
+
+ public static NetworkRequestDialogFragment newInstance(int uid, String packageName) {
+ Bundle args = new Bundle();
+ args.putInt("uid", uid);
+ args.putString("packageName", packageName);
+ NetworkRequestDialogFragment dialogFragment = new NetworkRequestDialogFragment();
+ dialogFragment.setArguments(args);
+ return dialogFragment;
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ Context context = getContext();
+
+ // Prepares title.
+ LayoutInflater inflater = LayoutInflater.from(context);
+ View customTitle = inflater.inflate(R.layout.network_request_dialog_title, null);
+
+ TextView title = customTitle.findViewById(R.id.network_request_title_text);
+ title.setText(R.string.network_connection_request_dialog_title);
+ ProgressBar progressBar = customTitle.findViewById(R.id.network_request_title_progress);
+ progressBar.setVisibility(View.VISIBLE);
+
+ // Prepares adapter.
+ AccessPointAdapter adapter = new AccessPointAdapter(context,
+ R.layout.preference_access_point, getAccessPointList());
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(context)
+ .setCustomTitle(customTitle)
+ .setAdapter(adapter, this)
+ .setPositiveButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
+ return builder.create();
+ }
+
+ List<AccessPoint> getAccessPointList() {
+ // Initials list for adapter, in case of display crashing.
+ if (mAccessPointList == null) {
+ mAccessPointList = new ArrayList<>();
+ }
+ return mAccessPointList;
+ }
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsProto.MetricsEvent.WIFI_SCANNING_NEEDED_DIALOG;
+ }
+
+ private class AccessPointAdapter extends ArrayAdapter<AccessPoint> {
+
+ private final int mResourceId;
+ private final LayoutInflater mInflater;
+
+ public AccessPointAdapter(Context context, int resourceId, List<AccessPoint> objects) {
+ super(context, resourceId, objects);
+ mResourceId = resourceId;
+ mInflater = LayoutInflater.from(context);
+ }
+
+ @Override
+ public View getView(int position, View view, ViewGroup parent) {
+ if (view == null) {
+ view = mInflater.inflate(mResourceId, parent, false);
+ }
+
+ // TODO: Sets correct information to list item.
+ final View divider = view.findViewById(com.android.settingslib.R.id.two_target_divider);
+ divider.setVisibility(View.GONE);
+
+ return view;
+ }
+ }
+}
+
diff --git a/src/com/android/settings/wifi/WifiSlice.java b/src/com/android/settings/wifi/WifiSlice.java
index e483d16..43f5372 100644
--- a/src/com/android/settings/wifi/WifiSlice.java
+++ b/src/com/android/settings/wifi/WifiSlice.java
@@ -71,7 +71,7 @@
.build();
@VisibleForTesting
- static final int DEFAULT_EXPANDED_ROW_COUNT = 4;
+ static final int DEFAULT_EXPANDED_ROW_COUNT = 3;
private final Context mContext;
@@ -137,10 +137,7 @@
.setSubtitle(placeholder));
}
}
- // Add more button
- return listBuilder
- .setSeeMoreAction(primaryAction)
- .build();
+ return listBuilder.build();
}
private RowBuilder getAccessPointRow(AccessPoint accessPoint) {
diff --git a/tests/robotests/src/com/android/settings/development/ClearAdbKeysPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/ClearAdbKeysPreferenceControllerTest.java
index 56f1944..6ab4d4c 100644
--- a/tests/robotests/src/com/android/settings/development/ClearAdbKeysPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/ClearAdbKeysPreferenceControllerTest.java
@@ -28,7 +28,7 @@
import static org.mockito.Mockito.when;
import android.content.Context;
-import android.hardware.usb.IUsbManager;
+import android.debug.IAdbManager;
import android.os.RemoteException;
import android.os.SystemProperties;
@@ -60,7 +60,7 @@
@Mock
private SwitchPreference mPreference;
@Mock
- private IUsbManager mUsbManager;
+ private IAdbManager mAdbManager;
@Mock
private DevelopmentSettingsDashboardFragment mFragment;
@@ -71,7 +71,7 @@
MockitoAnnotations.initMocks(this);
final Context context = RuntimeEnvironment.application;
mController = spy(new ClearAdbKeysPreferenceController(context, mFragment));
- ReflectionHelpers.setField(mController, "mUsbManager", mUsbManager);
+ ReflectionHelpers.setField(mController, "mAdbManager", mAdbManager);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
}
@@ -168,7 +168,7 @@
public void onClearAdbKeysConfirmed_shouldClearKeys() throws RemoteException {
mController.onClearAdbKeysConfirmed();
- verify(mUsbManager).clearUsbDebuggingKeys();
+ verify(mAdbManager).clearDebuggingKeys();
}
@Implements(ClearAdbKeysWarningDialog.class)
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProviderTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProviderTest.java
index 1932ab9..8b541c6 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProviderTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProviderTest.java
@@ -23,9 +23,12 @@
import android.net.Uri;
import android.os.Bundle;
+import com.android.settings.intelligence.ContextualCardProto.ContextualCard;
import com.android.settings.intelligence.ContextualCardProto.ContextualCardList;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.wifi.WifiSlice;
+import com.google.android.settings.intelligence.libs.contextualcards.ContextualCardCategory;
import com.google.android.settings.intelligence.libs.contextualcards.ContextualCardProvider;
import org.junit.Before;
@@ -62,4 +65,17 @@
returnValue.getByteArray(ContextualCardProvider.BUNDLE_CARD_LIST));
assertThat(cards.getCardCount()).isEqualTo(actualNo);
}
+
+ @Test
+ public void getContextualCards_wifiSlice_shouldGetCorrectCategory() {
+ final ContextualCardList cards = mProvider.getContextualCards();
+ ContextualCard wifiCard = null;
+ for (ContextualCard card : cards.getCardList()) {
+ if (card.getSliceUri().equals(WifiSlice.WIFI_URI.toString())) {
+ wifiCard = card;
+ }
+ }
+
+ assertThat(wifiCard.getCategory()).isEqualTo(ContextualCardCategory.IMPORTANT);
+ }
}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeAlarmsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeAlarmsPreferenceControllerTest.java
index 6702118..df4df51 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeAlarmsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeAlarmsPreferenceControllerTest.java
@@ -30,9 +30,6 @@
import android.content.Context;
import android.provider.Settings;
-import androidx.preference.PreferenceScreen;
-import androidx.preference.SwitchPreference;
-
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -45,6 +42,9 @@
import org.robolectric.shadows.ShadowApplication;
import org.robolectric.util.ReflectionHelpers;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
@RunWith(SettingsRobolectricTestRunner.class)
public class ZenModeAlarmsPreferenceControllerTest {
@@ -75,7 +75,8 @@
mContext = RuntimeEnvironment.application;
mContentResolver = RuntimeEnvironment.application.getContentResolver();
when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
- mController = new ZenModeAlarmsPreferenceController(mContext, mock(Lifecycle.class));
+ mController = new ZenModeAlarmsPreferenceController(mContext, mock(Lifecycle.class),
+ "zen_mode_behavior_alarms");
ReflectionHelpers.setField(mController, "mBackend", mBackend);
when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceControllerTest.java
deleted file mode 100644
index f1f1b2e..0000000
--- a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceControllerTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.notification;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.NotificationManager;
-import android.content.Context;
-
-import androidx.preference.Preference;
-
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.shadows.ShadowApplication;
-import org.robolectric.util.ReflectionHelpers;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public final class ZenModeBehaviorCallsPreferenceControllerTest {
-
- private ZenModeBehaviorCallsPreferenceController mController;
- @Mock
- private NotificationManager mNotificationManager;
- @Mock
- private NotificationManager.Policy mPolicy;
-
- private Context mContext;
- @Mock
- private ZenModeBackend mBackend;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- ShadowApplication shadowApplication = ShadowApplication.getInstance();
- shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
-
- mContext = RuntimeEnvironment.application;
- when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
-
- mController = new ZenModeBehaviorCallsPreferenceController(
- mContext, mock(Lifecycle.class));
- ReflectionHelpers.setField(mController, "mBackend", mBackend);
- }
-
- @Test
- public void testIsAvailable() {
- assertTrue(mController.isAvailable());
- }
-
- @Test
- public void testHasSummary() {
- Preference pref = mock(Preference.class);
- mController.updateState(pref);
- verify(pref).setSummary(any());
- }
-}
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceControllerTest.java
deleted file mode 100644
index 11cdfcc..0000000
--- a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceControllerTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.notification;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.NotificationManager;
-import android.content.Context;
-
-import androidx.preference.Preference;
-
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.shadows.ShadowApplication;
-import org.robolectric.util.ReflectionHelpers;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public final class ZenModeBehaviorMsgEventReminderPreferenceControllerTest {
-
- private ZenModeBehaviorMsgEventReminderPreferenceController mController;
- @Mock
- private NotificationManager mNotificationManager;
- @Mock
- private NotificationManager.Policy mPolicy;
-
- private Context mContext;
- @Mock
- private ZenModeBackend mBackend;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- ShadowApplication shadowApplication = ShadowApplication.getInstance();
- shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
-
- mContext = RuntimeEnvironment.application;
- when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
-
- mController = new ZenModeBehaviorMsgEventReminderPreferenceController(
- mContext, mock(Lifecycle.class));
- ReflectionHelpers.setField(mController, "mBackend", mBackend);
- }
-
- @Test
- public void testIsAvailable() {
- assertTrue(mController.isAvailable());
- }
-
- @Test
- public void testHasSummary() {
- Preference pref = mock(Preference.class);
- mController.updateState(pref);
- verify(pref).setSummary(any());
- }
-}
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceControllerTest.java
deleted file mode 100644
index c854e8a..0000000
--- a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceControllerTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.notification;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.NotificationManager;
-import android.content.Context;
-
-import androidx.preference.Preference;
-
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.shadows.ShadowApplication;
-import org.robolectric.util.ReflectionHelpers;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public final class ZenModeBehaviorSoundPreferenceControllerTest {
-
- private ZenModeBehaviorSoundPreferenceController mController;
- @Mock
- private NotificationManager mNotificationManager;
- @Mock
- private NotificationManager.Policy mPolicy;
-
- private Context mContext;
- @Mock
- private ZenModeBackend mBackend;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- ShadowApplication shadowApplication = ShadowApplication.getInstance();
- shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
-
- mContext = RuntimeEnvironment.application;
- when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
-
- mController = new ZenModeBehaviorSoundPreferenceController(
- mContext, mock(Lifecycle.class));
- ReflectionHelpers.setField(mController, "mBackend", mBackend);
- }
-
- @Test
- public void testIsAvailable() {
- assertTrue(mController.isAvailable());
- }
-
- @Test
- public void testHasSummary() {
- Preference pref = mock(Preference.class);
- mController.updateState(pref);
- verify(pref).setSummary(any());
- }
-}
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeCallsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeCallsPreferenceControllerTest.java
index 79619a7..fdc43f3 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeCallsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeCallsPreferenceControllerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,24 +16,15 @@
package com.android.settings.notification;
-import static android.provider.Settings.Global.ZEN_MODE;
-import static android.provider.Settings.Global.ZEN_MODE_ALARMS;
-import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
-import static android.provider.Settings.Global.ZEN_MODE_NO_INTERRUPTIONS;
-
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.NotificationManager;
-import android.content.ContentResolver;
import android.content.Context;
-import android.provider.Settings;
-import androidx.preference.ListPreference;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -46,32 +37,20 @@
import org.robolectric.shadows.ShadowApplication;
import org.robolectric.util.ReflectionHelpers;
+import androidx.preference.Preference;
+
@RunWith(SettingsRobolectricTestRunner.class)
-public class ZenModeCallsPreferenceControllerTest {
+public final class ZenModeCallsPreferenceControllerTest {
private ZenModeCallsPreferenceController mController;
-
- @Mock
- private ZenModeBackend mBackend;
@Mock
private NotificationManager mNotificationManager;
@Mock
- private ListPreference mockPref;
- @Mock
private NotificationManager.Policy mPolicy;
- @Mock
- private PreferenceScreen mPreferenceScreen;
- private ContentResolver mContentResolver;
- private Context mContext;
- /**
- * Array Values Key
- * 0: anyone
- * 1: contacts
- * 2: starred
- * 3: none
- */
- private String[] mValues;
+ private Context mContext;
+ @Mock
+ private ZenModeBackend mBackend;
@Before
public void setup() {
@@ -80,100 +59,22 @@
shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
mContext = RuntimeEnvironment.application;
- mValues = mContext.getResources().getStringArray(R.array.zen_mode_contacts_values);
- mContentResolver = RuntimeEnvironment.application.getContentResolver();
when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
- when(mBackend.getPriorityCallSenders())
- .thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
- when(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE))
- .thenCallRealMethod();
- when(mBackend.getContactsSummary(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
- .thenCallRealMethod();
-
- mController = new ZenModeCallsPreferenceController(mContext, mock(Lifecycle.class));
+ mController = new ZenModeCallsPreferenceController(
+ mContext, mock(Lifecycle.class), "zen_mode_calls_settings");
ReflectionHelpers.setField(mController, "mBackend", mBackend);
-
- when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
- mockPref);
- mController.displayPreference(mPreferenceScreen);
}
@Test
- public void updateState_TotalSilence() {
- Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_NO_INTERRUPTIONS);
-
- when(mBackend.isPriorityCategoryEnabled(
- NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
- .thenReturn(false);
- final ListPreference mockPref = mock(ListPreference.class);
- mController.updateState(mockPref);
-
- verify(mockPref).setEnabled(false);
- verify(mockPref).setSummary(R.string.zen_mode_from_none);
+ public void testIsAvailable() {
+ assertTrue(mController.isAvailable());
}
@Test
- public void updateState_AlarmsOnly() {
- Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_ALARMS);
-
- final ListPreference mockPref = mock(ListPreference.class);
- mController.updateState(mockPref);
-
- verify(mockPref).setEnabled(false);
- verify(mockPref).setSummary(R.string.zen_mode_from_none);
+ public void testHasSummary() {
+ Preference pref = mock(Preference.class);
+ mController.updateState(pref);
+ verify(pref).setSummary(any());
}
-
- @Test
- public void updateState_Priority() {
- Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
-
- when(mBackend.isPriorityCategoryEnabled(
- NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
- .thenReturn(true);
-
- mController.updateState(mockPref);
-
- verify(mockPref).setEnabled(true);
- verify(mockPref).setSummary(R.string.zen_mode_from_starred);
- }
-
- @Test
- public void onPreferenceChange_setSelectedContacts_any() {
- Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
- when(mBackend.getPriorityCallSenders()).thenReturn(
- NotificationManager.Policy.PRIORITY_SENDERS_ANY);
- mController.updateState(mockPref);
- verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
- ZenModeBackend.ZEN_MODE_FROM_ANYONE)]);
- }
-
- @Test
- public void onPreferenceChange_setSelectedContacts_none() {
- Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
- when(mBackend.getPriorityCallSenders()).thenReturn(ZenModeBackend.SOURCE_NONE);
- mController.updateState(mockPref);
- verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
- ZenModeBackend.ZEN_MODE_FROM_NONE)]);
- }
-
- @Test
- public void onPreferenceChange_setSelectedContacts_starred() {
- Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
- when(mBackend.getPriorityCallSenders()).thenReturn(
- NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
- mController.updateState(mockPref);
- verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
- ZenModeBackend.ZEN_MODE_FROM_STARRED)]);
- }
-
- @Test
- public void onPreferenceChange_setSelectedContacts_contacts() {
- Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
- when(mBackend.getPriorityCallSenders()).thenReturn(
- NotificationManager.Policy.PRIORITY_SENDERS_CONTACTS);
- mController.updateState(mockPref);
- verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
- ZenModeBackend.ZEN_MODE_FROM_CONTACTS)]);
- }
-}
\ No newline at end of file
+}
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeMessagesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeMessagesPreferenceControllerTest.java
index 0ff0665..890f6c2 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeMessagesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeMessagesPreferenceControllerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,24 +16,13 @@
package com.android.settings.notification;
-import static android.provider.Settings.Global.ZEN_MODE;
-import static android.provider.Settings.Global.ZEN_MODE_ALARMS;
-import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
-import static android.provider.Settings.Global.ZEN_MODE_NO_INTERRUPTIONS;
-
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.NotificationManager;
-import android.content.ContentResolver;
import android.content.Context;
-import android.provider.Settings;
-import androidx.preference.ListPreference;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -47,31 +36,17 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-public class ZenModeMessagesPreferenceControllerTest {
+public final class ZenModeMessagesPreferenceControllerTest {
private ZenModeMessagesPreferenceController mController;
-
- @Mock
- private ZenModeBackend mBackend;
@Mock
private NotificationManager mNotificationManager;
@Mock
- private ListPreference mockPref;
- @Mock
private NotificationManager.Policy mPolicy;
- @Mock
- private PreferenceScreen mPreferenceScreen;
- private ContentResolver mContentResolver;
- private Context mContext;
- /**
- * Array Values Key
- * 0: anyone
- * 1: contacts
- * 2: starred
- * 3: none
- */
- private String[] mValues;
+ private Context mContext;
+ @Mock
+ private ZenModeBackend mBackend;
@Before
public void setup() {
@@ -80,100 +55,23 @@
shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
mContext = RuntimeEnvironment.application;
- mValues = mContext.getResources().getStringArray(R.array.zen_mode_contacts_values);
- mContentResolver = RuntimeEnvironment.application.getContentResolver();
when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
- when(mBackend.getPriorityMessageSenders())
- .thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
- when(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE))
- .thenCallRealMethod();
- when(mBackend.getContactsSummary(NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES))
- .thenCallRealMethod();
-
- mController = new ZenModeMessagesPreferenceController(mContext, mock(Lifecycle.class));
+ mController = new ZenModeMessagesPreferenceController(
+ mContext, mock(Lifecycle.class), "zen_mode_messages_settings");
ReflectionHelpers.setField(mController, "mBackend", mBackend);
-
- when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
- mockPref);
- mController.displayPreference(mPreferenceScreen);
}
@Test
- public void updateState_TotalSilence() {
- Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_NO_INTERRUPTIONS);
-
- when(mBackend.isPriorityCategoryEnabled(
- NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES))
- .thenReturn(false);
- final ListPreference mockPref = mock(ListPreference.class);
- mController.updateState(mockPref);
-
- verify(mockPref).setEnabled(false);
- verify(mockPref).setSummary(R.string.zen_mode_from_none);
+ public void testIsAvailable() {
+ assertTrue(mController.isAvailable());
}
- @Test
- public void updateState_AlarmsOnly() {
- Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_ALARMS);
-
- final ListPreference mockPref = mock(ListPreference.class);
- mController.updateState(mockPref);
-
- verify(mockPref).setEnabled(false);
- verify(mockPref).setSummary(R.string.zen_mode_from_none);
- }
-
- @Test
- public void updateState_Priority() {
- Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
-
- when(mBackend.isPriorityCategoryEnabled(
- NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES))
- .thenReturn(true);
-
- mController.updateState(mockPref);
-
- verify(mockPref).setEnabled(true);
- verify(mockPref).setSummary(R.string.zen_mode_from_starred);
- }
-
- @Test
- public void onPreferenceChange_setSelectedContacts_any() {
- Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
- when(mBackend.getPriorityMessageSenders()).thenReturn(
- NotificationManager.Policy.PRIORITY_SENDERS_ANY);
- mController.updateState(mockPref);
- verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
- ZenModeBackend.ZEN_MODE_FROM_ANYONE)]);
- }
-
- @Test
- public void onPreferenceChange_setSelectedContacts_none() {
- Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
- when(mBackend.getPriorityMessageSenders()).thenReturn(ZenModeBackend.SOURCE_NONE);
- mController.updateState(mockPref);
- verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
- ZenModeBackend.ZEN_MODE_FROM_NONE)]);
- }
-
- @Test
- public void onPreferenceChange_setSelectedContacts_starred() {
- Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
- when(mBackend.getPriorityMessageSenders()).thenReturn(
- NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
- mController.updateState(mockPref);
- verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
- ZenModeBackend.ZEN_MODE_FROM_STARRED)]);
- }
-
- @Test
- public void onPreferenceChange_setSelectedContacts_contacts() {
- Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
- when(mBackend.getPriorityMessageSenders()).thenReturn(
- NotificationManager.Policy.PRIORITY_SENDERS_CONTACTS);
- mController.updateState(mockPref);
- verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
- ZenModeBackend.ZEN_MODE_FROM_CONTACTS)]);
- }
-}
\ No newline at end of file
+// TODO: (b/111475013 - beverlyt) set messages summary
+// @Test
+// public void testHasSummary() {
+// Preference pref = mock(Preference.class);
+// mController.updateState(pref);
+// verify(pref).setSummary(any());
+// }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModePriorityCallsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModePriorityCallsPreferenceControllerTest.java
new file mode 100644
index 0000000..36a1382
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/ZenModePriorityCallsPreferenceControllerTest.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification;
+
+import static android.provider.Settings.Global.ZEN_MODE;
+import static android.provider.Settings.Global.ZEN_MODE_ALARMS;
+import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
+import static android.provider.Settings.Global.ZEN_MODE_NO_INTERRUPTIONS;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationManager;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.R;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+import androidx.preference.ListPreference;
+import androidx.preference.PreferenceScreen;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class ZenModePriorityCallsPreferenceControllerTest {
+
+ private ZenModePriorityCallsPreferenceController mController;
+
+ @Mock
+ private ZenModeBackend mBackend;
+ @Mock
+ private NotificationManager mNotificationManager;
+ @Mock
+ private ListPreference mockPref;
+ @Mock
+ private NotificationManager.Policy mPolicy;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ private ContentResolver mContentResolver;
+ private Context mContext;
+
+ /**
+ * Array Values Key
+ * 0: anyone
+ * 1: contacts
+ * 2: starred
+ * 3: none
+ */
+ private String[] mValues;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
+
+ mContext = RuntimeEnvironment.application;
+ mValues = mContext.getResources().getStringArray(R.array.zen_mode_contacts_values);
+ mContentResolver = RuntimeEnvironment.application.getContentResolver();
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
+
+ when(mBackend.getPriorityCallSenders())
+ .thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
+ when(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE))
+ .thenCallRealMethod();
+ when(mBackend.getContactsSummary(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
+ .thenCallRealMethod();
+
+ mController = new ZenModePriorityCallsPreferenceController(mContext, mock(Lifecycle.class));
+ ReflectionHelpers.setField(mController, "mBackend", mBackend);
+
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
+ mockPref);
+ mController.displayPreference(mPreferenceScreen);
+ }
+
+ @Test
+ public void updateState_TotalSilence() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_NO_INTERRUPTIONS);
+
+ when(mBackend.isPriorityCategoryEnabled(
+ NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
+ .thenReturn(false);
+ final ListPreference mockPref = mock(ListPreference.class);
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(false);
+ verify(mockPref).setSummary(R.string.zen_mode_from_none);
+ }
+
+ @Test
+ public void updateState_AlarmsOnly() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_ALARMS);
+
+ final ListPreference mockPref = mock(ListPreference.class);
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(false);
+ verify(mockPref).setSummary(R.string.zen_mode_from_none);
+ }
+
+ @Test
+ public void updateState_Priority() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+
+ when(mBackend.isPriorityCategoryEnabled(
+ NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
+ .thenReturn(true);
+
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(true);
+ verify(mockPref).setSummary(R.string.zen_mode_from_starred);
+ }
+
+ @Test
+ public void onPreferenceChange_setSelectedContacts_any() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityCallSenders()).thenReturn(
+ NotificationManager.Policy.PRIORITY_SENDERS_ANY);
+ mController.updateState(mockPref);
+ verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
+ ZenModeBackend.ZEN_MODE_FROM_ANYONE)]);
+ }
+
+ @Test
+ public void onPreferenceChange_setSelectedContacts_none() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityCallSenders()).thenReturn(ZenModeBackend.SOURCE_NONE);
+ mController.updateState(mockPref);
+ verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
+ ZenModeBackend.ZEN_MODE_FROM_NONE)]);
+ }
+
+ @Test
+ public void onPreferenceChange_setSelectedContacts_starred() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityCallSenders()).thenReturn(
+ NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
+ mController.updateState(mockPref);
+ verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
+ ZenModeBackend.ZEN_MODE_FROM_STARRED)]);
+ }
+
+ @Test
+ public void onPreferenceChange_setSelectedContacts_contacts() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityCallSenders()).thenReturn(
+ NotificationManager.Policy.PRIORITY_SENDERS_CONTACTS);
+ mController.updateState(mockPref);
+ verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
+ ZenModeBackend.ZEN_MODE_FROM_CONTACTS)]);
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceControllerTest.java
new file mode 100644
index 0000000..75605a4
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceControllerTest.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2017 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.notification;
+
+import static android.provider.Settings.Global.ZEN_MODE;
+import static android.provider.Settings.Global.ZEN_MODE_ALARMS;
+import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
+import static android.provider.Settings.Global.ZEN_MODE_NO_INTERRUPTIONS;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationManager;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.R;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+import androidx.preference.ListPreference;
+import androidx.preference.PreferenceScreen;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class ZenModePriorityMessagesPreferenceControllerTest {
+
+ private ZenModePriorityMessagesPreferenceController mController;
+
+ @Mock
+ private ZenModeBackend mBackend;
+ @Mock
+ private NotificationManager mNotificationManager;
+ @Mock
+ private ListPreference mockPref;
+ @Mock
+ private NotificationManager.Policy mPolicy;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ private ContentResolver mContentResolver;
+ private Context mContext;
+
+ /**
+ * Array Values Key
+ * 0: anyone
+ * 1: contacts
+ * 2: starred
+ * 3: none
+ */
+ private String[] mValues;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
+
+ mContext = RuntimeEnvironment.application;
+ mValues = mContext.getResources().getStringArray(R.array.zen_mode_contacts_values);
+ mContentResolver = RuntimeEnvironment.application.getContentResolver();
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
+
+ when(mBackend.getPriorityMessageSenders())
+ .thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
+ when(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE))
+ .thenCallRealMethod();
+ when(mBackend.getContactsSummary(NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES))
+ .thenCallRealMethod();
+
+ mController = new ZenModePriorityMessagesPreferenceController(mContext, mock(Lifecycle.class));
+ ReflectionHelpers.setField(mController, "mBackend", mBackend);
+
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
+ mockPref);
+ mController.displayPreference(mPreferenceScreen);
+ }
+
+ @Test
+ public void updateState_TotalSilence() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_NO_INTERRUPTIONS);
+
+ when(mBackend.isPriorityCategoryEnabled(
+ NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES))
+ .thenReturn(false);
+ final ListPreference mockPref = mock(ListPreference.class);
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(false);
+ verify(mockPref).setSummary(R.string.zen_mode_from_none);
+ }
+
+ @Test
+ public void updateState_AlarmsOnly() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_ALARMS);
+
+ final ListPreference mockPref = mock(ListPreference.class);
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(false);
+ verify(mockPref).setSummary(R.string.zen_mode_from_none);
+ }
+
+ @Test
+ public void updateState_Priority() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+
+ when(mBackend.isPriorityCategoryEnabled(
+ NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES))
+ .thenReturn(true);
+
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(true);
+ verify(mockPref).setSummary(R.string.zen_mode_from_starred);
+ }
+
+ @Test
+ public void onPreferenceChange_setSelectedContacts_any() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityMessageSenders()).thenReturn(
+ NotificationManager.Policy.PRIORITY_SENDERS_ANY);
+ mController.updateState(mockPref);
+ verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
+ ZenModeBackend.ZEN_MODE_FROM_ANYONE)]);
+ }
+
+ @Test
+ public void onPreferenceChange_setSelectedContacts_none() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityMessageSenders()).thenReturn(ZenModeBackend.SOURCE_NONE);
+ mController.updateState(mockPref);
+ verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
+ ZenModeBackend.ZEN_MODE_FROM_NONE)]);
+ }
+
+ @Test
+ public void onPreferenceChange_setSelectedContacts_starred() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityMessageSenders()).thenReturn(
+ NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
+ mController.updateState(mockPref);
+ verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
+ ZenModeBackend.ZEN_MODE_FROM_STARRED)]);
+ }
+
+ @Test
+ public void onPreferenceChange_setSelectedContacts_contacts() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityMessageSenders()).thenReturn(
+ NotificationManager.Policy.PRIORITY_SENDERS_CONTACTS);
+ mController.updateState(mockPref);
+ verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
+ ZenModeBackend.ZEN_MODE_FROM_CONTACTS)]);
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
index 96e5658..4fc7d57 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
@@ -69,63 +69,6 @@
}
@Test
- public void testGetMsgEventReminderSettingSummary_none() {
- Policy policy = new Policy(0, 0, 0, 0);
- assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("None");
- }
-
- @Test
- public void testGetMsgEventReminderSettingSummary_single() {
- Policy policy = new Policy(
- Policy.PRIORITY_CATEGORY_ALARMS | Policy.PRIORITY_CATEGORY_EVENTS, 0 , 0 , 0);
- assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Events");
- }
-
- @Test
- public void testGetMsgEventReminderSettingSummary_someMsgs() {
- Policy policy = new Policy(Policy.PRIORITY_CATEGORY_MESSAGES, 0,
- Policy.PRIORITY_SENDERS_CONTACTS , 0);
- assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Some messages");
-
- policy = new Policy(Policy.PRIORITY_CATEGORY_MESSAGES, 0,
- Policy.PRIORITY_SENDERS_STARRED , 0);
- assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Some messages");
- }
-
- @Test
- public void testGetMsgEventReminderSettingSummary_msgs() {
- Policy policy = new Policy(Policy.PRIORITY_CATEGORY_MESSAGES, 0, 0, 0);
- assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Messages");
- }
-
- @Test
- public void testGetMsgEventReminderSettingSummary_someMsgsAndOther() {
- Policy policy = new Policy(
- Policy.PRIORITY_CATEGORY_MESSAGES | Policy.PRIORITY_CATEGORY_REMINDERS,
- 0, Policy.PRIORITY_SENDERS_CONTACTS , 0);
- assertThat(mBuilder.getMsgEventReminderSettingSummary(policy))
- .isEqualTo("Some messages and reminders");
- }
-
- @Test
- public void testGetMsgEventReminderSettingSummary_someMsgsAndAllOthers() {
- Policy policy = new Policy(Policy.PRIORITY_CATEGORY_EVENTS
- | Policy.PRIORITY_CATEGORY_MESSAGES | Policy.PRIORITY_CATEGORY_REMINDERS,
- 0, Policy.PRIORITY_SENDERS_CONTACTS , 0);
- assertThat(mBuilder.getMsgEventReminderSettingSummary(policy))
- .isEqualTo("Some messages, events, and reminders");
- }
-
- @Test
- public void testGetMsgEventReminderSettingSummary_noMsgsAndOther() {
- Policy policy = new Policy(
- Policy.PRIORITY_CATEGORY_EVENTS | Policy.PRIORITY_CATEGORY_REMINDERS,
- 0,0, 0);
- assertThat(mBuilder.getMsgEventReminderSettingSummary(policy))
- .isEqualTo("Events and reminders");
- }
-
- @Test
public void testGetCallsSettingSummary_none() {
Policy policy = new Policy(0, 0, 0, 0);
assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("None");
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockSettingsHelperTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockSettingsHelperTest.java
index 5d51178..e3f3833 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockSettingsHelperTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockSettingsHelperTest.java
@@ -62,8 +62,6 @@
assertEquals(
true,
(startedIntent.getFlags() & Intent.FLAG_ACTIVITY_FORWARD_RESULT) != 0);
- assertEquals(true, startedIntent.getBooleanExtra(
- ConfirmDeviceCredentialBaseFragment.ALLOW_FP_AUTHENTICATION, false));
assertFalse(startedIntent.getBooleanExtra(
ConfirmDeviceCredentialBaseFragment.DARK_THEME, false));
assertFalse(startedIntent.getBooleanExtra(
@@ -100,8 +98,6 @@
assertEquals(
false,
(startedIntent.getFlags() & Intent.FLAG_ACTIVITY_FORWARD_RESULT) != 0);
- assertEquals(false, startedIntent.getBooleanExtra(
- ConfirmDeviceCredentialBaseFragment.ALLOW_FP_AUTHENTICATION, false));
assertFalse(startedIntent.getBooleanExtra(
ConfirmDeviceCredentialBaseFragment.DARK_THEME, false));
assertFalse(startedIntent.getBooleanExtra(
diff --git a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
new file mode 100644
index 0000000..f987f40
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.content.DialogInterface;
+import android.widget.Button;
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.FragmentActivity;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.annotation.Config;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {SettingsShadowResourcesImpl.class, ShadowAlertDialogCompat.class})
+public class NetworkRequestDialogFragmentTest {
+
+ private FragmentActivity mActivity;
+ private NetworkRequestDialogFragment networkRequestDialogFragment;
+
+ @Before
+ public void setUp() {
+ mActivity = Robolectric.setupActivity(FragmentActivity.class);
+ networkRequestDialogFragment = spy(NetworkRequestDialogFragment.newInstance(-1, null));
+ }
+
+ @Test
+ public void display_shouldShowTheDialog() {
+ networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), null);
+ AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+ assertThat(alertDialog).isNotNull();
+ assertThat(alertDialog.isShowing()).isTrue();
+ }
+
+ @Test
+ public void clickPositiveButton_shouldCloseTheDialog() {
+ networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), null);
+ AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+ assertThat(alertDialog.isShowing()).isTrue();
+
+ Button positiveButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
+ assertThat(positiveButton).isNotNull();
+
+ positiveButton.performClick();
+ assertThat(alertDialog.isShowing()).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSliceTest.java b/tests/robotests/src/com/android/settings/wifi/WifiSliceTest.java
index bd1ad46..5ac25ed 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSliceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSliceTest.java
@@ -88,9 +88,8 @@
int rows = SliceQuery.findAll(wifiSlice, FORMAT_SLICE, HINT_LIST_ITEM,
null /* nonHints */).size();
- // All AP rows + title row + see more row
- // (see more row will drop the last AP row, thus -1)
- assertThat(rows).isEqualTo(DEFAULT_EXPANDED_ROW_COUNT - 1 + 2);
+ // All AP rows + title row
+ assertThat(rows).isEqualTo(DEFAULT_EXPANDED_ROW_COUNT + 1);
}
@Test