Merge "[Wi-Fi] Add one network request case for adding Wi-Fi for apps feature."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 4cdfa25..3f66cb8 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1185,7 +1185,7 @@
<activity
android:name="Settings$LocationSettingsActivity"
android:label="@string/location_settings_title"
- android:icon="@drawable/ic_homepage_location"
+ android:icon="@drawable/ic_settings_location"
android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter android:priority="1">
<action android:name="android.settings.LOCATION_SOURCE_SETTINGS" />
@@ -2623,7 +2623,7 @@
android:launchMode="singleTop"
android:taskAffinity=".wifi.NetworkRequestDialogActivity"
android:exported="true"
- android:permission="android.permission.MAINLINE_WIFI_STACK">
+ android:permission="android.permission.NETWORK_SETTINGS">
<intent-filter>
<action android:name="com.android.settings.wifi.action.NETWORK_REQUEST" />
<category android:name="android.intent.category.DEFAULT" />
diff --git a/res/layout/bluetooth_audio_bit_per_sample_dialog.xml b/res/layout/bluetooth_audio_bit_per_sample_dialog.xml
new file mode 100644
index 0000000..f0a5dc5
--- /dev/null
+++ b/res/layout/bluetooth_audio_bit_per_sample_dialog.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 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.
+-->
+
+<ScrollView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:padding="8dp">
+
+ <RadioGroup
+ android:id="@+id/bluetooth_audio_bit_per_sample_radio_group"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="@dimen/developer_option_dialog_margin_start">
+
+ <include
+ android:id="@+id/bluetooth_audio_bit_per_sample_default"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/bluetooth_audio_bit_per_sample_16"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/bluetooth_audio_bit_per_sample_24"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/bluetooth_audio_bit_per_sample_32"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+ </RadioGroup>
+
+ <include
+ android:id="@+id/bluetooth_audio_codec_help_info"
+ layout="@layout/preference_widget_dialog_summary"/>
+
+ </LinearLayout>
+
+</ScrollView>
+
diff --git a/res/layout/bluetooth_audio_quality_dialog.xml b/res/layout/bluetooth_audio_quality_dialog.xml
new file mode 100644
index 0000000..c3c1977
--- /dev/null
+++ b/res/layout/bluetooth_audio_quality_dialog.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 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.
+-->
+
+<ScrollView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:padding="8dp">
+
+ <RadioGroup
+ android:id="@+id/bluetooth_audio_quality_radio_group"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="@dimen/developer_option_dialog_margin_start">
+
+ <include
+ android:id="@+id/bluetooth_audio_quality_default"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/bluetooth_audio_quality_optimized_quality"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/bluetooth_audio_quality_optimized_connection"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/bluetooth_audio_quality_best_effort"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ </RadioGroup>
+
+ <include
+ android:id="@+id/bluetooth_audio_codec_help_info"
+ layout="@layout/preference_widget_dialog_summary"/>
+
+ </LinearLayout>
+
+</ScrollView>
+
diff --git a/res/layout/night_display_activation_button.xml b/res/layout/night_display_activation_button.xml
index df160ec..8765ff7 100644
--- a/res/layout/night_display_activation_button.xml
+++ b/res/layout/night_display_activation_button.xml
@@ -24,6 +24,7 @@
<Button
android:id="@+id/night_display_turn_on_button"
style="@style/ActionPrimaryButton"
+ android:focusableInTouchMode="true"
android:layout_marginStart="@dimen/screen_margin_sides"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -32,6 +33,7 @@
<Button
android:id="@+id/night_display_turn_off_button"
style="@style/ActionSecondaryButton"
+ android:focusableInTouchMode="true"
android:layout_marginStart="@dimen/screen_margin_sides"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout/wifi_add_network_view.xml b/res/layout/wifi_add_network_view.xml
index 9185c97..33154f6 100644
--- a/res/layout/wifi_add_network_view.xml
+++ b/res/layout/wifi_add_network_view.xml
@@ -19,6 +19,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:clipToPadding="true"
+ android:clipChildren="true"
android:orientation="vertical">
<include
diff --git a/res/layout/zen_mode_settings_button.xml b/res/layout/zen_mode_settings_button.xml
index 7bd9b47..2146e28 100644
--- a/res/layout/zen_mode_settings_button.xml
+++ b/res/layout/zen_mode_settings_button.xml
@@ -24,6 +24,7 @@
<Button
android:id="@+id/zen_mode_settings_turn_on_button"
style="@style/ActionPrimaryButton"
+ android:focusableInTouchMode="true"
android:layout_marginStart="@dimen/screen_margin_sides"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -33,6 +34,7 @@
<Button
android:id="@+id/zen_mode_settings_turn_off_button"
style="@style/ActionSecondaryButton"
+ android:focusableInTouchMode="true"
android:layout_marginStart="@dimen/screen_margin_sides"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/values/config.xml b/res/values/config.xml
index 4a02b97..35cc420 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -425,4 +425,7 @@
<string-array name="config_panel_keep_observe_uri" translatable="false">
<item>content://com.android.settings.slices/intent/media_output_indicator</item>
</string-array>
+
+ <!-- Uri to query non-public Slice Uris. -->
+ <string name="config_non_public_slice_query_uri" translatable="false"></string>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8ca793e..63dee46 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -95,8 +95,6 @@
<!-- Description for the button that makes interface elements larger. [CHAR_LIMIT=NONE] -->
<string name="font_size_make_larger_desc">Make larger</string>
- <!-- Sample text for font size preview. -->
- <string name="font_size_preview_text">Servez à ce monsieur une bière et des kiwis.</string>
<string name="font_size_preview_text_headline">Sample text</string>
<string name="font_size_preview_text_title"
translation_description="Title text in sample text used to illustrate how the currently selected font size will appear to the user. NOTE: Translate manually. No not adopt any copyrighted material for translation.">
@@ -3778,6 +3776,8 @@
<string name="location_recent_location_requests_see_all">See all</string>
<!-- Location settings screen, sub category for location services [CHAR LIMIT=30] -->
<string name="location_category_location_services">Location services</string>
+ <!-- Location settings screen, sub category for recent work profile app location requests [CHAR LIMIT=NONE] -->
+ <string name="location_category_recent_location_work_requests">Recent work app location requests</string>
<!-- Security & location settings screen, section header for settings relating to location -->
<string name="location_title">My Location</string>
@@ -7245,7 +7245,7 @@
<string name="keywords_sounds_and_notifications_interruptions">dont don\u2019t disturb, interrupt, interruption, break</string>
<string name="keywords_app">RAM</string>
<string name="keywords_location">nearby, location, history, reporting, GPS</string>
- <string name="keywords_accounts">account, add an account, work profile</string>
+ <string name="keywords_accounts">account, add an account, work profile, add account</string>
<string name="keywords_users">restriction, restrict, restricted</string>
<string name="keywords_keyboard_and_ime">text correction, correct, sound, vibrate, auto, language, gesture, suggest, suggestion, theme, offensive, word, type, emoji, international</string>
<string name="keywords_reset_apps">reset, preferences, default</string>
@@ -10597,6 +10597,17 @@
<item>@string/game_driver_app_preference_system</item>
</string-array>
+ <!-- Title for App Compatibility Changes dashboard where developers can configure per-app overrides for compatibility changes [CHAR LIMIT=50] -->
+ <string name="platform_compat_dashboard_title">App Compatibility Changes</string>
+ <!-- Summary for App Compatibility Changes dashboard [CHAR LIMIT=NONE] -->
+ <string name="platform_compat_dashboard_summary">Modify app compatibility change overrides</string>
+ <!-- Title for default enabled app compat changes category [CHAR LIMIT=50] -->
+ <string name="platform_compat_default_enabled_title">Default enabled changes</string>
+ <!-- Title for default disabled app compat changes category [CHAR LIMIT=50] -->
+ <string name="platform_compat_default_disabled_title">Default disabled changes</string>
+ <!-- Title for target SDK gated app compat changes category [CHAR LIMIT=50] -->
+ <string name="platform_compat_target_sdk_title">Enabled after SDK <xliff:g id="number" example="29">%d</xliff:g></string>
+
<!-- Slices Strings -->
<!-- Summary text on a card explaining that a setting does not exist / is not supported on the device [CHAR_LIMIT=NONE]-->
diff --git a/res/xml/dark_ui_settings.xml b/res/xml/dark_ui_settings.xml
new file mode 100644
index 0000000..8932670
--- /dev/null
+++ b/res/xml/dark_ui_settings.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2019 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/dark_ui_mode"
+ android:key="dark_ui_mode_screen"
+ settings:staticPreferenceLocation="append"
+ settings:keywords="@string/keywords_dark_ui_mode">
+</PreferenceScreen >
\ No newline at end of file
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index fb1e0ba..65a454e 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -215,6 +215,13 @@
android:fragment="com.android.settings.development.gamedriver.GameDriverDashboard"
settings:searchable="false" />
+ <Preference
+ android:key="platform_compat_dashboard"
+ android:title="@string/platform_compat_dashboard_title"
+ android:summary="@string/platform_compat_dashboard_summary"
+ android:fragment="com.android.settings.development.compat.PlatformCompatDashboard"
+ />
+
</PreferenceCategory>
<PreferenceCategory
diff --git a/res/xml/location_recent_requests_see_all.xml b/res/xml/location_recent_requests_see_all.xml
index dfb8804..5bfb0ac 100644
--- a/res/xml/location_recent_requests_see_all.xml
+++ b/res/xml/location_recent_requests_see_all.xml
@@ -10,9 +10,11 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="@string/location_category_recent_location_requests"
- android:key="recent_location_requests_see_all">
- <PreferenceCategory
- android:key="all_recent_location_requests"/>
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:title="@string/location_category_recent_location_requests"
+ android:key="all_recent_location_requests"
+ settings:controller="com.android.settings.location.RecentLocationRequestSeeAllPreferenceController">
+
</PreferenceScreen>
diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml
index 136e6ab..932cb65 100644
--- a/res/xml/location_settings.xml
+++ b/res/xml/location_settings.xml
@@ -14,64 +14,72 @@
limitations under the License.
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="location_settings"
- android:title="@string/location_settings_title"
- settings:keywords="@string/keywords_location">
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:key="location_settings"
+ android:title="@string/location_settings_title"
+ settings:keywords="@string/keywords_location">
- <PreferenceCategory
- android:key="recent_location_requests"
- android:title="@string/location_category_recent_location_requests"/>
+ <PreferenceCategory
+ android:key="recent_location_requests"
+ android:title="@string/location_category_recent_location_requests"
+ settings:controller="com.android.settings.location.RecentLocationRequestPreferenceController"/>
+
+ <Preference
+ android:key="recent_location_requests_see_all_button"
+ android:title="@string/location_recent_location_requests_see_all"
+ android:icon="@drawable/ic_chevron_right_24dp"
+ android:fragment="com.android.settings.location.RecentLocationRequestSeeAllFragment"
+ settings:searchable="false"/>
+
+ <PreferenceCategory
+ android:key="location_advanced_settings"
+ android:layout="@layout/preference_category_no_label"
+ settings:initialExpandedChildrenCount="2">
+
+ <!-- This preference category gets removed if new_recent_location_ui is disabled -->
+ <Preference
+ android:key="app_level_permissions"
+ android:title="@string/location_app_level_permissions"
+ settings:controller="com.android.settings.location.AppLocationPermissionPreferenceController">
+ <intent android:action="android.intent.action.MANAGE_PERMISSION_APPS">
+ <extra android:name="android.intent.extra.PERMISSION_NAME"
+ android:value="android.permission-group.LOCATION"/>
+ </intent>
+ </Preference>
<Preference
- android:key="recent_location_requests_see_all_button"
- android:title="@string/location_recent_location_requests_see_all"
- android:icon="@drawable/ic_chevron_right_24dp"
- android:fragment="com.android.settings.location.RecentLocationRequestSeeAllFragment"
- settings:searchable="false"/>
+ android:fragment="com.android.settings.location.ScanningSettings"
+ android:key="location_scanning"
+ android:title="@string/location_scanning_screen_title"
+ settings:controller="com.android.settings.location.LocationScanningPreferenceController"/>
+
+ <!-- This preference gets removed if there is no managed profile -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:enabled="false"
+ android:key="managed_profile_location_switch"
+ android:selectable="true"
+ android:title="@string/managed_profile_location_switch_title"
+ settings:controller="com.android.settings.location.LocationForWorkPreferenceController"
+ settings:useAdminDisabledSummary="true"/>
<PreferenceCategory
- android:key="location_advanced_settings"
+ android:key="location_services"
android:layout="@layout/preference_category_no_label"
- settings:initialExpandedChildrenCount="2">
+ settings:controller="com.android.settings.location.LocationServicePreferenceController"/>
- <!-- This preference category gets removed if new_recent_location_ui is disabled -->
- <Preference
- android:key="app_level_permissions"
- android:title="@string/location_app_level_permissions">
- <intent android:action="android.intent.action.MANAGE_PERMISSION_APPS">
- <extra android:name="android.intent.extra.PERMISSION_NAME"
- android:value="android.permission-group.LOCATION" />
- </intent>
- </Preference>
-
- <Preference
- android:key="location_scanning"
- android:title="@string/location_scanning_screen_title"
- android:fragment="com.android.settings.location.ScanningSettings"/>
-
- <!-- This preference gets removed if there is no managed profile -->
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="managed_profile_location_switch"
- android:title="@string/managed_profile_location_switch_title"
- settings:useAdminDisabledSummary="true"
- android:enabled="false"
- android:selectable="true" />
-
- <PreferenceCategory
- android:key="location_services"
- android:layout="@layout/preference_category_no_label"/>
-
- <!-- This preference gets removed if there is no managed profile -->
- <PreferenceCategory
- android:title="@string/managed_profile_location_services"
- android:key="location_services_managed_profile" />
-
- </PreferenceCategory>
-
+ <!-- This preference gets removed if there is no managed profile -->
<PreferenceCategory
- android:key="location_footer"
- android:layout="@layout/preference_category_no_label"
- settings:allowDividerAbove="false"/>
+ android:key="location_services_managed_profile"
+ android:title="@string/managed_profile_location_services"
+ settings:controller="com.android.settings.location.LocationServiceForWorkPreferenceController"/>
+
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="location_footer"
+ android:layout="@layout/preference_category_no_label"
+ settings:allowDividerAbove="false"
+ settings:controller="com.android.settings.location.LocationFooterPreferenceController"/>
</PreferenceScreen>
diff --git a/res/xml/location_settings_personal.xml b/res/xml/location_settings_personal.xml
new file mode 100644
index 0000000..f07d0e8
--- /dev/null
+++ b/res/xml/location_settings_personal.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 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:key="location_settings"
+ android:title="@string/location_settings_title"
+ settings:keywords="@string/keywords_location">
+
+ <PreferenceCategory
+ android:key="recent_location_requests"
+ android:title="@string/location_category_recent_location_requests"
+ settings:controller="com.android.settings.location.RecentLocationRequestPreferenceController"/>
+
+ <Preference
+ android:key="recent_location_requests_see_all_button"
+ android:title="@string/location_recent_location_requests_see_all"
+ android:icon="@drawable/ic_chevron_right_24dp"
+ android:fragment="com.android.settings.location.RecentLocationRequestSeeAllFragment"
+ settings:searchable="false"/>
+
+ <PreferenceCategory
+ android:key="location_advanced_settings"
+ android:layout="@layout/preference_category_no_label"
+ settings:initialExpandedChildrenCount="2">
+
+ <!-- This preference category gets removed if new_recent_location_ui is disabled -->
+ <Preference
+ android:key="app_level_permissions"
+ android:title="@string/location_app_level_permissions"
+ settings:controller="com.android.settings.location.AppLocationPermissionPreferenceController">
+ <intent android:action="android.intent.action.MANAGE_PERMISSION_APPS">
+ <extra android:name="android.intent.extra.PERMISSION_NAME"
+ android:value="android.permission-group.LOCATION"/>
+ </intent>
+ </Preference>
+
+ <Preference
+ android:key="location_scanning"
+ android:title="@string/location_scanning_screen_title"
+ android:fragment="com.android.settings.location.ScanningSettings"
+ settings:controller="com.android.settings.location.LocationScanningPreferenceController"/>
+
+ <PreferenceCategory
+ android:key="location_services"
+ android:layout="@layout/preference_category_no_label"
+ settings:controller="com.android.settings.location.LocationServicePreferenceController"/>
+
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="location_footer"
+ android:layout="@layout/preference_category_no_label"
+ settings:allowDividerAbove="false"
+ settings:controller="com.android.settings.location.LocationFooterPreferenceController"/>
+</PreferenceScreen>
diff --git a/res/xml/location_settings_workprofile.xml b/res/xml/location_settings_workprofile.xml
new file mode 100644
index 0000000..cb1416d
--- /dev/null
+++ b/res/xml/location_settings_workprofile.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 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:key="location_settings"
+ android:title="@string/location_settings_title"
+ settings:keywords="@string/keywords_location">
+
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="managed_profile_location_switch"
+ android:title="@string/managed_profile_location_switch_title"
+ settings:useAdminDisabledSummary="true"
+ settings:controller="com.android.settings.location.LocationForWorkPreferenceController"
+ android:enabled="false"
+ android:selectable="true"/>
+
+ <PreferenceCategory
+ android:key="recent_location_requests"
+ android:title="@string/location_category_recent_location_work_requests"
+ settings:controller="com.android.settings.location.RecentLocationRequestPreferenceController"/>
+
+ <Preference
+ android:key="recent_location_requests_see_all_button"
+ android:title="@string/location_recent_location_requests_see_all"
+ android:icon="@drawable/ic_chevron_right_24dp"
+ android:fragment="com.android.settings.location.RecentLocationRequestSeeAllFragment"
+ settings:searchable="false"/>
+
+ <PreferenceCategory
+ android:key="location_advanced_settings"
+ android:layout="@layout/preference_category_no_label"
+ settings:initialExpandedChildrenCount="2">
+
+ <!-- This preference category gets removed if new_recent_location_ui is disabled -->
+ <Preference
+ android:key="app_level_permissions"
+ android:title="@string/location_app_level_permissions"
+ settings:controller="com.android.settings.location.AppLocationPermissionPreferenceController">
+ <intent android:action="android.intent.action.MANAGE_PERMISSION_APPS">
+ <extra android:name="android.intent.extra.PERMISSION_NAME"
+ android:value="android.permission-group.LOCATION"/>
+ </intent>
+ </Preference>
+
+ <PreferenceCategory
+ android:title="@string/managed_profile_location_services"
+ android:layout="@layout/preference_category_no_label"
+ android:key="location_services_managed_profile"
+ settings:controller="com.android.settings.location.LocationServiceForWorkPreferenceController"/>
+
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="location_footer"
+ android:layout="@layout/preference_category_no_label"
+ settings:allowDividerAbove="false"
+ settings:controller="com.android.settings.location.LocationFooterPreferenceController"/>
+</PreferenceScreen>
diff --git a/res/xml/platform_compat_settings.xml b/res/xml/platform_compat_settings.xml
new file mode 100644
index 0000000..bee2324
--- /dev/null
+++ b/res/xml/platform_compat_settings.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2019 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:key="platform_compat_dashboard"
+ android:title="@string/platform_compat_dashboard_title">
+</PreferenceScreen>
diff --git a/src/com/android/settings/accessibility/AccessibilitySlicePreferenceController.java b/src/com/android/settings/accessibility/AccessibilitySlicePreferenceController.java
index d1a60fa..e53afeb 100644
--- a/src/com/android/settings/accessibility/AccessibilitySlicePreferenceController.java
+++ b/src/com/android/settings/accessibility/AccessibilitySlicePreferenceController.java
@@ -91,7 +91,7 @@
}
@Override
- public boolean isSliceable() {
+ public boolean isPublicSlice() {
return true;
}
diff --git a/src/com/android/settings/accessibility/MagnificationGesturesPreferenceController.java b/src/com/android/settings/accessibility/MagnificationGesturesPreferenceController.java
index f613c69..31a8c19 100644
--- a/src/com/android/settings/accessibility/MagnificationGesturesPreferenceController.java
+++ b/src/com/android/settings/accessibility/MagnificationGesturesPreferenceController.java
@@ -70,6 +70,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
public CharSequence getSummary() {
int resId = 0;
if (mIsFromSUW) {
diff --git a/src/com/android/settings/accessibility/MagnificationNavbarPreferenceController.java b/src/com/android/settings/accessibility/MagnificationNavbarPreferenceController.java
index 5af5d93..1b8d854d 100644
--- a/src/com/android/settings/accessibility/MagnificationNavbarPreferenceController.java
+++ b/src/com/android/settings/accessibility/MagnificationNavbarPreferenceController.java
@@ -77,6 +77,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
public CharSequence getSummary() {
int resId = 0;
if (mIsFromSUW) {
diff --git a/src/com/android/settings/accounts/AccountDashboardFragment.java b/src/com/android/settings/accounts/AccountDashboardFragment.java
index 46c08ab..bee9071 100644
--- a/src/com/android/settings/accounts/AccountDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountDashboardFragment.java
@@ -30,6 +30,7 @@
import com.android.settings.users.AutoSyncWorkDataPreferenceController;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.search.SearchIndexableRaw;
import java.util.ArrayList;
import java.util.List;
@@ -92,5 +93,11 @@
return buildPreferenceControllers(
context, null /* parent */, null /* authorities*/);
}
+
+ @Override
+ public List<SearchIndexableRaw> getDynamicRawDataToIndex(Context context,
+ boolean enabled) {
+ return null;
+ }
};
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/accounts/AccountPreferenceController.java b/src/com/android/settings/accounts/AccountPreferenceController.java
index 6e1727b..36a7012 100644
--- a/src/com/android/settings/accounts/AccountPreferenceController.java
+++ b/src/com/android/settings/accounts/AccountPreferenceController.java
@@ -80,6 +80,9 @@
private static final int ORDER_NEXT_TO_LAST = 1001;
private static final int ORDER_NEXT_TO_NEXT_TO_LAST = 1000;
+ private static final String PREF_KEY_REMOVE_PROFILE = "remove_profile";
+ private static final String PREF_KEY_WORK_PROFILE_SETTING = "work_profile_setting";
+
private UserManager mUm;
private SparseArray<ProfileData> mProfiles = new SparseArray<ProfileData>();
private ManagedProfileBroadcastReceiver mManagedProfileBroadcastReceiver =
@@ -170,7 +173,7 @@
}
@Override
- public void updateRawDataToIndex(List<SearchIndexableRaw> rawData) {
+ public void updateDynamicRawDataToIndex(List<SearchIndexableRaw> rawData) {
if (!isAvailable()) {
return;
}
@@ -178,29 +181,21 @@
final String screenTitle = res.getString(R.string.account_settings_title);
List<UserInfo> profiles = mUm.getProfiles(UserHandle.myUserId());
- final int profilesCount = profiles.size();
- for (int i = 0; i < profilesCount; i++) {
- UserInfo userInfo = profiles.get(i);
- if (userInfo.isEnabled()) {
- if (!mHelper.hasBaseUserRestriction(DISALLOW_MODIFY_ACCOUNTS, userInfo.id)) {
- SearchIndexableRaw data = new SearchIndexableRaw(mContext);
- data.title = res.getString(R.string.add_account_label);
+ for (final UserInfo userInfo : profiles) {
+ if (userInfo.isEnabled() && userInfo.isManagedProfile()) {
+ if (!mHelper.hasBaseUserRestriction(DISALLOW_REMOVE_MANAGED_PROFILE,
+ UserHandle.myUserId())) {
+ final SearchIndexableRaw data = new SearchIndexableRaw(mContext);
+ data.key = PREF_KEY_REMOVE_PROFILE;
+ data.title = res.getString(R.string.remove_managed_profile_label);
data.screenTitle = screenTitle;
rawData.add(data);
}
- if (userInfo.isManagedProfile()) {
- if (!mHelper.hasBaseUserRestriction(DISALLOW_REMOVE_MANAGED_PROFILE,
- UserHandle.myUserId())) {
- SearchIndexableRaw data = new SearchIndexableRaw(mContext);
- data.title = res.getString(R.string.remove_managed_profile_label);
- data.screenTitle = screenTitle;
- rawData.add(data);
- }
- SearchIndexableRaw data = new SearchIndexableRaw(mContext);
- data.title = res.getString(R.string.managed_profile_settings_title);
- data.screenTitle = screenTitle;
- rawData.add(data);
- }
+ final SearchIndexableRaw data = new SearchIndexableRaw(mContext);
+ data.key = PREF_KEY_WORK_PROFILE_SETTING;
+ data.title = res.getString(R.string.managed_profile_settings_title);
+ data.screenTitle = screenTitle;
+ rawData.add(data);
}
}
}
@@ -375,6 +370,7 @@
private RestrictedPreference newRemoveWorkProfilePreference() {
RestrictedPreference preference = new RestrictedPreference(
mParent.getPreferenceManager().getContext());
+ preference.setKey(PREF_KEY_REMOVE_PROFILE);
preference.setTitle(R.string.remove_managed_profile_label);
preference.setIcon(R.drawable.ic_delete);
preference.setOnPreferenceClickListener(this);
@@ -385,6 +381,7 @@
private Preference newManagedProfileSettings() {
Preference preference = new Preference(mParent.getPreferenceManager().getContext());
+ preference.setKey(PREF_KEY_WORK_PROFILE_SETTING);
preference.setTitle(R.string.managed_profile_settings_title);
preference.setIcon(R.drawable.ic_settings_24dp);
preference.setOnPreferenceClickListener(this);
diff --git a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
index a31340a..8dfa934 100644
--- a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
@@ -41,7 +41,7 @@
@Override
public int getMetricsCategory() {
- return SettingsEnums.ACCOUNT;
+ return SettingsEnums.ACCOUNT_WORK;
}
@Override
diff --git a/src/com/android/settings/core/TogglePreferenceController.java b/src/com/android/settings/core/TogglePreferenceController.java
index 165d7eb..7abe6e0 100644
--- a/src/com/android/settings/core/TogglePreferenceController.java
+++ b/src/com/android/settings/core/TogglePreferenceController.java
@@ -70,4 +70,13 @@
return SliceData.SliceType.SWITCH;
}
+ @Override
+ public boolean isSliceable() {
+ return true;
+ }
+
+ @Override
+ public boolean isPublicSlice() {
+ return false;
+ }
}
\ No newline at end of file
diff --git a/src/com/android/settings/dashboard/ControllerFutureTask.java b/src/com/android/settings/dashboard/ControllerFutureTask.java
new file mode 100644
index 0000000..84d11fd
--- /dev/null
+++ b/src/com/android/settings/dashboard/ControllerFutureTask.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2019 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.dashboard;
+
+import com.android.settingslib.core.AbstractPreferenceController;
+
+import java.util.concurrent.FutureTask;
+
+/**
+ * {@link FutureTask} of the Controller.
+ */
+public class ControllerFutureTask extends FutureTask<Void> {
+ private final AbstractPreferenceController mController;
+
+ public ControllerFutureTask(ControllerTask task, Void result) {
+ super(task, result);
+ mController = task.getController();
+ }
+
+ AbstractPreferenceController getController() {
+ return mController;
+ }
+}
diff --git a/src/com/android/settings/dashboard/ControllerTask.java b/src/com/android/settings/dashboard/ControllerTask.java
new file mode 100644
index 0000000..c62e738
--- /dev/null
+++ b/src/com/android/settings/dashboard/ControllerTask.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2019 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.dashboard;
+
+import android.app.settings.SettingsEnums;
+import android.os.SystemClock;
+import android.text.TextUtils;
+import android.util.Log;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+import com.android.settingslib.utils.ThreadUtils;
+
+/**
+ * A {@link Runnable} controller task. This task handle the visibility of the controller in the
+ * background. Also handle the state updating in the main thread.
+ */
+public class ControllerTask implements Runnable {
+ private static final String TAG = "ControllerTask";
+ private static final int CONTROLLER_UPDATESTATE_TIME_THRESHOLD = 50;
+
+ private final AbstractPreferenceController mController;
+ private final PreferenceScreen mScreen;
+ private final int mMetricsCategory;
+ private final MetricsFeatureProvider mMetricsFeature;
+
+ public ControllerTask(AbstractPreferenceController controller, PreferenceScreen screen,
+ MetricsFeatureProvider metricsFeature, int metricsCategory) {
+ mController = controller;
+ mScreen = screen;
+ mMetricsFeature = metricsFeature;
+ mMetricsCategory = metricsCategory;
+ }
+
+ @Override
+ public void run() {
+ if (!mController.isAvailable()) {
+ return;
+ }
+
+ final String key = mController.getPreferenceKey();
+ if (TextUtils.isEmpty(key)) {
+ Log.d(TAG, String.format("Preference key is %s in Controller %s",
+ key, mController.getClass().getSimpleName()));
+ return;
+ }
+
+ final Preference preference = mScreen.findPreference(key);
+ if (preference == null) {
+ Log.d(TAG, String.format("Cannot find preference with key %s in Controller %s",
+ key, mController.getClass().getSimpleName()));
+ return;
+ }
+ ThreadUtils.postOnMainThread(() -> {
+ final long t = SystemClock.elapsedRealtime();
+ mController.updateState(preference);
+ final int elapsedTime = (int) (SystemClock.elapsedRealtime() - t);
+ if (elapsedTime > CONTROLLER_UPDATESTATE_TIME_THRESHOLD) {
+ Log.w(TAG, "The updateState took " + elapsedTime + " ms in Controller "
+ + mController.getClass().getSimpleName());
+ if (mMetricsFeature != null) {
+ mMetricsFeature.action(SettingsEnums.PAGE_UNKNOWN,
+ SettingsEnums.ACTION_CONTROLLER_UPDATE_STATE, mMetricsCategory,
+ mController.getClass().getSimpleName(), elapsedTime);
+ }
+ }
+ });
+ }
+
+ AbstractPreferenceController getController() {
+ return mController;
+ }
+}
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index 4e541cb..282cdb9 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -60,6 +60,7 @@
import com.android.settings.SettingsActivity;
import com.android.settings.dashboard.profileselector.ProfileSelectDialog;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.widget.MasterSwitchPreference;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.drawer.ActivityTile;
import com.android.settingslib.drawer.DashboardCategory;
@@ -303,7 +304,7 @@
setSwitchEnabled(pref, false);
ThreadUtils.postOnBackgroundThread(() -> {
final Map<String, IContentProvider> providerMap = new ArrayMap<>();
- final Bundle result = TileUtils.putBooleanToUri(mContext, uri, providerMap,
+ final Bundle result = TileUtils.putBooleanToUriAndGetResult(mContext, uri, providerMap,
EXTRA_SWITCH_CHECKED_STATE, checked);
ThreadUtils.postOnMainThread(() -> {
@@ -335,13 +336,19 @@
}
private void setSwitchChecked(Preference pref, boolean checked) {
- if (pref instanceof SwitchPreference) {
+ if (pref instanceof MasterSwitchPreference) {
+ ((MasterSwitchPreference) pref).setChecked(checked);
+ } else if (pref instanceof SwitchPreference) {
((SwitchPreference) pref).setChecked(checked);
}
}
private void setSwitchEnabled(Preference pref, boolean enabled) {
- pref.setEnabled(enabled);
+ if (pref instanceof MasterSwitchPreference) {
+ ((MasterSwitchPreference) pref).setSwitchEnabled(enabled);
+ } else {
+ pref.setEnabled(enabled);
+ }
}
@VisibleForTesting
diff --git a/src/com/android/settings/dashboard/DashboardFragment.java b/src/com/android/settings/dashboard/DashboardFragment.java
index 30d6df3..f51b5cf 100644
--- a/src/com/android/settings/dashboard/DashboardFragment.java
+++ b/src/com/android/settings/dashboard/DashboardFragment.java
@@ -22,6 +22,7 @@
import android.os.Bundle;
import android.text.TextUtils;
import android.util.ArrayMap;
+import android.util.FeatureFlagUtils;
import android.util.Log;
import androidx.annotation.CallSuper;
@@ -35,9 +36,11 @@
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.FeatureFlags;
import com.android.settings.core.PreferenceControllerListHelper;
import com.android.settings.core.SettingsBaseActivity;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.widget.MasterSwitchPreference;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -45,6 +48,7 @@
import com.android.settingslib.drawer.ProviderTile;
import com.android.settingslib.drawer.Tile;
import com.android.settingslib.search.Indexable;
+import com.android.settingslib.utils.ThreadUtils;
import java.util.ArrayList;
import java.util.Arrays;
@@ -52,6 +56,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.concurrent.ExecutionException;
/**
* Base fragment for dashboard style UI containing a list of static and dynamic setting items.
@@ -305,9 +310,22 @@
}
/**
+ * @return {@code true} if the underlying controllers should be executed in parallel.
+ * Override this function to enable/disable the behavior.
+ */
+ protected boolean isParalleledControllers() {
+ return false;
+ }
+
+ /**
* Update state of each preference managed by PreferenceController.
*/
protected void updatePreferenceStates() {
+ if (isParalleledControllers() && FeatureFlagUtils.isEnabled(getContext(),
+ FeatureFlags.CONTROLLER_ENHANCEMENT)) {
+ updatePreferenceStatesInParallel();
+ return;
+ }
final PreferenceScreen screen = getPreferenceScreen();
Collection<List<AbstractPreferenceController>> controllerLists =
mPreferenceControllers.values();
@@ -336,6 +354,34 @@
}
/**
+ * Use parallel method to update state of each preference managed by PreferenceController.
+ */
+ @VisibleForTesting
+ void updatePreferenceStatesInParallel() {
+ final PreferenceScreen screen = getPreferenceScreen();
+ final Collection<List<AbstractPreferenceController>> controllerLists =
+ mPreferenceControllers.values();
+ final List<ControllerFutureTask> taskList = new ArrayList<>();
+ for (List<AbstractPreferenceController> controllerList : controllerLists) {
+ for (AbstractPreferenceController controller : controllerList) {
+ final ControllerFutureTask task = new ControllerFutureTask(
+ new ControllerTask(controller, screen, mMetricsFeatureProvider,
+ getMetricsCategory()), null /* result */);
+ taskList.add(task);
+ ThreadUtils.postOnBackgroundThread(task);
+ }
+ }
+
+ for (ControllerFutureTask task : taskList) {
+ try {
+ task.get();
+ } catch (InterruptedException | ExecutionException e) {
+ Log.w(TAG, task.getController().getPreferenceKey() + " " + e.getMessage());
+ }
+ }
+ }
+
+ /**
* Refresh all preference items, including both static prefs from xml, and dynamic items from
* DashboardCategory.
*/
@@ -453,7 +499,9 @@
Preference createPreference(Tile tile) {
return tile instanceof ProviderTile
? new SwitchPreference(getPrefContext())
- : new Preference(getPrefContext());
+ : tile.hasSwitch()
+ ? new MasterSwitchPreference(getPrefContext())
+ : new Preference(getPrefContext());
}
@VisibleForTesting
diff --git a/src/com/android/settings/dashboard/profileselector/ProfileFragmentBridge.java b/src/com/android/settings/dashboard/profileselector/ProfileFragmentBridge.java
index 047f740..816deca 100644
--- a/src/com/android/settings/dashboard/profileselector/ProfileFragmentBridge.java
+++ b/src/com/android/settings/dashboard/profileselector/ProfileFragmentBridge.java
@@ -21,6 +21,7 @@
import com.android.settings.accounts.AccountDashboardFragment;
import com.android.settings.applications.manageapplications.ManageApplications;
import com.android.settings.deviceinfo.StorageDashboardFragment;
+import com.android.settings.location.LocationSettings;
import java.util.Map;
@@ -43,5 +44,7 @@
ProfileSelectManageApplications.class.getName());
FRAGMENT_MAP.put(StorageDashboardFragment.class.getName(),
ProfileSelectStorageFragment.class.getName());
+ FRAGMENT_MAP.put(LocationSettings.class.getName(),
+ ProfileSelectLocationFragment.class.getName());
}
}
diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java
index b8d4be1..aee7982 100644
--- a/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java
+++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java
@@ -27,9 +27,11 @@
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentStatePagerAdapter;
+import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import com.android.settings.R;
+import com.android.settings.Utils;
import com.android.settings.dashboard.DashboardFragment;
import com.google.android.material.tabs.TabLayout;
@@ -90,6 +92,10 @@
listContainer.setLayoutParams(new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
+
+ final RecyclerView recyclerView = getListView();
+ recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
+ Utils.setActionBarShadowAnimation(getActivity(), getSettingsLifecycle(), recyclerView);
return mContentView;
}
diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationFragment.java
new file mode 100644
index 0000000..b256157
--- /dev/null
+++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationFragment.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2019 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.dashboard.profileselector;
+
+import android.os.Bundle;
+
+import androidx.fragment.app.Fragment;
+
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.location.LocationPersonalSettings;
+import com.android.settings.location.LocationSwitchBarController;
+import com.android.settings.location.LocationWorkProfileSettings;
+import com.android.settings.widget.SwitchBar;
+
+/**
+ * Location Setting page for personal/managed profile.
+ */
+public class ProfileSelectLocationFragment extends ProfileSelectFragment {
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ final SettingsActivity activity = (SettingsActivity) getActivity();
+ final SwitchBar switchBar = activity.getSwitchBar();
+ switchBar.setSwitchBarText(R.string.location_settings_master_switch_title,
+ R.string.location_settings_master_switch_title);
+ final LocationSwitchBarController switchBarController = new LocationSwitchBarController(
+ activity, switchBar, getSettingsLifecycle());
+ switchBar.show();
+ }
+
+ @Override
+ public Fragment[] getFragments() {
+ return new Fragment[]{
+ new LocationPersonalSettings(),
+ new LocationWorkProfileSettings()
+ };
+ }
+}
diff --git a/src/com/android/settings/datetime/DatePreferenceController.java b/src/com/android/settings/datetime/DatePreferenceController.java
index 1704bd6..ace24f6 100644
--- a/src/com/android/settings/datetime/DatePreferenceController.java
+++ b/src/com/android/settings/datetime/DatePreferenceController.java
@@ -17,8 +17,9 @@
package com.android.settings.datetime;
import android.app.Activity;
-import android.app.AlarmManager;
import android.app.DatePickerDialog;
+import android.app.timedetector.ManualTimeSuggestion;
+import android.app.timedetector.TimeDetector;
import android.content.Context;
import android.text.TextUtils;
import android.text.format.DateFormat;
@@ -119,7 +120,10 @@
long when = Math.max(c.getTimeInMillis(), DatePreferenceHost.MIN_DATE);
if (when / 1000 < Integer.MAX_VALUE) {
- ((AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE)).setTime(when);
+ TimeDetector timeDetector = mContext.getSystemService(TimeDetector.class);
+ ManualTimeSuggestion manualTimeSuggestion =
+ TimeDetector.createManualTimeSuggestion(when, "Settings: Set date");
+ timeDetector.suggestManualTime(manualTimeSuggestion);
}
}
}
diff --git a/src/com/android/settings/datetime/TimePreferenceController.java b/src/com/android/settings/datetime/TimePreferenceController.java
index 3ca26bc..582234e 100644
--- a/src/com/android/settings/datetime/TimePreferenceController.java
+++ b/src/com/android/settings/datetime/TimePreferenceController.java
@@ -17,8 +17,9 @@
package com.android.settings.datetime;
import android.app.Activity;
-import android.app.AlarmManager;
import android.app.TimePickerDialog;
+import android.app.timedetector.ManualTimeSuggestion;
+import android.app.timedetector.TimeDetector;
import android.content.Context;
import android.text.TextUtils;
import android.text.format.DateFormat;
@@ -117,7 +118,10 @@
long when = Math.max(c.getTimeInMillis(), TimePreferenceHost.MIN_DATE);
if (when / 1000 < Integer.MAX_VALUE) {
- ((AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE)).setTime(when);
+ TimeDetector timeDetector = mContext.getSystemService(TimeDetector.class);
+ ManualTimeSuggestion manualTimeSuggestion =
+ TimeDetector.createManualTimeSuggestion(when, "Settings: Set time");
+ timeDetector.suggestManualTime(manualTimeSuggestion);
}
}
}
diff --git a/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java b/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java
index 564f2c3..0d91fdd 100644
--- a/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java
+++ b/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java
@@ -31,4 +31,6 @@
int REQUEST_CODE_ANGLE_DRIVER_PKGS = 4;
int REQUEST_CODE_ANGLE_DRIVER_VALUES = 5;
+
+ int REQUEST_COMPAT_CHANGE_APP = 6;
}
diff --git a/src/com/android/settings/development/VerifyAppsOverUsbPreferenceController.java b/src/com/android/settings/development/VerifyAppsOverUsbPreferenceController.java
index 20b8f1f..56d49da 100644
--- a/src/com/android/settings/development/VerifyAppsOverUsbPreferenceController.java
+++ b/src/com/android/settings/development/VerifyAppsOverUsbPreferenceController.java
@@ -146,19 +146,11 @@
== AdbPreferenceController.ADB_SETTING_OFF) {
return false;
}
- if (Settings.Global.getInt(cr, Settings.Global.PACKAGE_VERIFIER_ENABLE, SETTING_VALUE_ON)
- == SETTING_VALUE_OFF) {
- return false;
- } else {
- final Intent verification = new Intent(Intent.ACTION_PACKAGE_NEEDS_VERIFICATION);
- verification.setType(PACKAGE_MIME_TYPE);
- verification.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- final List<ResolveInfo> receivers = mPackageManager.queryBroadcastReceivers(
- verification, 0 /* flags */);
- if (receivers.size() == 0) {
- return false;
- }
- }
- return true;
+ final Intent verification = new Intent(Intent.ACTION_PACKAGE_NEEDS_VERIFICATION);
+ verification.setType(PACKAGE_MIME_TYPE);
+ verification.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+ final List<ResolveInfo> receivers = mPackageManager.queryBroadcastReceivers(
+ verification, 0 /* flags */);
+ return !receivers.isEmpty();
}
}
diff --git a/src/com/android/settings/development/compat/PlatformCompatDashboard.java b/src/com/android/settings/development/compat/PlatformCompatDashboard.java
new file mode 100644
index 0000000..dab45f2
--- /dev/null
+++ b/src/com/android/settings/development/compat/PlatformCompatDashboard.java
@@ -0,0 +1,276 @@
+/*
+ * Copyright 2019 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.development.compat;
+
+import static com.android.settings.development.DevelopmentOptionsActivityRequestCodes.REQUEST_COMPAT_CHANGE_APP;
+
+import android.app.Activity;
+import android.app.settings.SettingsEnums;
+import android.compat.Compatibility.ChangeConfig;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.ArraySet;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.Preference.OnPreferenceChangeListener;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.SwitchPreference;
+
+import com.android.internal.compat.CompatibilityChangeConfig;
+import com.android.internal.compat.CompatibilityChangeInfo;
+import com.android.internal.compat.IPlatformCompat;
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.development.AppPicker;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+
+/**
+ * Dashboard for Platform Compat preferences.
+ */
+public class PlatformCompatDashboard extends DashboardFragment {
+ private static final String TAG = "PlatformCompatDashboard";
+ private static final String COMPAT_APP = "compat_app";
+
+ private IPlatformCompat mPlatformCompat;
+
+ private CompatibilityChangeInfo[] mChanges;
+
+ @VisibleForTesting
+ String mSelectedApp;
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.SETTINGS_PLATFORM_COMPAT_DASHBOARD;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.platform_compat_settings;
+ }
+
+ @Override
+ public int getHelpResource() {
+ return 0;
+ }
+
+ IPlatformCompat getPlatformCompat() {
+ if (mPlatformCompat == null) {
+ mPlatformCompat = IPlatformCompat.Stub
+ .asInterface(ServiceManager.getService(Context.PLATFORM_COMPAT_SERVICE));
+ }
+ return mPlatformCompat;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ try {
+ mChanges = getPlatformCompat().listAllChanges();
+ } catch (RemoteException e) {
+ throw new RuntimeException("Could not list changes!", e);
+ }
+ startAppPicker();
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putString(COMPAT_APP, mSelectedApp);
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == REQUEST_COMPAT_CHANGE_APP) {
+ if (resultCode == Activity.RESULT_OK) {
+ mSelectedApp = data.getAction();
+ addPreferences();
+ }
+ return;
+ }
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+
+ private void addPreferences() {
+ getPreferenceScreen().removeAll();
+ getPreferenceScreen().addPreference(
+ createAppPreference(getApplicationInfo().loadIcon(getPackageManager())));
+ // Differentiate compatibility changes into default enabled, default disabled and enabled
+ // after target sdk.
+ final CompatibilityChangeConfig configMappings = getAppChangeMappings();
+ final List<CompatibilityChangeInfo> enabledChanges = new ArrayList<>();
+ final List<CompatibilityChangeInfo> disabledChanges = new ArrayList<>();
+ final Map<Integer, List<CompatibilityChangeInfo>> targetSdkChanges = new TreeMap<>();
+ for (CompatibilityChangeInfo change : mChanges) {
+ if (change.getEnableAfterTargetSdk() != 0) {
+ List<CompatibilityChangeInfo> sdkChanges;
+ if (!targetSdkChanges.containsKey(change.getEnableAfterTargetSdk())) {
+ sdkChanges = new ArrayList<>();
+ targetSdkChanges.put(change.getEnableAfterTargetSdk(), sdkChanges);
+ } else {
+ sdkChanges = targetSdkChanges.get(change.getEnableAfterTargetSdk());
+ }
+ sdkChanges.add(change);
+ } else if (change.getDisabled()) {
+ disabledChanges.add(change);
+ } else {
+ enabledChanges.add(change);
+ }
+ }
+ createChangeCategoryPreference(enabledChanges, configMappings,
+ getString(R.string.platform_compat_default_enabled_title));
+ createChangeCategoryPreference(disabledChanges, configMappings,
+ getString(R.string.platform_compat_default_disabled_title));
+ for (Integer sdk : targetSdkChanges.keySet()) {
+ createChangeCategoryPreference(targetSdkChanges.get(sdk), configMappings,
+ getString(R.string.platform_compat_target_sdk_title, sdk));
+ }
+ }
+
+ private CompatibilityChangeConfig getAppChangeMappings() {
+ try {
+ final ApplicationInfo applicationInfo = getApplicationInfo();
+ return getPlatformCompat().getAppConfig(applicationInfo);
+ } catch (RemoteException e) {
+ throw new RuntimeException("Could not get app config!", e);
+ }
+ }
+
+ /**
+ * Create a {@link Preference} for a changeId.
+ *
+ * <p>The {@link Preference} is a toggle switch that can enable or disable the given change for
+ * the currently selected app.</p>
+ */
+ Preference createPreferenceForChange(Context context, CompatibilityChangeInfo change,
+ CompatibilityChangeConfig configMappings) {
+ final boolean currentValue = configMappings.isChangeEnabled(change.getId());
+ final SwitchPreference item = new SwitchPreference(context);
+ final String changeName =
+ change.getName() != null ? change.getName() : "Change_" + change.getId();
+ item.setSummary(changeName);
+ item.setKey(changeName);
+ item.setEnabled(true);
+ item.setChecked(currentValue);
+ item.setOnPreferenceChangeListener(
+ new CompatChangePreferenceChangeListener(change.getId()));
+ return item;
+ }
+
+ /**
+ * Get {@link ApplicationInfo} for the currently selected app.
+ *
+ * @return an {@link ApplicationInfo} instance.
+ */
+ ApplicationInfo getApplicationInfo() {
+ try {
+ return getPackageManager().getApplicationInfo(mSelectedApp, 0);
+ } catch (PackageManager.NameNotFoundException e) {
+ throw new RuntimeException("Could not get ApplicationInfo for selected app!", e);
+ }
+ }
+
+ /**
+ * Create a {@link Preference} for the selected app.
+ *
+ * <p>The {@link Preference} contains the icon, package name and target SDK for the selected
+ * app. Selecting this preference will also re-trigger the app selection dialog.</p>
+ */
+ Preference createAppPreference(Drawable icon) {
+ final ApplicationInfo applicationInfo = getApplicationInfo();
+ final Preference appPreference = new Preference(getPreferenceScreen().getContext());
+ appPreference.setIcon(icon);
+ appPreference.setSummary(mSelectedApp
+ + " SDK "
+ + applicationInfo.targetSdkVersion);
+ appPreference.setKey(mSelectedApp);
+ appPreference.setOnPreferenceClickListener(
+ preference -> {
+ startAppPicker();
+ return true;
+ });
+ return appPreference;
+ }
+
+ PreferenceCategory createChangeCategoryPreference(List<CompatibilityChangeInfo> changes,
+ CompatibilityChangeConfig configMappings, String title) {
+ final PreferenceCategory category =
+ new PreferenceCategory(getPreferenceScreen().getContext());
+ category.setTitle(title);
+ getPreferenceScreen().addPreference(category);
+ addChangePreferencesToCategory(changes, category, configMappings);
+ return category;
+ }
+
+ private void addChangePreferencesToCategory(List<CompatibilityChangeInfo> changes,
+ PreferenceCategory category, CompatibilityChangeConfig configMappings) {
+ for (CompatibilityChangeInfo change : changes) {
+ final Preference preference = createPreferenceForChange(getPreferenceScreen().getContext(),
+ change, configMappings);
+ category.addPreference(preference);
+ }
+ }
+
+ private void startAppPicker() {
+ final Intent intent = new Intent(getContext(), AppPicker.class);
+ startActivityForResult(intent, REQUEST_COMPAT_CHANGE_APP);
+ }
+
+ private class CompatChangePreferenceChangeListener implements OnPreferenceChangeListener {
+ private final long changeId;
+
+ CompatChangePreferenceChangeListener(long changeId) {
+ this.changeId = changeId;
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ try {
+ final ArraySet<Long> enabled = new ArraySet<>();
+ final ArraySet<Long> disabled = new ArraySet<>();
+ if ((Boolean) newValue) {
+ enabled.add(changeId);
+ } else {
+ disabled.add(changeId);
+ }
+ final CompatibilityChangeConfig overrides =
+ new CompatibilityChangeConfig(new ChangeConfig(enabled, disabled));
+ getPlatformCompat().setOverrides(overrides, mSelectedApp);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java b/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
index 40e34c0..52dbb5b 100644
--- a/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
@@ -103,6 +103,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
public boolean isCopyableSlice() {
return true;
}
diff --git a/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
index 71bd8c5..7d6f5e2 100644
--- a/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
@@ -96,6 +96,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
public boolean isCopyableSlice() {
return true;
}
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java
index daa10d2..3f93303 100644
--- a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java
@@ -69,6 +69,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
public CharSequence getSummary() {
return Build.VERSION.RELEASE;
}
diff --git a/src/com/android/settings/deviceinfo/hardwareinfo/DeviceModelPreferenceController.java b/src/com/android/settings/deviceinfo/hardwareinfo/DeviceModelPreferenceController.java
index 93dd826..8a07961 100644
--- a/src/com/android/settings/deviceinfo/hardwareinfo/DeviceModelPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/hardwareinfo/DeviceModelPreferenceController.java
@@ -41,6 +41,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
public CharSequence getSummary() {
return HardwareInfoPreferenceController.getDeviceModel();
}
diff --git a/src/com/android/settings/deviceinfo/hardwareinfo/HardwareRevisionPreferenceController.java b/src/com/android/settings/deviceinfo/hardwareinfo/HardwareRevisionPreferenceController.java
index e7f6423..62da477 100644
--- a/src/com/android/settings/deviceinfo/hardwareinfo/HardwareRevisionPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/hardwareinfo/HardwareRevisionPreferenceController.java
@@ -46,6 +46,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
public boolean isCopyableSlice() {
return true;
}
diff --git a/src/com/android/settings/deviceinfo/hardwareinfo/SerialNumberPreferenceController.java b/src/com/android/settings/deviceinfo/hardwareinfo/SerialNumberPreferenceController.java
index 7ef1313..9150482 100644
--- a/src/com/android/settings/deviceinfo/hardwareinfo/SerialNumberPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/hardwareinfo/SerialNumberPreferenceController.java
@@ -41,6 +41,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
public boolean isCopyableSlice() {
return true;
}
diff --git a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
index 3459b5c..bdce2f5 100644
--- a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
@@ -124,6 +124,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
public boolean isCopyableSlice() {
return true;
}
diff --git a/src/com/android/settings/display/AdaptiveSleepDetailPreferenceController.java b/src/com/android/settings/display/AdaptiveSleepDetailPreferenceController.java
index 0e2358c..d6eabec 100644
--- a/src/com/android/settings/display/AdaptiveSleepDetailPreferenceController.java
+++ b/src/com/android/settings/display/AdaptiveSleepDetailPreferenceController.java
@@ -36,7 +36,7 @@
}
@Override
- public boolean isSliceable() {
+ public boolean isPublicSlice() {
return true;
}
diff --git a/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java b/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
index a0b1f44..6dee5d2 100644
--- a/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
+++ b/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
@@ -56,6 +56,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
public boolean isChecked() {
return getConfig().alwaysOnEnabled(MY_USER);
}
diff --git a/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java b/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java
index daaf7b1..e143d73 100644
--- a/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java
+++ b/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java
@@ -88,6 +88,11 @@
return TextUtils.equals(getPreferenceKey(), "ambient_display_notification");
}
+ @Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
private AmbientDisplayConfiguration getAmbientConfig() {
if (mConfig == null) {
mConfig = new AmbientDisplayConfiguration(mContext);
diff --git a/src/com/android/settings/display/AutoBrightnessDetailPreferenceController.java b/src/com/android/settings/display/AutoBrightnessDetailPreferenceController.java
index a04ddbf..030c5b9 100644
--- a/src/com/android/settings/display/AutoBrightnessDetailPreferenceController.java
+++ b/src/com/android/settings/display/AutoBrightnessDetailPreferenceController.java
@@ -33,7 +33,7 @@
}
@Override
- public boolean isSliceable() {
+ public boolean isPublicSlice() {
return true;
}
}
diff --git a/src/com/android/settings/display/AutoRotatePreferenceController.java b/src/com/android/settings/display/AutoRotatePreferenceController.java
index f444d8a..202a085 100644
--- a/src/com/android/settings/display/AutoRotatePreferenceController.java
+++ b/src/com/android/settings/display/AutoRotatePreferenceController.java
@@ -82,6 +82,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
public boolean isChecked() {
return !RotationPolicy.isRotationLocked(mContext);
}
diff --git a/src/com/android/settings/display/DarkUIPreferenceController.java b/src/com/android/settings/display/DarkUIPreferenceController.java
index 20683c7..7e550d7 100644
--- a/src/com/android/settings/display/DarkUIPreferenceController.java
+++ b/src/com/android/settings/display/DarkUIPreferenceController.java
@@ -32,6 +32,7 @@
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
+import com.android.settings.display.darkmode.DarkModePreference;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
diff --git a/src/com/android/settings/display/NightDisplayActivationPreferenceController.java b/src/com/android/settings/display/NightDisplayActivationPreferenceController.java
index 5bb70fc..c1c477e 100644
--- a/src/com/android/settings/display/NightDisplayActivationPreferenceController.java
+++ b/src/com/android/settings/display/NightDisplayActivationPreferenceController.java
@@ -64,6 +64,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
@@ -126,10 +131,12 @@
mTurnOnButton.setVisibility(View.GONE);
mTurnOffButton.setVisibility(View.VISIBLE);
mTurnOffButton.setText(buttonText);
+ mTurnOffButton.requestFocus();
} else {
mTurnOnButton.setVisibility(View.VISIBLE);
mTurnOffButton.setVisibility(View.GONE);
mTurnOnButton.setText(buttonText);
+ mTurnOnButton.requestFocus();
}
}
}
diff --git a/src/com/android/settings/display/NightDisplayIntensityPreferenceController.java b/src/com/android/settings/display/NightDisplayIntensityPreferenceController.java
index c8447cb..02dde40 100644
--- a/src/com/android/settings/display/NightDisplayIntensityPreferenceController.java
+++ b/src/com/android/settings/display/NightDisplayIntensityPreferenceController.java
@@ -51,6 +51,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
final SeekBarPreference preference = screen.findPreference(getPreferenceKey());
diff --git a/src/com/android/settings/fuelgauge/SmartBatteryPreferenceController.java b/src/com/android/settings/fuelgauge/SmartBatteryPreferenceController.java
index af49f3d..040af9f 100644
--- a/src/com/android/settings/fuelgauge/SmartBatteryPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/SmartBatteryPreferenceController.java
@@ -56,6 +56,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
public void updateState(Preference preference) {
super.updateState(preference);
final boolean smartBatteryOn = Settings.Global.getInt(mContext.getContentResolver(),
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
index 56e90ff..1f4690e 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
@@ -59,7 +59,7 @@
}
@Override
- public boolean isSliceable() {
+ public boolean isPublicSlice() {
return true;
}
diff --git a/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java b/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java
index 751bb79..3d2e176 100644
--- a/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java
@@ -61,6 +61,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
protected String getVideoPrefKey() {
return PREF_KEY_VIDEO;
}
diff --git a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
index 4abf09a..c3171b8 100644
--- a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
@@ -78,6 +78,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
public boolean setChecked(boolean isChecked) {
return Settings.Secure.putInt(mContext.getContentResolver(), SECURE_KEY,
isChecked ? ON : OFF);
diff --git a/src/com/android/settings/gestures/DoubleTwistPreferenceController.java b/src/com/android/settings/gestures/DoubleTwistPreferenceController.java
index d4c63c0..afc5074 100644
--- a/src/com/android/settings/gestures/DoubleTwistPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTwistPreferenceController.java
@@ -78,6 +78,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
protected String getVideoPrefKey() {
return PREF_KEY_VIDEO;
}
diff --git a/src/com/android/settings/gestures/GlobalActionsPanelPreferenceController.java b/src/com/android/settings/gestures/GlobalActionsPanelPreferenceController.java
index b980499..32a7ba5 100644
--- a/src/com/android/settings/gestures/GlobalActionsPanelPreferenceController.java
+++ b/src/com/android/settings/gestures/GlobalActionsPanelPreferenceController.java
@@ -61,6 +61,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
public boolean isChecked() {
int enabled = Settings.Secure.getInt(mContext.getContentResolver(), ENABLED_SETTING, 0);
return enabled == 1;
diff --git a/src/com/android/settings/gestures/PickupGesturePreferenceController.java b/src/com/android/settings/gestures/PickupGesturePreferenceController.java
index 0738a51..c1590bf 100644
--- a/src/com/android/settings/gestures/PickupGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/PickupGesturePreferenceController.java
@@ -73,6 +73,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
protected String getVideoPrefKey() {
return PREF_KEY_VIDEO;
}
diff --git a/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java b/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
index 104abf9..af541ff 100644
--- a/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
+++ b/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
@@ -66,6 +66,11 @@
}
@Override
+ public boolean isPublicSlice() {
+ return true;
+ }
+
+ @Override
public boolean setChecked(boolean isChecked) {
setSwipeToNotification(mContext, isChecked);
return true;
diff --git a/src/com/android/settings/gestures/TapScreenGesturePreferenceController.java b/src/com/android/settings/gestures/TapScreenGesturePreferenceController.java
index ba2b869..179ed26 100644
--- a/src/com/android/settings/gestures/TapScreenGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/TapScreenGesturePreferenceController.java
@@ -23,7 +23,6 @@
import android.hardware.display.AmbientDisplayConfiguration;
import android.os.UserHandle;
import android.provider.Settings;
-import android.text.TextUtils;
public class TapScreenGesturePreferenceController extends GesturePreferenceController {
@@ -54,7 +53,7 @@
}
@Override
- public boolean isSliceable() {
+ public boolean isPublicSlice() {
return true;
}
diff --git a/src/com/android/settings/location/AppLocationPermissionPreferenceController.java b/src/com/android/settings/location/AppLocationPermissionPreferenceController.java
index 65abe99..90b3797 100644
--- a/src/com/android/settings/location/AppLocationPermissionPreferenceController.java
+++ b/src/com/android/settings/location/AppLocationPermissionPreferenceController.java
@@ -16,7 +16,6 @@
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.core.lifecycle.Lifecycle;
import java.util.Arrays;
import java.util.List;
@@ -25,7 +24,6 @@
public class AppLocationPermissionPreferenceController extends
LocationBasePreferenceController implements PreferenceControllerMixin {
- private static final String KEY_APP_LEVEL_PERMISSIONS = "app_level_permissions";
/** Total number of apps that has location permission. */
@VisibleForTesting
int mNumTotal = -1;
@@ -40,20 +38,16 @@
private final LocationManager mLocationManager;
private Preference mPreference;
- public AppLocationPermissionPreferenceController(Context context, Lifecycle lifecycle) {
- super(context, lifecycle);
+ public AppLocationPermissionPreferenceController(Context context, String key) {
+ super(context, key);
mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
}
@Override
- public String getPreferenceKey() {
- return KEY_APP_LEVEL_PERMISSIONS;
- }
-
- @Override
- public boolean isAvailable() {
+ public int getAvailabilityStatus() {
return Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.LOCATION_SETTINGS_LINK_TO_PERMISSIONS_ENABLED, 1) == 1;
+ Settings.Global.LOCATION_SETTINGS_LINK_TO_PERMISSIONS_ENABLED, 1) == 1 ? AVAILABLE
+ : UNSUPPORTED_ON_DEVICE;
}
@Override
diff --git a/src/com/android/settings/location/LocationBasePreferenceController.java b/src/com/android/settings/location/LocationBasePreferenceController.java
index 6cf8626..69ef1ad 100644
--- a/src/com/android/settings/location/LocationBasePreferenceController.java
+++ b/src/com/android/settings/location/LocationBasePreferenceController.java
@@ -16,29 +16,46 @@
import android.content.Context;
import android.os.UserManager;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.dashboard.DashboardFragment;
import com.android.settingslib.core.lifecycle.Lifecycle;
/**
* A base controller for preferences that listens to location settings change and modifies location
* settings.
*/
-public abstract class LocationBasePreferenceController extends AbstractPreferenceController
- implements PreferenceControllerMixin, LocationEnabler.LocationModeChangeListener {
+public abstract class LocationBasePreferenceController extends BasePreferenceController
+ implements LocationEnabler.LocationModeChangeListener {
- protected final UserManager mUserManager;
- protected final LocationEnabler mLocationEnabler;
+ protected UserManager mUserManager;
+ protected LocationEnabler mLocationEnabler;
+ protected DashboardFragment mFragment;
+ protected Lifecycle mLifecycle;
- public LocationBasePreferenceController(Context context, Lifecycle lifecycle) {
- super(context);
- mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
- mLocationEnabler = new LocationEnabler(context, this /* listener */, lifecycle);
+ /**
+ * Constructor of LocationBasePreferenceController. {@link BasePreferenceController} uses
+ * reflection to create controller, all controllers extends {@link BasePreferenceController}
+ * should have this function.
+ */
+ public LocationBasePreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ /**
+ * Initialize {@link LocationEnabler} in this controller
+ *
+ * @param fragment The {@link DashboardFragment} uses the controller.
+ */
+ public void init(DashboardFragment fragment) {
+ mFragment = fragment;
+ mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+ mLifecycle = mFragment.getSettingsLifecycle();
+ mLocationEnabler = new LocationEnabler(mContext, this /* listener */, mLifecycle);
}
@Override
- public boolean isAvailable() {
- return true;
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
}
}
diff --git a/src/com/android/settings/location/LocationFooterPreferenceController.java b/src/com/android/settings/location/LocationFooterPreferenceController.java
index 7c39fea..3b9324d 100644
--- a/src/com/android/settings/location/LocationFooterPreferenceController.java
+++ b/src/com/android/settings/location/LocationFooterPreferenceController.java
@@ -13,7 +13,6 @@
*/
package com.android.settings.location;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
@@ -24,7 +23,6 @@
import android.location.LocationManager;
import android.util.Log;
-import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
@@ -41,23 +39,16 @@
public class LocationFooterPreferenceController extends LocationBasePreferenceController {
private static final String TAG = "LocationFooter";
- private static final String KEY_LOCATION_FOOTER = "location_footer";
private static final Intent INJECT_INTENT =
new Intent(LocationManager.SETTINGS_FOOTER_DISPLAYED_ACTION);
private final PackageManager mPackageManager;
- public LocationFooterPreferenceController(Context context) {
- // we don't care location mode changes, so pass in a null lifecycle to disable listening
- super(context, null);
+ public LocationFooterPreferenceController(Context context, String key) {
+ super(context, key);
mPackageManager = context.getPackageManager();
}
- @Override
- public String getPreferenceKey() {
- return KEY_LOCATION_FOOTER;
- }
-
/**
* Insert footer preferences.
*/
@@ -97,8 +88,8 @@
* inject.
*/
@Override
- public boolean isAvailable() {
- return !getFooterData().isEmpty();
+ public int getAvailabilityStatus() {
+ return !getFooterData().isEmpty() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
/**
diff --git a/src/com/android/settings/location/LocationForWorkPreferenceController.java b/src/com/android/settings/location/LocationForWorkPreferenceController.java
index 1208ea2..342efff 100644
--- a/src/com/android/settings/location/LocationForWorkPreferenceController.java
+++ b/src/com/android/settings/location/LocationForWorkPreferenceController.java
@@ -17,6 +17,7 @@
import android.content.Context;
import android.os.UserManager;
+import android.text.TextUtils;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
@@ -25,25 +26,18 @@
import com.android.settings.Utils;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
-import com.android.settingslib.core.lifecycle.Lifecycle;
public class LocationForWorkPreferenceController extends LocationBasePreferenceController {
- /**
- * Key for managed profile location switch preference. Shown only
- * if there is a managed profile.
- */
- private static final String KEY_MANAGED_PROFILE_SWITCH = "managed_profile_location_switch";
-
private RestrictedSwitchPreference mPreference;
- public LocationForWorkPreferenceController(Context context, Lifecycle lifecycle) {
- super(context, lifecycle);
+ public LocationForWorkPreferenceController(Context context, String key) {
+ super(context, key);
}
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
- if (KEY_MANAGED_PROFILE_SWITCH.equals(preference.getKey())) {
+ if (TextUtils.equals(preference.getKey(), getPreferenceKey())) {
final boolean switchState = mPreference.isChecked();
mUserManager.setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, !switchState,
Utils.getManagedProfile(mUserManager));
@@ -57,19 +51,14 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = screen.findPreference(KEY_MANAGED_PROFILE_SWITCH);
+ mPreference = screen.findPreference(getPreferenceKey());
}
@Override
- public boolean isAvailable() {
+ public int getAvailabilityStatus() {
// Looking for a managed profile. If there are no managed profiles then we are removing the
// managed profile category.
- return Utils.getManagedProfile(mUserManager) != null;
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY_MANAGED_PROFILE_SWITCH;
+ return Utils.getManagedProfile(mUserManager) != null ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
diff --git a/src/com/android/settings/location/LocationPersonalSettings.java b/src/com/android/settings/location/LocationPersonalSettings.java
new file mode 100644
index 0000000..503937e
--- /dev/null
+++ b/src/com/android/settings/location/LocationPersonalSettings.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2019 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.location;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+
+/**
+ * Location Setting page for personal profile.
+ */
+public class LocationPersonalSettings extends DashboardFragment {
+
+ private static final String TAG = "LocationPersonal";
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.LOCATION;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.location_settings_personal;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+
+ use(AppLocationPermissionPreferenceController.class).init(this);
+ use(RecentLocationRequestPreferenceController.class).init(this);
+ use(LocationServicePreferenceController.class).init(this);
+ use(LocationFooterPreferenceController.class).init(this);
+ }
+
+ @Override
+ public int getHelpResource() {
+ return R.string.help_url_location_access;
+ }
+}
diff --git a/src/com/android/settings/location/LocationScanningPreferenceController.java b/src/com/android/settings/location/LocationScanningPreferenceController.java
index 2c05a39..436676d 100644
--- a/src/com/android/settings/location/LocationScanningPreferenceController.java
+++ b/src/com/android/settings/location/LocationScanningPreferenceController.java
@@ -19,19 +19,14 @@
import android.content.Context;
import android.provider.Settings;
-import androidx.annotation.VisibleForTesting;
-
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
public class LocationScanningPreferenceController extends BasePreferenceController {
- @VisibleForTesting static final String KEY_LOCATION_SCANNING = "location_scanning";
- private final Context mContext;
- public LocationScanningPreferenceController(Context context) {
- super(context, KEY_LOCATION_SCANNING);
- mContext = context;
+ public LocationScanningPreferenceController(Context context, String key) {
+ super(context, key);
}
@Override
diff --git a/src/com/android/settings/location/LocationServiceForWorkPreferenceController.java b/src/com/android/settings/location/LocationServiceForWorkPreferenceController.java
new file mode 100644
index 0000000..6b172dd
--- /dev/null
+++ b/src/com/android/settings/location/LocationServiceForWorkPreferenceController.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2019 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.location;
+
+import android.content.Context;
+import android.os.UserHandle;
+
+import androidx.preference.Preference;
+
+import com.android.settings.widget.RestrictedAppPreference;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Retrieve the Location Services used in profile user.
+ */
+public class LocationServiceForWorkPreferenceController extends
+ LocationServicePreferenceController {
+ private static final String TAG = "LocationWorkPrefCtrl";
+
+ public LocationServiceForWorkPreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ mCategoryLocationServices.removeAll();
+ final Map<Integer, List<Preference>> prefs = getLocationServices();
+ boolean show = false;
+ for (Map.Entry<Integer, List<Preference>> entry : prefs.entrySet()) {
+ for (Preference pref : entry.getValue()) {
+ if (pref instanceof RestrictedAppPreference) {
+ ((RestrictedAppPreference) pref).checkRestrictionAndSetDisabled();
+ }
+ }
+ if (entry.getKey() != UserHandle.myUserId()) {
+ LocationSettings.addPreferencesSorted(entry.getValue(),
+ mCategoryLocationServices);
+ show = true;
+ }
+ }
+ mCategoryLocationServices.setVisible(show);
+ }
+}
diff --git a/src/com/android/settings/location/LocationServicePreferenceController.java b/src/com/android/settings/location/LocationServicePreferenceController.java
index 70246cb..56a23bd 100644
--- a/src/com/android/settings/location/LocationServicePreferenceController.java
+++ b/src/com/android/settings/location/LocationServicePreferenceController.java
@@ -27,8 +27,8 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.Utils;
+import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.widget.RestrictedAppPreference;
-import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnPause;
import com.android.settingslib.core.lifecycle.events.OnResume;
@@ -39,58 +39,39 @@
public class LocationServicePreferenceController extends LocationBasePreferenceController
implements LifecycleObserver, OnResume, OnPause {
- private static final String TAG = "LocationServicePrefCtrl";
- /** Key for preference category "Location services" */
- private static final String KEY_LOCATION_SERVICES = "location_services";
- /** Key for preference category "Location services for work" */
- private static final String KEY_LOCATION_SERVICES_MANAGED = "location_services_managed_profile";
+ private static final String TAG = "LocationPrefCtrl";
@VisibleForTesting
static final IntentFilter INTENT_FILTER_INJECTED_SETTING_CHANGED =
new IntentFilter(SettingInjectorService.ACTION_INJECTED_SETTING_CHANGED);
- private PreferenceCategory mCategoryLocationServices;
- private PreferenceCategory mCategoryLocationServicesManaged;
- private final LocationSettings mFragment;
- private final AppSettingsInjector mInjector;
+ protected PreferenceCategory mCategoryLocationServices;
+ @VisibleForTesting
+ AppSettingsInjector mInjector;
/** Receives UPDATE_INTENT */
@VisibleForTesting
BroadcastReceiver mInjectedSettingsReceiver;
- public LocationServicePreferenceController(Context context, LocationSettings fragment,
- Lifecycle lifecycle) {
- this(context, fragment, lifecycle, new AppSettingsInjector(context));
- }
-
- @VisibleForTesting
- LocationServicePreferenceController(Context context, LocationSettings fragment,
- Lifecycle lifecycle, AppSettingsInjector injector) {
- super(context, lifecycle);
- mFragment = fragment;
- mInjector = injector;
- if (lifecycle != null) {
- lifecycle.addObserver(this);
- }
+ public LocationServicePreferenceController(Context context, String key) {
+ super(context, key);
}
@Override
- public String getPreferenceKey() {
- return KEY_LOCATION_SERVICES;
+ public void init(DashboardFragment fragment) {
+ super.init(fragment);
+ mInjector = new AppSettingsInjector(mContext);
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mCategoryLocationServices = screen.findPreference(KEY_LOCATION_SERVICES);
- mCategoryLocationServicesManaged = screen.findPreference(KEY_LOCATION_SERVICES_MANAGED);
+ mCategoryLocationServices = screen.findPreference(getPreferenceKey());
}
@Override
public void updateState(Preference preference) {
mCategoryLocationServices.removeAll();
- mCategoryLocationServicesManaged.removeAll();
final Map<Integer, List<Preference>> prefs = getLocationServices();
- boolean showPrimary = false;
- boolean showManaged = false;
+ boolean show = false;
for (Map.Entry<Integer, List<Preference>> entry : prefs.entrySet()) {
for (Preference pref : entry.getValue()) {
if (pref instanceof RestrictedAppPreference) {
@@ -98,16 +79,14 @@
}
}
if (entry.getKey() == UserHandle.myUserId()) {
- LocationSettings.addPreferencesSorted(entry.getValue(), mCategoryLocationServices);
- showPrimary = true;
- } else {
- LocationSettings.addPreferencesSorted(entry.getValue(),
- mCategoryLocationServicesManaged);
- showManaged = true;
+ if (mCategoryLocationServices != null) {
+ LocationSettings.addPreferencesSorted(entry.getValue(),
+ mCategoryLocationServices);
+ }
+ show = true;
}
}
- mCategoryLocationServices.setVisible(showPrimary);
- mCategoryLocationServicesManaged.setVisible(showManaged);
+ mCategoryLocationServices.setVisible(show);
}
@Override
@@ -139,7 +118,7 @@
mContext.unregisterReceiver(mInjectedSettingsReceiver);
}
- private Map<Integer, List<Preference>> getLocationServices() {
+ protected Map<Integer, List<Preference>> getLocationServices() {
// If location access is locked down by device policy then we only show injected settings
// for the primary profile.
final int profileUserId = Utils.getManagedProfileId(mUserManager, UserHandle.myUserId());
diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java
index 4afb504..26a4afd 100644
--- a/src/com/android/settings/location/LocationSettings.java
+++ b/src/com/android/settings/location/LocationSettings.java
@@ -29,12 +29,9 @@
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SwitchBar;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.location.RecentLocationApps;
import com.android.settingslib.search.SearchIndexable;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -82,6 +79,18 @@
}
@Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+
+ use(AppLocationPermissionPreferenceController.class).init(this);
+ use(RecentLocationRequestPreferenceController.class).init(this);
+ use(LocationServicePreferenceController.class).init(this);
+ use(LocationFooterPreferenceController.class).init(this);
+ use(LocationForWorkPreferenceController.class).init(this);
+ use(LocationServiceForWorkPreferenceController.class).init(this);
+ }
+
+ @Override
protected int getPreferenceScreenResId() {
return R.xml.location_settings;
}
@@ -91,11 +100,6 @@
return TAG;
}
- @Override
- protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
- return buildPreferenceControllers(context, this, getSettingsLifecycle());
- }
-
static void addPreferencesSorted(List<Preference> prefs, PreferenceGroup container) {
// If there's some items to display, sort the items and add them to the container.
Collections.sort(prefs,
@@ -110,29 +114,9 @@
return R.string.help_url_location_access;
}
- private static List<AbstractPreferenceController> buildPreferenceControllers(
- Context context, LocationSettings fragment, Lifecycle lifecycle) {
- final List<AbstractPreferenceController> controllers = new ArrayList<>();
- controllers.add(new AppLocationPermissionPreferenceController(context, lifecycle));
- controllers.add(new LocationForWorkPreferenceController(context, lifecycle));
- controllers.add(new RecentLocationRequestPreferenceController(context, fragment, lifecycle));
- controllers.add(new LocationScanningPreferenceController(context));
- controllers.add(new LocationServicePreferenceController(context, fragment, lifecycle));
- controllers.add(new LocationFooterPreferenceController(context));
- return controllers;
- }
-
/**
* For Search.
*/
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.location_settings) {
-
- @Override
- public List<AbstractPreferenceController> createPreferenceControllers(Context
- context) {
- return buildPreferenceControllers(context, null /* fragment */,
- null /* lifecycle */);
- }
- };
+ new BaseSearchIndexProvider(R.xml.location_settings);
}
diff --git a/src/com/android/settings/location/LocationWorkProfileSettings.java b/src/com/android/settings/location/LocationWorkProfileSettings.java
new file mode 100644
index 0000000..2c52211
--- /dev/null
+++ b/src/com/android/settings/location/LocationWorkProfileSettings.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2019 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.location;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+
+/**
+ * Location Setting page for managed profile.
+ */
+public class LocationWorkProfileSettings extends DashboardFragment {
+
+ private static final String TAG = "LocationWorkProfile";
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.LOCATION_WORK;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.location_settings_workprofile;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+
+ use(AppLocationPermissionPreferenceController.class).init(this);
+ use(RecentLocationRequestPreferenceController.class).init(this);
+ use(LocationServiceForWorkPreferenceController.class).init(this);
+ use(LocationFooterPreferenceController.class).init(this);
+ use(LocationForWorkPreferenceController.class).init(this);
+ }
+
+ @Override
+ public int getHelpResource() {
+ return R.string.help_url_location_access;
+ }
+}
diff --git a/src/com/android/settings/location/RecentLocationRequestPreferenceController.java b/src/com/android/settings/location/RecentLocationRequestPreferenceController.java
index fb8c62c..0af084c 100644
--- a/src/com/android/settings/location/RecentLocationRequestPreferenceController.java
+++ b/src/com/android/settings/location/RecentLocationRequestPreferenceController.java
@@ -26,18 +26,13 @@
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
-import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.location.RecentLocationApps;
import com.android.settingslib.widget.apppreference.AppPreference;
import java.util.List;
public class RecentLocationRequestPreferenceController extends LocationBasePreferenceController {
- /** Key for preference category "Recent location requests" */
- private static final String KEY_RECENT_LOCATION_REQUESTS = "recent_location_requests";
- @VisibleForTesting
- static final String KEY_SEE_ALL_BUTTON = "recent_location_requests_see_all_button";
- private final LocationSettings mFragment;
+
private final RecentLocationApps mRecentLocationApps;
private PreferenceCategory mCategoryRecentLocationRequests;
@@ -70,29 +65,15 @@
}
}
- public RecentLocationRequestPreferenceController(Context context, LocationSettings fragment,
- Lifecycle lifecycle) {
- this(context, fragment, lifecycle, new RecentLocationApps(context));
- }
-
- @VisibleForTesting
- RecentLocationRequestPreferenceController(Context context, LocationSettings fragment,
- Lifecycle lifecycle, RecentLocationApps recentApps) {
- super(context, lifecycle);
- mFragment = fragment;
- mRecentLocationApps = recentApps;
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY_RECENT_LOCATION_REQUESTS;
+ public RecentLocationRequestPreferenceController(Context context, String key) {
+ super(context, key);
+ mRecentLocationApps = new RecentLocationApps(context);
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mCategoryRecentLocationRequests =
- (PreferenceCategory) screen.findPreference(KEY_RECENT_LOCATION_REQUESTS);
+ mCategoryRecentLocationRequests = screen.findPreference(getPreferenceKey());
}
@Override
diff --git a/src/com/android/settings/location/RecentLocationRequestSeeAllFragment.java b/src/com/android/settings/location/RecentLocationRequestSeeAllFragment.java
index 32c9d0d..fc2a5fe 100644
--- a/src/com/android/settings/location/RecentLocationRequestSeeAllFragment.java
+++ b/src/com/android/settings/location/RecentLocationRequestSeeAllFragment.java
@@ -24,13 +24,8 @@
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.search.SearchIndexable;
-import java.util.ArrayList;
-import java.util.List;
-
/** Dashboard Fragment to display all recent location requests, sorted by recency. */
@SearchIndexable
public class RecentLocationRequestSeeAllFragment extends DashboardFragment {
@@ -52,6 +47,14 @@
}
@Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+
+ mController = use(RecentLocationRequestSeeAllPreferenceController.class);
+ mController.init(this);
+ }
+
+ @Override
protected int getPreferenceScreenResId() {
return R.xml.location_recent_requests_see_all;
}
@@ -62,11 +65,6 @@
}
@Override
- protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
- return buildPreferenceControllers(context, getSettingsLifecycle(), this);
- }
-
- @Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case MENU_SHOW_SYSTEM:
@@ -87,32 +85,6 @@
mHideSystemMenu.setVisible(mShowSystem);
}
- private static List<AbstractPreferenceController> buildPreferenceControllers(
- Context context, Lifecycle lifecycle, RecentLocationRequestSeeAllFragment fragment) {
- final List<AbstractPreferenceController> controllers = new ArrayList<>();
- final RecentLocationRequestSeeAllPreferenceController controller =
- new RecentLocationRequestSeeAllPreferenceController(context, lifecycle, fragment);
- controllers.add(controller);
- if (fragment != null) {
- fragment.mController = controller;
- }
- return controllers;
- }
-
- /**
- * For Search.
- */
- public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.location_recent_requests_see_all) {
-
- @Override
- public List<AbstractPreferenceController> getPreferenceControllers(Context
- context) {
- return buildPreferenceControllers(
- context, /* lifecycle = */ null, /* fragment = */ null);
- }
- };
-
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
@@ -122,4 +94,10 @@
R.string.menu_hide_system);
updateMenu();
}
+
+ /**
+ * For Search.
+ */
+ public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider(R.xml.location_recent_requests_see_all);
}
diff --git a/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java b/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java
index 3abccf7..4ed9d13 100644
--- a/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java
+++ b/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java
@@ -19,47 +19,26 @@
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
-import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
-import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settings.R;
import com.android.settingslib.location.RecentLocationApps;
import com.android.settingslib.widget.apppreference.AppPreference;
import java.util.List;
-import com.android.settings.R;
-
/** Preference controller for preference category displaying all recent location requests. */
public class RecentLocationRequestSeeAllPreferenceController
extends LocationBasePreferenceController {
- /** Key for preference category "All recent location requests" */
- private static final String KEY_ALL_RECENT_LOCATION_REQUESTS = "all_recent_location_requests";
- private final RecentLocationRequestSeeAllFragment mFragment;
- private PreferenceCategory mCategoryAllRecentLocationRequests;
+
+ private PreferenceScreen mCategoryAllRecentLocationRequests;
private RecentLocationApps mRecentLocationApps;
private boolean mShowSystem = false;
private Preference mPreference;
- public RecentLocationRequestSeeAllPreferenceController(
- Context context, Lifecycle lifecycle, RecentLocationRequestSeeAllFragment fragment) {
- this(context, lifecycle, fragment, new RecentLocationApps(context));
- }
-
- @VisibleForTesting
- RecentLocationRequestSeeAllPreferenceController(
- Context context,
- Lifecycle lifecycle,
- RecentLocationRequestSeeAllFragment fragment,
- RecentLocationApps recentLocationApps) {
- super(context, lifecycle);
- mFragment = fragment;
- mRecentLocationApps = recentLocationApps;
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY_ALL_RECENT_LOCATION_REQUESTS;
+ public RecentLocationRequestSeeAllPreferenceController(Context context, String key) {
+ super(context, key);
+ mRecentLocationApps = new RecentLocationApps(context);
}
@Override
@@ -70,8 +49,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mCategoryAllRecentLocationRequests =
- (PreferenceCategory) screen.findPreference(KEY_ALL_RECENT_LOCATION_REQUESTS);
+ mCategoryAllRecentLocationRequests = screen.findPreference(getPreferenceKey());
}
@Override
diff --git a/src/com/android/settings/network/AirplaneModePreferenceController.java b/src/com/android/settings/network/AirplaneModePreferenceController.java
index 1dc9588..3c79be3 100644
--- a/src/com/android/settings/network/AirplaneModePreferenceController.java
+++ b/src/com/android/settings/network/AirplaneModePreferenceController.java
@@ -103,7 +103,7 @@
}
@Override
- public boolean isSliceable() {
+ public boolean isPublicSlice() {
return true;
}
diff --git a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
index 2f176ef..3f77059 100644
--- a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
@@ -148,7 +148,8 @@
break;
}
}
- preference.setSummary(resId);
+ preference.setSummary(
+ SubscriptionManager.getResourcesForSubId(mContext, mSubId).getText(resId));
}
preference.setEnabled(mCallState == TelephonyManager.CALL_STATE_IDLE);
}
diff --git a/src/com/android/settings/nfc/NfcPreferenceController.java b/src/com/android/settings/nfc/NfcPreferenceController.java
index 34e7e24..9bf013c 100644
--- a/src/com/android/settings/nfc/NfcPreferenceController.java
+++ b/src/com/android/settings/nfc/NfcPreferenceController.java
@@ -23,7 +23,7 @@
import android.nfc.NfcAdapter;
import android.provider.Settings;
import android.util.Log;
-import androidx.annotation.VisibleForTesting;
+
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
@@ -90,7 +90,7 @@
}
@Override
- public boolean isSliceable() {
+ public boolean isPublicSlice() {
return true;
}
diff --git a/src/com/android/settings/nfc/SecureNfcPreferenceController.java b/src/com/android/settings/nfc/SecureNfcPreferenceController.java
index 12dbd57..4e548d1 100644
--- a/src/com/android/settings/nfc/SecureNfcPreferenceController.java
+++ b/src/com/android/settings/nfc/SecureNfcPreferenceController.java
@@ -77,7 +77,7 @@
}
@Override
- public boolean isSliceable() {
+ public boolean isPublicSlice() {
return true;
}
diff --git a/src/com/android/settings/notification/ZenModeButtonPreferenceController.java b/src/com/android/settings/notification/ZenModeButtonPreferenceController.java
index 3a9bcb7..a8d03ea 100644
--- a/src/com/android/settings/notification/ZenModeButtonPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeButtonPreferenceController.java
@@ -63,6 +63,7 @@
if (null == mZenButtonOn) {
mZenButtonOn = ((LayoutPreference) preference)
.findViewById(R.id.zen_mode_settings_turn_on_button);
+ mZenButtonOn.setFocusableInTouchMode(true);
updateZenButtonOnClickListener();
}
@@ -86,12 +87,14 @@
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
mZenButtonOff.setVisibility(View.VISIBLE);
mZenButtonOn.setVisibility(View.GONE);
+ mZenButtonOff.requestFocus();
break;
case Settings.Global.ZEN_MODE_OFF:
default:
mZenButtonOff.setVisibility(View.GONE);
updateZenButtonOnClickListener();
mZenButtonOn.setVisibility(View.VISIBLE);
+ mZenButtonOn.requestFocus();
}
}
diff --git a/src/com/android/settings/search/SettingsSearchIndexablesProvider.java b/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
index d504d9b..237e58f 100644
--- a/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
+++ b/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
@@ -61,10 +61,12 @@
import androidx.annotation.Nullable;
import androidx.slice.SliceViewManager;
+import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.slices.SettingsSliceProvider;
+import com.android.settingslib.drawer.ActivityTile;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
import com.android.settingslib.search.Indexable;
@@ -215,11 +217,13 @@
public Cursor querySliceUriPairs() {
final SliceViewManager manager = SliceViewManager.getInstance(getContext());
final MatrixCursor cursor = new MatrixCursor(SLICE_URI_PAIRS_COLUMNS);
- final Uri baseUri =
- new Uri.Builder()
+ final String queryUri = getContext().getString(R.string.config_non_public_slice_query_uri);
+ final Uri baseUri = !TextUtils.isEmpty(queryUri) ? Uri.parse(queryUri)
+ : new Uri.Builder()
.scheme(ContentResolver.SCHEME_CONTENT)
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
.build();
+
final Uri platformBaseUri =
new Uri.Builder()
.scheme(ContentResolver.SCHEME_CONTENT)
@@ -375,13 +379,19 @@
final String currentPackageName = context.getPackageName();
for (DashboardCategory category : dashboardFeatureProvider.getAllCategories()) {
for (Tile tile : category.getTiles()) {
- if (currentPackageName.equals(tile.getPackageName())) {
+ if (currentPackageName.equals(tile.getPackageName())
+ && tile instanceof ActivityTile) {
+ // Skip Settings injected items because they should be indexed in the sub-pages.
continue;
}
final SearchIndexableRaw raw = new SearchIndexableRaw(context);
+ final CharSequence title = tile.getTitle(context);
+ raw.title = TextUtils.isEmpty(title) ? null : title.toString();
+ if (TextUtils.isEmpty(raw.title)) {
+ continue;
+ }
raw.key = dashboardFeatureProvider.getDashboardKeyForTile(tile);
- raw.title = tile.getTitle(context).toString();
- CharSequence summary = tile.getSummary(context);
+ final CharSequence summary = tile.getSummary(context);
raw.summaryOn = TextUtils.isEmpty(summary) ? null : summary.toString();
raw.summaryOff = raw.summaryOn;
raw.className = CATEGORY_KEY_TO_PARENT_MAP.get(tile.getCategory());
diff --git a/src/com/android/settings/slices/SettingsSliceProvider.java b/src/com/android/settings/slices/SettingsSliceProvider.java
index 8a6496f..d908881 100644
--- a/src/com/android/settings/slices/SettingsSliceProvider.java
+++ b/src/com/android/settings/slices/SettingsSliceProvider.java
@@ -20,10 +20,13 @@
import android.app.PendingIntent;
import android.app.slice.SliceManager;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageManager;
import android.net.Uri;
+import android.os.Binder;
import android.os.StrictMode;
import android.provider.Settings;
import android.provider.SettingsSlicesContract;
@@ -265,16 +268,29 @@
@Override
public Collection<Uri> onGetSliceDescendants(Uri uri) {
final List<Uri> descendants = new ArrayList<>();
- final Pair<Boolean, String> pathData = SliceBuilderUtils.getPathData(uri);
+ Uri finalUri = uri;
+
+ if (isPrivateSlicesNeeded(finalUri)) {
+ descendants.addAll(
+ mSlicesDatabaseAccessor.getSliceUris(finalUri.getAuthority(),
+ false /* isPublicSlice */));
+ Log.d(TAG, "provide " + descendants.size() + " non-public slices");
+ finalUri = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(finalUri.getAuthority())
+ .build();
+ }
+
+ final Pair<Boolean, String> pathData = SliceBuilderUtils.getPathData(finalUri);
if (pathData != null) {
// Uri has a full path and will not have any descendants.
- descendants.add(uri);
+ descendants.add(finalUri);
return descendants;
}
- final String authority = uri.getAuthority();
- final String path = uri.getPath();
+ final String authority = finalUri.getAuthority();
+ final String path = finalUri.getPath();
final boolean isPathEmpty = path.isEmpty();
// Path is anything but empty, "action", or "intent". Return empty list.
@@ -286,7 +302,7 @@
}
// Add all descendants from db with matching authority.
- descendants.addAll(mSlicesDatabaseAccessor.getSliceUris(authority));
+ descendants.addAll(mSlicesDatabaseAccessor.getSliceUris(authority, true /*isPublicSlice*/));
if (isPathEmpty && TextUtils.isEmpty(authority)) {
// No path nor authority. Return all possible Uris by adding all special slice uri
@@ -404,6 +420,24 @@
return set;
}
+ @VisibleForTesting
+ boolean isPrivateSlicesNeeded(Uri uri) {
+ final String queryUri = getContext().getString(R.string.config_non_public_slice_query_uri);
+
+ if (!TextUtils.isEmpty(queryUri) && TextUtils.equals(uri.toString(), queryUri)) {
+ // check if the calling package is eligible for private slices
+ final int callingUid = Binder.getCallingUid();
+ final boolean hasPermission = getContext().checkPermission(
+ android.Manifest.permission.READ_SEARCH_INDEXABLES, Binder.getCallingPid(),
+ callingUid) == PackageManager.PERMISSION_GRANTED;
+ final String callingPackage = getContext().getPackageManager()
+ .getPackagesForUid(callingUid)[0];
+ return hasPermission && TextUtils.equals(callingPackage,
+ getContext().getString(R.string.config_settingsintelligence_package_name));
+ }
+ return false;
+ }
+
private void startBackgroundWorker(Sliceable sliceable, Uri uri) {
final Class workerClass = sliceable.getBackgroundWorkerClass();
if (workerClass == null) {
diff --git a/src/com/android/settings/slices/SlicesDatabaseAccessor.java b/src/com/android/settings/slices/SlicesDatabaseAccessor.java
index 4ae9a4c..e31715d 100644
--- a/src/com/android/settings/slices/SlicesDatabaseAccessor.java
+++ b/src/com/android/settings/slices/SlicesDatabaseAccessor.java
@@ -88,16 +88,18 @@
}
/**
- * @return a list of Slice {@link Uri}s matching {@param authority}.
+ * @return a list of Slice {@link Uri}s based on their visibility {@param isPublicSlice } and
+ * {@param authority}.
*/
- public List<Uri> getSliceUris(String authority) {
+ public List<Uri> getSliceUris(String authority, boolean isPublicSlice) {
verifyIndexing();
final List<Uri> uris = new ArrayList<>();
+ final String whereClause = IndexColumns.PUBLIC_SLICE + (isPublicSlice ? "=1" : "=0");
final SQLiteDatabase database = mHelper.getReadableDatabase();
final String[] columns = new String[]{IndexColumns.SLICE_URI};
- try (final Cursor resultCursor = database.query(TABLE_SLICES_INDEX, columns,
- null /* where */, null /* selection */, null /* groupBy */, null /* having */,
- null /* orderBy */)) {
+ try (Cursor resultCursor = database.query(TABLE_SLICES_INDEX, columns,
+ whereClause /* where */, null /* selection */, null /* groupBy */,
+ null /* having */, null /* orderBy */)) {
if (!resultCursor.moveToFirst()) {
return uris;
}
diff --git a/src/com/android/settings/widget/MasterSwitchPreference.java b/src/com/android/settings/widget/MasterSwitchPreference.java
index eb9301c..ad35cb0 100644
--- a/src/com/android/settings/widget/MasterSwitchPreference.java
+++ b/src/com/android/settings/widget/MasterSwitchPreference.java
@@ -36,6 +36,7 @@
private Switch mSwitch;
private boolean mChecked;
+ private boolean mCheckedSet;
private boolean mEnableSwitch = true;
public MasterSwitchPreference(Context context, AttributeSet attrs,
@@ -94,9 +95,14 @@
}
public void setChecked(boolean checked) {
- mChecked = checked;
- if (mSwitch != null) {
- mSwitch.setChecked(checked);
+ // Always set checked the first time; don't assume the field's default of false.
+ final boolean changed = mChecked != checked;
+ if (changed || !mCheckedSet) {
+ mChecked = checked;
+ mCheckedSet = true;
+ if (mSwitch != null) {
+ mSwitch.setChecked(checked);
+ }
}
}
diff --git a/src/com/android/settings/widget/VideoPreferenceController.java b/src/com/android/settings/widget/VideoPreferenceController.java
index 5f30fe4..4d7fc40 100644
--- a/src/com/android/settings/widget/VideoPreferenceController.java
+++ b/src/com/android/settings/widget/VideoPreferenceController.java
@@ -36,7 +36,7 @@
@Override
public int getAvailabilityStatus() {
- return mVideoPreference.isAnimationAvailable() ?
+ return mVideoPreference != null && mVideoPreference.isAnimationAvailable() ?
AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE;
}
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
index 11be7c3..025375c 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
@@ -116,8 +116,9 @@
final boolean isNonTtyOrTtyOnVolteEnabled = mImsManager.isNonTtyOrTtyOnVolteEnabled();
final boolean isWfcEnabled = mSwitchBar.isChecked()
&& isNonTtyOrTtyOnVolteEnabled;
-
- mSwitchBar.setEnabled((state == TelephonyManager.CALL_STATE_IDLE)
+ boolean isCallStateIdle =
+ mTelephonyManager.getCallState() == TelephonyManager.CALL_STATE_IDLE;
+ mSwitchBar.setEnabled(isCallStateIdle
&& isNonTtyOrTtyOnVolteEnabled);
boolean isWfcModeEditable = true;
@@ -138,13 +139,13 @@
final Preference pref = getPreferenceScreen().findPreference(BUTTON_WFC_MODE);
if (pref != null) {
pref.setEnabled(isWfcEnabled && isWfcModeEditable
- && (state == TelephonyManager.CALL_STATE_IDLE));
+ && isCallStateIdle);
}
final Preference pref_roam =
getPreferenceScreen().findPreference(BUTTON_WFC_ROAMING_MODE);
if (pref_roam != null) {
pref_roam.setEnabled(isWfcEnabled && isWfcRoamingModeEditable
- && (state == TelephonyManager.CALL_STATE_IDLE));
+ && isCallStateIdle);
}
}
};
@@ -271,8 +272,7 @@
mImsManager = getImsManager();
mImsMmTelManager = getImsMmTelManager();
- mTelephonyManager = ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE))
- .createForSubscriptionId(mSubId);
+ mTelephonyManager = ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE));
mButtonWfcMode = findPreference(BUTTON_WFC_MODE);
mButtonWfcMode.setOnPreferenceChangeListener(this);
@@ -340,19 +340,45 @@
}
}
- if (!isWifiOnlySupported) {
- mButtonWfcMode.setEntries(R.array.wifi_calling_mode_choices_without_wifi_only);
- mButtonWfcMode.setEntryValues(R.array.wifi_calling_mode_values_without_wifi_only);
- mButtonWfcMode.setEntrySummaries(R.array.wifi_calling_mode_summaries_without_wifi_only);
+ Resources res = getResourcesForSubId();
+ mButtonWfcMode.setTitle(res.getString(R.string.wifi_calling_mode_title));
+ mButtonWfcMode.setDialogTitle(res.getString(R.string.wifi_calling_mode_dialog_title));
+ mButtonWfcRoamingMode.setTitle(res.getString(R.string.wifi_calling_roaming_mode_title));
+ mButtonWfcRoamingMode.setDialogTitle(
+ res.getString(R.string.wifi_calling_roaming_mode_dialog_title));
+ if (isWifiOnlySupported) {
+ // Set string resources WITH option wifi only in mButtonWfcMode.
+ mButtonWfcMode.setEntries(
+ res.getStringArray(R.array.wifi_calling_mode_choices));
+ mButtonWfcMode.setEntryValues(res.getStringArray(R.array.wifi_calling_mode_values));
+ mButtonWfcMode.setEntrySummaries(
+ res.getStringArray(R.array.wifi_calling_mode_summaries));
+
+ // Set string resources WITH option wifi only in mButtonWfcRoamingMode.
mButtonWfcRoamingMode.setEntries(
- R.array.wifi_calling_mode_choices_v2_without_wifi_only);
+ res.getStringArray(R.array.wifi_calling_mode_choices_v2));
mButtonWfcRoamingMode.setEntryValues(
- R.array.wifi_calling_mode_values_without_wifi_only);
+ res.getStringArray(R.array.wifi_calling_mode_values));
mButtonWfcRoamingMode.setEntrySummaries(
- R.array.wifi_calling_mode_summaries_without_wifi_only);
- }
+ res.getStringArray(R.array.wifi_calling_mode_summaries));
+ } else {
+ // Set string resources WITHOUT option wifi only in mButtonWfcMode.
+ mButtonWfcMode.setEntries(
+ res.getStringArray(R.array.wifi_calling_mode_choices_without_wifi_only));
+ mButtonWfcMode.setEntryValues(
+ res.getStringArray(R.array.wifi_calling_mode_values_without_wifi_only));
+ mButtonWfcMode.setEntrySummaries(
+ res.getStringArray(R.array.wifi_calling_mode_summaries_without_wifi_only));
+ // Set string resources WITHOUT option wifi only in mButtonWfcRoamingMode.
+ mButtonWfcRoamingMode.setEntries(
+ res.getStringArray(R.array.wifi_calling_mode_choices_v2_without_wifi_only));
+ mButtonWfcRoamingMode.setEntryValues(
+ res.getStringArray(R.array.wifi_calling_mode_values_without_wifi_only));
+ mButtonWfcRoamingMode.setEntrySummaries(
+ res.getStringArray(R.array.wifi_calling_mode_summaries_without_wifi_only));
+ }
// NOTE: Buttons will be enabled/disabled in mPhoneStateListener
final boolean wfcEnabled = mImsManager.isWfcEnabledByUser()
@@ -406,9 +432,7 @@
if (mValidListener) {
mValidListener = false;
- final TelephonyManager tm = (TelephonyManager)
- getSystemService(Context.TELEPHONY_SERVICE);
- tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
+ mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
mSwitchBar.removeOnSwitchChangeListener(this);
}
@@ -591,7 +615,7 @@
return true;
}
- private int getWfcModeSummary(int wfcMode) {
+ private CharSequence getWfcModeSummary(int wfcMode) {
int resId = com.android.internal.R.string.wifi_calling_off_summary;
if (mImsManager.isWfcEnabledByUser()) {
switch (wfcMode) {
@@ -608,7 +632,7 @@
Log.e(TAG, "Unexpected WFC mode value: " + wfcMode);
}
}
- return resId;
+ return getResourcesForSubId().getString(resId);
}
@VisibleForTesting
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
index 68a4b40..967146c 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
@@ -25,6 +25,7 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.res.Resources;
import android.net.Uri;
import android.os.PersistableBundle;
import android.provider.Settings;
@@ -131,6 +132,7 @@
*/
public Slice createWifiCallingSlice(Uri sliceUri) {
final int subId = getDefaultVoiceSubId();
+ Resources res = getResourcesForSubId(subId);
if (subId <= SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
Log.d(TAG, "Invalid subscription Id");
@@ -157,12 +159,11 @@
// Activation needed for the next action of the user
// Give instructions to go to settings app
return getNonActionableWifiCallingSlice(
- mContext.getText(R.string.wifi_calling_settings_title),
- mContext.getText(
- R.string.wifi_calling_settings_activation_instructions),
+ res.getText(R.string.wifi_calling_settings_title),
+ res.getText(R.string.wifi_calling_settings_activation_instructions),
sliceUri, getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY));
}
- return getWifiCallingSlice(sliceUri, isWifiCallingEnabled);
+ return getWifiCallingSlice(sliceUri, isWifiCallingEnabled, subId);
} catch (InterruptedException | TimeoutException | ExecutionException e) {
Log.e(TAG, "Unable to read the current WiFi calling status", e);
return null;
@@ -188,13 +189,14 @@
* Builds a toggle slice where the intent takes you to the wifi calling page and the toggle
* enables/disables wifi calling.
*/
- private Slice getWifiCallingSlice(Uri sliceUri, boolean isWifiCallingEnabled) {
+ private Slice getWifiCallingSlice(Uri sliceUri, boolean isWifiCallingEnabled, int subId) {
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
+ Resources res = getResourcesForSubId(subId);
return new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
.setAccentColor(Utils.getColorAccentDefaultColor(mContext))
.addRow(new RowBuilder()
- .setTitle(mContext.getText(R.string.wifi_calling_settings_title))
+ .setTitle(res.getText(R.string.wifi_calling_settings_title))
.addEndItem(
SliceAction.createToggle(
getBroadcastIntent(ACTION_WIFI_CALLING_CHANGED),
@@ -203,7 +205,7 @@
getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY),
icon,
ListBuilder.ICON_IMAGE,
- mContext.getText(R.string.wifi_calling_settings_title))))
+ res.getText(R.string.wifi_calling_settings_title))))
.build();
}
@@ -259,14 +261,15 @@
}
if (!isWifiCallingEnabled) {
// wifi calling is not enabled. Ask user to enable wifi calling
+ Resources res = getResourcesForSubId(subId);
return getNonActionableWifiCallingSlice(
- mContext.getText(R.string.wifi_calling_mode_title),
- mContext.getText(R.string.wifi_calling_turn_on),
+ res.getText(R.string.wifi_calling_mode_title),
+ res.getText(R.string.wifi_calling_turn_on),
sliceUri, getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY));
}
// Return the slice to change wifi calling preference
return getWifiCallingPreferenceSlice(
- isWifiOnlySupported, wfcMode, sliceUri);
+ isWifiOnlySupported, wfcMode, sliceUri, subId);
}
/**
@@ -275,40 +278,43 @@
* @param isWifiOnlySupported adds row for wifi only if this is true
* @param currentWfcPref current Preference {@link ImsConfig}
* @param sliceUri sliceUri
+ * @param subId subscription id
* @return Slice for actionable wifi calling preference settings
*/
private Slice getWifiCallingPreferenceSlice(boolean isWifiOnlySupported,
int currentWfcPref,
- Uri sliceUri) {
+ Uri sliceUri,
+ int subId) {
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
+ Resources res = getResourcesForSubId(subId);
// Top row shows information on current preference state
final ListBuilder listBuilder = new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
.setAccentColor(Utils.getColorAccentDefaultColor(mContext));
listBuilder.setHeader(new ListBuilder.HeaderBuilder()
- .setTitle(mContext.getText(R.string.wifi_calling_mode_title))
- .setSubtitle(getWifiCallingPreferenceSummary(currentWfcPref))
+ .setTitle(res.getText(R.string.wifi_calling_mode_title))
+ .setSubtitle(getWifiCallingPreferenceSummary(currentWfcPref, subId))
.setPrimaryAction(SliceAction.createDeeplink(
getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY),
icon,
ListBuilder.ICON_IMAGE,
- mContext.getText(R.string.wifi_calling_mode_title))));
+ res.getText(R.string.wifi_calling_mode_title))));
if (isWifiOnlySupported) {
listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder,
com.android.internal.R.string.wfc_mode_wifi_only_summary,
ACTION_WIFI_CALLING_PREFERENCE_WIFI_ONLY,
- currentWfcPref == ImsMmTelManager.WIFI_MODE_WIFI_ONLY));
+ currentWfcPref == ImsMmTelManager.WIFI_MODE_WIFI_ONLY, subId));
}
listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder,
com.android.internal.R.string.wfc_mode_wifi_preferred_summary,
ACTION_WIFI_CALLING_PREFERENCE_WIFI_PREFERRED,
- currentWfcPref == ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED));
+ currentWfcPref == ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED, subId));
listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder,
com.android.internal.R.string.wfc_mode_cellular_preferred_summary,
ACTION_WIFI_CALLING_PREFERENCE_CELLULAR_PREFERRED,
- currentWfcPref == ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED));
+ currentWfcPref == ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED, subId));
return listBuilder.build();
}
@@ -319,16 +325,18 @@
* @param listBuilder ListBuilder that will be the parent for this RowBuilder
* @param preferenceTitleResId resource Id for the preference row title
* @param action action to be added for the row
+ * @param subId subscription id
* @return RowBuilder for the row
*/
private RowBuilder wifiPreferenceRowBuilder(ListBuilder listBuilder,
- int preferenceTitleResId, String action, boolean checked) {
+ int preferenceTitleResId, String action, boolean checked, int subId) {
final IconCompat icon =
IconCompat.createWithResource(mContext, R.drawable.radio_button_check);
+ Resources res = getResourcesForSubId(subId);
return new RowBuilder()
- .setTitle(mContext.getText(preferenceTitleResId))
+ .setTitle(res.getText(preferenceTitleResId))
.setTitleItem(SliceAction.createToggle(getBroadcastIntent(action),
- icon, mContext.getText(preferenceTitleResId), checked));
+ icon, res.getText(preferenceTitleResId), checked));
}
@@ -338,16 +346,17 @@
* @param wfcMode ImsConfig constant for the preference {@link ImsConfig}
* @return summary/name of the wifi calling preference
*/
- private CharSequence getWifiCallingPreferenceSummary(int wfcMode) {
+ private CharSequence getWifiCallingPreferenceSummary(int wfcMode, int subId) {
+ Resources res = getResourcesForSubId(subId);
switch (wfcMode) {
case ImsMmTelManager.WIFI_MODE_WIFI_ONLY:
- return mContext.getText(
+ return res.getText(
com.android.internal.R.string.wfc_mode_wifi_only_summary);
case ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED:
- return mContext.getText(
+ return res.getText(
com.android.internal.R.string.wfc_mode_wifi_preferred_summary);
case ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED:
- return mContext.getText(
+ return res.getText(
com.android.internal.R.string.wfc_mode_cellular_preferred_summary);
default:
return null;
@@ -573,4 +582,8 @@
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */);
}
+
+ private Resources getResourcesForSubId(int subId) {
+ return SubscriptionManager.getResourcesForSubId(mContext, subId);
+ }
}
diff --git a/tests/robotests/Android.bp b/tests/robotests/Android.bp
index 653f074..a825c32 100644
--- a/tests/robotests/Android.bp
+++ b/tests/robotests/Android.bp
@@ -62,7 +62,7 @@
static_libs: [
"SettingsLib-robo-testutils",
- "app-compat-annotations",
+ "android-support-annotations",
],
java_resource_dirs: ["config", "resources"],
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index b69d72e..db4b1e9 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -32,10 +32,12 @@
com.android.settings.dashboard.profileselector.ProfileSelectAccountFragment
com.android.settings.dashboard.profileselector.ProfileSelectManageApplications
com.android.settings.dashboard.profileselector.ProfileSelectStorageFragment
+com.android.settings.dashboard.profileselector.ProfileSelectLocationFragment
com.android.settings.datausage.AppDataUsage
com.android.settings.datausage.DataUsageList
com.android.settings.datausage.DataUsageSummary
com.android.settings.datetime.timezone.TimeZoneSettings
+com.android.settings.development.compat.PlatformCompatDashboard
com.android.settings.deviceinfo.PrivateVolumeSettings
com.android.settings.deviceinfo.PublicVolumeSettings
com.android.settings.deviceinfo.StorageProfileFragment
@@ -53,6 +55,8 @@
com.android.settings.inputmethod.KeyboardLayoutPickerFragment
com.android.settings.inputmethod.SpellCheckersSettings
com.android.settings.localepicker.LocaleListEditor
+com.android.settings.location.LocationPersonalSettings
+com.android.settings.location.LocationWorkProfileSettings
com.android.settings.network.ApnEditor
com.android.settings.network.ApnSettings
com.android.settings.network.telephony.NetworkSelectSettings
diff --git a/tests/robotests/res/values-mcc999/config.xml b/tests/robotests/res/values-mcc999/config.xml
index 679062b..dc638a5 100644
--- a/tests/robotests/res/values-mcc999/config.xml
+++ b/tests/robotests/res/values-mcc999/config.xml
@@ -94,4 +94,7 @@
<item>injected_tile_key</item>
<item>injected_tile_key2</item>
</string-array>
+
+ <!-- Uri to query non-public Slice Uris. -->
+ <string name="config_non_public_slice_query_uri" translatable="false">content://com.android.settings.slices/test</string>
</resources>
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySlicePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySlicePreferenceControllerTest.java
index 471f107..16ff3c4 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySlicePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySlicePreferenceControllerTest.java
@@ -121,6 +121,16 @@
new AccessibilitySlicePreferenceController(mContext, "not_split_by_slash");
}
+ @Test
+ public void isSliceable_returnTrue() {
+ assertThat(mController.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
+
private List<AccessibilityServiceInfo> getFakeServiceList() {
final List<AccessibilityServiceInfo> infoList = new ArrayList<>();
diff --git a/tests/robotests/src/com/android/settings/accessibility/MagnificationGesturesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/MagnificationGesturesPreferenceControllerTest.java
index c6bf343..c7d70e0 100644
--- a/tests/robotests/src/com/android/settings/accessibility/MagnificationGesturesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/MagnificationGesturesPreferenceControllerTest.java
@@ -130,4 +130,9 @@
new MagnificationGesturesPreferenceController(mContext, "bad_key");
assertThat(controller.isSliceable()).isFalse();
}
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/MagnificationNavbarPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/MagnificationNavbarPreferenceControllerTest.java
index 08b53b2..83fe496 100644
--- a/tests/robotests/src/com/android/settings/accessibility/MagnificationNavbarPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/MagnificationNavbarPreferenceControllerTest.java
@@ -174,4 +174,9 @@
new MagnificationNavbarPreferenceController(mContext, "bad_key");
assertThat(controller.isSliceable()).isFalse();
}
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
index bf64190..d4a855f 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
@@ -274,33 +274,33 @@
}
@Test
- public void updateRawDataToIndex_EnabledUser_shouldAddOne() {
+ public void updateDynamicRawDataToIndex_enabledUser_notManagedUser_shouldNotUpdate() {
final List<SearchIndexableRaw> data = new ArrayList<>();
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", 0));
when(mUserManager.isManagedProfile()).thenReturn(false);
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
- mController.updateRawDataToIndex(data);
+ mController.updateDynamicRawDataToIndex(data);
- assertThat(data.size()).isEqualTo(1);
+ assertThat(data.size()).isEqualTo(0);
}
@Test
- public void updateRawDataToIndex_ManagedUser_shouldAddThree() {
+ public void updateDynamicRawDataToIndex_managedUser_shouldAddTwo() {
final List<SearchIndexableRaw> data = new ArrayList<>();
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", UserInfo.FLAG_MANAGED_PROFILE));
when(mUserManager.isManagedProfile()).thenReturn(false);
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
- mController.updateRawDataToIndex(data);
+ mController.updateDynamicRawDataToIndex(data);
- assertThat(data.size()).isEqualTo(3);
+ assertThat(data.size()).isEqualTo(2);
}
@Test
- public void updateRawDataToIndex_DisallowRemove_shouldAddTwo() {
+ public void updateDynamicRawDataToIndex_disallowRemove_shouldAddOne() {
final List<SearchIndexableRaw> data = new ArrayList<>();
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", UserInfo.FLAG_MANAGED_PROFILE));
@@ -310,13 +310,13 @@
eq(UserManager.DISALLOW_REMOVE_MANAGED_PROFILE), anyInt()))
.thenReturn(true);
- mController.updateRawDataToIndex(data);
+ mController.updateDynamicRawDataToIndex(data);
- assertThat(data.size()).isEqualTo(2);
+ assertThat(data.size()).isEqualTo(1);
}
@Test
- public void updateRawDataToIndex_DisallowModify_shouldAddTwo() {
+ public void updateDynamicRawDataToIndex_disallowModify_shouldAddTwo() {
final List<SearchIndexableRaw> data = new ArrayList<>();
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", UserInfo.FLAG_MANAGED_PROFILE));
@@ -325,7 +325,7 @@
when(mAccountHelper.hasBaseUserRestriction(
eq(UserManager.DISALLOW_MODIFY_ACCOUNTS), anyInt())).thenReturn(true);
- mController.updateRawDataToIndex(data);
+ mController.updateDynamicRawDataToIndex(data);
assertThat(data.size()).isEqualTo(2);
}
diff --git a/tests/robotests/src/com/android/settings/core/TogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/core/TogglePreferenceControllerTest.java
index 7cda34a..541f0c4 100644
--- a/tests/robotests/src/com/android/settings/core/TogglePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/core/TogglePreferenceControllerTest.java
@@ -90,6 +90,16 @@
SliceData.SliceType.SWITCH);
}
+ @Test
+ public void isSliceable_returnTrue() {
+ assertThat(mToggleController.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isPublicSlice_returnFalse() {
+ assertThat(mToggleController.isPublicSlice()).isFalse();
+ }
+
private static class FakeToggle extends TogglePreferenceController {
private boolean checkedFlag;
diff --git a/tests/robotests/src/com/android/settings/dashboard/ControllerFutureTaskTest.java b/tests/robotests/src/com/android/settings/dashboard/ControllerFutureTaskTest.java
new file mode 100644
index 0000000..c66f2b5
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/dashboard/ControllerFutureTaskTest.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2019 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.dashboard;
+
+import static com.android.settingslib.core.instrumentation.Instrumentable.METRICS_CATEGORY_UNKNOWN;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.core.BasePreferenceController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class ControllerFutureTaskTest {
+ private static final String KEY = "my_key";
+
+ private Context mContext;
+ private TestPreferenceController mTestController;
+ private PreferenceScreen mScreen;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mTestController = new TestPreferenceController(mContext, KEY);
+ final PreferenceManager preferenceManager = new PreferenceManager(mContext);
+ mScreen = preferenceManager.createPreferenceScreen(mContext);
+ }
+
+ @Test
+ public void getController_addTask_checkControllerKey() {
+ final ControllerFutureTask futureTask = new ControllerFutureTask(
+ new ControllerTask(mTestController, mScreen, null /* metricsFeature */,
+ METRICS_CATEGORY_UNKNOWN), null /* result */);
+
+ assertThat(futureTask.getController().getPreferenceKey()).isEqualTo(KEY);
+ }
+
+
+ static class TestPreferenceController extends BasePreferenceController {
+ TestPreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/dashboard/ControllerTaskTest.java b/tests/robotests/src/com/android/settings/dashboard/ControllerTaskTest.java
new file mode 100644
index 0000000..17ab79c
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/dashboard/ControllerTaskTest.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2019 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.dashboard;
+
+import static com.android.settingslib.core.instrumentation.Instrumentable.METRICS_CATEGORY_UNKNOWN;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settingslib.core.AbstractPreferenceController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class ControllerTaskTest {
+ private static final String KEY = "my_key";
+
+ private Context mContext;
+ private PreferenceScreen mScreen;
+ private TestPreferenceController mTestController;
+ private ControllerTask mControllerTask;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ final PreferenceManager preferenceManager = new PreferenceManager(mContext);
+ mScreen = preferenceManager.createPreferenceScreen(mContext);
+ mTestController = spy(new TestPreferenceController(mContext));
+ mControllerTask = new ControllerTask(mTestController, mScreen, null /* metricsFeature */,
+ METRICS_CATEGORY_UNKNOWN);
+ }
+
+ @Test
+ public void doRun_controlNotAvailable_noRunUpdateState() {
+ mTestController.setAvailable(false);
+
+ mControllerTask.run();
+
+ verify(mTestController, never()).updateState(any(Preference.class));
+ }
+
+ @Test
+ public void doRun_emptyKey_noRunUpdateState() {
+ mTestController.setKey("");
+
+ mControllerTask.run();
+
+ verify(mTestController, never()).updateState(any(Preference.class));
+ }
+
+ @Test
+ public void doRun_preferenceNotExist_noRunUpdateState() {
+ mTestController.setKey(KEY);
+
+ mControllerTask.run();
+
+ verify(mTestController, never()).updateState(any(Preference.class));
+ }
+
+ @Test
+ public void doRun_executeUpdateState() {
+ mTestController.setKey(KEY);
+ final Preference preference = new Preference(mContext);
+ preference.setKey(KEY);
+ mScreen.addPreference(preference);
+
+ mControllerTask.run();
+
+ verify(mTestController).updateState(any(Preference.class));
+ }
+
+ static class TestPreferenceController extends AbstractPreferenceController {
+ private boolean mAvailable;
+ private String mKey;
+
+ TestPreferenceController(Context context) {
+ super(context);
+ mAvailable = true;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return mAvailable;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return mKey;
+ }
+
+ void setAvailable(boolean available) {
+ mAvailable = available;
+ }
+
+ void setKey(String key) {
+ mKey = key;
+ }
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
index 146b37a..e70578e 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
@@ -37,6 +37,7 @@
import android.content.pm.ProviderInfo;
import android.net.Uri;
import android.os.Bundle;
+import android.util.FeatureFlagUtils;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
@@ -45,9 +46,11 @@
import androidx.preference.SwitchPreference;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.core.FeatureFlags;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.slices.BlockingSlicePrefController;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.widget.MasterSwitchPreference;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
@@ -323,7 +326,47 @@
assertThat(pref).isInstanceOf(SwitchPreference.class);
}
- private static class TestPreferenceController extends AbstractPreferenceController
+ @Test
+ public void createPreference_isActivityTileAndHasSwitch_returnMasterSwitchPreference() {
+ mActivityTile.getMetaData().putString(META_DATA_PREFERENCE_SWITCH_URI, "uri");
+
+ final Preference pref = mTestFragment.createPreference(mActivityTile);
+
+ assertThat(pref).isInstanceOf(MasterSwitchPreference.class);
+ }
+
+ @Test
+ public void isFeatureFlagAndIsParalleled_runParalleledUpdatePreferenceStates() {
+ FeatureFlagUtils.setEnabled(mContext, FeatureFlags.CONTROLLER_ENHANCEMENT, true);
+ final TestFragment testFragment = spy(new TestFragment(RuntimeEnvironment.application));
+
+ testFragment.updatePreferenceStates();
+
+ verify(testFragment).updatePreferenceStatesInParallel();
+ }
+
+ @Test
+ public void notFeatureFlagAndIsParalleled_notRunParalleledUpdatePreferenceStates() {
+ FeatureFlagUtils.setEnabled(mContext, FeatureFlags.CONTROLLER_ENHANCEMENT, false);
+ final TestFragment testFragment = spy(new TestFragment(RuntimeEnvironment.application));
+
+ testFragment.updatePreferenceStates();
+
+ verify(testFragment, never()).updatePreferenceStatesInParallel();
+ }
+
+ @Test
+ public void isFeatureFlagAndNotParalleled_notRunParalleledUpdatePreferenceStates() {
+ FeatureFlagUtils.setEnabled(mContext, FeatureFlags.CONTROLLER_ENHANCEMENT, true);
+ final TestFragment testFragment = spy(new TestFragment(RuntimeEnvironment.application));
+ testFragment.setUsingControllerEnhancement(false);
+
+ testFragment.updatePreferenceStates();
+
+ verify(testFragment, never()).updatePreferenceStatesInParallel();
+ }
+
+ public static class TestPreferenceController extends AbstractPreferenceController
implements PreferenceControllerMixin {
private TestPreferenceController(Context context) {
@@ -352,19 +395,21 @@
private static class TestFragment extends DashboardFragment {
- public final PreferenceScreen mScreen;
-
private final PreferenceManager mPreferenceManager;
private final Context mContext;
private final List<AbstractPreferenceController> mControllers;
private final ContentResolver mContentResolver;
+ public final PreferenceScreen mScreen;
+ private boolean mIsParalleled;
+
public TestFragment(Context context) {
mContext = context;
mPreferenceManager = mock(PreferenceManager.class);
mScreen = mock(PreferenceScreen.class);
mContentResolver = mock(ContentResolver.class);
mControllers = new ArrayList<>();
+ mIsParalleled = true;
when(mPreferenceManager.getContext()).thenReturn(mContext);
ReflectionHelpers.setField(
@@ -410,6 +455,14 @@
protected ContentResolver getContentResolver() {
return mContentResolver;
}
+
+ protected boolean isParalleledControllers() {
+ return mIsParalleled;
+ }
+
+ public void setUsingControllerEnhancement(boolean isParalleled) {
+ mIsParalleled = isParalleled;
+ }
}
private static class TestDynamicDataObserver extends DynamicDataObserver {
diff --git a/tests/robotests/src/com/android/settings/datetime/DatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datetime/DatePreferenceControllerTest.java
index e0770aa..f4d4666 100644
--- a/tests/robotests/src/com/android/settings/datetime/DatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/DatePreferenceControllerTest.java
@@ -21,7 +21,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.app.AlarmManager;
+import android.app.timedetector.TimeDetector;
import android.content.Context;
import com.android.settingslib.RestrictedPreference;
@@ -40,7 +40,7 @@
@Mock
private Context mContext;
@Mock
- private AlarmManager mAlarmManager;
+ private TimeDetector mTimeDetector;
@Mock
private DatePreferenceController.DatePreferenceHost mHost;
@Mock
@@ -52,7 +52,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- when(mContext.getSystemService(Context.ALARM_SERVICE)).thenReturn(mAlarmManager);
+ when(mContext.getSystemService(TimeDetector.class)).thenReturn(mTimeDetector);
mPreference = new RestrictedPreference(RuntimeEnvironment.application);
mController = new DatePreferenceController(mContext, mHost, mAutoTimePreferenceController);
}
diff --git a/tests/robotests/src/com/android/settings/development/VerifyAppsOverUsbPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/VerifyAppsOverUsbPreferenceControllerTest.java
index f0961f1..87b9126 100644
--- a/tests/robotests/src/com/android/settings/development/VerifyAppsOverUsbPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/VerifyAppsOverUsbPreferenceControllerTest.java
@@ -130,17 +130,6 @@
}
@Test
- public void updateState_verifierOff_preferenceShouldNotBeChecked() {
- setupVerifyBroadcastReceivers(true);
- setupEnforcedAdmin(null);
- mGlobals.set(Global.ADB_ENABLED, 1 /* setting enabled */)
- .set(Global.PACKAGE_VERIFIER_INCLUDE_ADB, 1 /* setting enabled */)
- .set(Global.PACKAGE_VERIFIER_ENABLE, 0 /* setting disabled */);
- mController.updateState(mPreference);
- verify(mPreference).setChecked(false);
- }
-
- @Test
public void updateState_noBroadcastReceivers_preferenceShouldNotBeChecked() {
setupVerifyBroadcastReceivers(false);
setupEnforcedAdmin(null);
@@ -196,4 +185,4 @@
assertThat(mode).isEqualTo(VerifyAppsOverUsbPreferenceController.SETTING_VALUE_OFF);
}
-}
\ No newline at end of file
+}
diff --git a/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java
new file mode 100644
index 0000000..d13b927
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java
@@ -0,0 +1,176 @@
+/*
+ * Copyright 2019 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.development.compat;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.compat.Compatibility.ChangeConfig;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.graphics.drawable.Drawable;
+import android.os.RemoteException;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+import com.android.internal.compat.CompatibilityChangeConfig;
+import com.android.internal.compat.CompatibilityChangeInfo;
+import com.android.internal.compat.IPlatformCompat;
+import com.android.settings.R;
+
+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;
+import org.robolectric.RuntimeEnvironment;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+@RunWith(RobolectricTestRunner.class)
+public class PlatformCompatDashboardTest {
+ private PlatformCompatDashboard mDashboard;
+
+ @Mock
+ private IPlatformCompat mPlatformCompat;
+ private PreferenceScreen mPreferenceScreen;
+ @Mock
+ private ApplicationInfo mApplicationInfo;
+ @Mock
+ private PreferenceManager mPreferenceManager;
+
+ private Context mContext;
+ private CompatibilityChangeInfo[] mChanges;
+ private static final String APP_NAME = "foo.bar.baz";
+
+ @Before
+ public void setUp() throws RemoteException, NameNotFoundException {
+ MockitoAnnotations.initMocks(this);
+ mChanges = new CompatibilityChangeInfo[5];
+ mChanges[0] = new CompatibilityChangeInfo(1L, "Default_Enabled", 0, false);
+ mChanges[1] = new CompatibilityChangeInfo(2L, "Default_Disabled", 0, true);
+ mChanges[2] = new CompatibilityChangeInfo(3L, "Enabled_After_SDK_1_1", 1, false);
+ mChanges[3] = new CompatibilityChangeInfo(4L, "Enabled_After_SDK_1_2", 1, false);
+ mChanges[4] = new CompatibilityChangeInfo(5L, "Enabled_After_SDK_2", 2, false);
+ when(mPlatformCompat.listAllChanges()).thenReturn(mChanges);
+ mContext = RuntimeEnvironment.application;
+ mPreferenceManager = new PreferenceManager(mContext);
+ mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
+ mApplicationInfo.packageName = APP_NAME;
+ mDashboard = spy(new PlatformCompatDashboard());
+ mDashboard.mSelectedApp = APP_NAME;
+ doReturn(mApplicationInfo).when(mDashboard).getApplicationInfo();
+ doReturn(mPlatformCompat).when(mDashboard).getPlatformCompat();
+ doReturn(mPreferenceScreen).when(mDashboard).getPreferenceScreen();
+ doReturn(mPreferenceManager).when(mDashboard).getPreferenceManager();
+ }
+
+ @Test
+ public void getHelpResource_shouldNotHaveHelpResource() {
+ assertThat(mDashboard.getHelpResource()).isEqualTo(0);
+ }
+
+ @Test
+ public void getPreferenceScreenResId_shouldBePlatformCompatSettingsResId() {
+ assertThat(mDashboard.getPreferenceScreenResId())
+ .isEqualTo(R.xml.platform_compat_settings);
+ }
+
+ @Test
+ public void createAppPreference_targetSdkEquals1_summaryReturnsAppNameAndTargetSdk() {
+ mApplicationInfo.targetSdkVersion = 1;
+
+ Preference appPreference = mDashboard.createAppPreference(any(Drawable.class));
+
+ assertThat(appPreference.getSummary()).isEqualTo(APP_NAME + " SDK 1");
+ }
+
+ @Test
+ public void createPreferenceForChange_defaultEnabledChange_createCheckedEntry() {
+ CompatibilityChangeInfo enabledChange = mChanges[0];
+ CompatibilityChangeConfig config = new CompatibilityChangeConfig(
+ new ChangeConfig(new HashSet<Long>(Arrays.asList(enabledChange.getId())),
+ new HashSet<Long>()));
+
+ Preference enabledPreference = mDashboard.createPreferenceForChange(mContext, enabledChange,
+ config);
+
+ SwitchPreference enabledSwitchPreference = (SwitchPreference) enabledPreference;
+
+ assertThat(enabledPreference.getSummary()).isEqualTo(mChanges[0].getName());
+ assertThat(enabledPreference instanceof SwitchPreference).isTrue();
+ assertThat(enabledSwitchPreference.isChecked()).isTrue();
+ }
+
+ @Test
+ public void createPreferenceForChange_defaultDisabledChange_createUncheckedEntry() {
+ CompatibilityChangeInfo disabledChange = mChanges[1];
+ CompatibilityChangeConfig config = new CompatibilityChangeConfig(
+ new ChangeConfig(new HashSet<Long>(),
+ new HashSet<Long>(Arrays.asList(disabledChange.getId()))));
+
+ Preference disabledPreference = mDashboard.createPreferenceForChange(mContext,
+ disabledChange, config);
+
+ assertThat(disabledPreference.getSummary()).isEqualTo(mChanges[1].getName());
+ SwitchPreference disabledSwitchPreference = (SwitchPreference) disabledPreference;
+ assertThat(disabledSwitchPreference.isChecked()).isFalse();
+ }
+
+ @Test
+ public void createChangeCategoryPreference_enabledAndDisabled_hasTitleAndEntries() {
+ Set<Long> enabledChanges = new HashSet<>();
+ enabledChanges.add(mChanges[0].getId());
+ enabledChanges.add(mChanges[1].getId());
+ enabledChanges.add(mChanges[2].getId());
+ Set<Long> disabledChanges = new HashSet<>();
+ disabledChanges.add(mChanges[3].getId());
+ disabledChanges.add(mChanges[4].getId());
+ CompatibilityChangeConfig config = new CompatibilityChangeConfig(
+ new ChangeConfig(enabledChanges, disabledChanges));
+ List<CompatibilityChangeInfo> changesToAdd = new ArrayList<>();
+ for (int i = 0; i < mChanges.length; ++i) {
+ changesToAdd.add(new CompatibilityChangeInfo(mChanges[i].getId(), mChanges[i]
+ .getName(),
+ mChanges[i].getEnableAfterTargetSdk(), mChanges[i].getDisabled()));
+ }
+
+ PreferenceCategory category = mDashboard.createChangeCategoryPreference(changesToAdd,
+ config, "foo");
+
+ assertThat(category.getTitle()).isEqualTo("foo");
+ assertThat(category.getPreferenceCount()).isEqualTo(mChanges.length);
+ for (int i = 0; i < mChanges.length; ++i) {
+ Preference childPreference = category.getPreference(i);
+ assertThat(childPreference instanceof SwitchPreference).isTrue();
+ }
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
index 80a3a11..851e56f 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
@@ -205,4 +205,9 @@
final CharSequence data = clipboard.getPrimaryClip().getItemAt(0).getText();
assertThat(data.toString()).isEqualTo(mController.getSummary());
}
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
index 3e6e436..c47a1e6 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
@@ -179,4 +179,9 @@
final CharSequence data = clipboard.getPrimaryClip().getItemAt(0).getText();
assertThat(phoneNumber.contentEquals(data)).isTrue();
}
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceControllerTest.java
index adfff25..a3606e8 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceControllerTest.java
@@ -19,7 +19,6 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -89,6 +88,11 @@
verify(mContext).startActivity(any());
}
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
+
private static class TestController extends FirmwareVersionDetailPreferenceController {
public TestController(Context context, String key) {
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/DeviceModelPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/DeviceModelPreferenceControllerTest.java
index 1204c44..65e29b4 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/DeviceModelPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/DeviceModelPreferenceControllerTest.java
@@ -61,4 +61,9 @@
public void isAlwaysSliceable() {
assertThat(mController.isSliceable()).isTrue();
}
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/HardwareRevisionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/HardwareRevisionPreferenceControllerTest.java
index 98ffbd0..ce022fd 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/HardwareRevisionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/HardwareRevisionPreferenceControllerTest.java
@@ -51,6 +51,11 @@
}
@Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
+
+ @Test
public void isCopyableSlice_shouldBeCopyableSlice() {
assertThat(mController.isCopyableSlice()).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/SerialNumberPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/SerialNumberPreferenceControllerTest.java
index c2ae4af..93762b1 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/SerialNumberPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/SerialNumberPreferenceControllerTest.java
@@ -43,6 +43,11 @@
}
@Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
+
+ @Test
public void isCopyableSlice() {
assertThat(mController.isSliceable()).isTrue();
assertThat(mController.isCopyableSlice()).isTrue();
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
index 997c35e..24277fc 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
@@ -186,4 +186,9 @@
final CharSequence data = clipboard.getPrimaryClip().getItemAt(0).getText();
assertThat(data.toString()).isEqualTo(meid);
}
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/display/AdaptiveSleepDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AdaptiveSleepDetailPreferenceControllerTest.java
index 91a4ed6..981942d 100644
--- a/tests/robotests/src/com/android/settings/display/AdaptiveSleepDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AdaptiveSleepDetailPreferenceControllerTest.java
@@ -62,6 +62,11 @@
}
@Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
+
+ @Test
public void getAvailabilityStatus_configTrueSet_shouldReturnAvailable() {
SettingsShadowResources.overrideResource(R.bool.config_adaptive_sleep_available, true);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
diff --git a/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java
index 9928e6c..295eac5 100644
--- a/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java
@@ -133,10 +133,10 @@
}
@Test
- public void isSliceable_returnsFalse() {
+ public void isSliceable_returnsTrue() {
final AdaptiveSleepPreferenceController controller =
new AdaptiveSleepPreferenceController(mContext, "any_key");
- assertThat(controller.isSliceable()).isFalse();
+ assertThat(controller.isSliceable()).isTrue();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceControllerTest.java
index 7cd5a23..1548b42 100644
--- a/tests/robotests/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceControllerTest.java
@@ -128,4 +128,9 @@
new AmbientDisplayAlwaysOnPreferenceController(mContext, "bad_key");
assertThat(controller.isSliceable()).isFalse();
}
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceControllerTest.java
index fbfb8a4..6caa8bd 100644
--- a/tests/robotests/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceControllerTest.java
@@ -171,4 +171,9 @@
new AmbientDisplayNotificationsPreferenceController(mContext, "bad_key");
assertThat(controller.isSliceable()).isFalse();
}
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/display/AutoBrightnessDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AutoBrightnessDetailPreferenceControllerTest.java
index e76cff6..cdb08f3 100644
--- a/tests/robotests/src/com/android/settings/display/AutoBrightnessDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AutoBrightnessDetailPreferenceControllerTest.java
@@ -52,6 +52,11 @@
}
@Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
+
+ @Test
public void getAvailabilityStatus_configTrueSet_shouldReturnAvailable() {
SettingsShadowResources.overrideResource(
com.android.internal.R.bool.config_automatic_brightness_available, true);
diff --git a/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java
index a26e0b7..1d175de 100644
--- a/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java
@@ -35,7 +35,6 @@
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.shadow.ShadowRotationPolicy;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -153,6 +152,11 @@
assertThat(controller.isSliceable()).isFalse();
}
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
+
private void enableAutoRotationPreference() {
when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true);
when(mContext.getResources().getBoolean(anyInt())).thenReturn(true);
diff --git a/tests/robotests/src/com/android/settings/display/NightDisplayActivationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/NightDisplayActivationPreferenceControllerTest.java
index e666d61..bad112a 100644
--- a/tests/robotests/src/com/android/settings/display/NightDisplayActivationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/NightDisplayActivationPreferenceControllerTest.java
@@ -15,6 +15,7 @@
package com.android.settings.display;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;
@@ -57,7 +58,7 @@
mPreference = new LayoutPreference(mContext, R.layout.night_display_activation_button);
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
mPreferenceController = new NightDisplayActivationPreferenceController(mContext,
- "night_display_activation");
+ "night_display_activation");
mPreferenceController.displayPreference(mScreen);
}
@@ -83,7 +84,7 @@
@Test
public void isSliceableCorrectKey_returnsTrue() {
final NightDisplayActivationPreferenceController controller =
- new NightDisplayActivationPreferenceController(mContext,"night_display_activated");
+ new NightDisplayActivationPreferenceController(mContext, "night_display_activated");
assertThat(controller.isSliceable()).isTrue();
}
@@ -95,6 +96,11 @@
}
@Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mPreferenceController.isPublicSlice()).isTrue();
+ }
+
+ @Test
public void onClick_activates() {
mColorDisplayManager.setNightDisplayActivated(false);
diff --git a/tests/robotests/src/com/android/settings/display/NightDisplayIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/NightDisplayIntensityPreferenceControllerTest.java
index b9c2abd..be9ceaf 100644
--- a/tests/robotests/src/com/android/settings/display/NightDisplayIntensityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/NightDisplayIntensityPreferenceControllerTest.java
@@ -19,7 +19,9 @@
import android.content.Context;
import android.hardware.display.ColorDisplayManager;
import android.provider.Settings.Secure;
+
import com.android.settings.testutils.shadow.SettingsShadowResources;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -32,83 +34,89 @@
@Config(shadows = SettingsShadowResources.class)
public class NightDisplayIntensityPreferenceControllerTest {
- private Context mContext;
- private NightDisplayIntensityPreferenceController mPreferenceController;
+ private Context mContext;
+ private NightDisplayIntensityPreferenceController mPreferenceController;
- @Before
- public void setUp() {
- mContext = RuntimeEnvironment.application;
- mPreferenceController = new NightDisplayIntensityPreferenceController(mContext,
- "night_display_temperature");
- }
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mPreferenceController = new NightDisplayIntensityPreferenceController(mContext,
+ "night_display_temperature");
+ }
- @After
- public void tearDown() {
- SettingsShadowResources.reset();
- }
+ @After
+ public void tearDown() {
+ SettingsShadowResources.reset();
+ }
- @Test
- public void isAvailable_configuredAvailable_isActivated_available() {
- SettingsShadowResources.overrideResource(
- com.android.internal.R.bool.config_nightDisplayAvailable, true);
- Secure.putInt(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_ACTIVATED, 1);
- assertThat(mPreferenceController.isAvailable()).isTrue();
- }
+ @Test
+ public void isAvailable_configuredAvailable_isActivated_available() {
+ SettingsShadowResources.overrideResource(
+ com.android.internal.R.bool.config_nightDisplayAvailable, true);
+ Secure.putInt(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_ACTIVATED, 1);
+ assertThat(mPreferenceController.isAvailable()).isTrue();
+ }
- @Test
- public void isAvailable_configuredAvailable_isNotActivated_available() {
- SettingsShadowResources.overrideResource(
- com.android.internal.R.bool.config_nightDisplayAvailable, true);
- Secure.putInt(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_ACTIVATED, 0);
- assertThat(mPreferenceController.isAvailable()).isTrue();
- }
+ @Test
+ public void isAvailable_configuredAvailable_isNotActivated_available() {
+ SettingsShadowResources.overrideResource(
+ com.android.internal.R.bool.config_nightDisplayAvailable, true);
+ Secure.putInt(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_ACTIVATED, 0);
+ assertThat(mPreferenceController.isAvailable()).isTrue();
+ }
- @Test
- public void isAvailable_configuredUnavailable_unavailable() {
- SettingsShadowResources.overrideResource(
- com.android.internal.R.bool.config_nightDisplayAvailable, false);
- assertThat(mPreferenceController.isAvailable()).isFalse();
- }
+ @Test
+ public void isAvailable_configuredUnavailable_unavailable() {
+ SettingsShadowResources.overrideResource(
+ com.android.internal.R.bool.config_nightDisplayAvailable, false);
+ assertThat(mPreferenceController.isAvailable()).isFalse();
+ }
- @Test
- public void onPreferenceChange_changesTemperature() {
- SettingsShadowResources.overrideResource(
- com.android.internal.R.integer.config_nightDisplayColorTemperatureMin, 2950);
- SettingsShadowResources.overrideResource(
- com.android.internal.R.integer.config_nightDisplayColorTemperatureMax, 3050);
- // A slider-adjusted "20" here would be 1/5 from the left / least-intense, i.e. 3030.
- mPreferenceController.onPreferenceChange(null, 20);
+ @Test
+ public void onPreferenceChange_changesTemperature() {
+ SettingsShadowResources.overrideResource(
+ com.android.internal.R.integer.config_nightDisplayColorTemperatureMin, 2950);
+ SettingsShadowResources.overrideResource(
+ com.android.internal.R.integer.config_nightDisplayColorTemperatureMax, 3050);
+ // A slider-adjusted "20" here would be 1/5 from the left / least-intense, i.e. 3030.
+ mPreferenceController.onPreferenceChange(null, 20);
- assertThat(
- mContext.getSystemService(ColorDisplayManager.class).getNightDisplayColorTemperature())
- .isEqualTo(3030);
- }
+ assertThat(
+ mContext.getSystemService(
+ ColorDisplayManager.class).getNightDisplayColorTemperature())
+ .isEqualTo(3030);
+ }
- @Test
- public void rangeOfSlider_staysWithinValidRange() {
- SettingsShadowResources.overrideResource(
- com.android.internal.R.integer.config_nightDisplayColorTemperatureMin, 2950);
- SettingsShadowResources.overrideResource(
- com.android.internal.R.integer.config_nightDisplayColorTemperatureMax, 3050);
+ @Test
+ public void rangeOfSlider_staysWithinValidRange() {
+ SettingsShadowResources.overrideResource(
+ com.android.internal.R.integer.config_nightDisplayColorTemperatureMin, 2950);
+ SettingsShadowResources.overrideResource(
+ com.android.internal.R.integer.config_nightDisplayColorTemperatureMax, 3050);
- assertThat(mPreferenceController.getMax() - mPreferenceController.getMin())
- .isGreaterThan(0);
- }
+ assertThat(mPreferenceController.getMax() - mPreferenceController.getMin())
+ .isGreaterThan(0);
+ }
- @Test
- public void getMin_alwaysReturnsZero() {
- assertThat(mPreferenceController.getMin()).isEqualTo(0);
- }
+ @Test
+ public void getMin_alwaysReturnsZero() {
+ assertThat(mPreferenceController.getMin()).isEqualTo(0);
+ }
- @Test
- public void isSliceableCorrectKey_returnsTrue() {
- assertThat(mPreferenceController.isSliceable()).isTrue();
- }
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ assertThat(mPreferenceController.isSliceable()).isTrue();
+ }
- @Test
- public void isSliceableIncorrectKey_returnsFalse() {
- final NightDisplayIntensityPreferenceController controller =
- new NightDisplayIntensityPreferenceController(mContext, "bad_key");
- assertThat(controller.isSliceable()).isFalse();
- }
+ @Test
+ public void isSliceableIncorrectKey_returnsFalse() {
+ final NightDisplayIntensityPreferenceController controller =
+ new NightDisplayIntensityPreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mPreferenceController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/SmartBatteryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/SmartBatteryPreferenceControllerTest.java
index 7bc6ead..91e7b04 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/SmartBatteryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/SmartBatteryPreferenceControllerTest.java
@@ -120,4 +120,9 @@
new SmartBatteryPreferenceController(null);
assertThat(controller.isSliceable()).isTrue();
}
+
+ @Test
+ public void isPublicSlice_returnsTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java
index 8609599..c01c174 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java
@@ -110,4 +110,9 @@
verify(mPowerManager).setPowerSaveModeEnabled(false);
}
+
+ @Test
+ public void isPublicSlice_returnsTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
index fac5ae8..7582699 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
@@ -140,4 +140,9 @@
new DoubleTapPowerPreferenceController(mContext, "bad_key");
assertThat(controller.isSliceable()).isFalse();
}
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
index 0dc7a78..edcbd76 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
@@ -129,4 +129,9 @@
new DoubleTapScreenPreferenceController(mContext, "bad_key");
assertThat(controller.isSliceable()).isFalse();
}
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
index 0efbf57..7bdd262 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
@@ -170,4 +170,9 @@
new DoubleTwistPreferenceController(mContext, "bad_key");
assertThat(controller.isSliceable()).isFalse();
}
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/GlobalActionsPanelPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/GlobalActionsPanelPreferenceControllerTest.java
index 1fed7df..65f7ac7 100644
--- a/tests/robotests/src/com/android/settings/gestures/GlobalActionsPanelPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/GlobalActionsPanelPreferenceControllerTest.java
@@ -85,4 +85,9 @@
new GlobalActionsPanelPreferenceController(mContext, "bad_key");
assertThat(controller.isSliceable()).isFalse();
}
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
index b2ba216..b694db3 100644
--- a/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
@@ -118,4 +118,9 @@
new PickupGesturePreferenceController(mContext, "bad_key");
assertThat(controller.isSliceable()).isFalse();
}
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
index dbef598..519232e 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
@@ -184,4 +184,9 @@
new SwipeToNotificationPreferenceController(mContext, "bad_key");
assertThat(controller.isSliceable()).isFalse();
}
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/TapScreenGesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/TapScreenGesturePreferenceControllerTest.java
index 12715fd..b1a53cc 100644
--- a/tests/robotests/src/com/android/settings/gestures/TapScreenGesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/TapScreenGesturePreferenceControllerTest.java
@@ -30,7 +30,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
@@ -90,4 +89,9 @@
new TapScreenGesturePreferenceController(mContext, KEY_WAKE_LOCK_SCREEN);
assertThat(controller.isSliceable()).isTrue();
}
+
+ @Test
+ public void isPublicSlice_returnTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/location/AppLocationPermissionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/AppLocationPermissionPreferenceControllerTest.java
index 7392ec7..4303489 100644
--- a/tests/robotests/src/com/android/settings/location/AppLocationPermissionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/AppLocationPermissionPreferenceControllerTest.java
@@ -2,6 +2,9 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
import android.content.Context;
import android.location.LocationManager;
import android.provider.Settings;
@@ -30,6 +33,7 @@
private LifecycleOwner mLifecycleOwner;
private Lifecycle mLifecycle;
private LocationManager mLocationManager;
+ private LocationSettings mLocationSettings;
@Before
public void setUp() {
@@ -37,7 +41,10 @@
mContext = RuntimeEnvironment.application;
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
- mController = new AppLocationPermissionPreferenceController(mContext, mLifecycle);
+ mLocationSettings = spy(new LocationSettings());
+ when(mLocationSettings.getSettingsLifecycle()).thenReturn(mLifecycle);
+ mController = new AppLocationPermissionPreferenceController(mContext, "key");
+ mController.init(mLocationSettings);
mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
}
diff --git a/tests/robotests/src/com/android/settings/location/LocationFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationFooterPreferenceControllerTest.java
index dc3d40a..180f3e2 100644
--- a/tests/robotests/src/com/android/settings/location/LocationFooterPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationFooterPreferenceControllerTest.java
@@ -70,7 +70,7 @@
Context context = spy(RuntimeEnvironment.application);
when(context.getPackageManager()).thenReturn(mPackageManager);
when(mPreferenceCategory.getContext()).thenReturn(context);
- mController = spy(new LocationFooterPreferenceController(context));
+ mController = spy(new LocationFooterPreferenceController(context, "key"));
when(mPackageManager.getResourcesForApplication(any(ApplicationInfo.class)))
.thenReturn(mResources);
when(mResources.getString(TEST_RES_ID)).thenReturn(TEST_TEXT);
diff --git a/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java
index 9034688..5db5ed5 100644
--- a/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java
@@ -69,6 +69,7 @@
private LocationForWorkPreferenceController mController;
private LifecycleOwner mLifecycleOwner;
private Lifecycle mLifecycle;
+ private LocationSettings mLocationSettings;
@Before
public void setUp() {
@@ -77,10 +78,13 @@
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
- mController = spy(new LocationForWorkPreferenceController(mContext, mLifecycle));
+ mLocationSettings = spy(new LocationSettings());
+ when(mLocationSettings.getSettingsLifecycle()).thenReturn(mLifecycle);
+ mController = spy(new LocationForWorkPreferenceController(mContext, "key"));
+ mController.init(mLocationSettings);
mockManagedProfile();
ReflectionHelpers.setField(mController, "mLocationEnabler", mEnabler);
- when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+ when(mScreen.findPreference(any())).thenReturn(mPreference);
final String key = mController.getPreferenceKey();
when(mPreference.getKey()).thenReturn(key);
when(mPreference.isVisible()).thenReturn(true);
diff --git a/tests/robotests/src/com/android/settings/location/LocationScanningPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationScanningPreferenceControllerTest.java
index b85377c..28403b1 100644
--- a/tests/robotests/src/com/android/settings/location/LocationScanningPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationScanningPreferenceControllerTest.java
@@ -38,7 +38,7 @@
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
- mController = new LocationScanningPreferenceController(mContext);
+ mController = new LocationScanningPreferenceController(mContext, "key");
}
@Test
diff --git a/tests/robotests/src/com/android/settings/location/LocationServicePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationServicePreferenceControllerTest.java
index c6709ed..62c13af 100644
--- a/tests/robotests/src/com/android/settings/location/LocationServicePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationServicePreferenceControllerTest.java
@@ -59,8 +59,8 @@
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowUserManager.class)
public class LocationServicePreferenceControllerTest {
- private static final String LOCATION_SERVICES_MANAGED_PROFILE_KEY =
- "location_services_managed_profile";
+
+ private static final String KEY_LOCATION_SERVICES = "location_service";
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private LocationSettings mFragment;
@@ -86,14 +86,13 @@
mContext = spy(RuntimeEnvironment.application);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
- mController = spy(new LocationServicePreferenceController(
- mContext, mFragment, mLifecycle, mSettingsInjector));
+ mController = spy(new LocationServicePreferenceController(mContext, KEY_LOCATION_SERVICES));
+ when(mFragment.getSettingsLifecycle()).thenReturn(mLifecycle);
+ mController.init(mFragment);
+ mController.mInjector = mSettingsInjector;
final String key = mController.getPreferenceKey();
when(mScreen.findPreference(key)).thenReturn(mCategoryPrimary);
- when(mScreen.findPreference(LOCATION_SERVICES_MANAGED_PROFILE_KEY)).thenReturn(
- mCategoryManaged);
when(mCategoryPrimary.getKey()).thenReturn(key);
- when(mCategoryManaged.getKey()).thenReturn(LOCATION_SERVICES_MANAGED_PROFILE_KEY);
when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
.thenReturn(mDevicePolicyManager);
}
diff --git a/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java
index fb297fb..a0524fb 100644
--- a/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java
@@ -191,4 +191,9 @@
public void isSliceable_returnsTrue() {
assertThat(mController.isSliceable()).isTrue();
}
+
+ @Test
+ public void isPublicSlice_returnsTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
index bddc91f..c4f1948 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
@@ -42,7 +42,6 @@
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -122,7 +121,6 @@
}
@Test
- @Ignore
public void updateBottomNavigationViewV2_oneSubscription_shouldNotCrash() {
mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo1);
@@ -132,7 +130,6 @@
}
@Test
- @Ignore
public void updateBottomNavigationViewV2_twoSubscription_shouldNotCrash() {
mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo1, mSubscriptionInfo2);
@@ -142,7 +139,6 @@
}
@Test
- @Ignore
public void switchFragment_switchBetweenTwoSubscriptions() {
mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo1, mSubscriptionInfo2);
@@ -158,7 +154,6 @@
}
@Test
- @Ignore
public void switchFragment_subscriptionsUpdate_notifyByIntent() {
mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo1, mSubscriptionInfo2);
@@ -186,7 +181,6 @@
}
@Test
- @Ignore
public void onSaveInstanceState_saveCurrentSubId() {
mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo1, mSubscriptionInfo2);
diff --git a/tests/robotests/src/com/android/settings/nfc/NfcPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/nfc/NfcPreferenceControllerTest.java
index b6c8f37..872c712 100644
--- a/tests/robotests/src/com/android/settings/nfc/NfcPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/nfc/NfcPreferenceControllerTest.java
@@ -25,7 +25,6 @@
import android.content.Context;
import android.content.Intent;
-import android.net.Uri;
import android.nfc.NfcAdapter;
import android.nfc.NfcManager;
import android.os.UserManager;
@@ -36,7 +35,6 @@
import com.android.settings.nfc.NfcPreferenceController.NfcSliceWorker;
import com.android.settings.nfc.NfcPreferenceController.NfcSliceWorker.NfcUpdateReceiver;
-import com.android.settings.slices.SliceBuilderUtils;
import org.junit.Before;
import org.junit.Test;
@@ -286,4 +284,9 @@
verify(worker).updateSlice();
}
+
+ @Test
+ public void isPublicSlice_returnsTrue() {
+ assertThat(mNfcController.isPublicSlice()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/nfc/SecureNfcPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/nfc/SecureNfcPreferenceControllerTest.java
new file mode 100644
index 0000000..56f012a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/nfc/SecureNfcPreferenceControllerTest.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2019 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.nfc;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class SecureNfcPreferenceControllerTest {
+
+ private Context mContext;
+ private SecureNfcPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mController = new SecureNfcPreferenceController(mContext, "nfc_secure_settings");
+ }
+
+ @Test
+ public void isPublicSlice_returnsTrue() {
+ assertThat(mController.isPublicSlice()).isTrue();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/security/LockscreenDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/security/LockscreenDashboardFragmentTest.java
index 2db36b7..8b5c5fe 100644
--- a/tests/robotests/src/com/android/settings/security/LockscreenDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/security/LockscreenDashboardFragmentTest.java
@@ -123,13 +123,13 @@
}
@Test
- public void isPageSearchable_notLocked_shouldNotBeSearchable() {
+ public void isPageSearchable_notLocked_shouldBeSearchable() {
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(false);
when(mLockPatternUtils.isLockScreenDisabled(anyInt())).thenReturn(true);
assertThat(LockscreenDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
.getNonIndexableKeys(mContext))
- .contains("security_lockscreen_settings_screen");
+ .doesNotContain("security_lockscreen_settings_screen");
}
public static class TestFragment extends LockscreenDashboardFragment {
diff --git a/tests/robotests/src/com/android/settings/security/screenlock/LockScreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/screenlock/LockScreenPreferenceControllerTest.java
index 7ca9050..36eadba 100644
--- a/tests/robotests/src/com/android/settings/security/screenlock/LockScreenPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/screenlock/LockScreenPreferenceControllerTest.java
@@ -132,7 +132,7 @@
}
@Test
- public void onResume_unavailable_shouldHide() {
+ public void onResume_unavailable_shouldShow() {
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
when(mLockPatternUtils.getKeyguardStoredPasswordQuality(anyInt()))
.thenReturn(PASSWORD_QUALITY_UNSPECIFIED);
@@ -140,6 +140,6 @@
mController.displayPreference(mScreen);
mLifecycle.handleLifecycleEvent(ON_RESUME);
- assertThat(mPreference.isVisible()).isFalse();
+ assertThat(mPreference.isVisible()).isTrue();
}
}
diff --git a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
index ab4ece2..a969420 100644
--- a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
@@ -18,10 +18,13 @@
package com.android.settings.slices;
import static android.content.ContentResolver.SCHEME_CONTENT;
+import static android.content.pm.PackageManager.PERMISSION_DENIED;
+import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
@@ -66,12 +69,15 @@
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.Resetter;
import org.robolectric.shadow.api.Shadow;
import org.robolectric.shadows.ShadowAccessibilityManager;
+import org.robolectric.shadows.ShadowBinder;
+import org.robolectric.shadows.ShadowPackageManager;
import java.util.ArrayList;
import java.util.Arrays;
@@ -110,6 +116,7 @@
private Context mContext;
private SettingsSliceProvider mProvider;
+ private ShadowPackageManager mPackageManager;
@Mock
private SliceManager mManager;
@@ -146,6 +153,8 @@
doReturn(mManager).when(mContext).getSystemService(SliceManager.class);
when(mManager.getPinnedSlices()).thenReturn(Collections.emptyList());
+ mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
+
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
}
@@ -284,7 +293,8 @@
@Test
public void getDescendantUris_invalidPath_returnsEmpty() {
final String key = "platform_key";
- SliceTestUtils.insertSliceToDb(mContext, key, true /* isPlatformSlice */);
+ SliceTestUtils.insertSliceToDb(mContext, key, true /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, true /* isPublicSlice */);
final Uri uri = new Uri.Builder()
.scheme(SCHEME_CONTENT)
.authority(SettingsSlicesContract.AUTHORITY)
@@ -299,7 +309,8 @@
@Test
public void getDescendantUris_platformSlice_doesNotReturnOEMSlice() {
- SliceTestUtils.insertSliceToDb(mContext, "oem_key", false /* isPlatformSlice */);
+ SliceTestUtils.insertSliceToDb(mContext, "oem_key", false /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, true /* isPublicSlice */);
final Uri uri = new Uri.Builder()
.scheme(SCHEME_CONTENT)
.authority(SettingsSlicesContract.AUTHORITY)
@@ -313,7 +324,8 @@
@Test
public void getDescendantUris_oemSlice_doesNotReturnPlatformSlice() {
- SliceTestUtils.insertSliceToDb(mContext, "platform_key", true /* isPlatformSlice */);
+ SliceTestUtils.insertSliceToDb(mContext, "platform_key", true /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, true /* isPublicSlice */);
final Uri uri = new Uri.Builder()
.scheme(SCHEME_CONTENT)
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
@@ -328,7 +340,8 @@
@Test
public void getDescendantUris_oemSlice_returnsOEMUriDescendant() {
final String key = "oem_key";
- SliceTestUtils.insertSliceToDb(mContext, key, false /* isPlatformSlice */);
+ SliceTestUtils.insertSliceToDb(mContext, key, false /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, true /* isPublicSlice */);
final Uri uri = new Uri.Builder()
.scheme(SCHEME_CONTENT)
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
@@ -351,7 +364,8 @@
@Test
public void getDescendantUris_oemSliceNoPath_returnsOEMUriDescendant() {
final String key = "oem_key";
- SliceTestUtils.insertSliceToDb(mContext, key, false /* isPlatformSlice */);
+ SliceTestUtils.insertSliceToDb(mContext, key, false /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, true /* isPublicSlice */);
final Uri uri = new Uri.Builder()
.scheme(SCHEME_CONTENT)
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
@@ -371,9 +385,31 @@
}
@Test
+ public void getDescendantUris_oemSliceNoPath_notContainPrivateUri() {
+ final String key = "oem_key";
+ SliceTestUtils.insertSliceToDb(mContext, key, false /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, false /* isPublicSlice */);
+ final Uri uri = new Uri.Builder()
+ .scheme(SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .build();
+ final Uri expectedUri = new Uri.Builder()
+ .scheme(SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+ .appendPath(key)
+ .build();
+
+ final Collection<Uri> descendants = mProvider.onGetSliceDescendants(uri);
+
+ assertThat(descendants).doesNotContain(expectedUri);
+ }
+
+ @Test
public void getDescendantUris_platformSlice_returnsPlatformUriDescendant() {
final String key = "platform_key";
- SliceTestUtils.insertSliceToDb(mContext, key, true /* isPlatformSlice */);
+ SliceTestUtils.insertSliceToDb(mContext, key, true /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, true /* isPublicSlice */);
final Uri uri = new Uri.Builder()
.scheme(SCHEME_CONTENT)
.authority(SettingsSlicesContract.AUTHORITY)
@@ -396,7 +432,8 @@
@Test
public void getDescendantUris_platformSliceNoPath_returnsPlatformUriDescendant() {
final String key = "platform_key";
- SliceTestUtils.insertSliceToDb(mContext, key, true /* isPlatformSlice */);
+ SliceTestUtils.insertSliceToDb(mContext, key, true /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, true /* isPublicSlice */);
final Uri uri = new Uri.Builder()
.scheme(SCHEME_CONTENT)
.authority(SettingsSlicesContract.AUTHORITY)
@@ -419,8 +456,10 @@
public void getDescendantUris_noAuthorityNorPath_returnsAllUris() {
final String platformKey = "platform_key";
final String oemKey = "oemKey";
- SliceTestUtils.insertSliceToDb(mContext, platformKey, true /* isPlatformSlice */);
- SliceTestUtils.insertSliceToDb(mContext, oemKey, false /* isPlatformSlice */);
+ SliceTestUtils.insertSliceToDb(mContext, platformKey, true /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, true /* isPublicSlice */);
+ SliceTestUtils.insertSliceToDb(mContext, oemKey, false /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, true /* isPublicSlice */);
final Uri uri = new Uri.Builder()
.scheme(SCHEME_CONTENT)
.build();
@@ -446,6 +485,48 @@
}
@Test
+ @Config(qualifiers = "mcc999")
+ public void getDescendantUris_privateSlicesNeeded_containsPrivateSliceUri() {
+ final String privateKey = "test_private";
+ final Uri specialUri = Uri.parse("content://com.android.settings.slices/test");
+ doReturn(true).when(mProvider).isPrivateSlicesNeeded(specialUri);
+ SliceTestUtils.insertSliceToDb(mContext, privateKey /* key */, false /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, false /* isPublicSlice */);
+ final Collection<Uri> expectedUris = new HashSet<>();
+ expectedUris.addAll(SPECIAL_CASE_OEM_URIS);
+ expectedUris.add(new Uri.Builder()
+ .scheme(SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+ .appendPath(privateKey)
+ .build());
+
+ final Collection<Uri> descendants = mProvider.onGetSliceDescendants(specialUri);
+
+ assertThat(descendants).containsExactlyElementsIn(expectedUris);
+ }
+
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void getDescendantUris_privateSlicesNotNeeded_notContainPrivateSliceUri() {
+ final Uri specialUri = Uri.parse("content://com.android.settings.slices/test");
+ doReturn(false).when(mProvider).isPrivateSlicesNeeded(specialUri);
+ SliceTestUtils.insertSliceToDb(mContext,
+ "test_private" /* key */, false /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, false /* isPublicSlice */);
+ final Uri expectedUri = new Uri.Builder()
+ .scheme(SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+ .appendPath("test_private")
+ .build();
+
+ final Collection<Uri> descendants = mProvider.onGetSliceDescendants(specialUri);
+
+ assertThat(descendants).doesNotContain(expectedUri);
+ }
+
+ @Test
public void onCreatePermissionRequest_returnsSettingIntent() {
final PendingIntent pendingIntent = mProvider.onCreatePermissionRequest(
CustomSliceRegistry.FLASHLIGHT_SLICE_URI, "com.android.whaaaat");
@@ -531,6 +612,56 @@
.grantSlicePermission("com.android.settings.slice_whitelist_package", uris.get(0));
}
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void isPrivateSlicesNeeded_incorrectUri_returnFalse() {
+ final Uri uri = Uri.parse("content://com.android.settings.slices/test123");
+
+ assertThat(mProvider.isPrivateSlicesNeeded(uri)).isFalse();
+ }
+
+ @Test
+ public void isPrivateSlicesNeeded_noUri_returnFalse() {
+ final Uri uri = Uri.parse("content://com.android.settings.slices/test");
+
+ assertThat(mProvider.isPrivateSlicesNeeded(uri)).isFalse();
+ }
+
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void isPrivateSlicesNeeded_correctUriWithPermissionAndIsSI_returnTrue() {
+ final Uri uri = Uri.parse("content://com.android.settings.slices/test");
+ ShadowBinder.setCallingUid(123);
+ doReturn(PERMISSION_GRANTED)
+ .when(mContext).checkPermission(anyString(), anyInt(), anyInt());
+ mPackageManager.setPackagesForUid(123, new String[]{"com.android.settings.intelligence"});
+
+ assertThat(mProvider.isPrivateSlicesNeeded(uri)).isTrue();
+ }
+
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void isPrivateSlicesNeeded_correctUriWithPermissionNotSI_returnFalse() {
+ final Uri uri = Uri.parse("content://com.android.settings.slices/test");
+ ShadowBinder.setCallingUid(123);
+ doReturn(PERMISSION_GRANTED)
+ .when(mContext).checkPermission(anyString(), anyInt(), anyInt());
+ mPackageManager.setPackagesForUid(123, new String[]{"com.android.settings.test"});
+
+ assertThat(mProvider.isPrivateSlicesNeeded(uri)).isFalse();
+ }
+
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void isPrivateSlicesNeeded_correctUriNoPermission_returnFalse() {
+ final Uri uri = Uri.parse("content://com.android.settings.slices/test");
+ ShadowBinder.setCallingUid(123);
+ doReturn(PERMISSION_DENIED).when(mContext).checkPermission(anyString(), anyInt(), anyInt());
+ mPackageManager.setPackagesForUid(123, new String[]{"com.android.settings.intelligence"});
+
+ assertThat(mProvider.isPrivateSlicesNeeded(uri)).isFalse();
+ }
+
private static SliceData getDummyData() {
return new SliceData.Builder()
.setKey(KEY)
diff --git a/tests/robotests/src/com/android/settings/slices/SliceTestUtils.java b/tests/robotests/src/com/android/settings/slices/SliceTestUtils.java
index 4f5b3a1..1c9164a 100644
--- a/tests/robotests/src/com/android/settings/slices/SliceTestUtils.java
+++ b/tests/robotests/src/com/android/settings/slices/SliceTestUtils.java
@@ -47,6 +47,11 @@
public static void insertSliceToDb(Context context, String key, boolean isPlatformSlice,
String customizedUnavailableSliceSubtitle) {
+ insertSliceToDb(context, key, isPlatformSlice, customizedUnavailableSliceSubtitle, false);
+ }
+
+ public static void insertSliceToDb(Context context, String key, boolean isPlatformSlice,
+ String customizedUnavailableSliceSubtitle, boolean isPublicSlice) {
final SQLiteDatabase db = SlicesDatabaseHelper.getInstance(context).getWritableDatabase();
ContentValues values = new ContentValues();
values.put(SlicesDatabaseHelper.IndexColumns.KEY, key);
@@ -69,6 +74,7 @@
values.put(SlicesDatabaseHelper.IndexColumns.SLICE_TYPE, SliceData.SliceType.INTENT);
values.put(SlicesDatabaseHelper.IndexColumns.UNAVAILABLE_SLICE_SUBTITLE,
customizedUnavailableSliceSubtitle);
+ values.put(SlicesDatabaseHelper.IndexColumns.PUBLIC_SLICE, isPublicSlice);
db.replaceOrThrow(SlicesDatabaseHelper.Tables.TABLE_SLICES_INDEX, null, values);
db.close();
diff --git a/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java b/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java
index a28dba8..b4385d8 100644
--- a/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java
@@ -17,6 +17,8 @@
package com.android.settings.slices;
+import static android.content.ContentResolver.SCHEME_CONTENT;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.spy;
@@ -168,8 +170,10 @@
@Test
public void getDescendantUris_platformSlice_doesNotReturnOEMSlice() {
final String key = "oem_key";
- SliceTestUtils.insertSliceToDb(mContext, key, false /* isPlatformSlice */);
- final List<Uri> keys = mAccessor.getSliceUris(SettingsSlicesContract.AUTHORITY);
+ SliceTestUtils.insertSliceToDb(mContext, key, false /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, true /* isPublicSlice */);
+ final List<Uri> keys = mAccessor.getSliceUris(SettingsSlicesContract.AUTHORITY,
+ true /* isPublicSlice */);
assertThat(keys).isEmpty();
}
@@ -177,8 +181,10 @@
@Test
public void getDescendantUris_oemSlice_doesNotReturnPlatformSlice() {
final String key = "platform_key";
- SliceTestUtils.insertSliceToDb(mContext, key, true /* isPlatformSlice */);
- final List<Uri> keys = mAccessor.getSliceUris(SettingsSliceProvider.SLICE_AUTHORITY);
+ SliceTestUtils.insertSliceToDb(mContext, key, true /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, true /* isPublicSlice */);
+ final List<Uri> keys = mAccessor.getSliceUris(SettingsSliceProvider.SLICE_AUTHORITY,
+ true /* isPublicSlice */);
assertThat(keys).isEmpty();
}
@@ -186,8 +192,10 @@
@Test
public void getDescendantUris_oemSlice_returnsOEMUriDescendant() {
final String key = "oem_key";
- SliceTestUtils.insertSliceToDb(mContext, key, false /* isPlatformSlice */);
- final List<Uri> keys = mAccessor.getSliceUris(SettingsSliceProvider.SLICE_AUTHORITY);
+ SliceTestUtils.insertSliceToDb(mContext, key, false /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, true /* isPublicSlice */);
+ final List<Uri> keys = mAccessor.getSliceUris(SettingsSliceProvider.SLICE_AUTHORITY,
+ true /* isPublicSlice */);
assertThat(keys).containsExactly(
Uri.parse("content://com.android.settings.slices/action/oem_key"));
@@ -196,14 +204,52 @@
@Test
public void getDescendantUris_platformSlice_returnsPlatformUriDescendant() {
final String key = "platform_key";
- SliceTestUtils.insertSliceToDb(mContext, key, true /* isPlatformSlice */);
- final List<Uri> keys = mAccessor.getSliceUris(SettingsSlicesContract.AUTHORITY);
+ SliceTestUtils.insertSliceToDb(mContext, key, true /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, true /* isPublicSlice */);
+ final List<Uri> keys = mAccessor.getSliceUris(SettingsSlicesContract.AUTHORITY,
+ true /* isPublicSlice */);
assertThat(keys).containsExactly(
Uri.parse("content://android.settings.slices/action/platform_key"));
}
@Test
+ public void getSliceUris_publicSlice_returnPublicUri() {
+ SliceTestUtils.insertSliceToDb(mContext, "test_public", false /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, true /* isPublicSlice */);
+ SliceTestUtils.insertSliceToDb(mContext, "test_private", false /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, false /* isPublicSlice */);
+ final Uri expectedUri = new Uri.Builder()
+ .scheme(SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+ .appendPath("test_public")
+ .build();
+
+ final List<Uri> uri = mAccessor.getSliceUris(SettingsSliceProvider.SLICE_AUTHORITY, true);
+
+ assertThat(uri).containsExactly(expectedUri);
+ }
+
+ @Test
+ public void getSliceUris_nonPublicSlice_returnNonPublicUri() {
+ SliceTestUtils.insertSliceToDb(mContext, "test_public", false /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, true /* isPublicSlice */);
+ SliceTestUtils.insertSliceToDb(mContext, "test_private", false /* isPlatformSlice */,
+ null /* customizedUnavailableSliceSubtitle */, false /* isPublicSlice */);
+ final Uri expectedUri = new Uri.Builder()
+ .scheme(SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+ .appendPath("test_private")
+ .build();
+
+ final List<Uri> uri = mAccessor.getSliceUris(SettingsSliceProvider.SLICE_AUTHORITY, false);
+
+ assertThat(uri).containsExactly(expectedUri);
+ }
+
+ @Test
@Config(qualifiers = "mcc999")
public void getSliceKeys_indexesDatabase() {
// Force new indexing
@@ -220,7 +266,8 @@
FakeIndexProvider.SEARCH_INDEX_DATA_PROVIDER));
final SlicesDatabaseAccessor accessor = new SlicesDatabaseAccessor(mContext);
- final List<Uri> keys = accessor.getSliceUris(SettingsSliceProvider.SLICE_AUTHORITY);
+ final List<Uri> keys = accessor.getSliceUris(SettingsSliceProvider.SLICE_AUTHORITY,
+ true /* isPublicSlice */);
assertThat(keys).isNotEmpty();
}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowTileUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowTileUtils.java
index e1b815e..45a9dd6 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowTileUtils.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowTileUtils.java
@@ -58,7 +58,7 @@
}
@Implementation
- public static Bundle putBooleanToUri(Context context, Uri uri,
+ public static Bundle putBooleanToUriAndGetResult(Context context, Uri uri,
Map<String, IContentProvider> providerMap, String key, boolean value) {
sChecked = value;
return sResult;
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java b/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
index e64d015..d523866 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
@@ -50,7 +50,6 @@
import com.android.wifitrackerlib.WifiPickerTracker;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -241,9 +240,9 @@
}
@Test
- @Ignore
public void onCreateAdapter_hasStableIdsTrue() {
final PreferenceScreen preferenceScreen = mock(PreferenceScreen.class);
+ when(preferenceScreen.getContext()).thenReturn(mContext);
RecyclerView.Adapter adapter = mWifiSettings2.onCreateAdapter(preferenceScreen);
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
index ee14ca5..2fe7c5c 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
@@ -57,7 +57,6 @@
import com.android.settingslib.wifi.WifiTracker;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -296,9 +295,9 @@
}
@Test
- @Ignore
public void onCreateAdapter_hasStableIdsTrue() {
final PreferenceScreen preferenceScreen = mock(PreferenceScreen.class);
+ when(preferenceScreen.getContext()).thenReturn(mContext);
RecyclerView.Adapter adapter = mWifiSettings.onCreateAdapter(preferenceScreen);
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
index f0ac336..b990846 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
@@ -22,6 +22,7 @@
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
@@ -81,7 +82,6 @@
import com.android.settingslib.wifi.WifiTrackerFactory;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
@@ -1859,18 +1859,17 @@
}
@Test
- @Ignore
public void entityHeader_expiredPasspointR1_shouldHandleExpiration() {
- setUpForDisconnectedNetwork();
when(mockAccessPoint.isPasspoint()).thenReturn(true);
when(mockAccessPoint.isPasspointConfigurationR1()).thenReturn(true);
when(mockAccessPoint.isExpired()).thenReturn(true);
+ setUpForDisconnectedNetwork();
String expireSummary = mContext.getResources().getString(
com.android.settingslib.R.string.wifi_passpoint_expired);
displayAndResume();
- verify(mockButtonsPref).setButton3Visible(false);
+ verify(mockButtonsPref, atLeastOnce()).setButton3Visible(false);
verify(mockHeaderController).setSummary(expireSummary);
}
diff --git a/tests/robotests/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2Test.java b/tests/robotests/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2Test.java
index 8d15224..5b125e9 100644
--- a/tests/robotests/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2Test.java
@@ -22,6 +22,7 @@
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
@@ -81,7 +82,6 @@
import com.android.settingslib.wifi.WifiTrackerFactory;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
@@ -1859,18 +1859,17 @@
}
@Test
- @Ignore
public void entityHeader_expiredPasspointR1_shouldHandleExpiration() {
- setUpForDisconnectedNetwork();
when(mMockAccessPoint.isPasspoint()).thenReturn(true);
when(mMockAccessPoint.isPasspointConfigurationR1()).thenReturn(true);
when(mMockAccessPoint.isExpired()).thenReturn(true);
+ setUpForDisconnectedNetwork();
String expireSummary = mContext.getResources().getString(
com.android.settingslib.R.string.wifi_passpoint_expired);
displayAndResume();
- verify(mMockButtonsPref).setButton3Visible(false);
+ verify(mMockButtonsPref, atLeastOnce()).setButton3Visible(false);
verify(mMockHeaderController).setSummary(expireSummary);
}