Merge "Transition BatteryInfo and BatteryUtils to BatteryUsageStats API" into sc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6ac1ac9..30f181a 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2820,8 +2820,13 @@
</activity>
<!-- Show channel-level notification settings (channel passed in as extras) -->
- <activity android:name="Settings$ChannelNotificationSettingsActivity"
+ <activity android:name=".notification.app.ChannelPanelActivity"
android:label="@string/notification_channel_title"
+ android:theme="@style/Theme.Panel"
+ android:launchMode="singleInstance"
+ android:excludeFromRecents="true"
+ android:noHistory="true"
+ android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true">
<intent-filter android:priority="1">
<action android:name="android.settings.CHANNEL_NOTIFICATION_SETTINGS" />
@@ -2902,6 +2907,12 @@
android:grantUriPermissions="true"
android:exported="false"/>
+ <provider
+ android:name=".emergency.EmergencyActionContentProvider"
+ android:authorities="com.android.settings.emergency"
+ android:permission="android.permission.CALL_PRIVILEGED"
+ android:exported="true"/>
+
<activity
android:name=".wifi.RequestToggleWiFiActivity"
android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert"
@@ -3751,6 +3762,25 @@
android:launchMode="singleTask">
</activity>
+ <activity android:name="Settings$FactoryResetActivity"
+ android:permission="android.permission.BACKUP"
+ android:label="@string/main_clear_title"
+ android:exported="true"
+ android:theme="@style/SudThemeGlif.Light">
+ <intent-filter>
+ <action android:name="com.android.settings.action.FACTORY_RESET"/>
+ <category android:name="android.intent.category.DEFAULT"/>
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.MainClear"/>
+ </activity>
+
+ <activity android:name="Settings$FactoryResetConfirmActivity"
+ android:label="@string/main_clear_confirm_title"
+ android:exported="false"
+ android:theme="@style/SudThemeGlif.Light">
+ </activity>
+
<!-- This is the longest AndroidManifest.xml ever. -->
</application>
</manifest>
diff --git a/res/drawable/ic_battery_low.xml b/res/drawable/ic_battery_low.xml
new file mode 100644
index 0000000..82f9546
--- /dev/null
+++ b/res/drawable/ic_battery_low.xml
@@ -0,0 +1,28 @@
+<!--
+ Copyright (C) 2021 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="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="?android:attr/colorAccent"
+ android:pathData="M12,19m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0"/>
+ <path
+ android:fillColor="?android:attr/colorAccent"
+ android:pathData="M10,3h4v12h-4z"/>
+</vector>
diff --git a/res/drawable/one_handed_guideline.xml b/res/drawable/one_handed_guideline.xml
new file mode 100644
index 0000000..2c1a158
--- /dev/null
+++ b/res/drawable/one_handed_guideline.xml
@@ -0,0 +1,45 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:aapt="http://schemas.android.com/aapt"
+ android:width="412dp"
+ android:height="264dp"
+ android:viewportWidth="412"
+ android:viewportHeight="264">
+ <group>
+ <clip-path
+ android:pathData="M0,0h412v264h-412z"/>
+ <path
+ android:pathData="M126,-246C109.431,-246 96,-232.569 96,-216V195C96,211.569 109.431,225 126,225H284.5C301.069,225 314.5,211.569 314.5,195V-216C314.5,-232.569 301.069,-246 284.5,-246H126ZM122,-235C110.954,-235 102,-226.046 102,-215V189.5C102,200.546 110.954,209.5 122,209.5H288C299.046,209.5 308,200.546 308,189.5V-215C308,-226.046 299.046,-235 288,-235H122Z"
+ android:fillColor="#000000"
+ android:fillType="evenOdd"/>
+ <path
+ android:pathData="M122.12,-233L288.12,-233A20,20 0,0 1,308.12 -213L308.12,191.5A20,20 0,0 1,288.12 211.5L122.12,211.5A20,20 0,0 1,102.12 191.5L102.12,-213A20,20 0,0 1,122.12 -233z"
+ android:fillColor="#EAF1FF"/>
+ <path
+ android:pathData="M102.16,193.12H308.08C308.08,203.326 299.806,211.6 289.6,211.6H120.64C110.434,211.6 102.16,203.326 102.16,193.12Z"
+ android:fillColor="#B5CFFC"/>
+ <path
+ android:pathData="M187.5,202.72L222.5,202.72A0.5,0.5 0,0 1,223 203.22L223,203.22A0.5,0.5 0,0 1,222.5 203.72L187.5,203.72A0.5,0.5 0,0 1,187 203.22L187,203.22A0.5,0.5 0,0 1,187.5 202.72z"
+ android:fillColor="#666666"/>
+ <path
+ android:pathData="M197,115h36v94.684h-36z"
+ android:strokeAlpha="0.8"
+ android:fillAlpha="0.8">
+ <aapt:attr name="android:fillColor">
+ <gradient
+ android:startY="189.19"
+ android:startX="212.951"
+ android:endY="168.637"
+ android:endX="212.447"
+ android:type="linear">
+ <item android:offset="0" android:color="#FF4285F4"/>
+ <item android:offset="1" android:color="#004385F5"/>
+ </gradient>
+ </aapt:attr>
+ </path>
+ <path
+ android:pathData="M197,206.899a18,18.101 0,1 0,36 0a18,18.101 0,1 0,-36 0z"
+ android:strokeAlpha="0.8"
+ android:fillColor="#3B7BE4"
+ android:fillAlpha="0.8"/>
+ </group>
+</vector>
diff --git a/res/layout/view_airplane_mode_networks_button.xml b/res/layout/airplane_mode_message_preference.xml
similarity index 62%
rename from res/layout/view_airplane_mode_networks_button.xml
rename to res/layout/airplane_mode_message_preference.xml
index 0599274..032161b 100644
--- a/res/layout/view_airplane_mode_networks_button.xml
+++ b/res/layout/airplane_mode_message_preference.xml
@@ -22,7 +22,6 @@
android:orientation="vertical">
<TextView
- android:id="@+id/airplane_mode_text"
android:text="@string/condition_airplane_title"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
@@ -30,17 +29,6 @@
android:layout_gravity="center_horizontal"
android:layout_marginStart="@dimen/content_margin_left"
android:layout_marginEnd="@dimen/content_margin_left"
- android:layout_marginTop="@dimen/view_airplane_mode_networks_button_margin_vertical"
- android:layout_marginBottom="@dimen/view_airplane_mode_networks_button_margin_vertical"/>
-
- <Button
- android:id="@+id/view_airplane_mode_networks_button"
- android:text="@string/view_airplane_safe_networks"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal"
- android:layout_marginStart="@dimen/content_margin_left"
- android:layout_marginEnd="@dimen/content_margin_left"
- android:layout_marginBottom="@dimen/view_airplane_mode_networks_button_margin_vertical"
- style="@style/ActionPrimaryButton"/>
+ android:layout_marginTop="@dimen/airplane_mode_message_margin_vertical"
+ android:layout_marginBottom="@dimen/airplane_mode_message_margin_vertical"/>
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/manage_applications_apps_v2.xml b/res/layout/manage_applications_apps_v2.xml
index ecc764a..72c8ee8 100644
--- a/res/layout/manage_applications_apps_v2.xml
+++ b/res/layout/manage_applications_apps_v2.xml
@@ -48,7 +48,7 @@
android:id="@android:id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:gravity="center"
+ android:gravity="bottom|center_horizontal"
android:layout_gravity="center"
android:text="@string/no_applications"
android:textAppearance="?android:attr/textAppearanceLarge"
diff --git a/res/layout/notification_channel_panel.xml b/res/layout/notification_channel_panel.xml
new file mode 100644
index 0000000..49cd95c
--- /dev/null
+++ b/res/layout/notification_channel_panel.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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:id="@+id/main_content"
+ android:layout_height="@dimen/output_switcher_slice_max_height"
+ android:background="@drawable/settings_panel_background"
+ android:orientation="vertical"
+ android:layout_width="match_parent">
+
+ <FrameLayout
+ android:id="@android:id/list_container"
+ android:layout_height="0px"
+ android:layout_weight="1"
+ android:layout_width="match_parent"/>
+
+ <View
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/footer_divider"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/horizontal_divider_height"
+ android:background="?android:attr/dividerHorizontal"/>
+
+ <LinearLayout
+ android:id="@+id/footer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:paddingTop="8dp"
+ android:paddingBottom="8dp">
+
+ <Button
+ android:id="@+id/see_more"
+ style="@android:style/Widget.DeviceDefault.Button.Borderless.Colored"
+ android:layout_width="wrap_content"
+ android:layout_height="48dp"
+ android:layout_marginStart="12dp"
+ android:text="@string/see_more"/>
+
+ <Space
+ android:layout_weight="1"
+ android:layout_width="0dp"
+ android:layout_height="match_parent" />
+
+ <Button
+ android:id="@+id/done"
+ style="@android:style/Widget.DeviceDefault.Button.Borderless.Colored"
+ android:layout_width="wrap_content"
+ android:layout_height="48dp"
+ android:layout_marginEnd="12dp"
+ android:text="@string/done"/>
+ </LinearLayout>
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/one_handed_header.xml b/res/layout/one_handed_header.xml
new file mode 100644
index 0000000..2104e40
--- /dev/null
+++ b/res/layout/one_handed_header.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <ImageView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:scaleType="centerCrop"
+ android:cropToPadding="true"
+ android:src="@drawable/one_handed_guideline"
+ android:contentDescription="@null" />
+
+</FrameLayout>
diff --git a/res/layout/settings_collapsing_base_layout.xml b/res/layout/settings_collapsing_base_layout.xml
index ba9e625..7ebf433 100644
--- a/res/layout/settings_collapsing_base_layout.xml
+++ b/res/layout/settings_collapsing_base_layout.xml
@@ -39,7 +39,7 @@
app:statusBarScrim="?android:attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:expandedTitleMarginStart="18dp"
- app:expandedTitleMarginEnd="18dp"
+ app:expandedTitleMarginEnd="16dp"
app:toolbarId="@id/action_bar">
<Toolbar
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index f78120c..bde5288 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -170,6 +170,7 @@
<declare-styleable name="LabeledSeekBarPreference">
<attr name="textStart" format="reference" />
<attr name="textEnd" format="reference" />
+ <attr name="tickMark" format="reference" />
</declare-styleable>
<declare-styleable name="TintDrawable">
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 16db908..4fef726 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -213,7 +213,7 @@
<dimen name="wifi_detail_page_header_image_size">32dp</dimen>
<!-- Internet Preferences -->
- <dimen name="view_airplane_mode_networks_button_margin_vertical">24dp</dimen>
+ <dimen name="airplane_mode_message_margin_vertical">24dp</dimen>
<dimen name="reset_internet_ring_progress_right_margin">4dp</dimen>
<!-- Color picker -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9bae3a5..7ad7fe1 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2836,7 +2836,9 @@
<!-- adaptive_sleep settings screen, title about the required permission is missing [CHAR LIMIT=NONE]-->
<string name="adaptive_sleep_title_no_permission">Camera access needed</string>
<!-- adaptive_sleep settings screen, subtitle when permission is missing [CHAR LIMIT=NONE]-->
- <string name="adaptive_sleep_summary_no_permission">Tap to manage permissions for Device Personalization Services</string>
+ <string name="adaptive_sleep_summary_no_permission">Camera access is required for screen attention. Tap to manage permissions for Device Personalization Services</string>
+ <!-- adaptive_sleep settings screen, text for the camera permission button [CHAR LIMIT=NONE]-->
+ <string name="adaptive_sleep_manage_permission_button">Manage permissions</string>
<!-- Description about the feature adaptive sleep [CHAR LIMIT=NONE]-->
<string name="adaptive_sleep_description">Prevents your screen from turning off if you\u2019re looking at it</string>
<!-- Description feature's privacy sensitive details to make sure users understand what feature users, what it saves/sends etc [CHAR LIMIT=NONE]-->
@@ -4059,18 +4061,8 @@
<!-- [CHAR LIMIT=50] Location settings screen, sub category for location services for managed profile -->
<string name="managed_profile_location_services">Location services for work</string>
- <!-- [CHAR LIMIT=60] Location settings screen, screen title -->
- <string name="location_time_zone_detection_screen_title">Use location to set time zone</string>
- <!-- [CHAR LIMIT=50] Location settings screen, title for the setting that control whether the
- device can use its location for time zone detection. -->
- <string name="location_time_zone_detection_enabled_title">Location time zone detection</string>
- <!-- [CHAR LIMIT=NONE] Preference description text for location time zone detection -->
- <string name="location_time_zone_detection_enabled_description">Allows the device\u2019s location to be used to detect the current time zone. Other location settings such as Wi\u2011Fi scanning can affect the accuracy of time zone detection.</string>
-
- <!-- [CHAR LIMIT=NONE] Location settings screen, summary when location time zone detection is on -->
- <string name="location_time_zone_detection_on">On</string>
- <!-- [CHAR LIMIT=NONE] Location settings screen, summary when location time zone detection is off -->
- <string name="location_time_zone_detection_off">Off</string>
+ <!-- [CHAR LIMIT=60] Date&Time settings screen, toggle button title -->
+ <string name="location_time_zone_detection_toggle_title">Use location to set time zone</string>
<!-- [CHAR LIMIT=NONE] Location settings screen, summary when location time zone detection is not
applicable due to other settings like the "automatic time zone detection enabled" setting
being set to "off". -->
@@ -7841,10 +7833,10 @@
<string name="keywords_display_auto_brightness">dim screen, touchscreen, battery, smart brightness, dynamic brightness, Auto brightness</string>
<!-- Search keywords for adaptive sleep setting [CHAR LIMIT=NONE]-->
- <string name="keywords_display_adaptive_sleep">dim screen, sleep, battery, timeout, attention, display, screen, inactivity</string>
+ <string name="keywords_display_adaptive_sleep">smart, dim screen, sleep, battery, timeout, attention, display, screen, inactivity</string>
<!-- List of synonyms for the auto rotate (rotate the virtual display when the device rotates) setting, used to match in settings search [CHAR LIMIT=NONE] -->
- <string name="keywords_auto_rotate">rotate, flip, rotation, portrait, landscape, orientation, vertical, horizontal</string>
+ <string name="keywords_auto_rotate">camera, smart, auto rotate, auto-rotate, rotate, flip, rotation, portrait, landscape, orientation, vertical, horizontal</string>
<!-- List of synonyms for the System Update (update the operating system) setting, used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_system_update_settings">upgrade, android</string>
@@ -10496,8 +10488,6 @@
<string name="disabled_by_policy_title_suspend_packages">Can’t open this app</string>
<!-- Dialog title. This dialog lets a user know that a specific setting is blocked by their credit provider. Since the user purchased the device from the credit provider, the credit provider controls what they can access. [CHAR LIMIT=50] -->
<string name="disabled_by_policy_title_financed_device">Blocked by your credit provider</string>
- <!-- Shown when the user tries to change a settings locked by an admin [CHAR LIMIT=200] -->
- <string name="default_admin_support_msg">If you have questions, contact your IT admin</string>
<!-- Shown in dialog to allow user to see more information about the device admin [CHAR LIMIT=30] -->
<string name="admin_support_more_info">More details</string>
<!-- Shown in admin details page to warn user about policies the admin can set in a work profile. [CHAR LIMIT=NONE] -->
@@ -12725,10 +12715,8 @@
<string name="view_airplane_safe_networks">View airplane mode networks</string>
<!-- Text of message for viewing the networks that are available in airplane mode. [CHAR LIMIT=60] -->
<string name="viewing_airplane_mode_networks">Viewing airplane mode networks</string>
- <!-- Slice title text for turning on networks (e.g. Wi-Fi). [CHAR LIMIT=40] -->
- <string name="turn_on_networks">Turn on networks</string>
- <!-- Slice title text for turning off networks (e.g. Wi-Fi). [CHAR LIMIT=40] -->
- <string name="turn_off_networks">Turn off networks</string>
+ <!-- Slice title text for turning on the Wi-Fi networks. [CHAR LIMIT=40] -->
+ <string name="turn_on_wifi">Turn on Wi\u2011Fi</string>
<!-- Title for interrupting the voice call alert. [CHAR_LIMIT=NONE] -->
<string name="reset_your_internet_title">Reset your internet?</string>
<!-- Description for interrupting the voice call alert. [CHAR_LIMIT=NONE] -->
@@ -12739,12 +12727,10 @@
<string name="resetting_internet_text">Resetting your internet\u2026</string>
<!-- Menu option for data connectivity recovery for all requested technologies. [CHAR_LIMIT=NONE] -->
<string name="fix_connectivity">Fix connectivity</string>
- <!-- Summary for airplane mode networks available. [CHAR LIMIT=60] -->
- <string name="airplane_mode_network_available">Airplane mode networks available</string>
<!-- Summary for warning to disconnect ethernet first then switch to other networks. [CHAR LIMIT=60] -->
<string name="to_switch_networks_disconnect_ethernet">To switch networks, disconnect ethernet</string>
- <!-- Title for airplane mode network panel. [CHAR LIMIT=60] -->
- <string name="airplane_mode_network_panel_title">Airplane mode networks</string>
+ <!-- Panel subtitle for Wi-Fi turned on. [CHAR LIMIT=60] -->
+ <string name="wifi_is_turned_on_subtitle">Wi\u2011Fi is turned on</string>
<!-- Summary text separator for preferences including a short description
(eg. "Connected / 5G"). [CHAR LIMIT=50] -->
@@ -12794,13 +12780,15 @@
<string name="category_name_others">Others</string>
<!-- General category name [CHAR LIMIT=none] -->
<string name="category_name_general">General</string>
+ <!-- Title for Dark theme main switch preferences. [CHAR LIMIT=50] -->
+ <string name="dark_theme_main_switch_title">Use Dark theme</string>
+ <!-- Title for bluetooth main switch. [CHAR LIMIT=50] -->
+ <string name="bluetooth_main_switch_title">Use Bluetooth</string>
<!-- Do not translate. Title for prevent ringing main switch. [CHAR LIMIT=50] -->
<string name="prevent_ringing_main_switch_title" translatable="false">Use prevent ringing</string>
<!-- Do not translate. Title for use wifi hotspot main switch [CHAR LIMIT=50]-->
<string name="use_wifi_hotsopt_main_switch_title" translatable="false">Use Wi\u2011Fi hotspot</string>
- <!-- Do not translate. Title for bluetooth main switch. [CHAR LIMIT=50] -->
- <string name="bluetooth_main_switch_title" translatable="false">Use bluetooth</string>
<!-- Do not translate. Title for app pinning main switch. [CHAR LIMIT=50] -->
<string name="app_pinning_main_switch_title" translatable="false">Use app pinning</string>
<!-- Do not translate. Title for developer options main switch. [CHAR LIMIT=50] -->
@@ -12817,8 +12805,6 @@
<string name="battery_saver_main_switch_title" translatable="false">Use battery saver</string>
<!-- Do not translate. Title for Do Not Disturb main switch preferences. [CHAR LIMIT=50] -->
<string name="do_not_disturb_main_switch_title" translatable="false">Use Do Not Disturb</string>
- <!-- Do not translate. Title for Dark theme main switch preferences. [CHAR LIMIT=50] -->
- <string name="dark_theme_main_switch_title" translatable="false">Use Dark Theme</string>
<!-- Do not translate. Title for Night Light main switch preferences. [CHAR LIMIT=50] -->
<string name="night_light_main_switch_title" translatable="false">Use Night Light</string>
<!-- Do not translate. Title for NFC main switch preferences. [CHAR LIMIT=50] -->
diff --git a/res/xml/channel_notification_settings.xml b/res/xml/channel_notification_settings.xml
index 707cae9..95f7944 100644
--- a/res/xml/channel_notification_settings.xml
+++ b/res/xml/channel_notification_settings.xml
@@ -65,56 +65,56 @@
android:summary="@string/promote_conversation_summary"
settings:allowDividerAbove="true"/>
- <!-- Default ringtone -->
- <com.android.settings.notification.app.NotificationSoundPreference
- android:key="ringtone"
- android:title="@string/notification_channel_sound_title"
- android:dialogTitle="@string/notification_channel_sound_title"
- android:order="11"
- android:showSilent="true"
- android:showDefault="true"/>
+ <!-- Default ringtone -->
+ <com.android.settings.notification.app.NotificationSoundPreference
+ android:key="ringtone"
+ android:title="@string/notification_channel_sound_title"
+ android:dialogTitle="@string/notification_channel_sound_title"
+ android:order="11"
+ android:showSilent="true"
+ android:showDefault="true"/>
- <!-- Vibration -->
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="vibrate"
- android:order="12"
- android:title="@string/notification_vibrate_title"
- settings:useAdditionalSummary="true" />
+ <!-- Vibration -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="vibrate"
+ android:order="12"
+ android:title="@string/notification_vibrate_title"
+ settings:useAdditionalSummary="true" />
- <!-- Visibility Override -->
- <com.android.settings.RestrictedListPreference
- android:key="visibility_override"
- android:order="13"
- android:title="@string/app_notification_visibility_override_title"/>
+ <!-- Visibility Override -->
+ <com.android.settings.RestrictedListPreference
+ android:key="visibility_override"
+ android:order="13"
+ android:title="@string/app_notification_visibility_override_title"/>
- <!-- Lights -->
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="lights"
- android:order="14"
- android:title="@string/notification_show_lights_title"
- settings:useAdditionalSummary="true"/>
+ <!-- Lights -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="lights"
+ android:order="14"
+ android:title="@string/notification_show_lights_title"
+ settings:useAdditionalSummary="true"/>
- <!-- Show badge -->
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="badge"
- android:order="15"
- android:title="@string/notification_channel_badge_title"
- settings:useAdditionalSummary="true"
- settings:restrictedSwitchSummary="@string/enabled_by_admin"/>
+ <!-- Show badge -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="badge"
+ android:order="15"
+ android:title="@string/notification_channel_badge_title"
+ settings:useAdditionalSummary="true"
+ settings:restrictedSwitchSummary="@string/enabled_by_admin"/>
- <!-- Bypass DND -->
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="bypass_dnd"
- android:order="17"
- android:title="@string/app_notification_override_dnd_title"
- android:summary="@string/app_notification_override_dnd_summary"
- settings:useAdditionalSummary="true"/>
+ <!-- Bypass DND -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="bypass_dnd"
+ android:order="17"
+ android:title="@string/app_notification_override_dnd_title"
+ android:summary="@string/app_notification_override_dnd_summary"
+ settings:useAdditionalSummary="true"/>
- <Preference
- android:key="app_link"
- android:order="18"
- android:title="@string/app_settings_link"
- settings:allowDividerAbove="true"/>
+ <Preference
+ android:key="app_link"
+ android:order="18"
+ android:title="@string/app_settings_link"
+ settings:allowDividerAbove="true"/>
<com.android.settings.notification.app.NotificationFooterPreference
android:key="desc"
diff --git a/res/xml/conversation_notification_settings.xml b/res/xml/conversation_notification_settings.xml
index 65fdee5..ea555c2 100644
--- a/res/xml/conversation_notification_settings.xml
+++ b/res/xml/conversation_notification_settings.xml
@@ -62,10 +62,6 @@
android:key="block_desc"
settings:allowDividerAbove="false"/>
- <PreferenceCategory
- android:key="channel_advanced"
- android:order="50"
- settings:initialExpandedChildrenCount="0">
<!-- peeking -->
<com.android.settingslib.RestrictedSwitchPreference
@@ -107,6 +103,5 @@
android:icon="@drawable/ic_volume_ringer_vibrate"
android:title="@string/notification_vibrate_title"
settings:useAdditionalSummary="true" />
- </PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/date_time_prefs.xml b/res/xml/date_time_prefs.xml
index 43a797a..6fc0b25 100644
--- a/res/xml/date_time_prefs.xml
+++ b/res/xml/date_time_prefs.xml
@@ -53,12 +53,12 @@
settings:keywords="@string/keywords_time_zone"/>
<!-- This preference gets removed if location-based time zone detection is not supported -->
- <com.android.settingslib.RestrictedPreference
+ <com.android.settingslib.RestrictedSwitchPreference
android:key="location_time_zone_detection"
- android:title="@string/location_time_zone_detection_screen_title"
+ android:title="@string/location_time_zone_detection_toggle_title"
settings:controller="com.android.settings.datetime.LocationTimeZoneDetectionPreferenceController"
- android:fragment="com.android.settings.datetime.locationtimezone.TimeZoneDetectionSettings"
- settings:userRestriction="no_config_date_time"/>
+ settings:userRestriction="no_config_date_time"
+ />
<PreferenceCategory
android:key="time_format_preference_category"
diff --git a/res/xml/location_time_zone_detection.xml b/res/xml/location_time_zone_detection.xml
deleted file mode 100644
index 9f5e775..0000000
--- a/res/xml/location_time_zone_detection.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/location_time_zone_detection_screen_title">
-
- <SwitchPreference
- android:title="@string/location_time_zone_detection_enabled_title"
- android:summary="@string/location_time_zone_detection_enabled_description"
- settings:controller="com.android.settings.datetime.locationtimezone.TimeZoneDetectionTogglePreferenceController"
- android:key="location_time_zone_detection_enabled" />
-
-</PreferenceScreen>
diff --git a/res/xml/network_provider_settings.xml b/res/xml/network_provider_settings.xml
index a824b34..30fe6fe 100644
--- a/res/xml/network_provider_settings.xml
+++ b/res/xml/network_provider_settings.xml
@@ -28,12 +28,12 @@
android:layout="@layout/resetting_internet"
settings:allowDividerBelow="true"/>
- <!-- View airplane mode networks button -->
+ <!-- Airplane mode message -->
<com.android.settingslib.widget.LayoutPreference
- android:key="view_airplane_mode_netwokrs_button"
+ android:key="airplane_mode_message"
android:title="@string/condition_airplane_title"
android:selectable="false"
- android:layout="@layout/view_airplane_mode_networks_button"
+ android:layout="@layout/airplane_mode_message_preference"
settings:allowDividerBelow="true"/>
<Preference
diff --git a/res/xml/one_handed_settings.xml b/res/xml/one_handed_settings.xml
index 3508d8a..9382657 100644
--- a/res/xml/one_handed_settings.xml
+++ b/res/xml/one_handed_settings.xml
@@ -21,6 +21,14 @@
android:persistent="false"
android:title="@string/one_handed_title">
+ <com.android.settingslib.widget.LayoutPreference
+ android:key="one_handed_header"
+ android:layout="@layout/one_handed_header"
+ android:persistent="false"
+ android:selectable="false"
+ settings:allowDividerBelow="false"
+ settings:searchable="false"/>
+
<SwitchPreference
android:key="gesture_one_handed_mode_enabled"
android:title="@string/one_handed_mode_enabled"
diff --git a/src/com/android/settings/ActivityPicker.java b/src/com/android/settings/ActivityPicker.java
index ae61944..f75ce37 100644
--- a/src/com/android/settings/ActivityPicker.java
+++ b/src/com/android/settings/ActivityPicker.java
@@ -16,6 +16,8 @@
package com.android.settings;
+import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
@@ -71,6 +73,8 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
+ getWindow().addPrivateFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
final Intent intent = getIntent();
diff --git a/src/com/android/settings/applications/AppDashboardFragment.java b/src/com/android/settings/applications/AppDashboardFragment.java
index fc4bcd0..3b1a977 100644
--- a/src/com/android/settings/applications/AppDashboardFragment.java
+++ b/src/com/android/settings/applications/AppDashboardFragment.java
@@ -48,7 +48,7 @@
@Override
public int getMetricsCategory() {
- return SettingsEnums.SETTINGS_APP_NOTIF_CATEGORY;
+ return SettingsEnums.MANAGE_APPLICATIONS;
}
@Override
diff --git a/src/com/android/settings/applications/assist/DefaultVoiceInputPicker.java b/src/com/android/settings/applications/assist/DefaultVoiceInputPicker.java
index e5953db..d4ea4a9 100644
--- a/src/com/android/settings/applications/assist/DefaultVoiceInputPicker.java
+++ b/src/com/android/settings/applications/assist/DefaultVoiceInputPicker.java
@@ -24,7 +24,6 @@
import android.provider.Settings;
import android.text.TextUtils;
-import com.android.internal.app.AssistUtils;
import com.android.settings.R;
import com.android.settings.applications.defaultapps.DefaultAppPickerFragment;
import com.android.settingslib.applications.DefaultAppInfo;
@@ -35,8 +34,6 @@
public class DefaultVoiceInputPicker extends DefaultAppPickerFragment {
private VoiceInputHelper mHelper;
- private AssistUtils mAssistUtils;
- private String mAssistRestrict;
@Override
public int getMetricsCategory() {
@@ -46,13 +43,8 @@
@Override
public void onAttach(Context context) {
super.onAttach(context);
- mAssistUtils = new AssistUtils(context);
mHelper = new VoiceInputHelper(context);
mHelper.buildUi();
- final ComponentName assist = getCurrentAssist();
- if (isCurrentAssistVoiceService(assist, getCurrentService(mHelper))) {
- mAssistRestrict = assist.flattenToShortString();
- }
}
@Override
@@ -64,16 +56,9 @@
protected List<VoiceInputDefaultAppInfo> getCandidates() {
final List<VoiceInputDefaultAppInfo> candidates = new ArrayList<>();
final Context context = getContext();
- boolean hasEnabled = true;
- for (VoiceInputHelper.InteractionInfo info : mHelper.mAvailableInteractionInfos) {
- final boolean enabled = TextUtils.equals(info.key, mAssistRestrict);
- hasEnabled |= enabled;
- candidates.add(new VoiceInputDefaultAppInfo(context, mPm, mUserId, info, enabled));
- }
- final boolean assistIsService = !hasEnabled;
for (VoiceInputHelper.RecognizerInfo info : mHelper.mAvailableRecognizerInfos) {
- final boolean enabled = !assistIsService;
+ final boolean enabled = true;
candidates.add(new VoiceInputDefaultAppInfo(context, mPm, mUserId, info, enabled));
}
return candidates;
@@ -90,24 +75,9 @@
@Override
protected boolean setDefaultKey(String value) {
- for (VoiceInputHelper.InteractionInfo info : mHelper.mAvailableInteractionInfos) {
- if (TextUtils.equals(value, info.key)) {
- Settings.Secure.putString(getContext().getContentResolver(),
- Settings.Secure.VOICE_INTERACTION_SERVICE, value);
- Settings.Secure.putString(getContext().getContentResolver(),
- Settings.Secure.VOICE_RECOGNITION_SERVICE,
- new ComponentName(info.service.packageName,
- info.serviceInfo.getRecognitionService())
- .flattenToShortString());
- return true;
- }
- }
-
for (VoiceInputHelper.RecognizerInfo info : mHelper.mAvailableRecognizerInfos) {
if (TextUtils.equals(value, info.key)) {
Settings.Secure.putString(getContext().getContentResolver(),
- Settings.Secure.VOICE_INTERACTION_SERVICE, "");
- Settings.Secure.putString(getContext().getContentResolver(),
Settings.Secure.VOICE_RECOGNITION_SERVICE, value);
return true;
}
@@ -116,23 +86,7 @@
}
public static ComponentName getCurrentService(VoiceInputHelper helper) {
- if (helper.mCurrentVoiceInteraction != null) {
- return helper.mCurrentVoiceInteraction;
- } else if (helper.mCurrentRecognizer != null) {
- return helper.mCurrentRecognizer;
- } else {
- return null;
- }
- }
-
- private ComponentName getCurrentAssist() {
- return mAssistUtils.getAssistComponentForUser(mUserId);
- }
-
- public static boolean isCurrentAssistVoiceService(ComponentName currentAssist,
- ComponentName currentVoiceService) {
- return currentAssist == null && currentVoiceService == null ||
- currentAssist != null && currentAssist.equals(currentVoiceService);
+ return helper.mCurrentRecognizer;
}
public static class VoiceInputDefaultAppInfo extends DefaultAppInfo {
@@ -152,11 +106,7 @@
@Override
public CharSequence loadLabel() {
- if (mInfo instanceof VoiceInputHelper.InteractionInfo) {
- return mInfo.appLabel;
- } else {
- return mInfo.label;
- }
+ return mInfo.label;
}
public Intent getSettingIntent() {
diff --git a/src/com/android/settings/applications/assist/DefaultVoiceInputPreferenceController.java b/src/com/android/settings/applications/assist/DefaultVoiceInputPreferenceController.java
index e53334d..59f5731 100644
--- a/src/com/android/settings/applications/assist/DefaultVoiceInputPreferenceController.java
+++ b/src/com/android/settings/applications/assist/DefaultVoiceInputPreferenceController.java
@@ -26,7 +26,6 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
-import com.android.internal.app.AssistUtils;
import com.android.settings.applications.defaultapps.DefaultAppPreferenceController;
import com.android.settingslib.applications.DefaultAppInfo;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -42,17 +41,13 @@
private static final String KEY_VOICE_INPUT = "voice_input_settings";
private VoiceInputHelper mHelper;
- private AssistUtils mAssistUtils;
private PreferenceScreen mScreen;
private Preference mPreference;
- private SettingObserver mSettingObserver;
private Context mContext;
public DefaultVoiceInputPreferenceController(Context context, Lifecycle lifecycle) {
super(context);
mContext = context;
- mSettingObserver = new SettingObserver();
- mAssistUtils = new AssistUtils(context);
mHelper = new VoiceInputHelper(context);
mHelper.buildUi();
if (lifecycle != null) {
@@ -80,7 +75,6 @@
@Override
public void onResume() {
- mSettingObserver.register(mContext.getContentResolver(), true);
updatePreference();
}
@@ -91,9 +85,7 @@
}
@Override
- public void onPause() {
- mSettingObserver.register(mContext.getContentResolver(), false);
- }
+ public void onPause() {}
@Override
protected DefaultAppInfo getDefaultAppInfo() {
@@ -101,12 +93,6 @@
if (defaultKey == null) {
return null;
}
- for (VoiceInputHelper.InteractionInfo info : mHelper.mAvailableInteractionInfos) {
- if (TextUtils.equals(defaultKey, info.key)) {
- return new DefaultVoiceInputPicker.VoiceInputDefaultAppInfo(mContext,
- mPackageManager, mUserId, info, true /* enabled */);
- }
- }
for (VoiceInputHelper.RecognizerInfo info : mHelper.mAvailableRecognizerInfos) {
if (TextUtils.equals(defaultKey, info.key)) {
@@ -149,16 +135,4 @@
}
return currentService.flattenToShortString();
}
-
- class SettingObserver extends AssistSettingObserver {
- @Override
- protected List<Uri> getSettingUris() {
- return null;
- }
-
- @Override
- public void onSettingChange() {
- updatePreference();
- }
- }
}
diff --git a/src/com/android/settings/applications/assist/VoiceInputHelper.java b/src/com/android/settings/applications/assist/VoiceInputHelper.java
index fb60090..285f4f7 100644
--- a/src/com/android/settings/applications/assist/VoiceInputHelper.java
+++ b/src/com/android/settings/applications/assist/VoiceInputHelper.java
@@ -26,10 +26,7 @@
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.provider.Settings;
-import android.service.voice.VoiceInteractionService;
-import android.service.voice.VoiceInteractionServiceInfo;
import android.speech.RecognitionService;
-import android.util.ArraySet;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;
@@ -46,9 +43,9 @@
static final String TAG = "VoiceInputHelper";
final Context mContext;
- final List<ResolveInfo> mAvailableVoiceInteractions;
final List<ResolveInfo> mAvailableRecognition;
+ // TODO: Remove this superclass as we only have 1 class now (RecognizerInfo).
static public class BaseInfo implements Comparable {
public final ServiceInfo service;
public final ComponentName componentName;
@@ -75,15 +72,6 @@
}
}
- static public class InteractionInfo extends BaseInfo {
- public final VoiceInteractionServiceInfo serviceInfo;
-
- public InteractionInfo(PackageManager pm, VoiceInteractionServiceInfo _service) {
- super(pm, _service.getServiceInfo(), _service.getSettingsActivity());
- serviceInfo = _service;
- }
- }
-
static public class RecognizerInfo extends BaseInfo {
public final boolean mSelectableAsDefault;
@@ -96,56 +84,21 @@
}
}
- final ArrayList<InteractionInfo> mAvailableInteractionInfos = new ArrayList<>();
final ArrayList<RecognizerInfo> mAvailableRecognizerInfos = new ArrayList<>();
- ComponentName mCurrentVoiceInteraction;
ComponentName mCurrentRecognizer;
public VoiceInputHelper(Context context) {
mContext = context;
- mAvailableVoiceInteractions = mContext.getPackageManager().queryIntentServices(
- new Intent(VoiceInteractionService.SERVICE_INTERFACE),
- PackageManager.GET_META_DATA);
mAvailableRecognition = mContext.getPackageManager().queryIntentServices(
new Intent(RecognitionService.SERVICE_INTERFACE),
PackageManager.GET_META_DATA);
}
public void buildUi() {
- // Get the currently selected interactor from the secure setting.
- String currentSetting = Settings.Secure.getString(
- mContext.getContentResolver(), Settings.Secure.VOICE_INTERACTION_SERVICE);
- if (currentSetting != null && !currentSetting.isEmpty()) {
- mCurrentVoiceInteraction = ComponentName.unflattenFromString(currentSetting);
- } else {
- mCurrentVoiceInteraction = null;
- }
-
- ArraySet<ComponentName> interactorRecognizers = new ArraySet<>();
-
- // Iterate through all the available interactors and load up their info to show
- // in the preference.
- int size = mAvailableVoiceInteractions.size();
- for (int i = 0; i < size; i++) {
- ResolveInfo resolveInfo = mAvailableVoiceInteractions.get(i);
- VoiceInteractionServiceInfo info = new VoiceInteractionServiceInfo(
- mContext.getPackageManager(), resolveInfo.serviceInfo);
- if (info.getParseError() != null) {
- Log.w("VoiceInteractionService", "Error in VoiceInteractionService "
- + resolveInfo.serviceInfo.packageName + "/"
- + resolveInfo.serviceInfo.name + ": " + info.getParseError());
- continue;
- }
- mAvailableInteractionInfos.add(new InteractionInfo(mContext.getPackageManager(), info));
- interactorRecognizers.add(new ComponentName(resolveInfo.serviceInfo.packageName,
- info.getRecognitionService()));
- }
- Collections.sort(mAvailableInteractionInfos);
-
// Get the currently selected recognizer from the secure setting.
- currentSetting = Settings.Secure.getString(
+ String currentSetting = Settings.Secure.getString(
mContext.getContentResolver(), Settings.Secure.VOICE_RECOGNITION_SERVICE);
if (currentSetting != null && !currentSetting.isEmpty()) {
mCurrentRecognizer = ComponentName.unflattenFromString(currentSetting);
@@ -155,14 +108,11 @@
// Iterate through all the available recognizers and load up their info to show
// in the preference.
- size = mAvailableRecognition.size();
+ int size = mAvailableRecognition.size();
for (int i = 0; i < size; i++) {
ResolveInfo resolveInfo = mAvailableRecognition.get(i);
ComponentName comp = new ComponentName(resolveInfo.serviceInfo.packageName,
resolveInfo.serviceInfo.name);
- if (interactorRecognizers.contains(comp)) {
- //continue;
- }
ServiceInfo si = resolveInfo.serviceInfo;
String settingsActivity = null;
// Always show in voice input settings unless specifically set to False.
diff --git a/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java b/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java
index 792f2ee..f27530e 100644
--- a/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java
+++ b/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java
@@ -31,6 +31,7 @@
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceScreen;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
@@ -47,16 +48,23 @@
private final List<AutofillServiceInfo> mServices;
public PasswordsPreferenceController(Context context, String preferenceKey) {
+ this(context, preferenceKey,
+ AutofillServiceInfo.getAvailableServices(context, UserHandle.myUserId()));
+ }
+
+ @VisibleForTesting
+ public PasswordsPreferenceController(
+ Context context, String preferenceKey, List<AutofillServiceInfo> availableServices) {
super(context, preferenceKey);
mPm = context.getPackageManager();
mIconFactory = IconDrawableFactory.newInstance(mContext);
- mServices = AutofillServiceInfo.getAvailableServices(mContext, UserHandle.myUserId());
- for (int i = mServices.size() - 1; i >= 0; i--) {
- final String passwordsActivity = mServices.get(i).getPasswordsActivity();
+ for (int i = availableServices.size() - 1; i >= 0; i--) {
+ final String passwordsActivity = availableServices.get(i).getPasswordsActivity();
if (TextUtils.isEmpty(passwordsActivity)) {
- mServices.remove(i);
+ availableServices.remove(i);
}
}
+ mServices = availableServices;
}
@Override
diff --git a/src/com/android/settings/biometrics/BiometricEnrollBase.java b/src/com/android/settings/biometrics/BiometricEnrollBase.java
index 3fb8941..67148d1 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollBase.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollBase.java
@@ -48,6 +48,8 @@
public static final String EXTRA_KEY_LAUNCHED_CONFIRM = "launched_confirm_lock";
public static final String EXTRA_KEY_REQUIRE_VISION = "accessibility_vision";
public static final String EXTRA_KEY_REQUIRE_DIVERSITY = "accessibility_diversity";
+ public static final String EXTRA_KEY_SENSOR_ID = "sensor_id";
+ public static final String EXTRA_KEY_CHALLENGE = "challenge";
/**
* Used by the choose fingerprint wizard to indicate the wizard is
@@ -90,12 +92,16 @@
protected boolean mLaunchedConfirmLock;
protected byte[] mToken;
protected int mUserId;
+ protected int mSensorId;
+ protected long mChallenge;
protected boolean mFromSettingsSummary;
protected FooterBarMixin mFooterBarMixin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ mChallenge = getIntent().getLongExtra(EXTRA_KEY_CHALLENGE, -1L);
+ mSensorId = getIntent().getIntExtra(EXTRA_KEY_SENSOR_ID, -1);
// Don't need to retrieve the HAT if it already exists. In some cases, the extras do not
// contain EXTRA_KEY_CHALLENGE_TOKEN but contain EXTRA_KEY_GK_PW, in which case enrollment
// classes may request a HAT to be created (as opposed to being passed in)
@@ -110,6 +116,8 @@
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
mFromSettingsSummary =
savedInstanceState.getBoolean(EXTRA_FROM_SETTINGS_SUMMARY, false);
+ mChallenge = savedInstanceState.getLong(EXTRA_KEY_CHALLENGE);
+ mSensorId = savedInstanceState.getInt(EXTRA_KEY_SENSOR_ID);
}
mUserId = getIntent().getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
}
@@ -127,6 +135,8 @@
outState.putBoolean(EXTRA_KEY_LAUNCHED_CONFIRM, mLaunchedConfirmLock);
outState.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
outState.putBoolean(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
+ outState.putLong(EXTRA_KEY_CHALLENGE, mChallenge);
+ outState.putInt(EXTRA_KEY_SENSOR_ID, mSensorId);
}
@Override
@@ -173,10 +183,18 @@
setHeaderText(resId, false /* force */);
}
+ protected void setHeaderText(CharSequence title) {
+ getLayout().setHeaderText(title);
+ }
+
protected void setDescriptionText(int resId) {
getLayout().setDescriptionText(resId);
}
+ protected void setDescriptionText(CharSequence descriptionText) {
+ getLayout().setDescriptionText(descriptionText);
+ }
+
protected FooterButton getNextButton() {
if (mFooterBarMixin != null) {
return mFooterBarMixin.getPrimaryButton();
@@ -192,6 +210,8 @@
intent.setClassName(SETTINGS_PACKAGE_NAME, FingerprintEnrollEnrolling.class.getName());
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
+ intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
+ intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
if (mUserId != UserHandle.USER_NULL) {
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
}
diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
index 09344b0..b44c2c9 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
@@ -243,6 +243,8 @@
}
BiometricUtils.copyMultiBiometricExtras(getIntent(), intent);
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
+ intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
+ intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
startActivityForResult(intent, BIOMETRIC_FIND_SENSOR_REQUEST);
}
@@ -262,6 +264,8 @@
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
getNextButton().setEnabled(false);
getChallenge(((sensorId, challenge) -> {
+ mSensorId = sensorId;
+ mChallenge = challenge;
mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge);
BiometricUtils.removeGatekeeperPasswordHandle(this, data);
getNextButton().setEnabled(true);
@@ -276,6 +280,8 @@
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
getNextButton().setEnabled(false);
getChallenge(((sensorId, challenge) -> {
+ mSensorId = sensorId;
+ mChallenge = challenge;
mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge);
BiometricUtils.removeGatekeeperPasswordHandle(this, data);
getNextButton().setEnabled(true);
diff --git a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
index 9b86e78..0bfe56e 100644
--- a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
@@ -121,6 +121,8 @@
| Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
+ intent.putExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, mSensorId);
+ intent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, mChallenge);
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
if (mUserId != UserHandle.USER_NULL) {
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
diff --git a/src/com/android/settings/biometrics/MultiBiometricEnrollHelper.java b/src/com/android/settings/biometrics/MultiBiometricEnrollHelper.java
index 1ea6b08..84128e2 100644
--- a/src/com/android/settings/biometrics/MultiBiometricEnrollHelper.java
+++ b/src/com/android/settings/biometrics/MultiBiometricEnrollHelper.java
@@ -72,6 +72,8 @@
mGkPwHandle, mUserId, challenge);
final Intent faceIntent = BiometricUtils.getFaceIntroIntent(mActivity,
mActivity.getIntent());
+ faceIntent.putExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, sensorId);
+ faceIntent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, challenge);
if (mRequestEnrollFingerprint) {
// Give FaceEnroll a pendingIntent pointing to fingerprint enrollment, so that it
@@ -97,6 +99,8 @@
mGkPwHandle, mUserId, challenge);
final Intent intent = BiometricUtils.getFingerprintIntroIntent(mActivity,
mActivity.getIntent());
+ intent.putExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, sensorId);
+ intent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, challenge);
BiometricUtils.launchEnrollForResult(mActivity, intent, REQUEST_FINGERPRINT_ENROLL,
hardwareAuthToken, mGkPwHandle, mUserId);
}));
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollEducation.java b/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
index 3e9fba2..6c5a4b4 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
@@ -183,6 +183,8 @@
if (mUserId != UserHandle.USER_NULL) {
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
}
+ intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
+ intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
BiometricUtils.copyMultiBiometricExtras(getIntent(), intent);
final String flattenedString = getString(R.string.config_face_enroll);
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
index 3bffbbf..9110292 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
@@ -112,6 +112,8 @@
// the challenge is ready. Let's just do this for now.
mFaceManager.generateChallenge((sensorId, challenge) -> {
mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
+ mSensorId = sensorId;
+ mChallenge = challenge;
if (BiometricUtils.isMultiBiometricEnrollmentFlow(this)) {
BiometricUtils.removeGatekeeperPasswordHandle(this, getIntent());
}
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index 7751485..038d448 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -37,6 +37,7 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
+import com.android.settings.biometrics.BiometricEnrollBase;
import com.android.settings.biometrics.BiometricUtils;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
@@ -67,6 +68,8 @@
private UserManager mUserManager;
private FaceManager mFaceManager;
private int mUserId;
+ private int mSensorId;
+ private long mChallenge;
private byte[] mToken;
private FaceSettingsAttentionPreferenceController mAttentionController;
private FaceSettingsRemoveButtonPreferenceController mRemoveController;
@@ -147,6 +150,8 @@
mUserManager = context.getSystemService(UserManager.class);
mFaceManager = context.getSystemService(FaceManager.class);
mToken = getIntent().getByteArrayExtra(KEY_TOKEN);
+ mSensorId = getIntent().getIntExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, -1);
+ mChallenge = getIntent().getLongExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, 0L);
mUserId = getActivity().getIntent().getIntExtra(
Intent.EXTRA_USER_ID, UserHandle.myUserId());
@@ -247,6 +252,8 @@
mFaceManager.generateChallenge((sensorId, challenge) -> {
mToken = BiometricUtils.requestGatekeeperHat(getPrefContext(), data, mUserId,
challenge);
+ mSensorId = sensorId;
+ mChallenge = challenge;
BiometricUtils.removeGatekeeperPasswordHandle(getPrefContext(), data);
mAttentionController.setToken(mToken);
mEnrollController.setToken(mToken);
@@ -269,7 +276,7 @@
&& !mConfirmingPassword) {
// Revoke challenge and finish
if (mToken != null) {
- mFaceManager.revokeChallenge();
+ mFaceManager.revokeChallenge(mSensorId, mUserId, mChallenge);
mToken = null;
}
finish();
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index b403e42..10b31e3 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -324,7 +324,9 @@
@Override
public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) {
if (!TextUtils.isEmpty(helpString)) {
- mErrorText.removeCallbacks(mTouchAgainRunnable);
+ if (!mCanAssumeUdfps) {
+ mErrorText.removeCallbacks(mTouchAgainRunnable);
+ }
showError(helpString);
}
}
@@ -345,7 +347,9 @@
}
showErrorDialog(getText(msgId), errMsgId);
stopIconAnimation();
- mErrorText.removeCallbacks(mTouchAgainRunnable);
+ if (!mCanAssumeUdfps) {
+ mErrorText.removeCallbacks(mTouchAgainRunnable);
+ }
}
@Override
@@ -354,8 +358,10 @@
updateTitleAndDescription();
clearError();
animateFlash();
- mErrorText.removeCallbacks(mTouchAgainRunnable);
- mErrorText.postDelayed(mTouchAgainRunnable, HINT_TIMEOUT_DURATION);
+ if (!mCanAssumeUdfps) {
+ mErrorText.removeCallbacks(mTouchAgainRunnable);
+ mErrorText.postDelayed(mTouchAgainRunnable, HINT_TIMEOUT_DURATION);
+ }
}
private void updateProgress(boolean animate) {
@@ -397,22 +403,28 @@
}
private void showError(CharSequence error) {
- mErrorText.setText(error);
- if (mErrorText.getVisibility() == View.INVISIBLE) {
- mErrorText.setVisibility(View.VISIBLE);
- mErrorText.setTranslationY(getResources().getDimensionPixelSize(
- R.dimen.fingerprint_error_text_appear_distance));
- mErrorText.setAlpha(0f);
- mErrorText.animate()
- .alpha(1f)
- .translationY(0f)
- .setDuration(200)
- .setInterpolator(mLinearOutSlowInInterpolator)
- .start();
+ if (mCanAssumeUdfps) {
+ setHeaderText(error);
+ // Show nothing for subtitle when getting an error message.
+ setDescriptionText("");
} else {
- mErrorText.animate().cancel();
- mErrorText.setAlpha(1f);
- mErrorText.setTranslationY(0f);
+ mErrorText.setText(error);
+ if (mErrorText.getVisibility() == View.INVISIBLE) {
+ mErrorText.setVisibility(View.VISIBLE);
+ mErrorText.setTranslationY(getResources().getDimensionPixelSize(
+ R.dimen.fingerprint_error_text_appear_distance));
+ mErrorText.setAlpha(0f);
+ mErrorText.animate()
+ .alpha(1f)
+ .translationY(0f)
+ .setDuration(200)
+ .setInterpolator(mLinearOutSlowInInterpolator)
+ .start();
+ } else {
+ mErrorText.animate().cancel();
+ mErrorText.setAlpha(1f);
+ mErrorText.setTranslationY(0f);
+ }
}
if (isResumed()) {
mVibrator.vibrate(VIBRATE_EFFECT_ERROR, FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES);
@@ -420,7 +432,7 @@
}
private void clearError() {
- if (mErrorText.getVisibility() == View.VISIBLE) {
+ if (!mCanAssumeUdfps && mErrorText.getVisibility() == View.VISIBLE) {
mErrorText.animate()
.alpha(0f)
.translationY(getResources().getDimensionPixelSize(
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
index 094336a..94eb278 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
@@ -81,6 +81,8 @@
if (mToken == null && BiometricUtils.containsGatekeeperPasswordHandle(getIntent())) {
final FingerprintManager fpm = getSystemService(FingerprintManager.class);
fpm.generateChallenge(mUserId, (sensorId, challenge) -> {
+ mChallenge = challenge;
+ mSensorId = sensorId;
mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
BiometricUtils.removeGatekeeperPasswordHandle(this, getIntent());
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
index 481da1b..a989eef 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
@@ -141,7 +141,7 @@
private void postEnroll() {
final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
if (fpm != null) {
- fpm.revokeChallenge(mUserId);
+ fpm.revokeChallenge(mUserId, mChallenge);
}
}
@@ -151,6 +151,7 @@
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
+ intent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, mChallenge);
startActivity(intent);
}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
index 1d2793a..3e0591f 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
@@ -138,6 +138,8 @@
private CharSequence mFooterTitle;
private boolean mEnrollClicked;
+ private long mChallenge;
+
private static final String TAG_AUTHENTICATE_SIDECAR = "authenticate_sidecar";
private static final String TAG_REMOVAL_SIDECAR = "removal_sidecar";
private FingerprintAuthenticateSidecar mAuthenticateSidecar;
@@ -287,6 +289,8 @@
mToken = getIntent().getByteArrayExtra(
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
+ mChallenge = activity.getIntent()
+ .getLongExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, -1L);
mAuthenticateSidecar = (FingerprintAuthenticateSidecar)
getFragmentManager().findFragmentByTag(TAG_AUTHENTICATE_SIDECAR);
@@ -577,6 +581,7 @@
mFingerprintManager.generateChallenge(mUserId, (sensorId, challenge) -> {
mToken = BiometricUtils.requestGatekeeperHat(getActivity(), data,
mUserId, challenge);
+ mChallenge = challenge;
BiometricUtils.removeGatekeeperPasswordHandle(getActivity(), data);
updateAddPreference();
});
@@ -602,7 +607,7 @@
public void onDestroy() {
super.onDestroy();
if (getActivity().isFinishing()) {
- mFingerprintManager.revokeChallenge(mUserId);
+ mFingerprintManager.revokeChallenge(mUserId, mChallenge);
}
}
diff --git a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
index 394b673..5f2fbb5 100644
--- a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
@@ -40,6 +40,8 @@
protected Intent getFingerprintEnrollingIntent() {
Intent intent = new Intent(this, SetupFingerprintEnrollEnrolling.class);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
+ intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
+ intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
if (mUserId != UserHandle.USER_NULL) {
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
}
diff --git a/src/com/android/settings/datetime/LocationTimeZoneDetectionPreferenceController.java b/src/com/android/settings/datetime/LocationTimeZoneDetectionPreferenceController.java
index bbfbb19..1a45640 100644
--- a/src/com/android/settings/datetime/LocationTimeZoneDetectionPreferenceController.java
+++ b/src/com/android/settings/datetime/LocationTimeZoneDetectionPreferenceController.java
@@ -31,7 +31,7 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.TogglePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -43,7 +43,7 @@
* screen.
*/
public class LocationTimeZoneDetectionPreferenceController
- extends BasePreferenceController
+ extends TogglePreferenceController
implements LifecycleObserver, OnStart, OnStop, TimeManager.TimeZoneDetectorListener {
private final TimeManager mTimeManager;
@@ -58,6 +58,22 @@
}
@Override
+ public boolean isChecked() {
+ TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
+ mTimeManager.getTimeZoneCapabilitiesAndConfig();
+ TimeZoneConfiguration configuration = capabilitiesAndConfig.getConfiguration();
+ return configuration.isGeoDetectionEnabled();
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ TimeZoneConfiguration configuration = new TimeZoneConfiguration.Builder()
+ .setGeoDetectionEnabled(isChecked)
+ .build();
+ return mTimeManager.updateTimeZoneConfiguration(configuration);
+ }
+
+ @Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
@@ -126,10 +142,10 @@
summaryResId = R.string.location_time_zone_detection_not_applicable;
}
} else if (configureGeoDetectionEnabledCapability == CAPABILITY_POSSESSED) {
- boolean isGeoDetectionEnabled = configuration.isGeoDetectionEnabled();
- summaryResId = isGeoDetectionEnabled
- ? R.string.location_time_zone_detection_on
- : R.string.location_time_zone_detection_off;
+ // If capability is possessed, toggle status already tells all the information needed.
+ // Returning null will make previous text stick on toggling.
+ // See AbstractPreferenceController#refreshSummary.
+ return "";
} else {
// This is unexpected: getAvailabilityStatus() should ensure that the UI element isn't
// even shown for known cases, or the capability is unknown.
diff --git a/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionSettings.java b/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionSettings.java
deleted file mode 100644
index db6ffc4..0000000
--- a/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionSettings.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2020 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.datetime.locationtimezone;
-
-import android.app.settings.SettingsEnums;
-
-import com.android.settings.R;
-import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.search.SearchIndexable;
-
-/**
- * The controller for the "location time zone detection" screen.
- */
-@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
-public class TimeZoneDetectionSettings extends DashboardFragment {
- private static final String TAG = "LTZDetectionSettings";
-
- @Override
- public int getMetricsCategory() {
- return SettingsEnums.LOCATION_TIME_ZONE_DETECTION;
- }
-
- @Override
- protected int getPreferenceScreenResId() {
- return R.xml.location_time_zone_detection;
- }
-
- @Override
- protected String getLogTag() {
- return TAG;
- }
-
- /**
- * For Search.
- */
- public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.location_time_zone_detection);
-}
diff --git a/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionTogglePreferenceController.java b/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionTogglePreferenceController.java
deleted file mode 100644
index c91be7f..0000000
--- a/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionTogglePreferenceController.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2020 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.datetime.locationtimezone;
-
-import android.app.time.TimeManager;
-import android.app.time.TimeZoneCapabilitiesAndConfig;
-import android.app.time.TimeZoneConfiguration;
-import android.content.Context;
-
-import com.android.settings.core.TogglePreferenceController;
-
-/**
- * The controller for the "location time zone detection" switch on the location time zone detection
- * screen.
- */
-public class TimeZoneDetectionTogglePreferenceController extends TogglePreferenceController {
-
- private final TimeManager mTimeManager;
-
- public TimeZoneDetectionTogglePreferenceController(Context context, String key) {
- super(context, key);
- mTimeManager = context.getSystemService(TimeManager.class);
- }
-
- @Override
- public int getAvailabilityStatus() {
- return AVAILABLE;
- }
-
- @Override
- public boolean isChecked() {
- TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
- mTimeManager.getTimeZoneCapabilitiesAndConfig();
- TimeZoneConfiguration configuration = capabilitiesAndConfig.getConfiguration();
- return configuration.isGeoDetectionEnabled();
- }
-
- @Override
- public boolean setChecked(boolean isChecked) {
- TimeZoneConfiguration configuration = new TimeZoneConfiguration.Builder()
- .setGeoDetectionEnabled(isChecked)
- .build();
- return mTimeManager.updateTimeZoneConfiguration(configuration);
- }
-}
diff --git a/src/com/android/settings/display/AdaptiveSleepPermissionPreferenceController.java b/src/com/android/settings/display/AdaptiveSleepPermissionPreferenceController.java
index 1110ad2..0d21e9c 100644
--- a/src/com/android/settings/display/AdaptiveSleepPermissionPreferenceController.java
+++ b/src/com/android/settings/display/AdaptiveSleepPermissionPreferenceController.java
@@ -23,11 +23,11 @@
import android.content.pm.PackageManager;
import android.net.Uri;
-import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
+import com.android.settingslib.widget.BannerMessagePreference;
/**
* The controller of Screen attention's permission warning preference. The preference appears when
@@ -35,8 +35,8 @@
*/
public class AdaptiveSleepPermissionPreferenceController {
@VisibleForTesting
- Preference mPreference;
- private PackageManager mPackageManager;
+ BannerMessagePreference mPreference;
+ private final PackageManager mPackageManager;
public AdaptiveSleepPermissionPreferenceController(Context context) {
final String packageName = context.getPackageManager().getAttentionServicePackageName();
@@ -44,13 +44,12 @@
final Intent intent = new Intent(
android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + packageName));
- mPreference = new Preference(context);
+ mPreference = new BannerMessagePreference(context);
mPreference.setTitle(R.string.adaptive_sleep_title_no_permission);
mPreference.setSummary(R.string.adaptive_sleep_summary_no_permission);
- mPreference.setIcon(R.drawable.ic_info_outline_24);
- mPreference.setOnPreferenceClickListener(p -> {
+ mPreference.setPositiveButtonText(R.string.adaptive_sleep_manage_permission_button);
+ mPreference.setPositiveButtonOnClickListener(p -> {
context.startActivity(intent);
- return true;
});
}
diff --git a/src/com/android/settings/display/ScreenTimeoutSettings.java b/src/com/android/settings/display/ScreenTimeoutSettings.java
index f9bb99e..3b0d333 100644
--- a/src/com/android/settings/display/ScreenTimeoutSettings.java
+++ b/src/com/android/settings/display/ScreenTimeoutSettings.java
@@ -23,7 +23,6 @@
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
-import android.os.Bundle;
import android.os.UserHandle;
import android.provider.Settings;
import android.text.SpannableString;
@@ -39,8 +38,6 @@
import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.search.actionbar.SearchMenuController;
-import com.android.settings.support.actionbar.HelpMenuController;
import com.android.settings.support.actionbar.HelpResourceProvider;
import com.android.settings.widget.RadioButtonPickerFragment;
import com.android.settingslib.RestrictedLockUtils;
@@ -92,13 +89,6 @@
}
@Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- SearchMenuController.init(this /* host */);
- HelpMenuController.init(this /* host */);
- }
-
- @Override
public void onAttach(Context context) {
super.onAttach(context);
mInitialEntries = getResources().getStringArray(R.array.screen_timeout_entries);
diff --git a/src/com/android/settings/emergency/EmergencyActionContentProvider.java b/src/com/android/settings/emergency/EmergencyActionContentProvider.java
new file mode 100644
index 0000000..03f0faf
--- /dev/null
+++ b/src/com/android/settings/emergency/EmergencyActionContentProvider.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2021 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.emergency;
+
+import static android.telecom.TelecomManager.EXTRA_CALL_SOURCE;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Binder;
+import android.os.Bundle;
+import android.telecom.PhoneAccount;
+import android.telecom.TelecomManager;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.settings.R;
+import com.android.settingslib.emergencynumber.EmergencyNumberUtils;
+
+/**
+ * ContentProvider to delegate emergency action work
+ */
+public class EmergencyActionContentProvider extends ContentProvider {
+ private static final String TAG = "EmergencyActionContentP";
+
+ private static final String ACTION_START_EMERGENCY_CALL =
+ "com.android.settings.emergency.MAKE_EMERGENCY_CALL";
+
+ @Override
+ public Bundle call(String authority, String method, String arg, Bundle extras) {
+ int uid = Binder.getCallingUid();
+ Log.d(TAG, "calling pid/uid" + Binder.getCallingPid() + "/" + uid);
+ if (!isEmergencyInfo(getContext())) {
+ throw new SecurityException("Uid is not allowed: " + uid);
+ }
+ if (!TextUtils.equals(method, ACTION_START_EMERGENCY_CALL)) {
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+ placeEmergencyCall(getContext());
+ return new Bundle();
+ }
+
+ @Override
+ public boolean onCreate() {
+ return true;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
+ String sortOrder) {
+ return null;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ return null;
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ return null;
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ return 0;
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ return 0;
+ }
+
+ private static boolean isEmergencyInfo(Context context) {
+ final int callingUid = Binder.getCallingUid();
+ final String callingPackage = context.getPackageManager().getPackagesForUid(callingUid)[0];
+ return TextUtils.equals(callingPackage,
+ context.getString(R.string.config_aosp_emergency_package_name));
+ }
+
+ private static void placeEmergencyCall(Context context) {
+ if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
+ Log.i(TAG, "Telephony is not supported, skipping.");
+ return;
+ }
+ Bundle extras = new Bundle();
+ extras.putBoolean(TelecomManager.EXTRA_IS_USER_INTENT_EMERGENCY_CALL, true);
+ extras.putInt(EXTRA_CALL_SOURCE, TelecomManager.CALL_SOURCE_EMERGENCY_SHORTCUT);
+ TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
+ EmergencyNumberUtils emergencyNumberUtils = new EmergencyNumberUtils(context);
+ telecomManager.placeCall(
+ Uri.fromParts(PhoneAccount.SCHEME_TEL, emergencyNumberUtils.getPoliceNumber(),
+ /* fragment= */ null), extras);
+ }
+}
diff --git a/src/com/android/settings/emergency/EmergencyGestureEntrypointPreferenceController.java b/src/com/android/settings/emergency/EmergencyGestureEntrypointPreferenceController.java
index 43ff215..ab2c473 100644
--- a/src/com/android/settings/emergency/EmergencyGestureEntrypointPreferenceController.java
+++ b/src/com/android/settings/emergency/EmergencyGestureEntrypointPreferenceController.java
@@ -49,11 +49,11 @@
final String emergencyGestureSettingsPackageName = context.getResources().getString(
R.string.emergency_gesture_settings_package);
if (!TextUtils.isEmpty(emergencyGestureSettingsPackageName)) {
- mUseCustomIntent = true;
- // Use custom intent if it's configured and system can resolve it.
final Intent intent = new Intent(ACTION_EMERGENCY_GESTURE_SETTINGS)
.setPackage(emergencyGestureSettingsPackageName);
if (canResolveIntent(intent)) {
+ // Use custom intent if it's configured and system can resolve it.
+ mUseCustomIntent = true;
mIntent = intent;
}
}
diff --git a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
index 685da03..cf23c94 100644
--- a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
+++ b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
@@ -233,8 +233,6 @@
final TextView textView = root.findViewById(R.id.admin_support_msg);
if (supportMessage != null) {
textView.setText(supportMessage);
- } else if (!isFinancedDevice()) {
- textView.setText(R.string.default_admin_support_msg);
}
}
diff --git a/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java
index 4415e71..51d74d5 100644
--- a/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java
@@ -21,10 +21,12 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.graphics.ColorFilter;
import android.icu.text.NumberFormat;
import android.os.BatteryManager;
import android.os.PowerManager;
import android.text.TextUtils;
+import android.widget.ImageView;
import androidx.annotation.VisibleForTesting;
import androidx.preference.PreferenceFragmentCompat;
@@ -60,6 +62,7 @@
private Activity mActivity;
private PreferenceFragmentCompat mHost;
private Lifecycle mLifecycle;
+ private ColorFilter mAccentColorFilter;
private final PowerManager mPowerManager;
public BatteryHeaderPreferenceController(Context context, String key) {
@@ -85,6 +88,9 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mBatteryUsageProgressBarPref = screen.findPreference(getPreferenceKey());
+ mAccentColorFilter = com.android.settings.Utils.getAlphaInvariantColorFilterForColor(
+ com.android.settings.Utils.getColorAttrDefaultColor(
+ mContext, android.R.attr.colorAccent));
if (com.android.settings.Utils.isBatteryPresent(mContext)) {
quickUpdateHeaderPreference();
@@ -116,13 +122,12 @@
}
public void updateHeaderPreference(BatteryInfo info) {
-
- //TODO(b/179237746): Make progress bar widget support battery state icon
-
mBatteryUsageProgressBarPref.setUsageSummary(
formatBatteryPercentageText(info.batteryLevel));
mBatteryUsageProgressBarPref.setTotalSummary(generateLabel(info));
mBatteryUsageProgressBarPref.setPercent(info.batteryLevel, BATTERY_MAX_LEVEL);
+ mBatteryUsageProgressBarPref.setCustomContent(
+ getBatteryIcon(!info.discharging, info.batteryLevel));
}
/**
@@ -139,14 +144,30 @@
final boolean discharging =
batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) == 0;
- //TODO(b/179237746): Make progress bar widget support battery state icon
-
mBatteryUsageProgressBarPref.setUsageSummary(formatBatteryPercentageText(batteryLevel));
mBatteryUsageProgressBarPref.setPercent(batteryLevel, BATTERY_MAX_LEVEL);
+ mBatteryUsageProgressBarPref.setCustomContent(getBatteryIcon(!discharging, batteryLevel));
}
private CharSequence formatBatteryPercentageText(int batteryLevel) {
return TextUtils.expandTemplate(mContext.getText(R.string.battery_header_title_alternate),
NumberFormat.getIntegerInstance().format(batteryLevel));
}
+
+ //TODO(b/179237746): Update the battery icon after receiving final asset
+ private ImageView getBatteryIcon(boolean isCharging, int batteryLevel) {
+ ImageView batteryIcon = new ImageView(mContext);
+
+ if (batteryLevel <= (mContext.getResources().getInteger(
+ com.android.internal.R.integer.config_lowBatteryWarningLevel))) {
+ batteryIcon.setImageResource(R.drawable.ic_battery_low);
+ } else if (isCharging) {
+ batteryIcon.setColorFilter(mAccentColorFilter);
+ batteryIcon.setImageResource(R.drawable.ic_battery_charging_full);
+ } else {
+ batteryIcon = null;
+ }
+
+ return batteryIcon;
+ }
}
diff --git a/src/com/android/settings/fuelgauge/FakeUid.java b/src/com/android/settings/fuelgauge/FakeUid.java
index e1fc7f4..4bb98ed 100644
--- a/src/com/android/settings/fuelgauge/FakeUid.java
+++ b/src/com/android/settings/fuelgauge/FakeUid.java
@@ -361,6 +361,11 @@
}
@Override
+ public long getCpuMeasuredBatteryConsumptionUC() {
+ return 0;
+ }
+
+ @Override
public long[] getCustomConsumerMeasuredBatteryConsumptionUC() {
return null;
}
diff --git a/src/com/android/settings/inputmethod/OWNERS b/src/com/android/settings/inputmethod/OWNERS
index 9f33394..556de5f 100644
--- a/src/com/android/settings/inputmethod/OWNERS
+++ b/src/com/android/settings/inputmethod/OWNERS
@@ -1,5 +1,7 @@
-# Default reviewers for this and subdirectories.
-yukawa@google.com
-michaelwr@google.com
+# Bug component: 34867
+include platform/frameworks/base:/services/core/java/com/android/server/inputmethod/OWNERS
-# Emergency approvers in case the above are not available
\ No newline at end of file
+# Settings for physical keyboard and game pad are better to be reviewed by the input team
+per-file GameControllerPreferenceController.java = file: platform/frameworks/base:/services/core/java/com/android/server/input/OWNERS
+per-file KeyboardLayoutPicker*.java = file: platform/frameworks/base:/services/core/java/com/android/server/input/OWNERS
+per-file PhysicalKeyboard*.java = file: platform/frameworks/base:/services/core/java/com/android/server/input/OWNERS
diff --git a/src/com/android/settings/network/AirplaneSafeNetworksSlice.java b/src/com/android/settings/network/AirplaneSafeNetworksSlice.java
deleted file mode 100644
index 763e0c7..0000000
--- a/src/com/android/settings/network/AirplaneSafeNetworksSlice.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (C) 2020 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.network;
-
-import android.app.PendingIntent;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
-import android.graphics.drawable.Drawable;
-import android.net.Uri;
-import android.net.wifi.WifiManager;
-import android.util.Log;
-
-import androidx.annotation.IntDef;
-import androidx.core.graphics.drawable.IconCompat;
-import androidx.slice.Slice;
-import androidx.slice.builders.ListBuilder;
-import androidx.slice.builders.ListBuilder.RowBuilder;
-import androidx.slice.builders.SliceAction;
-import androidx.slice.core.SliceHints;
-
-import com.android.settings.AirplaneModeEnabler;
-import com.android.settings.R;
-import com.android.settings.Utils;
-import com.android.settings.slices.CustomSliceRegistry;
-import com.android.settings.slices.CustomSliceable;
-import com.android.settings.slices.SliceBackgroundWorker;
-import com.android.settings.slices.SliceBroadcastReceiver;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * {@link CustomSliceable} for airplane-safe networks, used by generic clients.
- */
-public class AirplaneSafeNetworksSlice implements CustomSliceable,
- AirplaneModeEnabler.OnAirplaneModeChangedListener {
-
- private static final String TAG = "AirplaneSafeNetworksSlice";
-
- public static final String ACTION_INTENT_EXTRA = "action";
-
- /**
- * Annotation for different action of the slice.
- *
- * {@code TURN_ON_NETWORKS} for action of turning on Wi-Fi networks.
- * {@code TURN_OFF_NETWORKS} for action of turning off Wi-Fi networks.
- */
- @Retention(RetentionPolicy.SOURCE)
- @IntDef(value = {
- Action.TURN_ON_NETWORKS,
- Action.TURN_OFF_NETWORKS,
- })
- public @interface Action {
- int TURN_ON_NETWORKS = 1;
- int TURN_OFF_NETWORKS = 2;
- }
-
- private final Context mContext;
- private final AirplaneModeEnabler mAirplaneModeEnabler;
- private final WifiManager mWifiManager;
-
- private boolean mIsAirplaneModeOn;
-
- public AirplaneSafeNetworksSlice(Context context) {
- mContext = context;
- mAirplaneModeEnabler = new AirplaneModeEnabler(context, this);
- mIsAirplaneModeOn = mAirplaneModeEnabler.isAirplaneModeOn();
- mWifiManager = mContext.getSystemService(WifiManager.class);
- }
-
- private static void logd(String s) {
- Log.d(TAG, s);
- }
-
- @Override
- public Slice getSlice() {
- final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY);
- if (mIsAirplaneModeOn) {
- listBuilder.addRow(new RowBuilder()
- .setTitle(getTitle())
- .addEndItem(getEndIcon(), SliceHints.ICON_IMAGE)
- .setPrimaryAction(getSliceAction()));
- }
- return listBuilder.build();
- }
-
- @Override
- public Uri getUri() {
- return CustomSliceRegistry.AIRPLANE_SAFE_NETWORKS_SLICE_URI;
- }
-
- @Override
- public void onNotifyChange(Intent intent) {
- final int action = intent.getIntExtra(ACTION_INTENT_EXTRA, 0);
- if (action == Action.TURN_ON_NETWORKS) {
- if (!mWifiManager.isWifiEnabled()) {
- logd("Action: turn on Wi-Fi networks");
- mWifiManager.setWifiEnabled(true);
- }
- } else if (action == Action.TURN_OFF_NETWORKS) {
- if (mWifiManager.isWifiEnabled()) {
- logd("Action: turn off Wi-Fi networks");
- mWifiManager.setWifiEnabled(false);
- }
- }
- }
-
- @Override
- public void onAirplaneModeChanged(boolean isAirplaneModeOn) {
- mIsAirplaneModeOn = isAirplaneModeOn;
- final AirplaneSafeNetworksWorker worker = SliceBackgroundWorker.getInstance(getUri());
- if (worker != null) {
- worker.updateSlice();
- }
- }
-
- @Override
- public Intent getIntent() {
- return new Intent(getUri().toString())
- .setData(getUri())
- .setClass(mContext, SliceBroadcastReceiver.class)
- .putExtra(ACTION_INTENT_EXTRA, getAction());
- }
-
- @Action
- private int getAction() {
- return mWifiManager.isWifiEnabled()
- ? Action.TURN_OFF_NETWORKS
- : Action.TURN_ON_NETWORKS;
- }
-
- private String getTitle() {
- return mContext.getText(
- (getAction() == Action.TURN_ON_NETWORKS)
- ? R.string.turn_on_networks
- : R.string.turn_off_networks).toString();
- }
-
- private IconCompat getEndIcon() {
- final Drawable drawable = mContext.getDrawable(
- (getAction() == Action.TURN_ON_NETWORKS) ? R.drawable.ic_airplane_safe_networks_24dp
- : R.drawable.ic_airplanemode_active);
- if (drawable == null) {
- return Utils.createIconWithDrawable(new ColorDrawable(Color.TRANSPARENT));
- }
- drawable.setTintList(Utils.getColorAttr(mContext, android.R.attr.colorAccent));
- return Utils.createIconWithDrawable(drawable);
- }
-
- private SliceAction getSliceAction() {
- final PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext,
- 0 /* requestCode */, getIntent(),
- PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
- final IconCompat icon = Utils.createIconWithDrawable(new ColorDrawable(Color.TRANSPARENT));
- return SliceAction.create(pendingIntent, icon, ListBuilder.ACTION_WITH_LABEL, getTitle());
- }
-
- @Override
- public Class getBackgroundWorkerClass() {
- return AirplaneSafeNetworksWorker.class;
- }
-
- public static class AirplaneSafeNetworksWorker extends SliceBackgroundWorker {
-
- private final IntentFilter mIntentFilter;
- private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {
- notifySliceChange();
- }
- }
- };
-
- public AirplaneSafeNetworksWorker(Context context, Uri uri) {
- super(context, uri);
- mIntentFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
- }
-
- @Override
- protected void onSlicePinned() {
- getContext().registerReceiver(mBroadcastReceiver, mIntentFilter);
- }
-
- @Override
- protected void onSliceUnpinned() {
- getContext().unregisterReceiver(mBroadcastReceiver);
- }
-
- @Override
- public void close() {
- // Do nothing.
- }
-
- public void updateSlice() {
- notifySliceChange();
- }
- }
-}
diff --git a/src/com/android/settings/network/AllowedNetworkTypesListener.java b/src/com/android/settings/network/AllowedNetworkTypesListener.java
index a9ed8be..ecc1d9c 100644
--- a/src/com/android/settings/network/AllowedNetworkTypesListener.java
+++ b/src/com/android/settings/network/AllowedNetworkTypesListener.java
@@ -24,7 +24,6 @@
import androidx.annotation.VisibleForTesting;
-import java.util.Map;
import java.util.concurrent.Executor;
@@ -72,9 +71,10 @@
}
@Override
- public void onAllowedNetworkTypesChanged(Map<Integer, Long> allowedNetworkTypesList) {
- long newAllowedNetworkType = allowedNetworkTypesList.get(
- TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER);
+ public void onAllowedNetworkTypesChanged(int reason, long newAllowedNetworkType) {
+ if (reason != TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER) {
+ return;
+ }
if (mListener != null && mAllowedNetworkType != newAllowedNetworkType) {
mListener.onAllowedNetworkTypesChanged();
Log.d(LOG_TAG, "onAllowedNetworkChanged: " + mAllowedNetworkType);
diff --git a/src/com/android/settings/network/InternetPreferenceController.java b/src/com/android/settings/network/InternetPreferenceController.java
index 2fe9c0a..f64ed30 100644
--- a/src/com/android/settings/network/InternetPreferenceController.java
+++ b/src/com/android/settings/network/InternetPreferenceController.java
@@ -124,12 +124,6 @@
return;
}
- if (mInternetType == INTERNET_NETWORKS_AVAILABLE
- && mInternetUpdater.isApmNetworksAvailable()) {
- mPreference.setSummary(R.string.airplane_mode_network_available);
- return;
- }
-
final @IdRes int summary = sSummaryMap.get(mInternetType);
if (summary != 0) {
mPreference.setSummary(summary);
diff --git a/src/com/android/settings/network/InternetUpdater.java b/src/com/android/settings/network/InternetUpdater.java
index 3bd1e7b..2f704e7 100644
--- a/src/com/android/settings/network/InternetUpdater.java
+++ b/src/com/android/settings/network/InternetUpdater.java
@@ -73,9 +73,9 @@
default void onAirplaneModeChanged(boolean isAirplaneModeOn) {};
/**
- * Called when airplane mode networks state is changed.
+ * Called when Wi-Fi enabled is changed.
*/
- default void onAirplaneModeNetworksChanged(boolean available) {};
+ default void onWifiEnabledChanged(boolean enabled) {};
}
/**
@@ -157,9 +157,8 @@
@Override
public void onReceive(Context context, Intent intent) {
fetchActiveNetwork();
- if (mListener != null && mAirplaneModeEnabler.isAirplaneModeOn()) {
- mListener.onAirplaneModeNetworksChanged(
- mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED);
+ if (mListener != null) {
+ mListener.onWifiEnabledChanged(mWifiManager.isWifiEnabled());
}
}
};
@@ -272,10 +271,9 @@
}
/**
- * Return ture when the APM networks is available.
+ * Return ture when the Wi-Fi is enabled.
*/
- public boolean isApmNetworksAvailable() {
- return mAirplaneModeEnabler.isAirplaneModeOn()
- && (mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED);
+ public boolean isWifiEnabled() {
+ return mWifiManager.isWifiEnabled();
}
}
diff --git a/src/com/android/settings/network/NetworkProviderSettings.java b/src/com/android/settings/network/NetworkProviderSettings.java
index 4d6849b..803b981 100644
--- a/src/com/android/settings/network/NetworkProviderSettings.java
+++ b/src/com/android/settings/network/NetworkProviderSettings.java
@@ -55,6 +55,7 @@
import androidx.preference.PreferenceScreen;
import androidx.recyclerview.widget.RecyclerView;
+import com.android.settings.AirplaneModeEnabler;
import com.android.settings.R;
import com.android.settings.RestrictedSettingsFragment;
import com.android.settings.core.FeatureFlags;
@@ -98,7 +99,8 @@
public class NetworkProviderSettings extends RestrictedSettingsFragment
implements Indexable, WifiPickerTracker.WifiPickerTrackerCallback,
WifiDialog2.WifiDialog2Listener, DialogInterface.OnDismissListener,
- ConnectivitySubsystemsRecoveryManager.RecoveryStatusCallback {
+ ConnectivitySubsystemsRecoveryManager.RecoveryStatusCallback,
+ AirplaneModeEnabler.OnAirplaneModeChangedListener {
public static final String ACTION_NETWORK_PROVIDER_SETTINGS =
"android.settings.NETWORK_PROVIDER_SETTINGS";
@@ -118,6 +120,7 @@
static final int CONFIG_NETWORK_REQUEST = 3;
static final int MANAGE_SUBSCRIPTION = 4;
+ private static final String PREF_KEY_AIRPLANE_MODE_MSG = "airplane_mode_message";
private static final String PREF_KEY_EMPTY_WIFI_LIST = "wifi_empty_list";
// TODO(b/70983952): Rename these to use WifiEntry instead of AccessPoint.
private static final String PREF_KEY_CONNECTED_ACCESS_POINTS = "connected_access_point";
@@ -185,6 +188,8 @@
private boolean mIsRestricted;
@VisibleForTesting
+ AirplaneModeEnabler mAirplaneModeEnabler;
+ @VisibleForTesting
WifiPickerTracker mWifiPickerTracker;
private WifiPickerTrackerHelper mWifiPickerTrackerHelper;
@@ -204,8 +209,7 @@
@VisibleForTesting
DataUsagePreference mDataUsagePreference;
@VisibleForTesting
- ViewAirplaneModeNetworksLayoutPreferenceController
- mViewAirplaneModeNetworksButtonPreference;
+ Preference mAirplaneModeMsgPreference;
@VisibleForTesting
LayoutPreference mResetInternetPreference;
@VisibleForTesting
@@ -241,6 +245,7 @@
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
+ mAirplaneModeEnabler = new AirplaneModeEnabler(getContext(), this);
// TODO(b/37429702): Add animations and preference comparator back after initial screen is
// loaded (ODR).
@@ -254,6 +259,8 @@
private void addPreferences() {
addPreferencesFromResource(R.xml.network_provider_settings);
+ mAirplaneModeMsgPreference = findPreference(PREF_KEY_AIRPLANE_MODE_MSG);
+ updateAirplaneModeMsgPreference(mAirplaneModeEnabler.isAirplaneModeOn() /* visible */);
mConnectedWifiEntryPreferenceCategory = findPreference(PREF_KEY_CONNECTED_ACCESS_POINTS);
mWifiEntryPreferenceCategory = findPreference(PREF_KEY_ACCESS_POINTS);
mConfigureWifiSettingsPreference = findPreference(PREF_KEY_CONFIGURE_WIFI_SETTINGS);
@@ -269,11 +276,16 @@
mResetInternetPreference.setVisible(false);
}
addNetworkMobileProviderController();
- addViewAirplaneModeNetworksButtonController();
addConnectedEthernetNetworkController();
addWifiSwitchPreferenceController();
}
+ private void updateAirplaneModeMsgPreference(boolean visible) {
+ if (mAirplaneModeMsgPreference != null) {
+ mAirplaneModeMsgPreference.setVisible(visible);
+ }
+ }
+
private void addNetworkMobileProviderController() {
if (mNetworkMobileProviderController == null) {
mNetworkMobileProviderController = new NetworkMobileProviderController(
@@ -283,15 +295,6 @@
mNetworkMobileProviderController.displayPreference(getPreferenceScreen());
}
- private void addViewAirplaneModeNetworksButtonController() {
- if (mViewAirplaneModeNetworksButtonPreference == null) {
- mViewAirplaneModeNetworksButtonPreference =
- new ViewAirplaneModeNetworksLayoutPreferenceController(
- getContext(), getSettingsLifecycle());
- }
- mViewAirplaneModeNetworksButtonPreference.displayPreference(getPreferenceScreen());
- }
-
private void addConnectedEthernetNetworkController() {
if (mConnectedEthernetNetworkController == null) {
mConnectedEthernetNetworkController =
@@ -386,10 +389,11 @@
@Override
public void onStart() {
super.onStart();
-
if (mIsRestricted) {
restrictUi();
+ return;
}
+ mAirplaneModeEnabler.start();
}
private void restrictUi() {
@@ -419,6 +423,7 @@
public void onStop() {
getView().removeCallbacks(mUpdateWifiEntryPreferencesRunnable);
getView().removeCallbacks(mHideProgressBarRunnable);
+ mAirplaneModeEnabler.stop();
super.onStop();
}
@@ -1188,9 +1193,7 @@
if (mResetInternetPreference != null) {
mResetInternetPreference.setVisible(true);
}
- if (mViewAirplaneModeNetworksButtonPreference != null) {
- mViewAirplaneModeNetworksButtonPreference.setVisible(false);
- }
+ updateAirplaneModeMsgPreference(false /* visible */);
}
/**
@@ -1200,9 +1203,18 @@
if (mResetInternetPreference != null) {
mResetInternetPreference.setVisible(false);
}
- if (mViewAirplaneModeNetworksButtonPreference != null
- && mViewAirplaneModeNetworksButtonPreference.isAvailable()) {
- mViewAirplaneModeNetworksButtonPreference.setVisible(true);
+ if (mAirplaneModeEnabler.isAirplaneModeOn()) {
+ updateAirplaneModeMsgPreference(true /* visible */);
}
}
+
+ /**
+ * Called when airplane mode status is changed.
+ *
+ * @param isAirplaneModeOn The airplane mode is on
+ */
+ @Override
+ public void onAirplaneModeChanged(boolean isAirplaneModeOn) {
+ updateAirplaneModeMsgPreference(isAirplaneModeOn /* visible */);
+ }
}
diff --git a/src/com/android/settings/network/TurnOnWifiSlice.java b/src/com/android/settings/network/TurnOnWifiSlice.java
new file mode 100644
index 0000000..05a873f
--- /dev/null
+++ b/src/com/android/settings/network/TurnOnWifiSlice.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2021 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.network;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
+import android.net.Uri;
+import android.net.wifi.WifiManager;
+import android.util.Log;
+
+import androidx.core.graphics.drawable.IconCompat;
+import androidx.slice.Slice;
+import androidx.slice.builders.ListBuilder;
+import androidx.slice.builders.ListBuilder.RowBuilder;
+import androidx.slice.builders.SliceAction;
+import androidx.slice.core.SliceHints;
+
+import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.slices.CustomSliceRegistry;
+import com.android.settings.slices.CustomSliceable;
+import com.android.settings.slices.SliceBackgroundWorker;
+import com.android.settings.slices.SliceBroadcastReceiver;
+
+/**
+ * {@link CustomSliceable} for turning on Wi-Fi, used by generic clients.
+ */
+public class TurnOnWifiSlice implements CustomSliceable {
+
+ private static final String TAG = "TurnOnWifiSlice";
+
+ private final Context mContext;
+ private final WifiManager mWifiManager;
+
+ public TurnOnWifiSlice(Context context) {
+ mContext = context;
+ mWifiManager = mContext.getSystemService(WifiManager.class);
+ }
+
+ private static void logd(String s) {
+ Log.d(TAG, s);
+ }
+
+ @Override
+ public Slice getSlice() {
+ if (mWifiManager.isWifiEnabled()) {
+ return null;
+ }
+ final String title = mContext.getText(R.string.turn_on_wifi).toString();
+ final SliceAction primaryAction = SliceAction.create(getBroadcastIntent(mContext),
+ getEndIcon(), ListBuilder.ICON_IMAGE, title);
+ final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY)
+ .addRow(new RowBuilder()
+ .setTitle(title)
+ .addEndItem(getEndIcon(), SliceHints.ICON_IMAGE)
+ .setPrimaryAction(primaryAction));
+ return listBuilder.build();
+ }
+
+ @Override
+ public Uri getUri() {
+ return CustomSliceRegistry.TURN_ON_WIFI_SLICE_URI;
+ }
+
+ @Override
+ public void onNotifyChange(Intent intent) {
+ logd("Action: turn on Wi-Fi networks");
+ mWifiManager.setWifiEnabled(true);
+ }
+
+ @Override
+ public Intent getIntent() {
+ return new Intent(getUri().toString())
+ .setData(getUri())
+ .setClass(mContext, SliceBroadcastReceiver.class);
+ }
+
+ private IconCompat getEndIcon() {
+ final Drawable drawable = mContext.getDrawable(R.drawable.ic_settings_wireless);
+ if (drawable == null) {
+ return Utils.createIconWithDrawable(new ColorDrawable(Color.TRANSPARENT));
+ }
+ drawable.setTintList(Utils.getColorAttr(mContext, android.R.attr.colorAccent));
+ return Utils.createIconWithDrawable(drawable);
+ }
+
+ @Override
+ public Class getBackgroundWorkerClass() {
+ return TurnOnWifiWorker.class;
+ }
+
+ /**
+ * The Slice background worker {@link SliceBackgroundWorker} is used to listen the Wi-Fi
+ * status change, and then notifies the Slice {@link Uri} to update.
+ */
+ public static class TurnOnWifiWorker extends SliceBackgroundWorker {
+
+ private final IntentFilter mIntentFilter;
+ private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {
+ notifySliceChange();
+ }
+ }
+ };
+
+ public TurnOnWifiWorker(Context context, Uri uri) {
+ super(context, uri);
+ mIntentFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
+ }
+
+ @Override
+ protected void onSlicePinned() {
+ getContext().registerReceiver(mBroadcastReceiver, mIntentFilter);
+ }
+
+ @Override
+ protected void onSliceUnpinned() {
+ getContext().unregisterReceiver(mBroadcastReceiver);
+ }
+
+ @Override
+ public void close() {
+ // Do nothing.
+ }
+ }
+}
diff --git a/src/com/android/settings/network/ViewAirplaneModeNetworksLayoutPreferenceController.java b/src/com/android/settings/network/ViewAirplaneModeNetworksLayoutPreferenceController.java
deleted file mode 100644
index 923e773..0000000
--- a/src/com/android/settings/network/ViewAirplaneModeNetworksLayoutPreferenceController.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2021 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.network;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.net.wifi.WifiManager;
-import android.view.View;
-import android.widget.Button;
-import android.widget.TextView;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.lifecycle.Lifecycle;
-import androidx.lifecycle.LifecycleObserver;
-import androidx.lifecycle.OnLifecycleEvent;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.AirplaneModeEnabler;
-import com.android.settings.R;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.widget.LayoutPreference;
-
-/**
- * This controls the airplane mode message and click button of the "View airplane mode networks"
- * item on the Network & internet page.
- */
-public class ViewAirplaneModeNetworksLayoutPreferenceController extends AbstractPreferenceController
- implements LifecycleObserver, AirplaneModeEnabler.OnAirplaneModeChangedListener,
- View.OnClickListener {
-
- public static final String KEY = "view_airplane_mode_netwokrs_button";
-
- private LayoutPreference mPreference;
- @VisibleForTesting
- TextView mTextView;
- @VisibleForTesting
- Button mButton;
-
- private AirplaneModeEnabler mAirplaneModeEnabler;
- private final WifiManager mWifiManager;
- private final IntentFilter mIntentFilter;
- private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {
- refreshLayout();
- }
- }
- };
-
- public ViewAirplaneModeNetworksLayoutPreferenceController(Context context,
- Lifecycle lifecycle) {
- super(context);
- if (lifecycle == null) {
- throw new IllegalArgumentException("Lifecycle must be set");
- }
- mAirplaneModeEnabler = new AirplaneModeEnabler(context, this);
- mWifiManager = context.getSystemService(WifiManager.class);
- mIntentFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
- lifecycle.addObserver(this);
- }
-
- @Override
- public boolean isAvailable() {
- return mAirplaneModeEnabler.isAirplaneModeOn();
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY;
- }
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- mPreference = screen.findPreference(getPreferenceKey());
- generateLayout();
- }
-
- /** Lifecycle.Event.ON_START */
- @OnLifecycleEvent(Lifecycle.Event.ON_START)
- public void onStart() {
- mAirplaneModeEnabler.start();
- }
-
- /** Lifecycle.Event.ON_STOP */
- @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
- public void onStop() {
- mAirplaneModeEnabler.stop();
- }
-
- /** Lifecycle.Event.ON_RESUME */
- @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
- public void onResume() {
- mContext.registerReceiver(mBroadcastReceiver, mIntentFilter);
- }
-
- /** Lifecycle.Event.ON_PAUSE */
- @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
- public void onPause() {
- mContext.unregisterReceiver(mBroadcastReceiver);
- }
-
- @Override
- public void onAirplaneModeChanged(boolean isAirplaneModeOn) {
- if (mPreference != null) {
- mPreference.setVisible(isAirplaneModeOn);
- }
- }
-
- @Override
- public void onClick(View v) {
- mWifiManager.setWifiEnabled(true);
- }
-
- private void generateLayout() {
- if (mPreference == null) {
- return;
- }
- if (mTextView == null) {
- mTextView = mPreference.findViewById(R.id.airplane_mode_text);
- }
- if (mButton == null) {
- mButton = mPreference.findViewById(R.id.view_airplane_mode_networks_button);
- }
- if (mButton != null) {
- mButton.setOnClickListener(this);
- }
- refreshLayout();
- }
-
- @VisibleForTesting
- void refreshLayout() {
- boolean isWifiEnabled = mWifiManager.isWifiEnabled();
- if (mTextView != null) {
- mTextView.setText(isWifiEnabled ? R.string.viewing_airplane_mode_networks
- : R.string.condition_airplane_title);
- }
- if (mButton != null) {
- mButton.setVisibility(isWifiEnabled ? View.GONE : View.VISIBLE);
- }
- }
-
- /**
- * Sets the visibility of the preference.
- */
- public void setVisible(boolean visible) {
- if (mPreference != null) {
- mPreference.setVisible(visible);
- }
- }
-}
diff --git a/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java b/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java
index 8d037fb..d00efc7 100644
--- a/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java
@@ -106,7 +106,7 @@
return false;
}
try {
- return imsMmTelMgr.isCrossSimCallingEnabledByUser();
+ return imsMmTelMgr.isCrossSimCallingEnabled();
} catch (ImsException exception) {
Log.w(LOG_TAG, "fail to get cross SIM calling configuration", exception);
}
diff --git a/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroup.java b/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroup.java
index 44fd029..c16dbc9 100644
--- a/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroup.java
+++ b/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroup.java
@@ -217,7 +217,12 @@
pref.setEnabled(getTelephonyManagerForSubscriptionId(subId).getCallState()
== TelephonyManager.CALL_STATE_IDLE);
pref.setOrder(order++);
- pref.setSummary(R.string.calls_sms_wfc_summary);
+
+ int resId = com.android.internal.R.string.wifi_calling_off_summary;
+ if (queryImsState(subId).isEnabledByUser()) {
+ resId = R.string.calls_sms_wfc_summary;
+ }
+ pref.setSummary(resId);
mWifiCallingForSubPreferences.put(subId, pref);
}
diff --git a/src/com/android/settings/notification/app/ChannelNotificationSettings.java b/src/com/android/settings/notification/app/ChannelNotificationSettings.java
index bdea30d..296863c 100644
--- a/src/com/android/settings/notification/app/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/app/ChannelNotificationSettings.java
@@ -68,12 +68,16 @@
if (mChannel != null && !TextUtils.isEmpty(mChannel.getConversationId())
&& !mChannel.isDemoted()) {
- startActivity(new SubSettingLauncher(mContext)
+ Intent intent = new SubSettingLauncher(mContext)
.setDestination(ConversationNotificationSettings.class.getName())
.setArguments(getArguments())
.setExtras(getIntent() != null ? getIntent().getExtras(): null)
.setSourceMetricsCategory(SettingsEnums.NOTIFICATION_TOPIC_NOTIFICATION)
- .toIntent());
+ .toIntent();
+ if (mPreferenceFilter != null) {
+ intent.setClass(mContext, ChannelPanelActivity.class);
+ }
+ startActivity(intent);
finish();
return;
}
@@ -84,6 +88,7 @@
controller.displayPreference(getPreferenceScreen());
}
updatePreferenceStates();
+ animatePanel();
}
@Override
diff --git a/src/com/android/settings/notification/app/ChannelPanelActivity.java b/src/com/android/settings/notification/app/ChannelPanelActivity.java
new file mode 100644
index 0000000..3ba118e
--- /dev/null
+++ b/src/com/android/settings/notification/app/ChannelPanelActivity.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2021 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.app;
+
+import android.app.settings.SettingsEnums;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.Window;
+import android.view.WindowManager;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.FragmentActivity;
+import androidx.fragment.app.FragmentManager;
+
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.settings.R;
+import com.android.settings.core.HideNonSystemOverlayMixin;
+import com.android.settings.core.SubSettingLauncher;
+
+/**
+ * Dialog Activity to host channel settings
+ */
+public class ChannelPanelActivity extends FragmentActivity {
+
+ private static final String TAG = "ChannelPanelActivity";
+
+ final Bundle mBundle = new Bundle();
+ NotificationSettings mPanelFragment;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (!getIntent().hasExtra(Settings.EXTRA_CHANNEL_FILTER_LIST)) {
+ launchFullSettings();
+ }
+
+ getApplicationContext().getTheme().rebase();
+ createOrUpdatePanel();
+ getLifecycle().addObserver(new HideNonSystemOverlayMixin(this));
+ }
+
+ @Override
+ protected void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+ setIntent(intent);
+ createOrUpdatePanel();
+ }
+
+ @Override
+ public void onConfigurationChanged(@NonNull Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ }
+
+ private void launchFullSettings() {
+ Bundle extras = getIntent().getExtras();
+ extras.remove(Settings.EXTRA_CHANNEL_FILTER_LIST);
+ startActivity(new SubSettingLauncher(this)
+ .setDestination(ChannelNotificationSettings.class.getName())
+ .setExtras(extras)
+ .setSourceMetricsCategory(SettingsEnums.NOTIFICATION_TOPIC_NOTIFICATION)
+ .toIntent());
+ finish();
+ }
+
+ private void createOrUpdatePanel() {
+ final Intent callingIntent = getIntent();
+ if (callingIntent == null) {
+ Log.e(TAG, "Null intent, closing Panel Activity");
+ finish();
+ return;
+ }
+
+ final FragmentManager fragmentManager = getSupportFragmentManager();
+ setContentView(R.layout.notification_channel_panel);
+
+ // Move the window to the bottom of screen, and make it take up the entire screen width.
+ final Window window = getWindow();
+ window.setGravity(Gravity.BOTTOM);
+ window.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
+ WindowManager.LayoutParams.WRAP_CONTENT);
+
+ findViewById(R.id.done).setOnClickListener(v -> finish());
+ findViewById(R.id.see_more).setOnClickListener(v -> launchFullSettings());
+
+ mPanelFragment = callingIntent.hasExtra(Settings.EXTRA_CONVERSATION_ID)
+ ? new ConversationNotificationSettings()
+ : new ChannelNotificationSettings();
+ mPanelFragment.setArguments(new Bundle(mBundle));
+ fragmentManager.beginTransaction().replace(
+ android.R.id.list_container, mPanelFragment).commit();
+ }
+}
diff --git a/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
index 313b387..73659b8 100644
--- a/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
@@ -93,6 +93,7 @@
.done(activity, mContext);
pref.findViewById(R.id.entity_header).setVisibility(View.VISIBLE);
+ pref.findViewById(R.id.entity_header).setBackground(null);
}
}
diff --git a/src/com/android/settings/notification/app/ConversationNotificationSettings.java b/src/com/android/settings/notification/app/ConversationNotificationSettings.java
index 819ba83..d712c84 100644
--- a/src/com/android/settings/notification/app/ConversationNotificationSettings.java
+++ b/src/com/android/settings/notification/app/ConversationNotificationSettings.java
@@ -49,10 +49,11 @@
for (NotificationPreferenceController controller : mControllers) {
controller.onResume(mAppRow, mChannel, mChannelGroup, mConversationDrawable,
- mConversationInfo, mSuspendedAppsAdmin, null);
+ mConversationInfo, mSuspendedAppsAdmin, mPreferenceFilter);
controller.displayPreference(getPreferenceScreen());
}
updatePreferenceStates();
+ animatePanel();
}
@Override
diff --git a/src/com/android/settings/notification/app/HeaderPreferenceController.java b/src/com/android/settings/notification/app/HeaderPreferenceController.java
index 6482943..4e9c039 100644
--- a/src/com/android/settings/notification/app/HeaderPreferenceController.java
+++ b/src/com/android/settings/notification/app/HeaderPreferenceController.java
@@ -92,6 +92,7 @@
.setRecyclerView(mFragment.getListView(), mFragment.getSettingsLifecycle())
.done(activity, mContext);
pref.findViewById(R.id.entity_header).setVisibility(View.VISIBLE);
+ pref.findViewById(R.id.entity_header).setBackground(null);
}
}
diff --git a/src/com/android/settings/notification/app/NotificationSettings.java b/src/com/android/settings/notification/app/NotificationSettings.java
index 44c735a..99f067d 100644
--- a/src/com/android/settings/notification/app/NotificationSettings.java
+++ b/src/com/android/settings/notification/app/NotificationSettings.java
@@ -18,6 +18,9 @@
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
+import android.animation.ValueAnimator;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
@@ -39,8 +42,13 @@
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
+import android.view.animation.DecelerateInterpolator;
import android.widget.Toast;
+import androidx.annotation.NonNull;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
@@ -85,6 +93,20 @@
protected Intent mIntent;
protected Bundle mArgs;
+ private ViewGroup mLayoutView;
+ private static final int DURATION_ANIMATE_PANEL_EXPAND_MS = 250;
+
+ private final ViewTreeObserver.OnGlobalLayoutListener mOnGlobalLayoutListener =
+ new ViewTreeObserver.OnGlobalLayoutListener() {
+ @Override
+ public void onGlobalLayout() {
+ animateIn();
+ if (mLayoutView != null) {
+ mLayoutView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
+ }
+ }
+ };
+
@Override
public void onAttach(Context context) {
super.onAttach(context);
@@ -187,6 +209,50 @@
collectConfigActivities();
}
+ protected void animatePanel() {
+ if (mPreferenceFilter != null) {
+ mLayoutView = getActivity().findViewById(R.id.main_content);
+ mLayoutView.getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener);
+ }
+ }
+
+ /**
+ * Animate a Panel onto the screen.
+ * <p>
+ * Takes the entire panel and animates in from behind the navigation bar.
+ * <p>
+ * Relies on the Panel being having a fixed height to begin the animation.
+ */
+ private void animateIn() {
+ final AnimatorSet animatorSet = buildAnimatorSet(mLayoutView,
+ mLayoutView.getHeight() /* startY */, 0.0f /* endY */,
+ 0.0f /* startAlpha */, 1.0f /* endAlpha */,
+ DURATION_ANIMATE_PANEL_EXPAND_MS);
+ final ValueAnimator animator = new ValueAnimator();
+ animator.setFloatValues(0.0f, 1.0f);
+ animatorSet.play(animator);
+ animatorSet.start();
+ }
+
+ /**
+ * Build an {@link AnimatorSet} to animate the Panel, {@param parentView} in or out of the
+ * screen, based on the positional parameters {@param startY}, {@param endY}, the parameters
+ * for alpha changes {@param startAlpha}, {@param endAlpha}, and the {@param duration} in
+ * milliseconds.
+ */
+ @NonNull
+ private static AnimatorSet buildAnimatorSet(@NonNull View targetView,
+ float startY, float endY,
+ float startAlpha, float endAlpha, int duration) {
+ final AnimatorSet animatorSet = new AnimatorSet();
+ animatorSet.setDuration(duration);
+ animatorSet.setInterpolator(new DecelerateInterpolator());
+ animatorSet.playTogether(
+ ObjectAnimator.ofFloat(targetView, View.TRANSLATION_Y, startY, endY),
+ ObjectAnimator.ofFloat(targetView, View.ALPHA, startAlpha, endAlpha));
+ return animatorSet;
+ }
+
private void loadPreferencesFilter() {
Intent intent = getActivity().getIntent();
mPreferenceFilter = intent != null
diff --git a/src/com/android/settings/panel/InternetConnectivityPanel.java b/src/com/android/settings/panel/InternetConnectivityPanel.java
index bdaa849..4fda0a4 100644
--- a/src/com/android/settings/panel/InternetConnectivityPanel.java
+++ b/src/com/android/settings/panel/InternetConnectivityPanel.java
@@ -50,9 +50,8 @@
@VisibleForTesting
boolean mIsProviderModelEnabled;
private PanelContentCallback mCallback;
- private InternetUpdater mInternetUpdater;
- private boolean mIsAirplaneModeOn;
- private boolean mIsApmNetworksAvailable;
+ @VisibleForTesting
+ InternetUpdater mInternetUpdater;
public static InternetConnectivityPanel create(Context context) {
return new InternetConnectivityPanel(context);
@@ -62,8 +61,6 @@
mContext = context.getApplicationContext();
mIsProviderModelEnabled = Utils.isProviderModelEnabled(mContext);
mInternetUpdater = new InternetUpdater(context, null /* Lifecycle */, this);
- mIsAirplaneModeOn = mInternetUpdater.isAirplaneModeOn();
- mIsApmNetworksAvailable = mInternetUpdater.isApmNetworksAvailable();
}
/** @OnLifecycleEvent(ON_RESUME) */
@@ -90,9 +87,8 @@
@Override
public CharSequence getTitle() {
if (mIsProviderModelEnabled) {
- return mContext.getText(mIsApmNetworksAvailable
- ? R.string.airplane_mode_network_panel_title
- : R.string.provider_internet_settings);
+ return mContext.getText(mInternetUpdater.isAirplaneModeOn()
+ ? R.string.airplane_mode : R.string.provider_internet_settings);
}
return mContext.getText(R.string.internet_connectivity_panel_title);
}
@@ -102,8 +98,9 @@
*/
@Override
public CharSequence getSubTitle() {
- if (mIsProviderModelEnabled && mIsAirplaneModeOn && !mIsApmNetworksAvailable) {
- return mContext.getText(R.string.condition_airplane_title);
+ if (mIsProviderModelEnabled && mInternetUpdater.isAirplaneModeOn()
+ && mInternetUpdater.isWifiEnabled()) {
+ return mContext.getText(R.string.wifi_is_turned_on_subtitle);
}
return null;
}
@@ -113,7 +110,7 @@
final List<Uri> uris = new ArrayList<>();
if (mIsProviderModelEnabled) {
uris.add(CustomSliceRegistry.PROVIDER_MODEL_SLICE_URI);
- uris.add(CustomSliceRegistry.AIRPLANE_SAFE_NETWORKS_SLICE_URI);
+ uris.add(CustomSliceRegistry.TURN_ON_WIFI_SLICE_URI);
} else {
uris.add(CustomSliceRegistry.WIFI_SLICE_URI);
uris.add(CustomSliceRegistry.MOBILE_DATA_SLICE_URI);
@@ -136,7 +133,7 @@
@Override
public CharSequence getCustomizedButtonTitle() {
- if (mIsAirplaneModeOn && !mIsApmNetworksAvailable) {
+ if (mInternetUpdater.isAirplaneModeOn() && !mInternetUpdater.isWifiEnabled()) {
return null;
}
return mContext.getText(R.string.settings_button);
@@ -162,19 +159,14 @@
*/
@Override
public void onAirplaneModeChanged(boolean isAirplaneModeOn) {
- if (!isAirplaneModeOn) {
- mIsApmNetworksAvailable = false;
- }
- mIsAirplaneModeOn = isAirplaneModeOn;
updatePanelTitle();
}
/**
- * Called when airplane mode networks state is changed.
+ * Called when Wi-Fi enabled is changed.
*/
@Override
- public void onAirplaneModeNetworksChanged(boolean available) {
- mIsApmNetworksAvailable = available;
+ public void onWifiEnabledChanged(boolean enabled) {
updatePanelTitle();
}
@@ -183,16 +175,14 @@
return;
}
- if (mIsAirplaneModeOn && !mIsApmNetworksAvailable) {
- // When the airplane mode is on.
- // Title: Internet
- // Sub-Title: Airplane mode is on
- // Settings button: Hide
+ if (mInternetUpdater.isAirplaneModeOn() && mInternetUpdater.isWifiEnabled()) {
+ // When the airplane mode is on and Wi-Fi is enabled.
+ // Title: Airplane mode
+ // Sub-Title: Wi-Fi is turned on
mCallback.onHeaderChanged();
} else {
- // Except for airplane mode on.
- // Title: Airplane mode networks / Internet
- // Settings button: Show
+ // Other situations.
+ // Title: Airplane mode / Internet
mCallback.onTitleChanged();
}
mCallback.onCustomizedButtonStateChanged();
diff --git a/src/com/android/settings/slices/CustomSliceRegistry.java b/src/com/android/settings/slices/CustomSliceRegistry.java
index e40b164..713d61a 100644
--- a/src/com/android/settings/slices/CustomSliceRegistry.java
+++ b/src/com/android/settings/slices/CustomSliceRegistry.java
@@ -39,8 +39,8 @@
import com.android.settings.location.LocationSlice;
import com.android.settings.media.MediaOutputIndicatorSlice;
import com.android.settings.media.RemoteMediaSlice;
-import com.android.settings.network.AirplaneSafeNetworksSlice;
import com.android.settings.network.ProviderModelSlice;
+import com.android.settings.network.TurnOnWifiSlice;
import com.android.settings.network.telephony.MobileDataSlice;
import com.android.settings.notification.zen.ZenModeButtonPreferenceController;
import com.android.settings.wifi.calling.WifiCallingSliceHelper;
@@ -307,13 +307,13 @@
.build();
/**
- * Backing Uri for the Always On Slice.
+ * Backing Uri for the Turn on Wi-Fi Slice.
*/
- public static final Uri AIRPLANE_SAFE_NETWORKS_SLICE_URI = new Uri.Builder()
+ public static final Uri TURN_ON_WIFI_SLICE_URI = new Uri.Builder()
.scheme(ContentResolver.SCHEME_CONTENT)
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
- .appendPath("airplane_safe_networks")
+ .appendPath("turn_on_wifi")
.build();
@VisibleForTesting
@@ -337,7 +337,7 @@
sUriToSlice.put(DARK_THEME_SLICE_URI, DarkThemeSlice.class);
sUriToSlice.put(REMOTE_MEDIA_SLICE_URI, RemoteMediaSlice.class);
sUriToSlice.put(ALWAYS_ON_SLICE_URI, AlwaysOnDisplaySlice.class);
- sUriToSlice.put(AIRPLANE_SAFE_NETWORKS_SLICE_URI, AirplaneSafeNetworksSlice.class);
+ sUriToSlice.put(TURN_ON_WIFI_SLICE_URI, TurnOnWifiSlice.class);
}
public static Class<? extends CustomSliceable> getSliceClassByUri(Uri uri) {
diff --git a/src/com/android/settings/widget/LabeledSeekBarPreference.java b/src/com/android/settings/widget/LabeledSeekBarPreference.java
index e2b2d68..3a9ac18 100644
--- a/src/com/android/settings/widget/LabeledSeekBarPreference.java
+++ b/src/com/android/settings/widget/LabeledSeekBarPreference.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.SeekBar;
import android.widget.TextView;
@@ -32,6 +33,7 @@
private final int mTextStartId;
private final int mTextEndId;
+ private final int mTickMarkId;
private OnPreferenceChangeListener mStopListener;
public LabeledSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
@@ -48,6 +50,8 @@
mTextEndId = styledAttrs.getResourceId(
R.styleable.LabeledSeekBarPreference_textEnd,
R.string.summary_placeholder);
+ mTickMarkId = styledAttrs.getResourceId(
+ R.styleable.LabeledSeekBarPreference_tickMark, /* defValue= */ 0);
styledAttrs.recycle();
}
@@ -65,6 +69,13 @@
final TextView endText = (TextView) holder.findViewById(android.R.id.text2);
startText.setText(mTextStartId);
endText.setText(mTextEndId);
+
+ if (mTickMarkId != 0) {
+ final Drawable tickMark = getContext().getDrawable(mTickMarkId);
+ final SeekBar seekBar = (SeekBar) holder.findViewById(
+ com.android.internal.R.id.seekbar);
+ seekBar.setTickMark(tickMark);
+ }
}
public void setOnPreferenceChangeStopListener(OnPreferenceChangeListener listener) {
diff --git a/tests/robotests/src/com/android/settings/datetime/LocationTimeZoneDetectionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datetime/LocationTimeZoneDetectionPreferenceControllerTest.java
index 0758869..ae200b9 100644
--- a/tests/robotests/src/com/android/settings/datetime/LocationTimeZoneDetectionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/LocationTimeZoneDetectionPreferenceControllerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2020 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.
@@ -23,6 +23,7 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.time.TimeManager;
@@ -62,9 +63,33 @@
}
@Test
+ public void setChecked_withTrue_shouldUpdateSetting() {
+ // Simulate the UI being clicked.
+ mController.setChecked(true);
+
+ // Verify the TimeManager was updated with the UI value.
+ TimeZoneConfiguration expectedConfiguration = new TimeZoneConfiguration.Builder()
+ .setGeoDetectionEnabled(true)
+ .build();
+ verify(mTimeManager).updateTimeZoneConfiguration(expectedConfiguration);
+ }
+
+ @Test
+ public void setChecked_withFalse_shouldUpdateSetting() {
+ // Simulate the UI being clicked.
+ mController.setChecked(false);
+
+ // Verify the TimeManager was updated with the UI value.
+ TimeZoneConfiguration expectedConfiguration = new TimeZoneConfiguration.Builder()
+ .setGeoDetectionEnabled(false)
+ .build();
+ verify(mTimeManager).updateTimeZoneConfiguration(expectedConfiguration);
+ }
+
+ @Test
public void testLocationTimeZoneDetection_supported_shouldBeShown() {
TimeZoneCapabilities capabilities =
- createTimeZoneCapabilities(/* geoDetectionSupported= */ true);
+ createTimeZoneCapabilities(CAPABILITY_POSSESSED);
TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true);
TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
@@ -76,7 +101,7 @@
@Test
public void testLocationTimeZoneDetection_unsupported_shouldNotBeShown() {
TimeZoneCapabilities capabilities =
- createTimeZoneCapabilities(/* geoDetectionSupported= */ false);
+ createTimeZoneCapabilities(CAPABILITY_NOT_SUPPORTED);
TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true);
TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
@@ -91,20 +116,34 @@
@Test
public void testLocationTimeZoneDetection_summary_geoDetectionEnabled() {
TimeZoneCapabilities capabilities =
- createTimeZoneCapabilities(/* geoDetectionSupported= */ true);
+ createTimeZoneCapabilities(CAPABILITY_POSSESSED);
TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true);
TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
when(mTimeManager.getTimeZoneCapabilitiesAndConfig()).thenReturn(capabilitiesAndConfig);
- assertThat(mController.getSummary()).isEqualTo(
- mContext.getString(R.string.location_time_zone_detection_on));
+ assertThat(mController.getSummary().toString()).isEmpty();
}
- private static TimeZoneCapabilities createTimeZoneCapabilities(boolean geoDetectionSupported) {
+ @Test
+ public void testLocationTimeZoneDetection_toggleIsOn_whenGeoDetectionEnabledAnsMlsIsOff() {
+ TimeZoneCapabilities capabilities =
+ createTimeZoneCapabilities(CAPABILITY_NOT_APPLICABLE);
+ TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true);
+ TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
+ new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
+
+ when(mTimeManager.getTimeZoneCapabilitiesAndConfig()).thenReturn(capabilitiesAndConfig);
+ when(mLocationManager.isLocationEnabled()).thenReturn(false);
+
+ assertThat(mController.isChecked()).isTrue();
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getString(R.string.location_app_permission_summary_location_off));
+ }
+
+ private static TimeZoneCapabilities createTimeZoneCapabilities(
+ @TimeZoneCapabilities.CapabilityState int geoDetectionCapability) {
UserHandle arbitraryUserHandle = UserHandle.of(123);
- int geoDetectionCapability =
- geoDetectionSupported ? CAPABILITY_POSSESSED : CAPABILITY_NOT_SUPPORTED;
return new TimeZoneCapabilities.Builder(arbitraryUserHandle)
.setConfigureAutoDetectionEnabledCapability(CAPABILITY_POSSESSED)
.setConfigureGeoDetectionEnabledCapability(geoDetectionCapability)
diff --git a/tests/robotests/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionSettingsTest.java b/tests/robotests/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionSettingsTest.java
deleted file mode 100644
index 9f16492..0000000
--- a/tests/robotests/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionSettingsTest.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.datetime.locationtimezone;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.provider.SearchIndexableResource;
-
-import com.android.settings.R;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-import java.util.List;
-
-@RunWith(RobolectricTestRunner.class)
-public class TimeZoneDetectionSettingsTest {
-
- private Context mContext;
-
- @Before
- public void setUp() {
- mContext = RuntimeEnvironment.application;
- }
-
- @Test
- public void searchProvider_shouldIndexDefaultXml() {
- final List<SearchIndexableResource> sir =
- TimeZoneDetectionSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
- mContext, /* enabled= */ true);
-
- assertThat(sir).hasSize(1);
- assertThat(sir.get(0).xmlResId).isEqualTo(R.xml.location_time_zone_detection);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionTogglePreferenceControllerTest.java
deleted file mode 100644
index 27a9859..0000000
--- a/tests/robotests/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionTogglePreferenceControllerTest.java
+++ /dev/null
@@ -1,119 +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.datetime.locationtimezone;
-
-import static android.app.time.TimeZoneCapabilities.CAPABILITY_NOT_APPLICABLE;
-import static android.app.time.TimeZoneCapabilities.CAPABILITY_POSSESSED;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.time.TimeManager;
-import android.app.time.TimeZoneCapabilities;
-import android.app.time.TimeZoneCapabilitiesAndConfig;
-import android.app.time.TimeZoneConfiguration;
-import android.content.Context;
-import android.os.UserHandle;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-
-@RunWith(RobolectricTestRunner.class)
-public class TimeZoneDetectionTogglePreferenceControllerTest {
-
- private static final String PREF_KEY = "test_key";
-
- @Mock
- private Context mContext;
-
- @Mock
- private TimeManager mTimeManager;
- private TimeZoneDetectionTogglePreferenceController mController;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- when(mContext.getSystemService(TimeManager.class)).thenReturn(mTimeManager);
-
- mController = new TimeZoneDetectionTogglePreferenceController(mContext, PREF_KEY);
- }
-
- @Test
- public void isAvailable_shouldReturnTrue() {
- assertThat(mController.isAvailable()).isTrue();
- }
-
- @Test
- public void isChecked_whenEnabled_shouldReturnTrue() {
- when(mTimeManager.getTimeZoneCapabilitiesAndConfig())
- .thenReturn(createTimeZoneCapabilitiesAndConfig(true));
-
- assertThat(mController.isChecked()).isTrue();
- }
-
- @Test
- public void isChecked_whenDisabled_shouldReturnFalse() {
- when(mTimeManager.getTimeZoneCapabilitiesAndConfig())
- .thenReturn(createTimeZoneCapabilitiesAndConfig(false));
-
- assertThat(mController.isChecked()).isFalse();
- }
-
- @Test
- public void setChecked_withTrue_shouldUpdateSetting() {
- // Simulate the UI being clicked.
- mController.setChecked(true);
-
- // Verify the TimeManager was updated with the UI value.
- TimeZoneConfiguration expectedConfiguration = new TimeZoneConfiguration.Builder()
- .setGeoDetectionEnabled(true)
- .build();
- verify(mTimeManager).updateTimeZoneConfiguration(expectedConfiguration);
- }
-
- @Test
- public void setChecked_withFalse_shouldUpdateSetting() {
- // Simulate the UI being clicked.
- mController.setChecked(false);
-
- // Verify the TimeManager was updated with the UI value.
- TimeZoneConfiguration expectedConfiguration = new TimeZoneConfiguration.Builder()
- .setGeoDetectionEnabled(false)
- .build();
- verify(mTimeManager).updateTimeZoneConfiguration(expectedConfiguration);
- }
-
- private static TimeZoneCapabilitiesAndConfig createTimeZoneCapabilitiesAndConfig(
- boolean geoDetectionEnabled) {
- UserHandle arbitraryUserHandle = UserHandle.of(123);
- TimeZoneCapabilities capabilities = new TimeZoneCapabilities.Builder(arbitraryUserHandle)
- .setConfigureAutoDetectionEnabledCapability(CAPABILITY_POSSESSED)
- .setConfigureGeoDetectionEnabledCapability(CAPABILITY_POSSESSED)
- .setSuggestManualTimeZoneCapability(CAPABILITY_NOT_APPLICABLE)
- .build();
- TimeZoneConfiguration configuration = new TimeZoneConfiguration.Builder()
- .setAutoDetectionEnabled(true)
- .setGeoDetectionEnabled(geoDetectionEnabled)
- .build();
- return new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/emergency/EmergencyGestureEntrypointPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/emergency/EmergencyGestureEntrypointPreferenceControllerTest.java
index 65fa187..8d38509 100644
--- a/tests/robotests/src/com/android/settings/emergency/EmergencyGestureEntrypointPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/emergency/EmergencyGestureEntrypointPreferenceControllerTest.java
@@ -105,7 +105,7 @@
}
@Test
- public void getAvailabilityStatus_noSuitableIntent_shouldReturnUnsupported() {
+ public void getAvailabilityStatus_noSuitableIntent_shouldReturnAvailable() {
SettingsShadowResources.overrideResource(
R.bool.config_show_emergency_gesture_settings,
Boolean.TRUE);
@@ -117,7 +117,8 @@
EmergencyGestureEntrypointPreferenceController controller =
new EmergencyGestureEntrypointPreferenceController(mContext, PREF_KEY);
- assertThat(controller.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+ assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ assertThat(controller.mIntent).isNull();
}
private void prepareCustomIntent() {
diff --git a/tests/robotests/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelperTest.java b/tests/robotests/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelperTest.java
index 1ff1d79..b245017 100644
--- a/tests/robotests/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelperTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelperTest.java
@@ -195,6 +195,27 @@
}
@Test
+ public void testSetAdminSupportDetails_shortSupportMessageIsNull() {
+ final ShadowDevicePolicyManager dpmShadow = ShadowDevicePolicyManager.getShadow();
+ final UserManager userManager = RuntimeEnvironment.application.getSystemService(
+ UserManager.class);
+ final ShadowUserManager userManagerShadow = Shadow.extract(userManager);
+ final ViewGroup view = new FrameLayout(mActivity);
+ final ComponentName component = new ComponentName("some.package.name",
+ "some.package.name.SomeClass");
+ final EnforcedAdmin admin = new EnforcedAdmin(component, UserHandle.of(123));
+ final TextView textView = createAdminSupportTextView(view, mActivity);
+ dpmShadow.setShortSupportMessageForUser(component, 123, null);
+ dpmShadow.setIsAdminActiveAsUser(true);
+ createShadowWorkProfile(userManagerShadow);
+
+ mHelper.setAdminSupportDetails(mActivity, view, admin);
+
+ assertNotNull(admin.component);
+ assertEquals("", Shadows.shadowOf(textView).innerText());
+ }
+
+ @Test
public void testSetAdminSupportDetailsNotAdmin() {
final ShadowDevicePolicyManager dpmShadow = ShadowDevicePolicyManager.getShadow();
final UserManager userManager = RuntimeEnvironment.application.getSystemService(
@@ -212,27 +233,6 @@
mHelper.setAdminSupportDetails(mActivity, textView, admin);
assertNull(admin.component);
- assertEquals(mActivity.getString(R.string.default_admin_support_msg),
- Shadows.shadowOf(textView).innerText());
- }
-
- @Test
- public void testSetAdminSupportDetailsForFinancedDevice_shortSupportMessageIsNull() {
- final ShadowDevicePolicyManager dpmShadow = ShadowDevicePolicyManager.getShadow();
- final UserManager userManager = RuntimeEnvironment.application.getSystemService(
- UserManager.class);
- final ShadowUserManager userManagerShadow = Shadow.extract(userManager);
- final ViewGroup view = new FrameLayout(mActivity);
- final ComponentName component = new ComponentName("some.package.name",
- "some.package.name.SomeClass");
- final EnforcedAdmin admin = new EnforcedAdmin(component, UserHandle.of(123));
- final TextView textView = createAdminSupportTextView(view, mActivity);
- setupFinancedDevice(dpmShadow);
- createShadowWorkProfile(userManagerShadow);
-
- mHelper.setAdminSupportDetails(mActivity, view, admin);
-
- assertNotNull(admin.component);
assertEquals("", Shadows.shadowOf(textView).innerText());
}
diff --git a/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java b/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
index aa96666..d7c0ffe 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
@@ -54,6 +54,7 @@
import androidx.preference.PreferenceScreen;
import androidx.recyclerview.widget.RecyclerView;
+import com.android.settings.AirplaneModeEnabler;
import com.android.settings.R;
import com.android.settings.datausage.DataUsagePreference;
import com.android.settings.testutils.shadow.ShadowDataUsageUtils;
@@ -90,6 +91,8 @@
@Mock
private UserManager mUserManager;
@Mock
+ private AirplaneModeEnabler mAirplaneModeEnabler;
+ @Mock
private DataUsagePreference mDataUsagePreference;
private Context mContext;
private NetworkProviderSettings mNetworkProviderSettings;
@@ -100,8 +103,7 @@
@Mock
private ConnectivitySubsystemsRecoveryManager mConnectivitySubsystemsRecoveryManager;
@Mock
- private ViewAirplaneModeNetworksLayoutPreferenceController
- mViewAirplaneModeNetworksButtonPreference;
+ private Preference mAirplaneModeMsgPreference;
@Mock
private LayoutPreference mResetInternetPreference;
@Mock
@@ -126,6 +128,9 @@
new Preference(mContext);
mNetworkProviderSettings.mWifiPickerTracker = mMockWifiPickerTracker;
mNetworkProviderSettings.mWifiManager = mWifiManager;
+ mNetworkProviderSettings.mResetInternetPreference = mResetInternetPreference;
+ mNetworkProviderSettings.mAirplaneModeMsgPreference = mAirplaneModeMsgPreference;
+ mNetworkProviderSettings.mAirplaneModeEnabler = mAirplaneModeEnabler;
}
@Test
@@ -421,27 +426,35 @@
}
@Test
- public void onSubsystemRestartOperationBegin_showResetInternetHideApmNetworks() {
- mNetworkProviderSettings.mResetInternetPreference = mResetInternetPreference;
- mNetworkProviderSettings.mViewAirplaneModeNetworksButtonPreference =
- mViewAirplaneModeNetworksButtonPreference;
-
+ public void onSubsystemRestartOperationBegin_showResetInternetHideApmMsg() {
mNetworkProviderSettings.onSubsystemRestartOperationBegin();
verify(mResetInternetPreference).setVisible(true);
- verify(mViewAirplaneModeNetworksButtonPreference).setVisible(false);
+ verify(mAirplaneModeMsgPreference).setVisible(false);
}
@Test
- public void onSubsystemRestartOperationEnd_showApmNetworksHideResetInternet() {
- mNetworkProviderSettings.mResetInternetPreference = mResetInternetPreference;
- mNetworkProviderSettings.mViewAirplaneModeNetworksButtonPreference =
- mViewAirplaneModeNetworksButtonPreference;
- doReturn(true).when(mViewAirplaneModeNetworksButtonPreference).isAvailable();
+ public void onSubsystemRestartOperationEnd_showApmMsgHideResetInternet() {
+ doReturn(true).when(mAirplaneModeEnabler).isAirplaneModeOn();
mNetworkProviderSettings.onSubsystemRestartOperationEnd();
verify(mResetInternetPreference).setVisible(false);
- verify(mViewAirplaneModeNetworksButtonPreference).setVisible(true);
+ verify(mAirplaneModeMsgPreference).setVisible(true);
+ }
+
+ @Test
+ public void onAirplaneModeChanged_apmIsOn_showApmMsg() {
+ mNetworkProviderSettings.onAirplaneModeChanged(true);
+
+ verify(mAirplaneModeMsgPreference).setVisible(true);
+ }
+
+
+ @Test
+ public void onAirplaneModeChanged_apmIsOff_hideApmMsg() {
+ mNetworkProviderSettings.onAirplaneModeChanged(false);
+
+ verify(mAirplaneModeMsgPreference).setVisible(false);
}
}
diff --git a/tests/unit/src/com/android/settings/applications/autofill/PasswordsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/autofill/PasswordsPreferenceControllerTest.java
new file mode 100644
index 0000000..216658f
--- /dev/null
+++ b/tests/unit/src/com/android/settings/applications/autofill/PasswordsPreferenceControllerTest.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2021 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.applications.autofill;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.os.Looper;
+import android.service.autofill.AutofillServiceInfo;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceScreen;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.google.android.collect.Lists;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.Collections;
+import java.util.List;
+
+@RunWith(AndroidJUnit4.class)
+public class PasswordsPreferenceControllerTest {
+
+ private Context mContext;
+ private PreferenceScreen mScreen;
+ private PreferenceCategory mPasswordsPreferenceCategory;
+
+ @Before
+ public void setUp() {
+ mContext = ApplicationProvider.getApplicationContext();
+ if (Looper.myLooper() == null) {
+ Looper.prepare(); // needed to create the preference screen
+ }
+ mScreen = new PreferenceManager(mContext).createPreferenceScreen(mContext);
+ mPasswordsPreferenceCategory = new PreferenceCategory(mContext);
+ mPasswordsPreferenceCategory.setKey("passwords");
+ mScreen.addPreference(mPasswordsPreferenceCategory);
+ }
+
+ @Test
+ public void getAvailabilityStatus_noServices_returnsUnavailable() {
+ PasswordsPreferenceController controller =
+ createControllerWithServices(Collections.emptyList());
+ assertThat(controller.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_noPasswords_returnsUnavailable() {
+ AutofillServiceInfo service = new AutofillServiceInfo.TestDataBuilder().build();
+ PasswordsPreferenceController controller =
+ createControllerWithServices(Lists.newArrayList(service));
+ assertThat(controller.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_withPasswords_returnsAvailable() {
+ PasswordsPreferenceController controller =
+ createControllerWithServices(Lists.newArrayList(createServiceWithPasswords()));
+ assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void displayPreference_noServices_noPreferencesAdded() {
+ PasswordsPreferenceController controller =
+ createControllerWithServices(Collections.emptyList());
+ controller.displayPreference(mScreen);
+ assertThat(mPasswordsPreferenceCategory.getPreferenceCount()).isEqualTo(0);
+ }
+
+ @Test
+ public void displayPreference_noPasswords_noPreferencesAdded() {
+ AutofillServiceInfo service = new AutofillServiceInfo.TestDataBuilder().build();
+ PasswordsPreferenceController controller =
+ createControllerWithServices(Lists.newArrayList(service));
+ controller.displayPreference(mScreen);
+ assertThat(mPasswordsPreferenceCategory.getPreferenceCount()).isEqualTo(0);
+ }
+
+ @Test
+ public void displayPreference_withPasswords_addsPreference() {
+ AutofillServiceInfo service = createServiceWithPasswords();
+ PasswordsPreferenceController controller =
+ createControllerWithServices(Lists.newArrayList(service));
+ controller.displayPreference(mScreen);
+
+ assertThat(mPasswordsPreferenceCategory.getPreferenceCount()).isEqualTo(1);
+ Preference pref = mPasswordsPreferenceCategory.getPreference(0);
+ assertThat(pref.getIcon()).isNotNull();
+ assertThat(pref.getIntent().getComponent())
+ .isEqualTo(
+ new ComponentName(
+ service.getServiceInfo().packageName,
+ service.getPasswordsActivity()));
+ }
+
+ private PasswordsPreferenceController createControllerWithServices(
+ List<AutofillServiceInfo> availableServices) {
+ return new PasswordsPreferenceController(
+ mContext, mPasswordsPreferenceCategory.getKey(), availableServices);
+ }
+
+ private AutofillServiceInfo createServiceWithPasswords() {
+ return new AutofillServiceInfo.TestDataBuilder()
+ .setPasswordsActivity("com.android.test.Passwords")
+ .build();
+ }
+}
diff --git a/tests/unit/src/com/android/settings/network/AirplaneSafeNetworksSliceTest.java b/tests/unit/src/com/android/settings/network/AirplaneSafeNetworksSliceTest.java
deleted file mode 100644
index a90b89d..0000000
--- a/tests/unit/src/com/android/settings/network/AirplaneSafeNetworksSliceTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2020 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.network;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.content.Intent;
-import android.net.wifi.WifiManager;
-
-import androidx.slice.Slice;
-import androidx.slice.SliceItem;
-import androidx.slice.SliceMetadata;
-import androidx.slice.SliceProvider;
-import androidx.slice.widget.SliceLiveData;
-import androidx.test.core.app.ApplicationProvider;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import com.android.settings.testutils.ResourcesUtils;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
-
-@RunWith(AndroidJUnit4.class)
-public class AirplaneSafeNetworksSliceTest {
-
- @Rule
- public MockitoRule mMocks = MockitoJUnit.rule();
- @Mock
- private WifiManager mWifiManager;
-
- private Context mContext;
- private AirplaneSafeNetworksSlice mAirplaneSafeNetworksSlice;
-
- @Before
- public void setUp() {
- mContext = spy(ApplicationProvider.getApplicationContext());
- when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
-
- // Set-up specs for SliceMetadata.
- SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
-
- mAirplaneSafeNetworksSlice = new AirplaneSafeNetworksSlice(mContext);
- mAirplaneSafeNetworksSlice.onAirplaneModeChanged(true);
- }
-
- @Test
- public void getSlice_airplaneModeOff_shouldBeNotNull() {
- mAirplaneSafeNetworksSlice.onAirplaneModeChanged(false);
-
- assertThat(mAirplaneSafeNetworksSlice.getSlice()).isNotNull();
- }
-
- @Test
- public void getSlice_wifiDisabled_shouldShowTurnOnNetworks() {
- when(mWifiManager.isWifiEnabled()).thenReturn(false);
-
- final Slice slice = mAirplaneSafeNetworksSlice.getSlice();
-
- assertThat(slice).isNotNull();
- final SliceItem sliceTitle =
- SliceMetadata.from(mContext, slice).getListContent().getHeader().getTitleItem();
- assertThat(sliceTitle.getText()).isEqualTo(
- ResourcesUtils.getResourcesString(mContext, "turn_on_networks"));
- }
-
- @Test
- public void getSlice_wifiEnabled_shouldShowTurnOffNetworks() {
- when(mWifiManager.isWifiEnabled()).thenReturn(true);
-
- final Slice slice = mAirplaneSafeNetworksSlice.getSlice();
-
- assertThat(slice).isNotNull();
- final SliceItem sliceTitle =
- SliceMetadata.from(mContext, slice).getListContent().getHeader().getTitleItem();
- assertThat(sliceTitle.getText()).isEqualTo(
- ResourcesUtils.getResourcesString(mContext, "turn_off_networks"));
- }
-
- @Test
- public void onNotifyChange_turnOnNetworks_shouldSetWifiEnabled() {
- when(mWifiManager.isWifiEnabled()).thenReturn(false);
- Intent intent = mAirplaneSafeNetworksSlice.getIntent();
-
- mAirplaneSafeNetworksSlice.onNotifyChange(intent);
-
- verify(mWifiManager).setWifiEnabled(true);
- }
-
- @Test
- public void onNotifyChange_turnOffNetworks_shouldSetWifiDisabled() {
- when(mWifiManager.isWifiEnabled()).thenReturn(true);
- Intent intent = mAirplaneSafeNetworksSlice.getIntent();
-
- mAirplaneSafeNetworksSlice.onNotifyChange(intent);
-
- verify(mWifiManager).setWifiEnabled(false);
- }
-}
diff --git a/tests/unit/src/com/android/settings/network/AllowedNetworkTypesListenerTest.java b/tests/unit/src/com/android/settings/network/AllowedNetworkTypesListenerTest.java
index d8f3c78..e89a257 100644
--- a/tests/unit/src/com/android/settings/network/AllowedNetworkTypesListenerTest.java
+++ b/tests/unit/src/com/android/settings/network/AllowedNetworkTypesListenerTest.java
@@ -40,9 +40,6 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import java.util.HashMap;
-import java.util.Map;
-
@RunWith(AndroidJUnit4.class)
public class AllowedNetworkTypesListenerTest {
@@ -73,12 +70,11 @@
@Test
public void onChange_shouldCallListener() {
mAllowedNetworkTypesListener.mListener = mListener;
- Map<Integer, Long> allowedNetworkTypesList = new HashMap<>();
long networkType = (long) RadioAccessFamily.getRafFromNetworkType(
TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO);
- allowedNetworkTypesList.put(TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER,
- networkType);
- mAllowedNetworkTypesListener.onAllowedNetworkTypesChanged(allowedNetworkTypesList);
+
+ mAllowedNetworkTypesListener.onAllowedNetworkTypesChanged(
+ TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER, networkType);
verify(mListener).onAllowedNetworkTypesChanged();
}
diff --git a/tests/unit/src/com/android/settings/network/TurnOnWifiSliceTest.java b/tests/unit/src/com/android/settings/network/TurnOnWifiSliceTest.java
new file mode 100644
index 0000000..befa655
--- /dev/null
+++ b/tests/unit/src/com/android/settings/network/TurnOnWifiSliceTest.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2021 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.network;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.wifi.WifiManager;
+
+import androidx.slice.SliceProvider;
+import androidx.slice.widget.SliceLiveData;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+
+@RunWith(AndroidJUnit4.class)
+public class TurnOnWifiSliceTest {
+
+ @Rule
+ public MockitoRule mMocks = MockitoJUnit.rule();
+ @Mock
+ private WifiManager mWifiManager;
+
+ private Context mContext;
+ private TurnOnWifiSlice mSlice;
+
+ @Before
+ public void setUp() {
+ mContext = spy(ApplicationProvider.getApplicationContext());
+ when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
+
+ // Set-up specs for SliceMetadata.
+ SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
+ mSlice = new TurnOnWifiSlice(mContext);
+ }
+
+ @Test
+ public void getSlice_wifiEnabled_shouldBeNull() {
+ when(mWifiManager.isWifiEnabled()).thenReturn(true);
+
+ assertThat(mSlice.getSlice()).isNull();
+ }
+
+ @Test
+ public void getSlice_wifiDisabled_shouldBeNotNull() {
+ when(mWifiManager.isWifiEnabled()).thenReturn(false);
+
+ assertThat(mSlice.getSlice()).isNotNull();
+ }
+
+ @Test
+ public void onNotifyChange_shouldSetWifiEnabled() {
+ Intent intent = mSlice.getIntent();
+
+ mSlice.onNotifyChange(intent);
+
+ verify(mWifiManager).setWifiEnabled(true);
+ }
+}
diff --git a/tests/unit/src/com/android/settings/network/ViewAirplaneModeNetworksLayoutPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/ViewAirplaneModeNetworksLayoutPreferenceControllerTest.java
deleted file mode 100644
index 972e3fb..0000000
--- a/tests/unit/src/com/android/settings/network/ViewAirplaneModeNetworksLayoutPreferenceControllerTest.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2021 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.network;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-
-import android.content.Context;
-import android.net.wifi.WifiManager;
-import android.os.Looper;
-import android.view.View;
-
-import androidx.preference.PreferenceManager;
-import androidx.preference.PreferenceScreen;
-import androidx.test.core.app.ApplicationProvider;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import com.android.settings.testutils.AirplaneModeRule;
-import com.android.settings.testutils.ResourcesUtils;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.widget.LayoutPreference;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
-
-@RunWith(AndroidJUnit4.class)
-public class ViewAirplaneModeNetworksLayoutPreferenceControllerTest {
-
- private static final String KEY = ViewAirplaneModeNetworksLayoutPreferenceController.KEY;
- private static final String RES_ID_AIRPLANE_MODE_IS_ON = "condition_airplane_title";
- private static final String RES_ID_VIEWING_AIRPLANE_MODE_NETWORKS =
- "viewing_airplane_mode_networks";
-
- @Rule
- public final MockitoRule mMockitoRule = MockitoJUnit.rule();
- @Rule
- public AirplaneModeRule mAirplaneModeRule = new AirplaneModeRule();
- @Mock
- private WifiManager mWifiManager;
-
- private Context mContext;
- private PreferenceScreen mScreen;
- private LayoutPreference mPreference;
- private ViewAirplaneModeNetworksLayoutPreferenceController mController;
-
- @Before
- public void setUp() {
- mContext = spy(ApplicationProvider.getApplicationContext());
- doReturn(mWifiManager).when(mContext).getSystemService(Context.WIFI_SERVICE);
-
- mController = new ViewAirplaneModeNetworksLayoutPreferenceController(mContext,
- mock(Lifecycle.class));
- if (Looper.myLooper() == null) {
- Looper.prepare();
- }
- final PreferenceManager preferenceManager = new PreferenceManager(mContext);
- mScreen = preferenceManager.createPreferenceScreen(mContext);
- mPreference = new LayoutPreference(mContext,
- ResourcesUtils.getResourcesId(
- mContext, "layout", "view_airplane_mode_networks_button"));
- mPreference.setKey(KEY);
- mScreen.addPreference(mPreference);
- }
-
- @Test
- public void isAvailable_airplaneModeOff_returnFalse() {
- mAirplaneModeRule.setAirplaneMode(false);
-
- assertThat(mController.isAvailable()).isFalse();
- }
-
- @Test
- public void isAvailable_airplaneModeOn_returnTrue() {
- mAirplaneModeRule.setAirplaneMode(true);
-
- assertThat(mController.isAvailable()).isTrue();
- }
-
- @Test
- public void displayPreference_wifiDisabled_showAirplaneModeIsOnButtonVisible() {
- mAirplaneModeRule.setAirplaneMode(true);
- doReturn(false).when(mWifiManager).isWifiEnabled();
-
- mController.displayPreference(mScreen);
-
- assertThat(mController.mTextView.getText())
- .isEqualTo(ResourcesUtils.getResourcesString(mContext, RES_ID_AIRPLANE_MODE_IS_ON));
- assertThat(mController.mButton.getVisibility()).isEqualTo(View.VISIBLE);
- }
-
- @Test
- public void displayPreference_wifiEnabled_showViewingAirplaneModeNetworksButtonGone() {
- mAirplaneModeRule.setAirplaneMode(true);
- doReturn(true).when(mWifiManager).isWifiEnabled();
-
- mController.displayPreference(mScreen);
-
- assertThat(mController.mTextView.getText()).isEqualTo(
- ResourcesUtils.getResourcesString(mContext, RES_ID_VIEWING_AIRPLANE_MODE_NETWORKS));
- assertThat(mController.mButton.getVisibility()).isEqualTo(View.GONE);
- }
-
- @Test
- public void refreshLayout_wifiEnabledThenDisabled_showAirplaneModeIsOnButtonVisible() {
- mAirplaneModeRule.setAirplaneMode(true);
- // Wi-Fi enabled
- doReturn(true).when(mWifiManager).isWifiEnabled();
- // Display preference
- mController.displayPreference(mScreen);
- // Then Wi-Fi disabled
- doReturn(false).when(mWifiManager).isWifiEnabled();
-
- // Refresh layout
- mController.refreshLayout();
-
- assertThat(mController.mTextView.getText())
- .isEqualTo(ResourcesUtils.getResourcesString(mContext, RES_ID_AIRPLANE_MODE_IS_ON));
- assertThat(mController.mButton.getVisibility()).isEqualTo(View.VISIBLE);
- }
-
- @Test
- public void refreshLayout_wifiDisabledThenEnabled_showViewingAirplaneModeNetworksButtonGone() {
- mAirplaneModeRule.setAirplaneMode(true);
- // Wi-Fi disabled
- doReturn(false).when(mWifiManager).isWifiEnabled();
- // Display preference
- mController.displayPreference(mScreen);
- // Then Wi-Fi enabled
- doReturn(true).when(mWifiManager).isWifiEnabled();
-
- // Refresh layout
- mController.refreshLayout();
-
- assertThat(mController.mTextView.getText()).isEqualTo(
- ResourcesUtils.getResourcesString(mContext, RES_ID_VIEWING_AIRPLANE_MODE_NETWORKS));
- assertThat(mController.mButton.getVisibility()).isEqualTo(View.GONE);
- }
-
- @Test
- public void onClick_shouldSetWifiEnabled() {
- mAirplaneModeRule.setAirplaneMode(true);
- doReturn(false).when(mWifiManager).isWifiEnabled();
-
- mController.onClick(mock(View.class));
-
- verify(mWifiManager).setWifiEnabled(true);
- }
-}
diff --git a/tests/unit/src/com/android/settings/panel/InternetConnectivityPanelTest.java b/tests/unit/src/com/android/settings/panel/InternetConnectivityPanelTest.java
index 4b4ec32..ba5ee8e 100644
--- a/tests/unit/src/com/android/settings/panel/InternetConnectivityPanelTest.java
+++ b/tests/unit/src/com/android/settings/panel/InternetConnectivityPanelTest.java
@@ -19,6 +19,7 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.clearInvocations;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -29,6 +30,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.settings.network.AirplaneModePreferenceController;
+import com.android.settings.network.InternetUpdater;
import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.testutils.ResourcesUtils;
@@ -47,10 +49,10 @@
public static final String TITLE_INTERNET = ResourcesUtils.getResourcesString(
ApplicationProvider.getApplicationContext(), "provider_internet_settings");
- public static final String TITLE_APM_NETWORKS = ResourcesUtils.getResourcesString(
- ApplicationProvider.getApplicationContext(), "airplane_mode_network_panel_title");
- public static final String SUBTITLE_APM_IS_ON = ResourcesUtils.getResourcesString(
- ApplicationProvider.getApplicationContext(), "condition_airplane_title");
+ public static final String TITLE_APM = ResourcesUtils.getResourcesString(
+ ApplicationProvider.getApplicationContext(), "airplane_mode");
+ public static final String SUBTITLE_WIFI_IS_TURNED_ON = ResourcesUtils.getResourcesString(
+ ApplicationProvider.getApplicationContext(), "wifi_is_turned_on_subtitle");
public static final String BUTTON_SETTINGS = ResourcesUtils.getResourcesString(
ApplicationProvider.getApplicationContext(), "settings_button");
@@ -58,6 +60,8 @@
public final MockitoRule mMocks = MockitoJUnit.rule();
@Mock
PanelContentCallback mPanelContentCallback;
+ @Mock
+ InternetUpdater mInternetUpdater;
private Context mContext;
private InternetConnectivityPanel mPanel;
@@ -69,73 +73,65 @@
mPanel = InternetConnectivityPanel.create(mContext);
mPanel.registerCallback(mPanelContentCallback);
mPanel.mIsProviderModelEnabled = true;
+ mPanel.mInternetUpdater = mInternetUpdater;
}
@Test
- public void getTitle_apmOnApmNetworksOff_shouldBeInternet() {
- mPanel.onAirplaneModeChanged(true);
- mPanel.onAirplaneModeNetworksChanged(false);
+ public void getTitle_apmOff_shouldBeInternet() {
+ doReturn(false).when(mInternetUpdater).isAirplaneModeOn();
assertThat(mPanel.getTitle()).isEqualTo(TITLE_INTERNET);
}
@Test
- public void getTitle_apmOnApmNetworksOn_shouldBeApmNetworks() {
- mPanel.onAirplaneModeChanged(true);
- mPanel.onAirplaneModeNetworksChanged(true);
+ public void getTitle_apmOn_shouldBeApm() {
+ doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
- assertThat(mPanel.getTitle()).isEqualTo(TITLE_APM_NETWORKS);
- }
-
- @Test
- public void getTitle_notInternetApmNetworks_shouldBeInternet() {
- mPanel.onAirplaneModeNetworksChanged(false);
-
- assertThat(mPanel.getTitle()).isEqualTo(TITLE_INTERNET);
- }
-
- @Test
- public void getSubTitle_apmOnApmNetworksOff_shouldBeApmIsOn() {
- mPanel.onAirplaneModeChanged(true);
- mPanel.onAirplaneModeNetworksChanged(false);
-
- assertThat(mPanel.getSubTitle()).isEqualTo(SUBTITLE_APM_IS_ON);
- }
-
- @Test
- public void getSubTitle_apmOnApmNetworksOn_shouldBeNull() {
- mPanel.onAirplaneModeChanged(true);
- mPanel.onAirplaneModeNetworksChanged(true);
-
- assertThat(mPanel.getSubTitle()).isNull();
+ assertThat(mPanel.getTitle()).isEqualTo(TITLE_APM);
}
@Test
public void getSubTitle_apmOff_shouldBeNull() {
- mPanel.onAirplaneModeChanged(false);
+ doReturn(false).when(mInternetUpdater).isAirplaneModeOn();
assertThat(mPanel.getSubTitle()).isNull();
}
@Test
- public void getCustomizedButtonTitle_apmOnApmNetworksOff_shouldBeNull() {
- mPanel.onAirplaneModeChanged(true);
- mPanel.onAirplaneModeNetworksChanged(false);
+ public void getSubTitle_apmOnWifiOff_shouldBeNull() {
+ doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
+ doReturn(false).when(mInternetUpdater).isWifiEnabled();
- assertThat(mPanel.getCustomizedButtonTitle()).isNull();
+ assertThat(mPanel.getSubTitle()).isNull();
}
@Test
- public void getCustomizedButtonTitle_apmOnApmNetworksOn_shouldBeSettings() {
- mPanel.onAirplaneModeChanged(true);
- mPanel.onAirplaneModeNetworksChanged(true);
+ public void getSubTitle_apmOnWifiOn_shouldWifiIsTurnedOn() {
+ doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
+ doReturn(true).when(mInternetUpdater).isWifiEnabled();
+
+ assertThat(mPanel.getSubTitle()).isEqualTo(SUBTITLE_WIFI_IS_TURNED_ON);
+ }
+
+ @Test
+ public void getCustomizedButtonTitle_apmOff_shouldBeSettings() {
+ doReturn(false).when(mInternetUpdater).isAirplaneModeOn();
assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_SETTINGS);
}
@Test
- public void getCustomizedButtonTitle_apmOff_shouldBeSettings() {
- mPanel.onAirplaneModeChanged(false);
+ public void getCustomizedButtonTitle_apmOnWifiOff_shouldBeNull() {
+ doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
+ doReturn(false).when(mInternetUpdater).isWifiEnabled();
+
+ assertThat(mPanel.getCustomizedButtonTitle()).isNull();
+ }
+
+ @Test
+ public void getCustomizedButtonTitle_apmOnWifiOn_shouldBeSettings() {
+ doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
+ doReturn(true).when(mInternetUpdater).isWifiEnabled();
assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_SETTINGS);
}
@@ -157,7 +153,7 @@
assertThat(uris).containsExactly(
CustomSliceRegistry.PROVIDER_MODEL_SLICE_URI,
- CustomSliceRegistry.AIRPLANE_SAFE_NETWORKS_SLICE_URI);
+ CustomSliceRegistry.TURN_ON_WIFI_SLICE_URI);
}
@Test
@@ -166,46 +162,86 @@
}
@Test
- public void onAirplaneModeOn_apmNetworksOff_changeHeaderAndHideSettings() {
- mPanel.onAirplaneModeNetworksChanged(false);
+ public void onAirplaneModeOn_apmOff_onTitleChanged() {
+ doReturn(false).when(mInternetUpdater).isAirplaneModeOn();
+ clearInvocations(mPanelContentCallback);
+
+ mPanel.onAirplaneModeChanged(false);
+
+ verify(mPanelContentCallback).onTitleChanged();
+ }
+
+ @Test
+ public void onAirplaneModeOn_apmOnWifiOff_onTitleChanged() {
+ doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
+ doReturn(false).when(mInternetUpdater).isWifiEnabled();
+ clearInvocations(mPanelContentCallback);
+
+ mPanel.onAirplaneModeChanged(true);
+
+ verify(mPanelContentCallback).onTitleChanged();
+ }
+
+ @Test
+ public void onAirplaneModeOn_apmOnWifiOn_onHeaderChanged() {
+ doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
+ doReturn(true).when(mInternetUpdater).isWifiEnabled();
clearInvocations(mPanelContentCallback);
mPanel.onAirplaneModeChanged(true);
verify(mPanelContentCallback).onHeaderChanged();
- verify(mPanelContentCallback).onCustomizedButtonStateChanged();
}
@Test
- public void onAirplaneModeOn_apmNetworksOn_changeTitleAndShowSettings() {
- mPanel.onAirplaneModeNetworksChanged(true);
+ public void onAirplaneModeOn_onCustomizedButtonStateChanged() {
+ doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
clearInvocations(mPanelContentCallback);
mPanel.onAirplaneModeChanged(true);
- verify(mPanelContentCallback).onTitleChanged();
verify(mPanelContentCallback).onCustomizedButtonStateChanged();
}
@Test
- public void onAirplaneModeNetworksOn_apmOff_changeTitleAndShowSettings() {
- mPanel.onAirplaneModeChanged(false);
+ public void onWifiEnabledChanged_apmOff_onTitleChanged() {
+ doReturn(false).when(mInternetUpdater).isAirplaneModeOn();
clearInvocations(mPanelContentCallback);
- mPanel.onAirplaneModeNetworksChanged(true);
+ mPanel.onWifiEnabledChanged(false);
verify(mPanelContentCallback).onTitleChanged();
- verify(mPanelContentCallback).onCustomizedButtonStateChanged();
}
@Test
- public void onAirplaneModeNetworksOff_apmOff_changeTitleAndShowSettings() {
- mPanel.onAirplaneModeChanged(false);
+ public void onWifiEnabledChanged_apmOnWifiOff_onTitleChanged() {
+ doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
+ doReturn(false).when(mInternetUpdater).isWifiEnabled();
clearInvocations(mPanelContentCallback);
- mPanel.onAirplaneModeNetworksChanged(false);
+ mPanel.onWifiEnabledChanged(true);
verify(mPanelContentCallback).onTitleChanged();
+ }
+
+ @Test
+ public void onWifiEnabledChanged_apmOnWifiOn_onHeaderChanged() {
+ doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
+ doReturn(true).when(mInternetUpdater).isWifiEnabled();
+ clearInvocations(mPanelContentCallback);
+
+ mPanel.onWifiEnabledChanged(true);
+
+ verify(mPanelContentCallback).onHeaderChanged();
+ }
+
+ @Test
+ public void onWifiEnabledChanged_onCustomizedButtonStateChanged() {
+ doReturn(true).when(mInternetUpdater).isWifiEnabled();
+ clearInvocations(mPanelContentCallback);
+
+ mPanel.onWifiEnabledChanged(true);
+
verify(mPanelContentCallback).onCustomizedButtonStateChanged();
}
}