Snap for 7402811 from 1e747a593f to sc-release
Change-Id: I14423eab0669f373f8a6fe24893a853c07a0b9aa
This commit is contained in:
@@ -2115,6 +2115,8 @@
|
||||
android:value="com.android.settings.category.ia.system" />
|
||||
<meta-data android:name="com.android.settings.summary"
|
||||
android:resource="@string/summary_empty"/>
|
||||
<meta-data android:name="com.android.settings.icon"
|
||||
android:resource="@drawable/ic_settings_development" />
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.development.DevelopmentSettingsDashboardFragment" />
|
||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||
@@ -2584,6 +2586,8 @@
|
||||
android:value="com.android.settings.category.ia.system" />
|
||||
<meta-data android:name="com.android.settings.summary_uri"
|
||||
android:value="content://com.android.settings.dashboard.SummaryProvider/user" />
|
||||
<meta-data android:name="com.android.settings.icon"
|
||||
android:resource="@drawable/ic_settings_multiuser" />
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.users.UserSettings" />
|
||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||
@@ -3288,6 +3292,8 @@
|
||||
<!-- Tell Settings app which category it belongs to -->
|
||||
<meta-data android:name="com.android.settings.category"
|
||||
android:value="com.android.settings.category.ia.system" />
|
||||
<meta-data android:name="com.android.settings.icon"
|
||||
android:resource="@drawable/ic_settings_backup" />
|
||||
<meta-data android:name="com.android.settings.order" android:value="-60"/>
|
||||
</activity>
|
||||
|
||||
@@ -3317,15 +3323,6 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".Settings$AppAndNotificationDashboardActivity"
|
||||
android:label="@string/app_and_notification_dashboard_title"
|
||||
android:icon="@drawable/ic_homepage_apps"
|
||||
android:exported="true">
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.applications.AppAndNotificationDashboardFragment"/>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".Settings$AppDashboardActivity"
|
||||
android:label="@string/apps_dashboard_title"
|
||||
|
||||
26
res/drawable/ic_arrow_forward.xml
Normal file
26
res/drawable/ic_arrow_forward.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<!--
|
||||
Copyright (C) 2021 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:autoMirrored="true"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M6.23,20.23l1.77,1.77l10,-10l-10,-10l-1.77,1.77l8.23,8.23z"/>
|
||||
</vector>
|
||||
@@ -21,6 +21,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<LinearLayout
|
||||
@@ -29,8 +31,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="start|center_vertical"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||
>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/icon_frame"
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
app:sudVideo="@raw/face_education"/>
|
||||
|
||||
<!-- Animation res MUST be set in code, gated by config_face_education_use_lottie. -->
|
||||
<com.airbnb.lottie.LottieAnimationView
|
||||
android:id="@+id/illustration_lottie"
|
||||
android:layout_width="match_parent"
|
||||
@@ -55,7 +54,8 @@
|
||||
android:scaleType="fitCenter"
|
||||
android:visibility="invisible"
|
||||
app:lottie_autoPlay="true"
|
||||
app:lottie_loop="true" />
|
||||
app:lottie_loop="true"
|
||||
app:lottie_rawRes="@raw/face_education_lottie" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/illustration_accessibility"
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
android:id="@android:id/widget_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:minWidth="64dp"
|
||||
android:minWidth="@dimen/two_target_min_width"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" />
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:minWidth="64dp"
|
||||
android:minWidth="@dimen/two_target_min_width"
|
||||
android:orientation="vertical" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:paddingStart="24dp"
|
||||
android:paddingEnd="24dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_settings_accent"
|
||||
|
||||
@@ -22,6 +22,4 @@
|
||||
android:layout_height="match_parent"
|
||||
android:minWidth="@dimen/two_target_min_width"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:clickable="false" />
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
android:id="@+id/button_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="64dp"
|
||||
android:minWidth="@dimen/two_target_min_width"
|
||||
android:minHeight="@dimen/min_tap_target_size"
|
||||
android:layout_gravity="center"
|
||||
android:background="?android:attr/selectableItemBackground"/>
|
||||
|
||||
@@ -394,8 +394,6 @@
|
||||
<!-- Elevation of bluetooth icon -->
|
||||
<dimen name="bt_icon_elevation">4dp</dimen>
|
||||
|
||||
<dimen name="two_target_min_width">80dp</dimen>
|
||||
|
||||
<!-- Maximum height for SliceView, override on slices/view/src/main/res/values/dimens.xml -->
|
||||
<dimen name="abc_slice_large_height">1800dp</dimen>
|
||||
|
||||
|
||||
@@ -98,11 +98,11 @@
|
||||
<string name="font_size_make_larger_desc">Make larger</string>
|
||||
|
||||
<!-- Auto rotate switchbar title. [CHAR_LIMIT=NONE] -->
|
||||
<string name="auto_rotate_settings_primary_switch_title">Use Auto-Rotate</string>
|
||||
<string name="auto_rotate_settings_primary_switch_title">Use Auto-rotate</string>
|
||||
|
||||
<!-- Disclaimer for camera based rotate [CHAR_LIMIT=NONE] -->
|
||||
<string name="smart_rotate_text_headline">
|
||||
Face Detection uses the front-facing camera to improve Auto-Rotate accuracy. Images are never stored or sent to Google.<br><br>
|
||||
Face Detection uses the front-facing camera to improve Auto-rotate accuracy. Images are never stored or sent to Google.<br><br>
|
||||
<a href="<xliff:g example="http://www.google.com" id="url">http://support.google.com/mobile?p=telephony_rtt</xliff:g>">Learn more</a>
|
||||
</string>
|
||||
<string name="font_size_preview_text_headline">Sample text</string>
|
||||
@@ -8747,6 +8747,12 @@
|
||||
<!-- Preference title for showing all apps on device [CHAR_LIMIT=50]-->
|
||||
<string name="recent_notifications_see_all_title">See all from last 7 days</string>
|
||||
|
||||
<!-- notification header for general notification settings [CHAR LIMIT=80]-->
|
||||
<string name="general_notification_header">General</string>
|
||||
|
||||
<!-- notification preference for app specific notification settings [CHAR LIMIT=80]-->
|
||||
<string name="app_notification_field">App settings</string>
|
||||
|
||||
<!-- Configure Notifications: Advanced section header [CHAR LIMIT=30] -->
|
||||
<string name="advanced_section_header">General</string>
|
||||
|
||||
@@ -11465,6 +11471,9 @@
|
||||
<!-- [CHAR LIMIT=60] Summary string for screen attention explaining why the toggle is disabled by battery saver-->
|
||||
<string name="ambient_camera_summary_battery_saver_on">Temporarily disabled due to Battery Saver</string>
|
||||
|
||||
<!-- [CHAR LIMIT=60] Button text for screen attention to turn off battery saver-->
|
||||
<string name="ambient_camera_battery_saver_off">Turn off battery saver</string>
|
||||
|
||||
<!-- [CHAR LIMIT=60] Summary string on dark theme explaining why the toggle is disabled while the setting is off-->
|
||||
<string name="dark_ui_mode_disabled_summary_dark_theme_off">Temporarily turned on due to Battery Saver</string>
|
||||
|
||||
@@ -13208,6 +13217,8 @@
|
||||
<string name="keywords_internet">network connection, internet, wireless, data, wifi, wi-fi, wi fi, cellular, mobile, cell carrier, 4g, 3g, 2g, lte</string>
|
||||
<!-- Slice title text for turning on the Wi-Fi networks. [CHAR LIMIT=40] -->
|
||||
<string name="turn_on_wifi">Turn on Wi\u2011Fi</string>
|
||||
<!-- Slice title text for turning off the Wi-Fi networks. [CHAR LIMIT=40] -->
|
||||
<string name="turn_off_wifi">Turn off Wi\u2011Fi</string>
|
||||
<!-- Title for interrupting the voice call alert. [CHAR_LIMIT=NONE] -->
|
||||
<string name="reset_your_internet_title">Reset your internet?</string>
|
||||
<!-- Description for interrupting the voice call alert. [CHAR_LIMIT=NONE] -->
|
||||
@@ -13222,8 +13233,8 @@
|
||||
<string name="networks_available">Networks available</string>
|
||||
<!-- Summary for warning to disconnect ethernet first then switch to other networks. [CHAR LIMIT=60] -->
|
||||
<string name="to_switch_networks_disconnect_ethernet">To switch networks, disconnect ethernet</string>
|
||||
<!-- Panel subtitle for Wi-Fi turned on. [CHAR LIMIT=60] -->
|
||||
<string name="wifi_is_turned_on_subtitle">Wi\u2011Fi is turned on</string>
|
||||
<!-- Panel subtitle for Wi-Fi turned off. [CHAR LIMIT=60] -->
|
||||
<string name="wifi_is_off">Wi\u2011Fi is off</string>
|
||||
<!-- Panel subtitle for tapping a network to connect to internet. [CHAR LIMIT=60] -->
|
||||
<string name="tap_a_network_to_connect">Tap a network to connect</string>
|
||||
<!-- Title for merged carrier Wi-Fi offload toggle. [CHAR LIMIT=NONE] -->
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2016 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="apps_and_notification_screen"
|
||||
android:title="@string/app_and_notification_dashboard_title"
|
||||
settings:initialExpandedChildrenCount="4">
|
||||
<!-- the initial count should include the dynamic tiles -->
|
||||
|
||||
<Preference
|
||||
android:key="all_app_info"
|
||||
android:title="@string/applications_settings"
|
||||
android:order="-999"
|
||||
android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
|
||||
settings:controller="com.android.settings.applications.AllAppsInfoPreferenceController"
|
||||
settings:keywords="@string/keywords_applications_settings"/>
|
||||
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="recent_open_apps"
|
||||
android:title="@string/recent_app_category_title"
|
||||
android:layout="@layout/app_entities_header"
|
||||
android:selectable="false"
|
||||
android:order="-998"
|
||||
settings:allowDividerBelow="true"
|
||||
settings:controller="com.android.settings.applications.RecentAppsPreferenceController"/>
|
||||
|
||||
<!-- Empty category to draw divider -->
|
||||
<PreferenceCategory
|
||||
android:key="recent_apps_divider"
|
||||
android:layout="@layout/preference_category_no_label"
|
||||
android:order="-997"/>
|
||||
|
||||
<Preference
|
||||
android:key="conversations"
|
||||
android:title="@string/conversations_category_title"
|
||||
android:order="-550"
|
||||
settings:controller="com.android.settings.notification.ConversationListSummaryPreferenceController"
|
||||
android:fragment="com.android.settings.notification.app.ConversationListSettings"
|
||||
/>
|
||||
|
||||
<Preference
|
||||
android:key="configure_notification_settings"
|
||||
android:title="@string/configure_notification_settings"
|
||||
android:summary="@string/notification_screen_summary"
|
||||
android:order="-440"
|
||||
android:fragment="com.android.settings.notification.ConfigureNotificationSettings"/>
|
||||
|
||||
<!-- Notifications (appears before manage_perms), default apps (appears after) -->
|
||||
<PreferenceCategory
|
||||
android:key="dashboard_tile_placeholder"
|
||||
android:order="10"/>
|
||||
|
||||
<Preference
|
||||
android:key="default_apps"
|
||||
android:title="@string/app_default_dashboard_title"
|
||||
android:order="11"
|
||||
settings:controller="com.android.settings.applications.DefaultAppsPreferenceController">
|
||||
<intent android:action="android.settings.MANAGE_DEFAULT_APPS_SETTINGS"/>
|
||||
</Preference>
|
||||
|
||||
<Preference
|
||||
android:key="manage_perms"
|
||||
android:title="@string/app_permissions"
|
||||
android:summary="@string/runtime_permissions_summary_control_app_access"
|
||||
android:order="12"
|
||||
settings:keywords="@string/keywords_app_permissions">
|
||||
<intent android:action="android.intent.action.MANAGE_PERMISSIONS"/>
|
||||
</Preference>
|
||||
|
||||
<Preference
|
||||
android:key="hibernated_apps"
|
||||
android:title="@string/unused_apps"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:order="13"
|
||||
settings:keywords="app_hibernation_key"
|
||||
settings:controller="com.android.settings.applications.HibernatedAppsPreferenceController">
|
||||
<intent android:action="android.intent.action.MANAGE_UNUSED_APPS"/>
|
||||
</Preference>
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="app_and_notif_cell_broadcast_settings"
|
||||
android:title="@string/cell_broadcast_settings"
|
||||
android:order="15"
|
||||
settings:useAdminDisabledSummary="true">
|
||||
<intent
|
||||
android:action="android.intent.action.MAIN"
|
||||
android:targetPackage="@string/config_cell_broadcast_receiver_package"
|
||||
android:targetClass="com.android.cellbroadcastreceiver.CellBroadcastSettings"/>
|
||||
</com.android.settingslib.RestrictedPreference>
|
||||
|
||||
<Preference
|
||||
android:key="special_access"
|
||||
android:fragment="com.android.settings.applications.specialaccess.SpecialAccessSettings"
|
||||
android:title="@string/special_access"
|
||||
android:order="20"
|
||||
settings:controller="com.android.settings.applications.SpecialAppAccessPreferenceController"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -18,33 +18,33 @@
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="installed_app_detail_settings_screen"
|
||||
settings:initialExpandedChildrenCount="6">
|
||||
android:key="installed_app_detail_settings_screen">
|
||||
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="header_view"
|
||||
android:layout="@layout/settings_entity_header"
|
||||
android:selectable="false"
|
||||
android:order="-10000"
|
||||
settings:allowDividerBelow="true"/>
|
||||
android:order="-10000" />
|
||||
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="instant_app_buttons"
|
||||
android:layout="@layout/instant_app_buttons"
|
||||
android:selectable="false"
|
||||
android:order="-9999"
|
||||
settings:allowDividerAbove="true"
|
||||
settings:allowDividerBelow="true"/>
|
||||
android:order="-9999" />
|
||||
|
||||
<com.android.settingslib.widget.ActionButtonsPreference
|
||||
android:key="action_buttons"
|
||||
android:order="-9998" />
|
||||
|
||||
<Preference
|
||||
android:key="app_settings_link"
|
||||
android:title="@string/app_settings_link"
|
||||
settings:controller="com.android.settings.applications.appinfo.AppSettingPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="notification_settings"
|
||||
android:title="@string/notifications_label"
|
||||
settings:controller="com.android.settings.applications.appinfo.AppNotificationPreferenceController"
|
||||
settings:allowDividerAbove="true"/>
|
||||
settings:controller="com.android.settings.applications.appinfo.AppNotificationPreferenceController" />
|
||||
|
||||
<com.android.settings.widget.FixedLineSummaryPreference
|
||||
android:key="permission_settings"
|
||||
@@ -71,6 +71,12 @@
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.applications.appinfo.AppDataUsagePreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="extra_app_info_settings"
|
||||
android:title="@string/extra_app_info_label"
|
||||
android:summary="@string/extra_app_info_summary"
|
||||
settings:controller="com.android.settings.applications.appinfo.ExtraAppInfoPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="time_spent_in_app"
|
||||
android:title="@string/time_spent_in_app_pref_title"
|
||||
@@ -184,12 +190,6 @@
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<Preference
|
||||
android:key="app_settings_link"
|
||||
android:title="@string/app_settings_link"
|
||||
settings:controller="com.android.settings.applications.appinfo.AppSettingPreferenceController"
|
||||
settings:allowDividerAbove="true" />
|
||||
|
||||
<Preference
|
||||
android:key="app_version"
|
||||
android:selectable="false"
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2021 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="installed_app_detail_settings_screen">
|
||||
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="header_view"
|
||||
android:layout="@layout/settings_entity_header"
|
||||
android:selectable="false"
|
||||
android:order="-10000" />
|
||||
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="instant_app_buttons"
|
||||
android:layout="@layout/instant_app_buttons"
|
||||
android:selectable="false"
|
||||
android:order="-9999" />
|
||||
|
||||
<com.android.settingslib.widget.ActionButtonsPreference
|
||||
android:key="action_buttons"
|
||||
android:order="-9998" />
|
||||
|
||||
<Preference
|
||||
android:key="app_settings_link"
|
||||
android:title="@string/app_settings_link"
|
||||
settings:controller="com.android.settings.applications.appinfo.AppSettingPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="notification_settings"
|
||||
android:title="@string/notifications_label"
|
||||
settings:controller="com.android.settings.applications.appinfo.AppNotificationPreferenceController" />
|
||||
|
||||
<com.android.settings.widget.FixedLineSummaryPreference
|
||||
android:key="permission_settings"
|
||||
android:title="@string/permissions_label"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:summaryLineCount="1"
|
||||
settings:controller="com.android.settings.applications.appinfo.AppPermissionPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="storage_settings"
|
||||
android:title="@string/storage_settings_for_app"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.applications.appinfo.AppStoragePreferenceController" />
|
||||
|
||||
<com.android.settings.applications.AppDomainsPreference
|
||||
android:key="instant_app_launch_supported_domain_urls"
|
||||
android:title="@string/app_launch_supported_domain_urls_title"
|
||||
android:selectable="true"
|
||||
settings:controller="com.android.settings.applications.appinfo.InstantAppDomainsPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="data_settings"
|
||||
android:title="@string/data_usage_app_summary_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.applications.appinfo.AppDataUsagePreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="extra_app_info_settings"
|
||||
android:title="@string/extra_app_info_label"
|
||||
android:summary="@string/extra_app_info_summary"
|
||||
settings:controller="com.android.settings.applications.appinfo.ExtraAppInfoPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="time_spent_in_app"
|
||||
android:title="@string/time_spent_in_app_pref_title"
|
||||
settings:controller="com.android.settings.applications.appinfo.TimeSpentInAppPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="battery"
|
||||
android:title="@string/power_usage_summary_title"
|
||||
android:summary="@string/summary_placeholder" />
|
||||
|
||||
<Preference
|
||||
android:key="preferred_settings"
|
||||
android:title="@string/launch_by_default"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:selectable="true"
|
||||
settings:controller="com.android.settings.applications.appinfo.AppOpenByDefaultPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="memory"
|
||||
android:title="@string/memory_settings_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:enabled="false" />
|
||||
|
||||
<!-- Default apps shortcuts -->
|
||||
<Preference
|
||||
android:key="default_home"
|
||||
android:title="@string/home_app"
|
||||
android:summary="@string/summary_placeholder" />
|
||||
|
||||
<Preference
|
||||
android:key="default_browser"
|
||||
android:title="@string/default_browser_title"
|
||||
android:summary="@string/summary_placeholder" />
|
||||
|
||||
<Preference
|
||||
android:key="default_phone_app"
|
||||
android:title="@string/default_phone_title"
|
||||
android:summary="@string/default_phone_title" />
|
||||
|
||||
<Preference
|
||||
android:key="default_emergency_app"
|
||||
android:title="@string/default_emergency_app"
|
||||
android:summary="@string/summary_placeholder" />
|
||||
|
||||
<Preference
|
||||
android:key="default_sms_app"
|
||||
android:title="@string/sms_application_title"
|
||||
android:summary="@string/summary_placeholder" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="app_hibernation_info"
|
||||
android:title="@string/unused_apps"
|
||||
settings:controller=
|
||||
"com.android.settings.applications.appinfo.AppHibernationPreferenceCategoryController">
|
||||
|
||||
<SwitchPreference
|
||||
android:key="hibernation_switch"
|
||||
android:title="@string/unused_apps_switch"
|
||||
settings:controller=
|
||||
"com.android.settings.applications.appinfo.HibernationSwitchPreferenceController" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<!-- Advanced apps settings -->
|
||||
<PreferenceCategory
|
||||
android:key="advanced_app_info"
|
||||
android:title="@string/advanced_apps"
|
||||
settings:controller="com.android.settings.applications.appinfo.AdvancedAppInfoPreferenceCategoryController">
|
||||
|
||||
<Preference
|
||||
android:key="system_alert_window"
|
||||
android:title="@string/draw_overlay"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.applications.appinfo.DrawOverlayDetailPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="write_settings_apps"
|
||||
android:title="@string/write_settings"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.applications.appinfo.WriteSystemSettingsPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="picture_in_picture"
|
||||
android:title="@string/picture_in_picture_app_detail_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetailPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="install_other_apps"
|
||||
android:title="@string/install_other_apps"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.applications.appinfo.ExternalSourceDetailPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="interact_across_profiles"
|
||||
android:title="@string/interact_across_profiles_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.applications.specialaccess.interactacrossprofiles.InteractAcrossProfilesDetailsPreferenceController" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<!-- App installer info -->
|
||||
<PreferenceCategory
|
||||
android:key="app_installer"
|
||||
android:title="@string/app_install_details_group_title"
|
||||
settings:controller="com.android.settings.applications.appinfo.AppInstallerPreferenceCategoryController">
|
||||
|
||||
<Preference
|
||||
android:key="app_info_store"
|
||||
android:title="@string/app_install_details_title"
|
||||
settings:controller="com.android.settings.applications.appinfo.AppInstallerInfoPreferenceController" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<Preference
|
||||
android:key="app_version"
|
||||
android:selectable="false"
|
||||
android:order="9999"
|
||||
settings:controller="com.android.settings.applications.appinfo.AppVersionPreferenceController"
|
||||
settings:allowDividerAbove="true"
|
||||
settings:enableCopying="true"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -18,6 +18,39 @@
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/configure_notification_settings">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="general_notifications_category"
|
||||
android:title="@string/general_notification_header">
|
||||
<!-- See all apps button -->
|
||||
<Preference
|
||||
android:key="all_notifications"
|
||||
android:order="10"
|
||||
android:title="@string/app_notification_field"
|
||||
android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
|
||||
settings:searchable="false">
|
||||
<extra
|
||||
android:name="classname"
|
||||
android:value="com.android.settings.Settings$NotificationAppListActivity"/>
|
||||
</Preference>
|
||||
<Preference
|
||||
android:key="notification_history"
|
||||
android:order="11"
|
||||
android:title="@string/notification_history"
|
||||
android:summary="@string/notification_history_summary">
|
||||
<intent
|
||||
android:action="android.intent.action.MAIN"
|
||||
android:targetPackage="com.android.settings"
|
||||
android:targetClass="com.android.settings.notification.history.NotificationHistoryActivity" />
|
||||
</Preference>
|
||||
<Preference
|
||||
android:key="notification_access"
|
||||
android:order="12"
|
||||
android:title="@string/manage_notification_access_title"
|
||||
android:summary="@string/manage_notification_access_summary"
|
||||
android:fragment="com.android.settings.notification.NotificationAccessSettings"
|
||||
settings:controller="com.android.settings.applications.specialaccess.notificationaccess.NotificationAccessController" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="conversation_category"
|
||||
android:title="@string/conversation_notifs_category">
|
||||
@@ -39,59 +72,9 @@
|
||||
/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="recent_notifications_category"
|
||||
android:title="@string/recent_notifications">
|
||||
<!-- Placeholder for a list of recent apps -->
|
||||
<com.android.settings.widget.PrimarySwitchPreference
|
||||
android:key="app1"
|
||||
android:title=" "
|
||||
android:summary=" "
|
||||
android:order="5"/>
|
||||
<com.android.settings.widget.PrimarySwitchPreference
|
||||
android:key="app2"
|
||||
android:title=" "
|
||||
android:summary=" "
|
||||
android:order="6"/>
|
||||
<com.android.settings.widget.PrimarySwitchPreference
|
||||
android:key="app3"
|
||||
android:title=" "
|
||||
android:summary=" "
|
||||
android:order="7"/>
|
||||
|
||||
<!-- See all apps button -->
|
||||
<Preference
|
||||
android:key="all_notifications"
|
||||
android:order="10"
|
||||
android:title="@string/notifications_title"
|
||||
android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
|
||||
settings:searchable="false">
|
||||
<extra
|
||||
android:name="classname"
|
||||
android:value="com.android.settings.Settings$NotificationAppListActivity"/>
|
||||
</Preference>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="configure_notifications_lock"
|
||||
android:title="@string/lock_screen_notifications_title">
|
||||
<Preference
|
||||
android:key="notification_history"
|
||||
android:order="11"
|
||||
android:title="@string/notification_history"
|
||||
android:summary="@string/notification_history_summary">
|
||||
<intent
|
||||
android:action="android.intent.action.MAIN"
|
||||
android:targetPackage="com.android.settings"
|
||||
android:targetClass="com.android.settings.notification.history.NotificationHistoryActivity" />
|
||||
</Preference>
|
||||
<Preference
|
||||
android:key="notification_access"
|
||||
android:order="12"
|
||||
android:title="@string/manage_notification_access_title"
|
||||
android:summary="@string/manage_notification_access_summary"
|
||||
android:fragment="com.android.settings.notification.NotificationAccessSettings"
|
||||
settings:controller="com.android.settings.applications.specialaccess.notificationaccess.NotificationAccessController" />
|
||||
<!-- When device is locked -->
|
||||
<com.android.settings.RestrictedListPreference
|
||||
android:key="lock_screen_notifications"
|
||||
|
||||
@@ -40,24 +40,13 @@
|
||||
android:key="add_bt_devices"
|
||||
android:title="@string/bluetooth_pairing_pref_title"
|
||||
android:icon="@drawable/ic_add_24dp"
|
||||
android:fragment="com.android.settings.bluetooth.BluetoothPairingDetail"
|
||||
settings:allowDividerAbove="true"
|
||||
settings:keywords="@string/keywords_add_bt_device"
|
||||
settings:userRestriction="no_config_bluetooth"
|
||||
settings:useAdminDisabledSummary="true"
|
||||
settings:controller="com.android.settings.connecteddevice.AddDevicePreferenceController"/>
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="add_bt_devices_summary"
|
||||
android:title="@string/bluetooth_pairing_pref_title"
|
||||
android:icon="@drawable/ic_add_24dp"
|
||||
android:summary="@string/connected_device_add_device_summary"
|
||||
android:fragment="com.android.settings.bluetooth.BluetoothPairingDetail"
|
||||
settings:allowDividerAbove="true"
|
||||
settings:keywords="@string/keywords_add_bt_device"
|
||||
settings:userRestriction="no_config_bluetooth"
|
||||
settings:useAdminDisabledSummary="true"
|
||||
settings:controller="com.android.settings.connecteddevice.AddDeviceSummaryPreferenceController"/>
|
||||
settings:controller="com.android.settings.connecteddevice.AddDevicePreferenceController"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="previously_connected_devices"
|
||||
|
||||
@@ -19,134 +19,140 @@
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="display_settings_screen"
|
||||
android:title="@string/display_settings"
|
||||
settings:keywords="@string/keywords_display"
|
||||
settings:initialExpandedChildrenCount="6">
|
||||
settings:keywords="@string/keywords_display">
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="brightness"
|
||||
android:title="@string/brightness"
|
||||
settings:keywords="@string/keywords_display_brightness_level"
|
||||
settings:useAdminDisabledSummary="true"
|
||||
settings:userRestriction="no_config_brightness">
|
||||
<intent android:action="com.android.intent.action.SHOW_BRIGHTNESS_DIALOG" />
|
||||
</com.android.settingslib.RestrictedPreference>
|
||||
<PreferenceCategory
|
||||
android:title="@string/category_name_brightness">
|
||||
|
||||
<com.android.settings.display.darkmode.DarkModePreference
|
||||
android:key="dark_ui_mode"
|
||||
android:title="@string/dark_ui_mode"
|
||||
android:fragment="com.android.settings.display.darkmode.DarkModeSettingsFragment"
|
||||
android:widgetLayout="@null"
|
||||
settings:widgetLayout="@null"
|
||||
settings:controller="com.android.settings.display.DarkUIPreferenceController"
|
||||
settings:keywords="@string/keywords_dark_ui_mode"/>
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="brightness"
|
||||
android:title="@string/brightness"
|
||||
settings:keywords="@string/keywords_display_brightness_level"
|
||||
settings:useAdminDisabledSummary="true"
|
||||
settings:userRestriction="no_config_brightness"/>
|
||||
|
||||
<com.android.settings.widget.PrimarySwitchPreference
|
||||
android:key="night_display"
|
||||
android:title="@string/night_display_title"
|
||||
android:fragment="com.android.settings.display.NightDisplaySettings"
|
||||
settings:controller="com.android.settings.display.NightDisplayPreferenceController"
|
||||
settings:keywords="@string/keywords_display_night_display"/>
|
||||
<com.android.settings.widget.PrimarySwitchPreference
|
||||
android:key="auto_brightness_entry"
|
||||
android:title="@string/auto_brightness_title"
|
||||
android:fragment="com.android.settings.display.AutoBrightnessSettings"
|
||||
settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<Preference
|
||||
android:key="auto_brightness_entry"
|
||||
android:title="@string/auto_brightness_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.display.AutoBrightnessSettings"
|
||||
settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"/>
|
||||
<PreferenceCategory
|
||||
android:title="@string/category_name_lock_display">
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="wallpaper"
|
||||
android:title="@string/wallpaper_settings_title"
|
||||
settings:keywords="@string/keywords_display_wallpaper"
|
||||
settings:useAdminDisabledSummary="true"
|
||||
settings:controller="com.android.settings.display.WallpaperPreferenceController">
|
||||
</com.android.settingslib.RestrictedPreference>
|
||||
<Preference
|
||||
android:key="lockscreen_from_display_settings"
|
||||
android:title="@string/lockscreen_settings_title"
|
||||
android:fragment="com.android.settings.security.LockscreenDashboardFragment"
|
||||
settings:keywords="@string/keywords_ambient_display_screen"
|
||||
settings:controller="com.android.settings.security.screenlock.LockScreenPreferenceController"/>
|
||||
|
||||
<!-- Cross-listed item, if you change this, also change it in power_usage_summary.xml -->
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="screen_timeout"
|
||||
android:title="@string/screen_timeout"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.display.ScreenTimeoutSettings"
|
||||
settings:controller="com.android.settings.display.ScreenTimeoutPreferenceController" />
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="screen_timeout"
|
||||
android:title="@string/screen_timeout"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.display.ScreenTimeoutSettings"
|
||||
settings:controller="com.android.settings.display.ScreenTimeoutPreferenceController"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="auto_rotate"
|
||||
android:title="@string/accelerometer_title"
|
||||
settings:keywords="@string/keywords_auto_rotate"
|
||||
settings:controller="com.android.settings.display.AutoRotatePreferenceController" />
|
||||
<PreferenceCategory
|
||||
android:title="@string/category_name_appearance">
|
||||
|
||||
<Preference
|
||||
android:key="color_mode"
|
||||
android:title="@string/color_mode_title"
|
||||
android:fragment="com.android.settings.display.ColorModePreferenceFragment"
|
||||
settings:controller="com.android.settings.display.ColorModePreferenceController"
|
||||
settings:keywords="@string/keywords_color_mode" />
|
||||
<com.android.settings.display.darkmode.DarkModePreference
|
||||
android:key="dark_ui_mode"
|
||||
android:title="@string/dark_ui_mode"
|
||||
android:fragment="com.android.settings.display.darkmode.DarkModeSettingsFragment"
|
||||
android:widgetLayout="@null"
|
||||
settings:widgetLayout="@null"
|
||||
settings:controller="com.android.settings.display.DarkUIPreferenceController"
|
||||
settings:keywords="@string/keywords_dark_ui_mode"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="display_white_balance"
|
||||
android:title="@string/display_white_balance_title"
|
||||
android:summary="@string/display_white_balance_summary"
|
||||
settings:controller="com.android.settings.display.DisplayWhiteBalancePreferenceController" />
|
||||
<Preference
|
||||
android:key="font_size"
|
||||
android:title="@string/title_font_size"
|
||||
android:fragment="com.android.settings.display.ToggleFontSizePreferenceFragment"
|
||||
settings:controller="com.android.settings.display.FontSizePreferenceController"
|
||||
settings:keywords="@string/keywords_font_size"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="peak_refresh_rate"
|
||||
android:title="@string/peak_refresh_rate_title"
|
||||
android:summary="@string/peak_refresh_rate_summary"
|
||||
settings:controller="com.android.settings.display.PeakRefreshRatePreferenceController" />
|
||||
<com.android.settings.display.ScreenZoomPreference
|
||||
android:key="display_settings_screen_zoom"
|
||||
android:title="@string/screen_zoom_title"
|
||||
android:fragment="com.android.settings.display.ScreenZoomSettings"
|
||||
settings:keywords="@string/keywords_display_size"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<Preference
|
||||
android:key="font_size"
|
||||
android:title="@string/title_font_size"
|
||||
android:fragment="com.android.settings.display.ToggleFontSizePreferenceFragment"
|
||||
settings:controller="com.android.settings.display.FontSizePreferenceController"
|
||||
settings:keywords="@string/keywords_font_size" />
|
||||
<PreferenceCategory
|
||||
android:title="@string/category_name_color">
|
||||
|
||||
<com.android.settings.display.ScreenZoomPreference
|
||||
android:key="display_settings_screen_zoom"
|
||||
android:title="@string/screen_zoom_title"
|
||||
android:fragment="com.android.settings.display.ScreenZoomSettings"
|
||||
settings:keywords="@string/keywords_display_size"/>
|
||||
<com.android.settings.widget.PrimarySwitchPreference
|
||||
android:key="night_display"
|
||||
android:title="@string/night_display_title"
|
||||
android:fragment="com.android.settings.display.NightDisplaySettings"
|
||||
settings:controller="com.android.settings.display.NightDisplayPreferenceController"
|
||||
settings:keywords="@string/keywords_display_night_display"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="show_operator_name"
|
||||
android:title="@string/show_operator_name_title"
|
||||
android:summary="@string/show_operator_name_summary" />
|
||||
<Preference
|
||||
android:key="color_mode"
|
||||
android:title="@string/color_mode_title"
|
||||
android:fragment="com.android.settings.display.ColorModePreferenceFragment"
|
||||
settings:controller="com.android.settings.display.ColorModePreferenceController"
|
||||
settings:keywords="@string/keywords_color_mode"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<Preference
|
||||
android:key="screensaver"
|
||||
android:title="@string/screensaver_settings_title"
|
||||
android:fragment="com.android.settings.dream.DreamSettings" />
|
||||
<PreferenceCategory
|
||||
android:title="@string/category_name_display_controls">
|
||||
|
||||
<Preference
|
||||
android:key="lockscreen_from_display_settings"
|
||||
android:title="@string/lockscreen_settings_title"
|
||||
android:fragment="com.android.settings.security.LockscreenDashboardFragment"
|
||||
settings:keywords="@string/keywords_ambient_display_screen"
|
||||
settings:controller="com.android.settings.security.screenlock.LockScreenPreferenceController" />
|
||||
<SwitchPreference
|
||||
android:key="auto_rotate"
|
||||
android:title="@string/accelerometer_title"
|
||||
settings:keywords="@string/keywords_auto_rotate"
|
||||
settings:controller="com.android.settings.display.AutoRotatePreferenceController"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="camera_gesture"
|
||||
android:title="@string/camera_gesture_title"
|
||||
android:summary="@string/camera_gesture_desc" />
|
||||
<SwitchPreference
|
||||
android:key="display_white_balance"
|
||||
android:title="@string/display_white_balance_title"
|
||||
android:summary="@string/display_white_balance_summary"
|
||||
settings:controller="com.android.settings.display.DisplayWhiteBalancePreferenceController"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="lift_to_wake"
|
||||
android:title="@string/lift_to_wake_title" />
|
||||
<SwitchPreference
|
||||
android:key="peak_refresh_rate"
|
||||
android:title="@string/peak_refresh_rate_title"
|
||||
android:summary="@string/peak_refresh_rate_summary"
|
||||
settings:controller="com.android.settings.display.PeakRefreshRatePreferenceController"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="tap_to_wake"
|
||||
android:title="@string/tap_to_wake"
|
||||
android:summary="@string/tap_to_wake_summary" />
|
||||
<SwitchPreference
|
||||
android:key="show_operator_name"
|
||||
android:title="@string/show_operator_name_title"
|
||||
android:summary="@string/show_operator_name_summary"/>
|
||||
|
||||
<ListPreference
|
||||
android:key="theme"
|
||||
android:title="@string/device_theme"
|
||||
android:summary="@string/summary_placeholder" />
|
||||
<Preference
|
||||
android:key="screensaver"
|
||||
android:title="@string/screensaver_settings_title"
|
||||
android:fragment="com.android.settings.dream.DreamSettings"/>
|
||||
|
||||
<Preference
|
||||
android:key="vr_display_pref"
|
||||
android:title="@string/display_vr_pref_title"
|
||||
android:fragment="com.android.settings.display.VrDisplayPreferencePicker" />
|
||||
<SwitchPreference
|
||||
android:key="camera_gesture"
|
||||
android:title="@string/camera_gesture_title"
|
||||
android:summary="@string/camera_gesture_desc"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="lift_to_wake"
|
||||
android:title="@string/lift_to_wake_title"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="tap_to_wake"
|
||||
android:title="@string/tap_to_wake"
|
||||
android:summary="@string/tap_to_wake_summary"/>
|
||||
|
||||
<ListPreference
|
||||
android:key="theme"
|
||||
android:title="@string/device_theme"
|
||||
android:summary="@string/summary_placeholder"/>
|
||||
|
||||
<Preference
|
||||
android:key="vr_display_pref"
|
||||
android:title="@string/display_vr_pref_title"
|
||||
android:fragment="com.android.settings.display.VrDisplayPreferencePicker"/>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -1,159 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2020 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="display_settings_screen"
|
||||
android:title="@string/display_settings"
|
||||
settings:keywords="@string/keywords_display">
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/category_name_brightness">
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="brightness"
|
||||
android:title="@string/brightness"
|
||||
settings:keywords="@string/keywords_display_brightness_level"
|
||||
settings:useAdminDisabledSummary="true"
|
||||
settings:userRestriction="no_config_brightness">
|
||||
</com.android.settingslib.RestrictedPreference>
|
||||
|
||||
<com.android.settings.widget.PrimarySwitchPreference
|
||||
android:key="auto_brightness_entry"
|
||||
android:title="@string/auto_brightness_title"
|
||||
android:fragment="com.android.settings.display.AutoBrightnessSettings"
|
||||
settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/category_name_lock_display">
|
||||
|
||||
<Preference
|
||||
android:key="lockscreen_from_display_settings"
|
||||
android:title="@string/lockscreen_settings_title"
|
||||
android:fragment="com.android.settings.security.LockscreenDashboardFragment"
|
||||
settings:keywords="@string/keywords_ambient_display_screen"
|
||||
settings:controller="com.android.settings.security.screenlock.LockScreenPreferenceController"/>
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="screen_timeout"
|
||||
android:title="@string/screen_timeout"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.display.ScreenTimeoutSettings"
|
||||
settings:controller="com.android.settings.display.ScreenTimeoutPreferenceController"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/category_name_appearance">
|
||||
|
||||
<com.android.settings.display.darkmode.DarkModePreference
|
||||
android:key="dark_ui_mode"
|
||||
android:title="@string/dark_ui_mode"
|
||||
android:fragment="com.android.settings.display.darkmode.DarkModeSettingsFragment"
|
||||
android:widgetLayout="@null"
|
||||
settings:widgetLayout="@null"
|
||||
settings:controller="com.android.settings.display.DarkUIPreferenceController"
|
||||
settings:keywords="@string/keywords_dark_ui_mode"/>
|
||||
|
||||
<Preference
|
||||
android:key="font_size"
|
||||
android:title="@string/title_font_size"
|
||||
android:fragment="com.android.settings.display.ToggleFontSizePreferenceFragment"
|
||||
settings:controller="com.android.settings.display.FontSizePreferenceController"
|
||||
settings:keywords="@string/keywords_font_size"/>
|
||||
|
||||
<com.android.settings.display.ScreenZoomPreference
|
||||
android:key="display_settings_screen_zoom"
|
||||
android:title="@string/screen_zoom_title"
|
||||
android:fragment="com.android.settings.display.ScreenZoomSettings"
|
||||
settings:keywords="@string/keywords_display_size"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/category_name_color">
|
||||
|
||||
<com.android.settings.widget.PrimarySwitchPreference
|
||||
android:key="night_display"
|
||||
android:title="@string/night_display_title"
|
||||
android:fragment="com.android.settings.display.NightDisplaySettings"
|
||||
settings:controller="com.android.settings.display.NightDisplayPreferenceController"
|
||||
settings:keywords="@string/keywords_display_night_display"/>
|
||||
|
||||
<Preference
|
||||
android:key="color_mode"
|
||||
android:title="@string/color_mode_title"
|
||||
android:fragment="com.android.settings.display.ColorModePreferenceFragment"
|
||||
settings:controller="com.android.settings.display.ColorModePreferenceController"
|
||||
settings:keywords="@string/keywords_color_mode"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/category_name_display_controls">
|
||||
|
||||
<SwitchPreference
|
||||
android:key="auto_rotate"
|
||||
android:title="@string/accelerometer_title"
|
||||
settings:keywords="@string/keywords_auto_rotate"
|
||||
settings:controller="com.android.settings.display.AutoRotatePreferenceController"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="display_white_balance"
|
||||
android:title="@string/display_white_balance_title"
|
||||
android:summary="@string/display_white_balance_summary"
|
||||
settings:controller="com.android.settings.display.DisplayWhiteBalancePreferenceController"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="peak_refresh_rate"
|
||||
android:title="@string/peak_refresh_rate_title"
|
||||
android:summary="@string/peak_refresh_rate_summary"
|
||||
settings:controller="com.android.settings.display.PeakRefreshRatePreferenceController"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="show_operator_name"
|
||||
android:title="@string/show_operator_name_title"
|
||||
android:summary="@string/show_operator_name_summary"/>
|
||||
|
||||
<Preference
|
||||
android:key="screensaver"
|
||||
android:title="@string/screensaver_settings_title"
|
||||
android:fragment="com.android.settings.dream.DreamSettings"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="camera_gesture"
|
||||
android:title="@string/camera_gesture_title"
|
||||
android:summary="@string/camera_gesture_desc"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="lift_to_wake"
|
||||
android:title="@string/lift_to_wake_title"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="tap_to_wake"
|
||||
android:title="@string/tap_to_wake"
|
||||
android:summary="@string/tap_to_wake_summary"/>
|
||||
|
||||
<ListPreference
|
||||
android:key="theme"
|
||||
android:title="@string/device_theme"
|
||||
android:summary="@string/summary_placeholder"/>
|
||||
|
||||
<Preference
|
||||
android:key="vr_display_pref"
|
||||
android:title="@string/display_vr_pref_title"
|
||||
android:fragment="com.android.settings.display.VrDisplayPreferencePicker"/>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
@@ -25,16 +25,14 @@
|
||||
android:key="resetting_your_internet"
|
||||
android:title="@string/resetting_internet_text"
|
||||
android:selectable="false"
|
||||
android:layout="@layout/resetting_internet"
|
||||
settings:allowDividerBelow="true"/>
|
||||
android:layout="@layout/resetting_internet"/>
|
||||
|
||||
<!-- Airplane mode message -->
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="airplane_mode_message"
|
||||
android:title="@string/condition_airplane_title"
|
||||
android:selectable="false"
|
||||
android:layout="@layout/airplane_mode_message_preference"
|
||||
settings:allowDividerBelow="true"/>
|
||||
android:layout="@layout/airplane_mode_message_preference"/>
|
||||
|
||||
<Preference
|
||||
android:key="connected_ethernet_network"
|
||||
@@ -64,14 +62,12 @@
|
||||
android:key="wifi_switch"
|
||||
android:title="@string/wifi"
|
||||
android:summary="@string/wifi_switch_summary"
|
||||
settings:allowDividerAbove="true"
|
||||
settings:keywords="@string/keywords_wifi"/>
|
||||
|
||||
<Preference
|
||||
android:key="configure_wifi_settings"
|
||||
android:title="@string/network_and_internet_preferences_title"
|
||||
android:summary="@string/network_and_internet_preferences_summary"
|
||||
settings:allowDividerAbove="true"
|
||||
android:fragment="com.android.settings.wifi.ConfigureWifiSettings"/>
|
||||
|
||||
<Preference
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
android:key="connection_header"
|
||||
android:layout="@layout/settings_entity_header"
|
||||
android:selectable="false"
|
||||
android:order="-10000"
|
||||
settings:allowDividerBelow="true"/>
|
||||
android:order="-10000"/>
|
||||
|
||||
<com.android.settings.datausage.DataUsageSummaryPreference
|
||||
android:key="status_header"
|
||||
@@ -34,21 +33,18 @@
|
||||
<com.android.settings.widget.LinkifySummaryPreference
|
||||
android:key="second_summary"
|
||||
android:icon="@drawable/ic_info_outline_24dp"
|
||||
android:selectable="false"
|
||||
settings:allowDividerAbove="false"/>
|
||||
android:selectable="false"/>
|
||||
|
||||
<!-- Buttons -->
|
||||
<com.android.settingslib.widget.ActionButtonsPreference
|
||||
android:key="buttons"
|
||||
android:selectable="false"
|
||||
settings:allowDividerAbove="true"/>
|
||||
android:selectable="false"/>
|
||||
|
||||
<!-- General Details Preferences -->
|
||||
<Preference
|
||||
android:key="signal_strength"
|
||||
android:title="@string/wifi_signal"
|
||||
android:selectable="false"
|
||||
settings:allowDividerAbove="true"/>
|
||||
android:selectable="false"/>
|
||||
|
||||
<Preference
|
||||
android:key="frequency"
|
||||
@@ -79,21 +75,18 @@
|
||||
<Preference
|
||||
android:key="subscription_detail"
|
||||
android:title="@string/wifi_subscription"
|
||||
android:summary="@string/wifi_subscription_summary"
|
||||
settings:allowDividerAbove="true"/>
|
||||
android:summary="@string/wifi_subscription_summary"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="auto_connect"
|
||||
android:title="@string/wifi_auto_connect_title"
|
||||
android:summary="@string/wifi_auto_connect_summary"
|
||||
settings:allowDividerAbove="true"/>
|
||||
android:summary="@string/wifi_auto_connect_summary"/>
|
||||
|
||||
<!-- Add device Preference -->
|
||||
<Preference
|
||||
android:key="add_device_to_network"
|
||||
android:title="@string/wifi_dpp_add_device"
|
||||
android:summary="@string/wifi_dpp_connect_network_using_qr_code"
|
||||
settings:allowDividerAbove="true"/>
|
||||
android:summary="@string/wifi_dpp_connect_network_using_qr_code"/>
|
||||
|
||||
<!-- Network Details -->
|
||||
<PreferenceCategory
|
||||
|
||||
@@ -19,10 +19,7 @@ package com.android.settings;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.display.BrightnessLevelPreferenceController;
|
||||
import com.android.settings.display.CameraGesturePreferenceController;
|
||||
@@ -38,7 +35,6 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||
@@ -57,9 +53,6 @@ public class DisplaySettings extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
|
||||
return R.xml.display_settings_v2;
|
||||
}
|
||||
return R.xml.display_settings;
|
||||
}
|
||||
|
||||
@@ -93,16 +86,7 @@ public class DisplaySettings extends DashboardFragment {
|
||||
}
|
||||
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
||||
Context context, boolean enabled) {
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = FeatureFlagUtils.isEnabled(context, FeatureFlags.SILKY_HOME)
|
||||
? R.xml.display_settings_v2 : R.xml.display_settings;
|
||||
return Arrays.asList(sir);
|
||||
}
|
||||
new BaseSearchIndexProvider(R.xml.display_settings) {
|
||||
|
||||
@Override
|
||||
public List<AbstractPreferenceController> createPreferenceControllers(
|
||||
|
||||
@@ -161,6 +161,10 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
/** Whether or not app hibernation is enabled on the device **/
|
||||
public static final String PROPERTY_APP_HIBERNATION_ENABLED = "app_hibernation_enabled";
|
||||
|
||||
/** Whether or not app hibernation targets apps that target a pre-S SDK **/
|
||||
public static final String PROPERTY_HIBERNATION_TARGETS_PRE_S_APPS =
|
||||
"app_hibernation_targets_pre_s_apps";
|
||||
|
||||
/** Whether or not Settings Shared Axis transition is enabled */
|
||||
public static final String SETTINGS_SHARED_AXIS_ENABLED = "settings_shared_axis_enabled";
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.android.settings.display.FontSizePreferenceFragmentForSetupWizard;
|
||||
import com.android.settings.search.actionbar.SearchMenuController;
|
||||
import com.android.settings.support.actionbar.HelpResourceProvider;
|
||||
import com.android.settingslib.core.instrumentation.Instrumentable;
|
||||
import com.android.settingslib.transition.SettingsTransitionHelper;
|
||||
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
import com.google.android.setupdesign.util.ThemeHelper;
|
||||
@@ -92,6 +93,7 @@ public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivit
|
||||
: Instrumentable.METRICS_CATEGORY_UNKNOWN)
|
||||
.setExtras(SetupWizardUtils.copyLifecycleExtra(getIntent().getExtras(),
|
||||
new Bundle()))
|
||||
.setTransitionType(SettingsTransitionHelper.TransitionType.TRANSITION_FADE)
|
||||
.launch();
|
||||
return true;
|
||||
}
|
||||
@@ -119,7 +121,8 @@ public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivit
|
||||
.setArguments(args)
|
||||
.setSourceMetricsCategory(Instrumentable.METRICS_CATEGORY_UNKNOWN)
|
||||
.setExtras(SetupWizardUtils.copyLifecycleExtra(getIntent().getExtras(),
|
||||
new Bundle()));
|
||||
new Bundle()))
|
||||
.setTransitionType(SettingsTransitionHelper.TransitionType.TRANSITION_FADE);
|
||||
|
||||
Log.d(LOG_TAG, "Launch font size settings");
|
||||
subSettingLauncher.launch();
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* 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.applications;
|
||||
|
||||
import android.app.usage.UsageStats;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AllAppsInfoPreferenceController extends BasePreferenceController
|
||||
implements RecentAppStatsMixin.RecentAppStatsListener {
|
||||
|
||||
@VisibleForTesting
|
||||
Preference mPreference;
|
||||
|
||||
public AllAppsInfoPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mPreference = screen.findPreference(getPreferenceKey());
|
||||
// In most cases, device has recently opened apps. So, we hide it by default.
|
||||
mPreference.setVisible(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReloadDataCompleted(@NonNull List<UsageStats> recentApps) {
|
||||
// If device has recently opened apps, we don't show all apps preference.
|
||||
if (!recentApps.isEmpty()) {
|
||||
mPreference.setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
mPreference.setVisible(true);
|
||||
// Show total number of installed apps as See all's summary.
|
||||
new InstalledAppCounter(mContext, InstalledAppCounter.IGNORE_INSTALL_REASON,
|
||||
mContext.getPackageManager()) {
|
||||
@Override
|
||||
protected void onCountComplete(int num) {
|
||||
mPreference.setSummary(mContext.getString(R.string.apps_summary, num));
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.app.usage.UsageStats;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.notification.EmergencyBroadcastPreferenceController;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import com.android.settingslib.widget.AppEntitiesHeaderController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class AppAndNotificationDashboardFragment extends DashboardFragment
|
||||
implements RecentAppStatsMixin.RecentAppStatsListener {
|
||||
|
||||
private static final String TAG = "AppAndNotifDashboard";
|
||||
|
||||
private RecentAppStatsMixin mRecentAppStatsMixin;
|
||||
private RecentAppsPreferenceController mRecentAppsPreferenceController;
|
||||
private AllAppsInfoPreferenceController mAllAppsInfoPreferenceController;
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.SETTINGS_APP_NOTIF_CATEGORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHelpResource() {
|
||||
return R.string.help_url_apps_and_notifications;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.app_and_notification;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
|
||||
use(SpecialAppAccessPreferenceController.class).setSession(getSettingsLifecycle());
|
||||
|
||||
mRecentAppStatsMixin = new RecentAppStatsMixin(context,
|
||||
AppEntitiesHeaderController.MAXIMUM_APPS);
|
||||
getSettingsLifecycle().addObserver(mRecentAppStatsMixin);
|
||||
mRecentAppStatsMixin.addListener(this);
|
||||
|
||||
mRecentAppsPreferenceController = use(RecentAppsPreferenceController.class);
|
||||
mRecentAppsPreferenceController.setFragment(this /* fragment */);
|
||||
mRecentAppStatsMixin.addListener(mRecentAppsPreferenceController);
|
||||
|
||||
mAllAppsInfoPreferenceController = use(AllAppsInfoPreferenceController.class);
|
||||
mRecentAppStatsMixin.addListener(mAllAppsInfoPreferenceController);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
setPinnedHeaderView(R.layout.progress_header);
|
||||
showPinnedHeader(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
showPinnedHeader(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReloadDataCompleted(@NonNull List<UsageStats> recentApps) {
|
||||
showPinnedHeader(false);
|
||||
if (!recentApps.isEmpty()) {
|
||||
Utils.setActionBarShadowAnimation(getActivity(), getSettingsLifecycle(),
|
||||
getListView());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
return buildPreferenceControllers(context);
|
||||
}
|
||||
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new EmergencyBroadcastPreferenceController(context,
|
||||
"app_and_notif_cell_broadcast_settings"));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
||||
Context context, boolean enabled) {
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.app_and_notification;
|
||||
return Arrays.asList(sir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AbstractPreferenceController> createPreferenceControllers(
|
||||
Context context) {
|
||||
return buildPreferenceControllers(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
// TODO(b/174964405): This method should be removed when silky home launched.
|
||||
// This page is going to deprecate, we should make this page unsearchable
|
||||
// when the silky home is enabled, otherwise search results will contain the
|
||||
// old data and launch this page even if the silky home is enabled.
|
||||
return !FeatureFlagUtils.isEnabled(context, FeatureFlags.SILKY_HOME);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -19,14 +19,11 @@ package com.android.settings.applications;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.drawer.CategoryKey;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -79,16 +76,6 @@ public class AppDashboardFragment extends DashboardFragment {
|
||||
return buildPreferenceControllers(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCategoryKey() {
|
||||
// TODO(b/174964405): Remove this function when the silky flag was deprecated.
|
||||
// To include injection tiles, map this app fragment to the app category in the short term.
|
||||
// When we deprecate the silky flag, we have to:
|
||||
// 1. Remove this method.
|
||||
// 2. Update the mapping in DashboardFragmentRegistry.PARENT_TO_CATEGORY_KEY_MAP.
|
||||
return CategoryKey.CATEGORY_APPS;
|
||||
}
|
||||
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
@@ -104,12 +91,5 @@ public class AppDashboardFragment extends DashboardFragment {
|
||||
Context context) {
|
||||
return buildPreferenceControllers(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
// TODO(b/174964405): This method should be removed when silky home launched.
|
||||
// Only allow this page can be searchable when silky home enabled.
|
||||
return FeatureFlagUtils.isEnabled(context, FeatureFlags.SILKY_HOME);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications;
|
||||
|
||||
import android.app.Application;
|
||||
import android.app.usage.UsageStats;
|
||||
import android.content.Context;
|
||||
import android.icu.text.RelativeDateTimeFormatter;
|
||||
import android.os.UserHandle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
|
||||
import com.android.settings.applications.manageapplications.ManageApplications;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.Utils;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settingslib.utils.StringUtil;
|
||||
import com.android.settingslib.widget.AppEntitiesHeaderController;
|
||||
import com.android.settingslib.widget.AppEntityInfo;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This controller displays up to three recently used apps.
|
||||
* If there is no recently used app, we only show up an "App Info" preference.
|
||||
*/
|
||||
public class RecentAppsPreferenceController extends BasePreferenceController
|
||||
implements RecentAppStatsMixin.RecentAppStatsListener {
|
||||
|
||||
@VisibleForTesting
|
||||
static final String KEY_DIVIDER = "recent_apps_divider";
|
||||
|
||||
@VisibleForTesting
|
||||
AppEntitiesHeaderController mAppEntitiesController;
|
||||
@VisibleForTesting
|
||||
LayoutPreference mRecentAppsPreference;
|
||||
@VisibleForTesting
|
||||
Preference mDivider;
|
||||
|
||||
private final ApplicationsState mApplicationsState;
|
||||
private final int mUserId;
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
|
||||
private Fragment mHost;
|
||||
private List<UsageStats> mRecentApps;
|
||||
|
||||
public RecentAppsPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mApplicationsState = ApplicationsState.getInstance(
|
||||
(Application) mContext.getApplicationContext());
|
||||
mUserId = UserHandle.myUserId();
|
||||
mMetricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
|
||||
}
|
||||
|
||||
public void setFragment(Fragment fragment) {
|
||||
mHost = fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE_UNSEARCHABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
|
||||
mDivider = screen.findPreference(KEY_DIVIDER);
|
||||
mRecentAppsPreference = screen.findPreference(getPreferenceKey());
|
||||
final View view = mRecentAppsPreference.findViewById(R.id.app_entities_header);
|
||||
mAppEntitiesController = AppEntitiesHeaderController.newInstance(mContext, view)
|
||||
.setHeaderTitleRes(R.string.recent_app_category_title)
|
||||
.setHeaderDetailsClickListener((View v) -> {
|
||||
mMetricsFeatureProvider.logClickedPreference(mRecentAppsPreference,
|
||||
getMetricsCategory());
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(ManageApplications.class.getName())
|
||||
.setArguments(null /* arguments */)
|
||||
.setTitleRes(R.string.application_info_label)
|
||||
.setSourceMetricsCategory(getMetricsCategory())
|
||||
.launch();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReloadDataCompleted(@NonNull List<UsageStats> recentApps) {
|
||||
mRecentApps = recentApps;
|
||||
refreshUi();
|
||||
// Show total number of installed apps as See all's summary.
|
||||
new InstalledAppCounter(mContext, InstalledAppCounter.IGNORE_INSTALL_REASON,
|
||||
mContext.getPackageManager()) {
|
||||
@Override
|
||||
protected void onCountComplete(int num) {
|
||||
mAppEntitiesController.setHeaderDetails(
|
||||
mContext.getResources().getQuantityString(R.plurals.see_all_apps_title,
|
||||
num, num));
|
||||
mAppEntitiesController.apply();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private void refreshUi() {
|
||||
if (!mRecentApps.isEmpty()) {
|
||||
displayRecentApps();
|
||||
mRecentAppsPreference.setVisible(true);
|
||||
mDivider.setVisible(true);
|
||||
} else {
|
||||
mDivider.setVisible(false);
|
||||
mRecentAppsPreference.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void displayRecentApps() {
|
||||
int showAppsCount = 0;
|
||||
|
||||
for (UsageStats stat : mRecentApps) {
|
||||
final AppEntityInfo appEntityInfoInfo = createAppEntity(stat);
|
||||
if (appEntityInfoInfo != null) {
|
||||
mAppEntitiesController.setAppEntity(showAppsCount++, appEntityInfoInfo);
|
||||
}
|
||||
|
||||
if (showAppsCount == AppEntitiesHeaderController.MAXIMUM_APPS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private AppEntityInfo createAppEntity(UsageStats stat) {
|
||||
final String pkgName = stat.getPackageName();
|
||||
final ApplicationsState.AppEntry appEntry =
|
||||
mApplicationsState.getEntry(pkgName, mUserId);
|
||||
if (appEntry == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new AppEntityInfo.Builder()
|
||||
.setIcon(Utils.getBadgedIcon(mContext, appEntry.info))
|
||||
.setTitle(appEntry.label)
|
||||
.setSummary(StringUtil.formatRelativeTime(mContext,
|
||||
System.currentTimeMillis() - stat.getLastTimeUsed(), false,
|
||||
RelativeDateTimeFormatter.Style.SHORT))
|
||||
.setOnClickListener(v -> {
|
||||
mMetricsFeatureProvider.logClickedPreference(mRecentAppsPreference,
|
||||
getMetricsCategory());
|
||||
AppInfoBase.startAppInfoFragment(AppInfoDashboardFragment.class,
|
||||
R.string.application_info_label, pkgName, appEntry.info.uid,
|
||||
mHost, 1001 /*RequestCode*/, getMetricsCategory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package com.android.settings.applications.appinfo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.BatteryUsageStats;
|
||||
import android.os.Bundle;
|
||||
import android.os.UidBatteryConsumer;
|
||||
@@ -34,6 +35,8 @@ import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.fuelgauge.AdvancedPowerUsageDetail;
|
||||
import com.android.settings.fuelgauge.BatteryChartPreferenceController;
|
||||
import com.android.settings.fuelgauge.BatteryDiffEntry;
|
||||
import com.android.settings.fuelgauge.BatteryEntry;
|
||||
import com.android.settings.fuelgauge.BatteryUsageStatsLoader;
|
||||
import com.android.settings.fuelgauge.BatteryUtils;
|
||||
@@ -63,13 +66,18 @@ public class AppBatteryPreferenceController extends BasePreferenceController
|
||||
private final AppInfoDashboardFragment mParent;
|
||||
private String mBatteryPercent;
|
||||
private final String mPackageName;
|
||||
private final int mUid;
|
||||
private BatteryDiffEntry mBatteryDiffEntry;
|
||||
private boolean mBatteryUsageStatsLoaded = false;
|
||||
private boolean mBatteryDiffEntriesLoaded = false;
|
||||
|
||||
public AppBatteryPreferenceController(Context context, AppInfoDashboardFragment parent,
|
||||
String packageName, Lifecycle lifecycle) {
|
||||
String packageName, int uid, Lifecycle lifecycle) {
|
||||
super(context, KEY_BATTERY);
|
||||
mParent = parent;
|
||||
mBatteryUtils = BatteryUtils.getInstance(mContext);
|
||||
mPackageName = packageName;
|
||||
mUid = uid;
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
@@ -87,6 +95,7 @@ public class AppBatteryPreferenceController extends BasePreferenceController
|
||||
super.displayPreference(screen);
|
||||
mPreference = screen.findPreference(getPreferenceKey());
|
||||
mPreference.setEnabled(false);
|
||||
loadBatteryDiffEntries();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,6 +103,17 @@ public class AppBatteryPreferenceController extends BasePreferenceController
|
||||
if (!KEY_BATTERY.equals(preference.getKey())) {
|
||||
return false;
|
||||
}
|
||||
if (mBatteryDiffEntry != null) {
|
||||
AdvancedPowerUsageDetail.startBatteryDetailPage(
|
||||
mParent.getActivity(),
|
||||
mParent,
|
||||
mBatteryDiffEntry,
|
||||
mBatteryPercent,
|
||||
/*isValidToShowSummary=*/ true,
|
||||
/*slotInformation=*/ null);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isBatteryStatsAvailable()) {
|
||||
final UserManager userManager =
|
||||
(UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
||||
@@ -121,6 +141,31 @@ public class AppBatteryPreferenceController extends BasePreferenceController
|
||||
AppInfoDashboardFragment.LOADER_BATTERY_USAGE_STATS);
|
||||
}
|
||||
|
||||
private void loadBatteryDiffEntries() {
|
||||
new AsyncTask<Void, Void, BatteryDiffEntry>() {
|
||||
@Override
|
||||
protected BatteryDiffEntry doInBackground(Void... unused) {
|
||||
final List<BatteryDiffEntry> batteryDiffEntries =
|
||||
BatteryChartPreferenceController.getBatteryLast24HrUsageData(mContext);
|
||||
if (batteryDiffEntries != null) {
|
||||
for (BatteryDiffEntry batteryDiffEntry : batteryDiffEntries) {
|
||||
if (batteryDiffEntry.mBatteryHistEntry.mUid == mUid) {
|
||||
return batteryDiffEntry;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(BatteryDiffEntry batteryDiffEntry) {
|
||||
mBatteryDiffEntry = batteryDiffEntry;
|
||||
mBatteryDiffEntriesLoaded = true;
|
||||
mPreference.setEnabled(mBatteryUsageStatsLoaded);
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private void onLoadFinished() {
|
||||
if (mBatteryUsageStats == null) {
|
||||
return;
|
||||
@@ -138,7 +183,8 @@ public class AppBatteryPreferenceController extends BasePreferenceController
|
||||
|
||||
@VisibleForTesting
|
||||
void updateBattery() {
|
||||
mPreference.setEnabled(true);
|
||||
mBatteryUsageStatsLoaded = true;
|
||||
mPreference.setEnabled(mBatteryDiffEntriesLoaded);
|
||||
if (isBatteryStatsAvailable()) {
|
||||
final int percentOfMax = (int) mBatteryUtils.calculateBatteryPercent(
|
||||
mUidBatteryConsumer.getConsumedPower(), mBatteryUsageStats.getConsumedPower(),
|
||||
|
||||
@@ -35,7 +35,6 @@ import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
@@ -49,7 +48,6 @@ import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.applications.manageapplications.ManageApplications;
|
||||
import com.android.settings.applications.specialaccess.interactacrossprofiles.InteractAcrossProfilesDetailsPreferenceController;
|
||||
import com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetailPreferenceController;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
@@ -111,6 +109,7 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
private PackageInfo mPackageInfo;
|
||||
private int mUserId;
|
||||
private String mPackageName;
|
||||
private int mUid;
|
||||
|
||||
private DevicePolicyManager mDpm;
|
||||
private UserManager mUserManager;
|
||||
@@ -166,9 +165,7 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
use(AppStoragePreferenceController.class).setParentFragment(this);
|
||||
use(AppVersionPreferenceController.class).setParentFragment(this);
|
||||
use(InstantAppDomainsPreferenceController.class).setParentFragment(this);
|
||||
if (FeatureFlagUtils.isEnabled(context, FeatureFlags.SILKY_HOME)) {
|
||||
use(ExtraAppInfoPreferenceController.class).setPackageName(packageName);
|
||||
}
|
||||
use(ExtraAppInfoPreferenceController.class).setPackageName(packageName);
|
||||
|
||||
final HibernationSwitchPreferenceController appHibernationSettings =
|
||||
use(HibernationSwitchPreferenceController.class);
|
||||
@@ -258,9 +255,6 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
|
||||
return R.xml.app_info_settings_v2;
|
||||
}
|
||||
return R.xml.app_info_settings;
|
||||
}
|
||||
|
||||
@@ -297,7 +291,8 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
(SettingsActivity) getActivity(), this, lifecycle, packageName, mState,
|
||||
REQUEST_UNINSTALL, REQUEST_REMOVE_DEVICE_ADMIN);
|
||||
controllers.add(mAppButtonsPreferenceController);
|
||||
controllers.add(new AppBatteryPreferenceController(context, this, packageName, lifecycle));
|
||||
controllers.add(new AppBatteryPreferenceController(
|
||||
context, this, packageName, getUid(), lifecycle));
|
||||
controllers.add(new AppMemoryPreferenceController(context, this, lifecycle));
|
||||
controllers.add(new DefaultHomeShortcutPreferenceController(context, packageName));
|
||||
controllers.add(new DefaultBrowserShortcutPreferenceController(context, packageName));
|
||||
@@ -568,7 +563,7 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
final Bundle args = getArguments();
|
||||
mPackageName = (args != null) ? args.getString(ARG_PACKAGE_NAME) : null;
|
||||
if (mPackageName == null) {
|
||||
final Intent intent = (args == null) ?
|
||||
final Intent intent = args == null ?
|
||||
getActivity().getIntent() : (Intent) args.getParcelable("intent");
|
||||
if (intent != null) {
|
||||
mPackageName = intent.getData().getSchemeSpecificPart();
|
||||
@@ -577,6 +572,22 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
return mPackageName;
|
||||
}
|
||||
|
||||
private int getUid() {
|
||||
if (mUid > 0) {
|
||||
return mUid;
|
||||
}
|
||||
final Bundle args = getArguments();
|
||||
mUid = (args != null) ? args.getInt(ARG_PACKAGE_UID) : -1;
|
||||
if (mUid <= 0) {
|
||||
final Intent intent = args == null
|
||||
? getActivity().getIntent() : (Intent) args.getParcelable("intent");
|
||||
if (intent != null && intent.getExtras() != null) {
|
||||
mUid = intent.getIntExtra("uId", -1);
|
||||
}
|
||||
}
|
||||
return mUid;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void retrieveAppEntry() {
|
||||
final Activity activity = getActivity();
|
||||
|
||||
@@ -23,6 +23,7 @@ import static android.app.AppOpsManager.OPSTR_AUTO_REVOKE_PERMISSIONS_IF_UNUSED;
|
||||
import static android.provider.DeviceConfig.NAMESPACE_APP_HIBERNATION;
|
||||
|
||||
import static com.android.settings.Utils.PROPERTY_APP_HIBERNATION_ENABLED;
|
||||
import static com.android.settings.Utils.PROPERTY_HIBERNATION_TARGETS_PRE_S_APPS;
|
||||
|
||||
import android.app.AppOpsManager;
|
||||
import android.content.Context;
|
||||
@@ -95,8 +96,11 @@ public final class HibernationSwitchPreferenceController extends AppInfoPreferen
|
||||
: android.os.Build.VERSION_CODES.Q;
|
||||
try {
|
||||
mPackageUid = packageManager.getPackageUid(packageName, /* flags */ 0);
|
||||
mIsPackageExemptByDefault = packageManager.getTargetSdkVersion(packageName)
|
||||
<= maxTargetSdkVersionForExemptApps;
|
||||
mIsPackageExemptByDefault =
|
||||
hibernationTargetsPreSApps()
|
||||
? false
|
||||
: packageManager.getTargetSdkVersion(packageName)
|
||||
<= maxTargetSdkVersionForExemptApps;
|
||||
mIsPackageSet = true;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Slog.w(TAG, "Package [" + mPackageName + "] is not found!");
|
||||
@@ -142,4 +146,9 @@ public final class HibernationSwitchPreferenceController extends AppInfoPreferen
|
||||
return DeviceConfig.getBoolean(
|
||||
NAMESPACE_APP_HIBERNATION, PROPERTY_APP_HIBERNATION_ENABLED, false);
|
||||
}
|
||||
|
||||
private static boolean hibernationTargetsPreSApps() {
|
||||
return DeviceConfig.getBoolean(
|
||||
NAMESPACE_APP_HIBERNATION, PROPERTY_HIBERNATION_TARGETS_PRE_S_APPS, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextUtils.TruncateAt;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.util.EventLog;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
@@ -338,7 +337,6 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
|
||||
mActionButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE);
|
||||
mActionButton.setFilterTouchesWhenObscured(true);
|
||||
mAddMsg = dialog.findViewById(R.id.add_msg_simplified);
|
||||
mAddMsg.setMovementMethod(new ScrollingMovementMethod());
|
||||
mAddMsg.setText(mAddMsgText);
|
||||
mAdminWarning = dialog.findViewById(R.id.admin_warning_simplified);
|
||||
mAdminWarning.setText(getString(R.string.device_admin_warning_simplified,
|
||||
|
||||
@@ -112,7 +112,6 @@ public class FaceEnrollEducation extends BiometricEnrollBase {
|
||||
if (mIsUsingLottie) {
|
||||
mIllustrationDefault.stop();
|
||||
mIllustrationDefault.setVisibility(View.INVISIBLE);
|
||||
mIllustrationLottie.setAnimation(R.raw.face_education_lottie);
|
||||
mIllustrationLottie.setVisibility(View.VISIBLE);
|
||||
mIllustrationLottie.playAnimation();
|
||||
}
|
||||
|
||||
@@ -41,6 +41,12 @@ public class BluetoothDeviceRenamePreferenceController extends
|
||||
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@link Fragment} that used to show {@link LocalDeviceNameDialogFragment}
|
||||
* in {@code handlePreferenceTreeClick}
|
||||
|
||||
@@ -177,6 +177,15 @@ public final class BluetoothPairingService extends Service {
|
||||
pairingDialogIntent.setClass(this, BluetoothPairingService.class);
|
||||
pairingDialogIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
|
||||
pairingDialogIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, type);
|
||||
|
||||
if (type == BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION
|
||||
|| type == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY
|
||||
|| type == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN) {
|
||||
int pairingKey = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_KEY,
|
||||
BluetoothDevice.ERROR);
|
||||
pairingDialogIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_KEY, pairingKey);
|
||||
}
|
||||
|
||||
PendingIntent pairIntent = PendingIntent.getService(this, 0, pairingDialogIntent,
|
||||
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
|
||||
/**
|
||||
* Controller to maintain the {@link androidx.preference.Preference} for add
|
||||
* device without summary at beginning. It monitor Bluetooth's status(on/off) and decide if need
|
||||
* device. It monitor Bluetooth's status(on/off) and decide if need
|
||||
* to show summary or not.
|
||||
*/
|
||||
public class AddDevicePreferenceController extends BasePreferenceController
|
||||
@@ -43,12 +43,11 @@ public class AddDevicePreferenceController extends BasePreferenceController
|
||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
updateState();
|
||||
updateState(mPreference);
|
||||
}
|
||||
};
|
||||
private IntentFilter mIntentFilter;
|
||||
|
||||
protected BluetoothAdapter mBluetoothAdapter;
|
||||
private BluetoothAdapter mBluetoothAdapter;
|
||||
|
||||
public AddDevicePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
@@ -59,7 +58,6 @@ public class AddDevicePreferenceController extends BasePreferenceController
|
||||
@Override
|
||||
public void onStart() {
|
||||
mContext.registerReceiver(mReceiver, mIntentFilter);
|
||||
updateState(mPreference);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,13 +70,13 @@ public class AddDevicePreferenceController extends BasePreferenceController
|
||||
super.displayPreference(screen);
|
||||
if (isAvailable()) {
|
||||
mPreference = screen.findPreference(getPreferenceKey());
|
||||
updateState(mPreference);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
|
||||
&& isBluetoothEnabled()
|
||||
? AVAILABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
@@ -93,8 +91,4 @@ public class AddDevicePreferenceController extends BasePreferenceController
|
||||
protected boolean isBluetoothEnabled() {
|
||||
return mBluetoothAdapter != null && mBluetoothAdapter.isEnabled();
|
||||
}
|
||||
|
||||
void updateState() {
|
||||
updateState(mPreference);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.settings.connecteddevice;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
/**
|
||||
* Controller to maintain the {@link androidx.preference.Preference} for add
|
||||
* device with summary at beginning. It monitor Bluetooth's status(on/off) and decide if need
|
||||
* to show summary or not.
|
||||
*/
|
||||
public class AddDeviceSummaryPreferenceController extends AddDevicePreferenceController {
|
||||
|
||||
public AddDeviceSummaryPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
|
||||
&& !isBluetoothEnabled()
|
||||
? AVAILABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
@@ -103,6 +103,7 @@ public class PreviouslyConnectedDevicePreferenceController extends BasePreferenc
|
||||
final Context context = screen.getContext();
|
||||
mBluetoothDeviceUpdater.setPrefContext(context);
|
||||
mSavedDockUpdater.setPreferenceContext(context);
|
||||
mBluetoothDeviceUpdater.forceUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -163,81 +163,23 @@ public class SettingsBaseActivity extends FragmentActivity {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivity(Intent intent) {
|
||||
if (!Utils.isPageTransitionEnabled(this)) {
|
||||
super.startActivity(intent);
|
||||
return;
|
||||
}
|
||||
|
||||
final int transitionType = getTransitionType(intent);
|
||||
if (transitionType == TransitionType.TRANSITION_SLIDE) {
|
||||
super.startActivity(intent, null);
|
||||
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
|
||||
return;
|
||||
} else if (transitionType == TransitionType.TRANSITION_NONE) {
|
||||
super.startActivity(intent, null);
|
||||
return;
|
||||
}
|
||||
super.startActivity(intent, createActivityOptionsBundleForTransition(null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivity(Intent intent, @androidx.annotation.Nullable Bundle options) {
|
||||
final int transitionType = getTransitionType(intent);
|
||||
if (!Utils.isPageTransitionEnabled(this) ||
|
||||
transitionType == TransitionType.TRANSITION_NONE) {
|
||||
super.startActivity(intent, options);
|
||||
return;
|
||||
}
|
||||
|
||||
if (transitionType == TransitionType.TRANSITION_SLIDE) {
|
||||
super.startActivity(intent, options);
|
||||
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
|
||||
return;
|
||||
}
|
||||
super.startActivity(intent, createActivityOptionsBundleForTransition(options));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityForResult(Intent intent, int requestCode) {
|
||||
final int transitionType = getTransitionType(intent);
|
||||
// startActivity() will eventually calls startActivityForResult() with requestCode -1.
|
||||
// Adding this condition to avoid multiple calls.
|
||||
if (!Utils.isPageTransitionEnabled(this) || requestCode == DEFAULT_REQUEST
|
||||
|| transitionType == TransitionType.TRANSITION_NONE) {
|
||||
super.startActivityForResult(intent, requestCode);
|
||||
return;
|
||||
}
|
||||
|
||||
if (transitionType == TransitionType.TRANSITION_SLIDE) {
|
||||
super.startActivityForResult(intent, requestCode, null);
|
||||
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
|
||||
return;
|
||||
}
|
||||
|
||||
super.startActivityForResult(intent, requestCode,
|
||||
createActivityOptionsBundleForTransition(null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityForResult(Intent intent, int requestCode,
|
||||
@androidx.annotation.Nullable Bundle options) {
|
||||
final int transitionType = getTransitionType(intent);
|
||||
if (!Utils.isPageTransitionEnabled(this) || requestCode == DEFAULT_REQUEST
|
||||
|| transitionType == TransitionType.TRANSITION_NONE) {
|
||||
super.startActivityForResult(intent, requestCode, options);
|
||||
if (Utils.isPageTransitionEnabled(this) &&
|
||||
transitionType == TransitionType.TRANSITION_SHARED_AXIS) {
|
||||
super.startActivityForResult(intent, requestCode,
|
||||
createActivityOptionsBundleForTransition(options));
|
||||
return;
|
||||
}
|
||||
|
||||
super.startActivityForResult(intent, requestCode, options);
|
||||
if (transitionType == TransitionType.TRANSITION_SLIDE) {
|
||||
super.startActivityForResult(intent, requestCode, options);
|
||||
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
|
||||
return;
|
||||
} else if (transitionType == TransitionType.TRANSITION_FADE) {
|
||||
overridePendingTransition(android.R.anim.fade_in, R.anim.sud_stay);
|
||||
}
|
||||
|
||||
super.startActivityForResult(intent, requestCode,
|
||||
createActivityOptionsBundleForTransition(options));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -267,6 +209,10 @@ public class SettingsBaseActivity extends FragmentActivity {
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
// For accessibility activities launched from setup wizard.
|
||||
if (getTransitionType(getIntent()) == TransitionType.TRANSITION_FADE) {
|
||||
overridePendingTransition(R.anim.sud_stay, android.R.anim.fade_out);
|
||||
}
|
||||
unregisterReceiver(mPackageReceiver);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import com.android.settings.accounts.AccountDashboardFragment;
|
||||
import com.android.settings.accounts.AccountSyncSettings;
|
||||
import com.android.settings.accounts.ChooseAccountFragment;
|
||||
import com.android.settings.accounts.ManagedProfileSettings;
|
||||
import com.android.settings.applications.AppAndNotificationDashboardFragment;
|
||||
import com.android.settings.applications.AppDashboardFragment;
|
||||
import com.android.settings.applications.ProcessStatsSummary;
|
||||
import com.android.settings.applications.ProcessStatsUi;
|
||||
@@ -293,7 +292,6 @@ public class SettingsGateway {
|
||||
NetworkDashboardFragment.class.getName(),
|
||||
ConnectedDeviceDashboardFragment.class.getName(),
|
||||
UsbDetailsFragment.class.getName(),
|
||||
AppAndNotificationDashboardFragment.class.getName(),
|
||||
AppDashboardFragment.class.getName(),
|
||||
WifiCallingDisclaimerFragment.class.getName(),
|
||||
AccountDashboardFragment.class.getName(),
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.android.settings.DisplaySettings;
|
||||
import com.android.settings.LegalSettings;
|
||||
import com.android.settings.accounts.AccountDashboardFragment;
|
||||
import com.android.settings.accounts.AccountDetailDashboardFragment;
|
||||
import com.android.settings.applications.AppAndNotificationDashboardFragment;
|
||||
import com.android.settings.applications.AppDashboardFragment;
|
||||
import com.android.settings.connecteddevice.AdvancedConnectedDeviceDashboardFragment;
|
||||
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
|
||||
import com.android.settings.development.DevelopmentSettingsDashboardFragment;
|
||||
@@ -76,7 +76,7 @@ public class DashboardFragmentRegistry {
|
||||
CategoryKey.CATEGORY_CONNECT);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(AdvancedConnectedDeviceDashboardFragment.class.getName(),
|
||||
CategoryKey.CATEGORY_DEVICE);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(AppAndNotificationDashboardFragment.class.getName(),
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(AppDashboardFragment.class.getName(),
|
||||
CategoryKey.CATEGORY_APPS);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(PowerUsageSummary.class.getName(),
|
||||
CategoryKey.CATEGORY_BATTERY);
|
||||
|
||||
@@ -70,7 +70,7 @@ import java.util.List;
|
||||
*/
|
||||
public class StorageCategoryFragment extends DashboardFragment
|
||||
implements
|
||||
LoaderManager.LoaderCallbacks<SparseArray<StorageAsyncLoader.AppsStorageResult>>,
|
||||
LoaderManager.LoaderCallbacks<SparseArray<StorageAsyncLoader.StorageResult>>,
|
||||
Preference.OnPreferenceClickListener {
|
||||
private static final String TAG = "StorageCategoryFrag";
|
||||
private static final String SUMMARY_PREF_KEY = "storage_summary";
|
||||
@@ -83,7 +83,7 @@ public class StorageCategoryFragment extends DashboardFragment
|
||||
private UserManager mUserManager;
|
||||
private StorageEntry mSelectedStorageEntry;
|
||||
private PrivateStorageInfo mStorageInfo;
|
||||
private SparseArray<StorageAsyncLoader.AppsStorageResult> mAppsResult;
|
||||
private SparseArray<StorageAsyncLoader.StorageResult> mAppsResult;
|
||||
private CachedStorageValuesHelper mCachedStorageValuesHelper;
|
||||
|
||||
private StorageItemPreferenceController mPreferenceController;
|
||||
@@ -232,7 +232,7 @@ public class StorageCategoryFragment extends DashboardFragment
|
||||
* Updates the secondary user controller sizes.
|
||||
*/
|
||||
private void updateSecondaryUserControllers(List<AbstractPreferenceController> controllers,
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> stats) {
|
||||
SparseArray<StorageAsyncLoader.StorageResult> stats) {
|
||||
for (int i = 0, size = controllers.size(); i < size; i++) {
|
||||
final AbstractPreferenceController controller = controllers.get(i);
|
||||
if (controller instanceof StorageAsyncLoader.ResultHandler) {
|
||||
@@ -244,7 +244,7 @@ public class StorageCategoryFragment extends DashboardFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public Loader<SparseArray<StorageAsyncLoader.AppsStorageResult>> onCreateLoader(int id,
|
||||
public Loader<SparseArray<StorageAsyncLoader.StorageResult>> onCreateLoader(int id,
|
||||
Bundle args) {
|
||||
final Context context = getContext();
|
||||
return new StorageAsyncLoader(context, mUserManager,
|
||||
@@ -254,15 +254,15 @@ public class StorageCategoryFragment extends DashboardFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<SparseArray<StorageAsyncLoader.AppsStorageResult>> loader,
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> data) {
|
||||
public void onLoadFinished(Loader<SparseArray<StorageAsyncLoader.StorageResult>> loader,
|
||||
SparseArray<StorageAsyncLoader.StorageResult> data) {
|
||||
mAppsResult = data;
|
||||
maybeCacheFreshValues();
|
||||
onReceivedSizes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<SparseArray<StorageAsyncLoader.AppsStorageResult>> loader) {
|
||||
public void onLoaderReset(Loader<SparseArray<StorageAsyncLoader.StorageResult>> loader) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -296,20 +296,20 @@ public class StorageCategoryFragment extends DashboardFragment
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public SparseArray<StorageAsyncLoader.AppsStorageResult> getAppsStorageResult() {
|
||||
public SparseArray<StorageAsyncLoader.StorageResult> getStorageResult() {
|
||||
return mAppsResult;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setAppsStorageResult(SparseArray<StorageAsyncLoader.AppsStorageResult> info) {
|
||||
public void setStorageResult(SparseArray<StorageAsyncLoader.StorageResult> info) {
|
||||
mAppsResult = info;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void initializeCachedValues() {
|
||||
final PrivateStorageInfo info = mCachedStorageValuesHelper.getCachedPrivateStorageInfo();
|
||||
final SparseArray<StorageAsyncLoader.AppsStorageResult> loaderResult =
|
||||
mCachedStorageValuesHelper.getCachedAppsStorageResult();
|
||||
final SparseArray<StorageAsyncLoader.StorageResult> loaderResult =
|
||||
mCachedStorageValuesHelper.getCachedStorageResult();
|
||||
if (info == null || loaderResult == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ import java.util.List;
|
||||
@SearchIndexable
|
||||
public class StorageDashboardFragment extends DashboardFragment
|
||||
implements
|
||||
LoaderManager.LoaderCallbacks<SparseArray<StorageAsyncLoader.AppsStorageResult>>,
|
||||
LoaderManager.LoaderCallbacks<SparseArray<StorageAsyncLoader.StorageResult>>,
|
||||
Preference.OnPreferenceClickListener {
|
||||
private static final String TAG = "StorageDashboardFrag";
|
||||
private static final String SUMMARY_PREF_KEY = "storage_summary";
|
||||
@@ -100,7 +100,7 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
private final List<StorageEntry> mStorageEntries = new ArrayList<>();
|
||||
private StorageEntry mSelectedStorageEntry;
|
||||
private PrivateStorageInfo mStorageInfo;
|
||||
private SparseArray<StorageAsyncLoader.AppsStorageResult> mAppsResult;
|
||||
private SparseArray<StorageAsyncLoader.StorageResult> mAppsResult;
|
||||
private CachedStorageValuesHelper mCachedStorageValuesHelper;
|
||||
|
||||
private StorageItemPreferenceController mPreferenceController;
|
||||
@@ -414,7 +414,7 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
* Updates the secondary user controller sizes.
|
||||
*/
|
||||
private void updateSecondaryUserControllers(List<AbstractPreferenceController> controllers,
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> stats) {
|
||||
SparseArray<StorageAsyncLoader.StorageResult> stats) {
|
||||
for (int i = 0, size = controllers.size(); i < size; i++) {
|
||||
final AbstractPreferenceController controller = controllers.get(i);
|
||||
if (controller instanceof StorageAsyncLoader.ResultHandler) {
|
||||
@@ -455,7 +455,7 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
};
|
||||
|
||||
@Override
|
||||
public Loader<SparseArray<StorageAsyncLoader.AppsStorageResult>> onCreateLoader(int id,
|
||||
public Loader<SparseArray<StorageAsyncLoader.StorageResult>> onCreateLoader(int id,
|
||||
Bundle args) {
|
||||
final Context context = getContext();
|
||||
return new StorageAsyncLoader(context, mUserManager,
|
||||
@@ -465,15 +465,15 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<SparseArray<StorageAsyncLoader.AppsStorageResult>> loader,
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> data) {
|
||||
public void onLoadFinished(Loader<SparseArray<StorageAsyncLoader.StorageResult>> loader,
|
||||
SparseArray<StorageAsyncLoader.StorageResult> data) {
|
||||
mAppsResult = data;
|
||||
maybeCacheFreshValues();
|
||||
onReceivedSizes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<SparseArray<StorageAsyncLoader.AppsStorageResult>> loader) {
|
||||
public void onLoaderReset(Loader<SparseArray<StorageAsyncLoader.StorageResult>> loader) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -507,20 +507,20 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public SparseArray<StorageAsyncLoader.AppsStorageResult> getAppsStorageResult() {
|
||||
public SparseArray<StorageAsyncLoader.StorageResult> getStorageResult() {
|
||||
return mAppsResult;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setAppsStorageResult(SparseArray<StorageAsyncLoader.AppsStorageResult> info) {
|
||||
public void setStorageResult(SparseArray<StorageAsyncLoader.StorageResult> info) {
|
||||
mAppsResult = info;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void initializeCachedValues() {
|
||||
final PrivateStorageInfo info = mCachedStorageValuesHelper.getCachedPrivateStorageInfo();
|
||||
final SparseArray<StorageAsyncLoader.AppsStorageResult> loaderResult =
|
||||
mCachedStorageValuesHelper.getCachedAppsStorageResult();
|
||||
final SparseArray<StorageAsyncLoader.StorageResult> loaderResult =
|
||||
mCachedStorageValuesHelper.getCachedStorageResult();
|
||||
if (info == null || loaderResult == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
package com.android.settings.deviceinfo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
@@ -25,7 +26,6 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.utils.FileSizeFormatter;
|
||||
|
||||
public class StorageItemPreference extends Preference {
|
||||
public int userHandle;
|
||||
@@ -49,12 +49,8 @@ public class StorageItemPreference extends Preference {
|
||||
|
||||
public void setStorageSize(long size, long total) {
|
||||
mStorageSize = size;
|
||||
setSummary(
|
||||
FileSizeFormatter.formatFileSize(
|
||||
getContext(),
|
||||
size,
|
||||
getGigabyteSuffix(getContext().getResources()),
|
||||
FileSizeFormatter.GIGABYTE_IN_BYTES));
|
||||
setSummary(getStorageSummary(size));
|
||||
|
||||
if (total == 0) {
|
||||
mProgressPercent = 0;
|
||||
} else {
|
||||
@@ -82,7 +78,10 @@ public class StorageItemPreference extends Preference {
|
||||
super.onBindViewHolder(view);
|
||||
}
|
||||
|
||||
private static int getGigabyteSuffix(Resources res) {
|
||||
return res.getIdentifier("gigabyteShort", "string", "android");
|
||||
private String getStorageSummary(long bytes) {
|
||||
final Formatter.BytesResult result = Formatter.formatBytes(getContext().getResources(),
|
||||
bytes, Formatter.FLAG_SHORTER);
|
||||
return TextUtils.expandTemplate(getContext().getText(R.string.storage_size_large),
|
||||
result.value, result.units).toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,9 +35,11 @@ public class CachedStorageValuesHelper {
|
||||
public static final String FREE_BYTES_KEY = "free_bytes";
|
||||
public static final String TOTAL_BYTES_KEY = "total_bytes";
|
||||
public static final String GAME_APPS_SIZE_KEY = "game_apps_size";
|
||||
public static final String MUSIC_APPS_SIZE_KEY = "music_apps_size";
|
||||
public static final String VIDEO_APPS_SIZE_KEY = "video_apps_size";
|
||||
public static final String PHOTO_APPS_SIZE_KEY = "photo_apps_size";
|
||||
public static final String AUDIO_SIZE_KEY = "audio_size";
|
||||
public static final String VIDEOS_SIZE_KEY = "videos_size";
|
||||
public static final String IMAGES_SIZE_KEY = "images_size";
|
||||
public static final String DOCUMENTS_AND_OTHER_SIZE_KEY = "documents_and_other_size";
|
||||
public static final String TRASH_SIZE_KEY = "trash_size";
|
||||
public static final String OTHER_APPS_SIZE_KEY = "other_apps_size";
|
||||
public static final String CACHE_APPS_SIZE_KEY = "cache_apps_size";
|
||||
public static final String EXTERNAL_TOTAL_BYTES = "external_total_bytes";
|
||||
@@ -78,21 +80,27 @@ public class CachedStorageValuesHelper {
|
||||
return new PrivateStorageInfo(freeBytes, totalBytes);
|
||||
}
|
||||
|
||||
public SparseArray<StorageAsyncLoader.AppsStorageResult> getCachedAppsStorageResult() {
|
||||
/** Returns cached storage result or null if it's not available. */
|
||||
public SparseArray<StorageAsyncLoader.StorageResult> getCachedStorageResult() {
|
||||
if (!isDataValid()) {
|
||||
return null;
|
||||
}
|
||||
final long gamesSize = mSharedPreferences.getLong(GAME_APPS_SIZE_KEY, -1);
|
||||
final long musicAppsSize = mSharedPreferences.getLong(MUSIC_APPS_SIZE_KEY, -1);
|
||||
final long videoAppsSize = mSharedPreferences.getLong(VIDEO_APPS_SIZE_KEY, -1);
|
||||
final long photoAppSize = mSharedPreferences.getLong(PHOTO_APPS_SIZE_KEY, -1);
|
||||
final long otherAppsSize = mSharedPreferences.getLong(OTHER_APPS_SIZE_KEY, -1);
|
||||
final long audioSize = mSharedPreferences.getLong(AUDIO_SIZE_KEY, -1);
|
||||
final long videosSize = mSharedPreferences.getLong(VIDEOS_SIZE_KEY, -1);
|
||||
final long imagesSize = mSharedPreferences.getLong(IMAGES_SIZE_KEY, -1);
|
||||
final long documentsAndOtherSize =
|
||||
mSharedPreferences.getLong(DOCUMENTS_AND_OTHER_SIZE_KEY, -1);
|
||||
final long trashSize = mSharedPreferences.getLong(TRASH_SIZE_KEY, -1);
|
||||
final long allAppsExceptGamesSize = mSharedPreferences.getLong(OTHER_APPS_SIZE_KEY, -1);
|
||||
final long cacheSize = mSharedPreferences.getLong(CACHE_APPS_SIZE_KEY, -1);
|
||||
if (gamesSize < 0
|
||||
|| musicAppsSize < 0
|
||||
|| videoAppsSize < 0
|
||||
|| photoAppSize < 0
|
||||
|| otherAppsSize < 0
|
||||
|| audioSize < 0
|
||||
|| videosSize < 0
|
||||
|| imagesSize < 0
|
||||
|| documentsAndOtherSize < 0
|
||||
|| trashSize < 0
|
||||
|| allAppsExceptGamesSize < 0
|
||||
|| cacheSize < 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -117,31 +125,34 @@ public class CachedStorageValuesHelper {
|
||||
externalVideoBytes,
|
||||
externalImageBytes,
|
||||
externalAppBytes);
|
||||
final StorageAsyncLoader.AppsStorageResult result =
|
||||
new StorageAsyncLoader.AppsStorageResult();
|
||||
final StorageAsyncLoader.StorageResult result = new StorageAsyncLoader.StorageResult();
|
||||
result.gamesSize = gamesSize;
|
||||
result.musicAppsSize = musicAppsSize;
|
||||
result.videoAppsSize = videoAppsSize;
|
||||
result.photosAppsSize = photoAppSize;
|
||||
result.otherAppsSize = otherAppsSize;
|
||||
result.audioSize = audioSize;
|
||||
result.videosSize = videosSize;
|
||||
result.imagesSize = imagesSize;
|
||||
result.documentsAndOtherSize = documentsAndOtherSize;
|
||||
result.trashSize = trashSize;
|
||||
result.allAppsExceptGamesSize = allAppsExceptGamesSize;
|
||||
result.cacheSize = cacheSize;
|
||||
result.externalStats = externalStats;
|
||||
final SparseArray<StorageAsyncLoader.AppsStorageResult> resultArray = new SparseArray<>();
|
||||
final SparseArray<StorageAsyncLoader.StorageResult> resultArray = new SparseArray<>();
|
||||
resultArray.append(mUserId, result);
|
||||
return resultArray;
|
||||
}
|
||||
|
||||
public void cacheResult(
|
||||
PrivateStorageInfo storageInfo, StorageAsyncLoader.AppsStorageResult result) {
|
||||
PrivateStorageInfo storageInfo, StorageAsyncLoader.StorageResult result) {
|
||||
mSharedPreferences
|
||||
.edit()
|
||||
.putLong(FREE_BYTES_KEY, storageInfo.freeBytes)
|
||||
.putLong(TOTAL_BYTES_KEY, storageInfo.totalBytes)
|
||||
.putLong(GAME_APPS_SIZE_KEY, result.gamesSize)
|
||||
.putLong(MUSIC_APPS_SIZE_KEY, result.musicAppsSize)
|
||||
.putLong(VIDEO_APPS_SIZE_KEY, result.videoAppsSize)
|
||||
.putLong(PHOTO_APPS_SIZE_KEY, result.photosAppsSize)
|
||||
.putLong(OTHER_APPS_SIZE_KEY, result.otherAppsSize)
|
||||
.putLong(AUDIO_SIZE_KEY, result.audioSize)
|
||||
.putLong(VIDEOS_SIZE_KEY, result.videosSize)
|
||||
.putLong(IMAGES_SIZE_KEY, result.imagesSize)
|
||||
.putLong(DOCUMENTS_AND_OTHER_SIZE_KEY, result.documentsAndOtherSize)
|
||||
.putLong(TRASH_SIZE_KEY, result.trashSize)
|
||||
.putLong(OTHER_APPS_SIZE_KEY, result.allAppsExceptGamesSize)
|
||||
.putLong(CACHE_APPS_SIZE_KEY, result.cacheSize)
|
||||
.putLong(EXTERNAL_TOTAL_BYTES, result.externalStats.totalBytes)
|
||||
.putLong(EXTERNAL_AUDIO_BYTES, result.externalStats.audioBytes)
|
||||
|
||||
@@ -168,9 +168,9 @@ public class SecondaryUserController extends AbstractPreferenceController implem
|
||||
mTotalSizeBytes = totalSizeBytes;
|
||||
}
|
||||
|
||||
public void handleResult(SparseArray<StorageAsyncLoader.AppsStorageResult> stats) {
|
||||
int userId = getUser().id;
|
||||
StorageAsyncLoader.AppsStorageResult result = stats.get(userId);
|
||||
@Override
|
||||
public void handleResult(SparseArray<StorageAsyncLoader.StorageResult> stats) {
|
||||
final StorageAsyncLoader.StorageResult result = stats.get(getUser().id);
|
||||
if (result != null) {
|
||||
setSize(result.externalStats.totalBytes);
|
||||
}
|
||||
|
||||
@@ -21,13 +21,20 @@ import static android.content.pm.ApplicationInfo.CATEGORY_GAME;
|
||||
import static android.content.pm.ApplicationInfo.CATEGORY_IMAGE;
|
||||
import static android.content.pm.ApplicationInfo.CATEGORY_VIDEO;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.provider.MediaStore.Files.FileColumns;
|
||||
import android.provider.MediaStore.MediaColumns;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
@@ -37,7 +44,6 @@ import com.android.settingslib.utils.AsyncLoaderCompat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -45,7 +51,7 @@ import java.util.List;
|
||||
* users
|
||||
*/
|
||||
public class StorageAsyncLoader
|
||||
extends AsyncLoaderCompat<SparseArray<StorageAsyncLoader.AppsStorageResult>> {
|
||||
extends AsyncLoaderCompat<SparseArray<StorageAsyncLoader.StorageResult>> {
|
||||
private UserManager mUserManager;
|
||||
private static final String TAG = "StorageAsyncLoader";
|
||||
|
||||
@@ -64,38 +70,81 @@ public class StorageAsyncLoader
|
||||
}
|
||||
|
||||
@Override
|
||||
public SparseArray<AppsStorageResult> loadInBackground() {
|
||||
return loadApps();
|
||||
public SparseArray<StorageResult> loadInBackground() {
|
||||
return getStorageResultsForUsers();
|
||||
}
|
||||
|
||||
private SparseArray<AppsStorageResult> loadApps() {
|
||||
private SparseArray<StorageResult> getStorageResultsForUsers() {
|
||||
mSeenPackages = new ArraySet<>();
|
||||
SparseArray<AppsStorageResult> result = new SparseArray<>();
|
||||
List<UserInfo> infos = mUserManager.getUsers();
|
||||
final SparseArray<StorageResult> results = new SparseArray<>();
|
||||
final List<UserInfo> infos = mUserManager.getUsers();
|
||||
|
||||
// Sort the users by user id ascending.
|
||||
Collections.sort(
|
||||
infos,
|
||||
new Comparator<UserInfo>() {
|
||||
@Override
|
||||
public int compare(UserInfo userInfo, UserInfo otherUser) {
|
||||
return Integer.compare(userInfo.id, otherUser.id);
|
||||
}
|
||||
});
|
||||
for (int i = 0, userCount = infos.size(); i < userCount; i++) {
|
||||
final UserInfo info = infos.get(i);
|
||||
result.put(info.id, getStorageResultForUser(info.id));
|
||||
Collections.sort(infos,
|
||||
(userInfo, otherUser) -> Integer.compare(userInfo.id, otherUser.id));
|
||||
|
||||
for (UserInfo info : infos) {
|
||||
final StorageResult result = getAppsAndGamesSize(info.id);
|
||||
|
||||
result.imagesSize = getFilesSize(info.id, MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||
null /* queryArgs */);
|
||||
result.videosSize = getFilesSize(info.id, MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
|
||||
null /* queryArgs */);
|
||||
result.audioSize = getFilesSize(info.id, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
|
||||
null /* queryArgs */);
|
||||
|
||||
final Bundle documentsAndOtherQueryArgs = new Bundle();
|
||||
documentsAndOtherQueryArgs.putString(ContentResolver.QUERY_ARG_SQL_SELECTION,
|
||||
FileColumns.MEDIA_TYPE + "!=" + FileColumns.MEDIA_TYPE_IMAGE
|
||||
+ " AND " + FileColumns.MEDIA_TYPE + "!=" + FileColumns.MEDIA_TYPE_VIDEO
|
||||
+ " AND " + FileColumns.MEDIA_TYPE + "!=" + FileColumns.MEDIA_TYPE_AUDIO
|
||||
+ " AND " + FileColumns.MIME_TYPE + " IS NOT NULL");
|
||||
result.documentsAndOtherSize = getFilesSize(info.id,
|
||||
MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL),
|
||||
documentsAndOtherQueryArgs);
|
||||
|
||||
final Bundle trashQueryArgs = new Bundle();
|
||||
trashQueryArgs.putInt(MediaStore.QUERY_ARG_MATCH_TRASHED, MediaStore.MATCH_ONLY);
|
||||
result.trashSize = getFilesSize(info.id,
|
||||
MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL), trashQueryArgs);
|
||||
|
||||
results.put(info.id, result);
|
||||
}
|
||||
return result;
|
||||
return results;
|
||||
}
|
||||
|
||||
private AppsStorageResult getStorageResultForUser(int userId) {
|
||||
private long getFilesSize(int userId, Uri uri, Bundle queryArgs) {
|
||||
final Context perUserContext;
|
||||
try {
|
||||
perUserContext = getContext().createPackageContextAsUser(
|
||||
getContext().getApplicationContext().getPackageName(),
|
||||
0 /* flags= */,
|
||||
UserHandle.of(userId));
|
||||
} catch (NameNotFoundException e) {
|
||||
Log.e(TAG, "Not able to get Context for user ID " + userId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
try (Cursor cursor = perUserContext.getContentResolver().query(
|
||||
uri,
|
||||
new String[] {"sum(" + MediaColumns.SIZE + ")"},
|
||||
queryArgs,
|
||||
null /* cancellationSignal */)) {
|
||||
if (cursor == null) {
|
||||
return 0;
|
||||
}
|
||||
return cursor.moveToFirst() ? cursor.getInt(0) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
private StorageResult getAppsAndGamesSize(int userId) {
|
||||
Log.d(TAG, "Loading apps");
|
||||
List<ApplicationInfo> applicationInfos =
|
||||
final List<ApplicationInfo> applicationInfos =
|
||||
mPackageManager.getInstalledApplicationsAsUser(0, userId);
|
||||
AppsStorageResult result = new AppsStorageResult();
|
||||
UserHandle myUser = UserHandle.of(userId);
|
||||
final StorageResult result = new StorageResult();
|
||||
final UserHandle myUser = UserHandle.of(userId);
|
||||
for (int i = 0, size = applicationInfos.size(); i < size; i++) {
|
||||
ApplicationInfo app = applicationInfos.get(i);
|
||||
final ApplicationInfo app = applicationInfos.get(i);
|
||||
|
||||
StorageStatsSource.AppStorageStats stats;
|
||||
try {
|
||||
@@ -131,28 +180,9 @@ public class StorageAsyncLoader
|
||||
result.gamesSize += blamedSize;
|
||||
break;
|
||||
case CATEGORY_AUDIO:
|
||||
// TODO(b/170918505): Should revamp audio size calculation with the data
|
||||
// from media provider.
|
||||
result.musicAppsSize += blamedSize;
|
||||
result.musicAppsSize -= stats.getCodeBytes();
|
||||
|
||||
result.otherAppsSize += blamedSize;
|
||||
break;
|
||||
case CATEGORY_VIDEO:
|
||||
// TODO(b/170918505): Should revamp video size calculation with the data
|
||||
// from media provider.
|
||||
result.videoAppsSize += blamedSize;
|
||||
result.videoAppsSize -= stats.getCodeBytes();
|
||||
|
||||
result.otherAppsSize += blamedSize;
|
||||
break;
|
||||
case CATEGORY_IMAGE:
|
||||
// TODO(b/170918505): Should revamp image size calculation with the data
|
||||
// from media provider.
|
||||
result.photosAppsSize += blamedSize;
|
||||
result.photosAppsSize -= stats.getCodeBytes();
|
||||
|
||||
result.otherAppsSize += blamedSize;
|
||||
result.allAppsExceptGamesSize += blamedSize;
|
||||
break;
|
||||
default:
|
||||
// The deprecated game flag does not set the category.
|
||||
@@ -160,7 +190,7 @@ public class StorageAsyncLoader
|
||||
result.gamesSize += blamedSize;
|
||||
break;
|
||||
}
|
||||
result.otherAppsSize += blamedSize;
|
||||
result.allAppsExceptGamesSize += blamedSize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -177,15 +207,22 @@ public class StorageAsyncLoader
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDiscardResult(SparseArray<AppsStorageResult> result) {
|
||||
protected void onDiscardResult(SparseArray<StorageResult> result) {
|
||||
}
|
||||
|
||||
public static class AppsStorageResult {
|
||||
/** Storage result for displaying file categories size in Storage Settings. */
|
||||
public static class StorageResult {
|
||||
// APP based sizes.
|
||||
public long gamesSize;
|
||||
public long musicAppsSize;
|
||||
public long photosAppsSize;
|
||||
public long videoAppsSize;
|
||||
public long otherAppsSize;
|
||||
public long allAppsExceptGamesSize;
|
||||
|
||||
// File based sizes.
|
||||
public long audioSize;
|
||||
public long imagesSize;
|
||||
public long videosSize;
|
||||
public long documentsAndOtherSize;
|
||||
public long trashSize;
|
||||
|
||||
public long cacheSize;
|
||||
public long duplicateCodeSize;
|
||||
public StorageStatsSource.ExternalStorageStats externalStats;
|
||||
@@ -196,6 +233,7 @@ public class StorageAsyncLoader
|
||||
* {@link StorageAsyncLoader}.
|
||||
*/
|
||||
public interface ResultHandler {
|
||||
void handleResult(SparseArray<AppsStorageResult> result);
|
||||
/** Overrides this method to get storage result once it's available. */
|
||||
void handleResult(SparseArray<StorageResult> result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,18 +357,18 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
updatePrivateStorageCategoryPreferencesOrder();
|
||||
}
|
||||
|
||||
public void onLoadFinished(SparseArray<StorageAsyncLoader.AppsStorageResult> result,
|
||||
/** Fragments use it to set storage result and update UI of this controller. */
|
||||
public void onLoadFinished(SparseArray<StorageAsyncLoader.StorageResult> result,
|
||||
int userId) {
|
||||
final StorageAsyncLoader.AppsStorageResult data = result.get(userId);
|
||||
final StorageAsyncLoader.StorageResult data = result.get(userId);
|
||||
|
||||
mImagesPreference.setStorageSize(getImagesSize(data), mTotalSize);
|
||||
mVideosPreference.setStorageSize(getVideosSize(data), mTotalSize);
|
||||
mAudioPreference.setStorageSize(getAudioSize(data), mTotalSize);
|
||||
mAppsPreference.setStorageSize(getAppsSize(data), mTotalSize);
|
||||
mGamesPreference.setStorageSize(getGamesSize(data), mTotalSize);
|
||||
mDocumentsAndOtherPreference.setStorageSize(getDocumentsAndOtherSize(data),
|
||||
mTotalSize);
|
||||
mTrashPreference.setStorageSize(getTrashSize(data), mTotalSize);
|
||||
mImagesPreference.setStorageSize(data.imagesSize, mTotalSize);
|
||||
mVideosPreference.setStorageSize(data.videosSize, mTotalSize);
|
||||
mAudioPreference.setStorageSize(data.audioSize, mTotalSize);
|
||||
mAppsPreference.setStorageSize(data.allAppsExceptGamesSize, mTotalSize);
|
||||
mGamesPreference.setStorageSize(data.gamesSize, mTotalSize);
|
||||
mDocumentsAndOtherPreference.setStorageSize(data.documentsAndOtherSize, mTotalSize);
|
||||
mTrashPreference.setStorageSize(data.trashSize, mTotalSize);
|
||||
|
||||
if (mSystemPreference != null) {
|
||||
// Everything else that hasn't already been attributed is tracked as
|
||||
@@ -377,13 +377,15 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
// from media provider.
|
||||
long attributedSize = 0;
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
final StorageAsyncLoader.AppsStorageResult otherData = result.valueAt(i);
|
||||
final StorageAsyncLoader.StorageResult otherData = result.valueAt(i);
|
||||
attributedSize +=
|
||||
otherData.gamesSize
|
||||
+ otherData.musicAppsSize
|
||||
+ otherData.videoAppsSize
|
||||
+ otherData.photosAppsSize
|
||||
+ otherData.otherAppsSize;
|
||||
+ otherData.audioSize
|
||||
+ otherData.videosSize
|
||||
+ otherData.imagesSize
|
||||
+ otherData.documentsAndOtherSize
|
||||
+ otherData.trashSize
|
||||
+ otherData.allAppsExceptGamesSize;
|
||||
attributedSize += otherData.externalStats.totalBytes
|
||||
- otherData.externalStats.appBytes;
|
||||
attributedSize -= otherData.duplicateCodeSize;
|
||||
@@ -418,18 +420,6 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
mContext.startActivityAsUser(intent, new UserHandle(mUserId));
|
||||
}
|
||||
|
||||
private long getImagesSize(StorageAsyncLoader.AppsStorageResult data) {
|
||||
return data.photosAppsSize + data.externalStats.imageBytes + data.externalStats.videoBytes;
|
||||
}
|
||||
|
||||
private long getVideosSize(StorageAsyncLoader.AppsStorageResult data) {
|
||||
return data.videoAppsSize;
|
||||
}
|
||||
|
||||
private long getAudioSize(StorageAsyncLoader.AppsStorageResult data) {
|
||||
return data.musicAppsSize + data.externalStats.audioBytes;
|
||||
}
|
||||
|
||||
private void launchAppsIntent() {
|
||||
final Bundle args = getWorkAnnotatedBundle(3);
|
||||
args.putString(ManageApplications.EXTRA_CLASSNAME,
|
||||
@@ -446,10 +436,6 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
Utils.launchIntent(mFragment, intent);
|
||||
}
|
||||
|
||||
private long getAppsSize(StorageAsyncLoader.AppsStorageResult data) {
|
||||
return data.otherAppsSize;
|
||||
}
|
||||
|
||||
private void launchGamesIntent() {
|
||||
final Bundle args = getWorkAnnotatedBundle(1);
|
||||
args.putString(ManageApplications.EXTRA_CLASSNAME,
|
||||
@@ -464,10 +450,6 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
Utils.launchIntent(mFragment, intent);
|
||||
}
|
||||
|
||||
private long getGamesSize(StorageAsyncLoader.AppsStorageResult data) {
|
||||
return data.gamesSize;
|
||||
}
|
||||
|
||||
private Bundle getWorkAnnotatedBundle(int additionalCapacity) {
|
||||
final Bundle args = new Bundle(1 + additionalCapacity);
|
||||
args.putInt(SettingsActivity.EXTRA_SHOW_FRAGMENT_TAB,
|
||||
@@ -475,14 +457,6 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
return args;
|
||||
}
|
||||
|
||||
private long getDocumentsAndOtherSize(StorageAsyncLoader.AppsStorageResult data) {
|
||||
return data.externalStats.totalBytes
|
||||
- data.externalStats.audioBytes
|
||||
- data.externalStats.videoBytes
|
||||
- data.externalStats.imageBytes
|
||||
- data.externalStats.appBytes;
|
||||
}
|
||||
|
||||
private void launchTrashIntent() {
|
||||
final Intent intent = new Intent("android.settings.VIEW_TRASH");
|
||||
|
||||
@@ -493,11 +467,6 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
|
||||
}
|
||||
}
|
||||
|
||||
private long getTrashSize(StorageAsyncLoader.AppsStorageResult data) {
|
||||
// TODO(170918505): Implement it.
|
||||
return 0L;
|
||||
}
|
||||
|
||||
private static long totalValues(StorageMeasurement.MeasurementDetails details, int userId,
|
||||
String... keys) {
|
||||
long total = 0;
|
||||
|
||||
@@ -70,7 +70,7 @@ public class SmartAutoRotateBatterySaverController extends BasePreferenceControl
|
||||
super.displayPreference(screen);
|
||||
mPreference = screen.findPreference(getPreferenceKey());
|
||||
((BannerMessagePreference) mPreference)
|
||||
.setPositiveButtonText(R.string.disable_text)
|
||||
.setPositiveButtonText(R.string.ambient_camera_battery_saver_off)
|
||||
.setPositiveButtonOnClickListener(v -> {
|
||||
mPowerManager.setPowerSaveModeEnabled(false);
|
||||
});
|
||||
|
||||
@@ -51,8 +51,8 @@ import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
|
||||
import com.android.settingslib.utils.StringUtil;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -189,6 +189,8 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
mPrefContext = screen.getContext();
|
||||
mAppListPrefGroup = screen.findPreference(mPreferenceKey);
|
||||
mAppListPrefGroup.setOrderingAsAdded(false);
|
||||
mAppListPrefGroup.setTitle(
|
||||
mPrefContext.getString(R.string.battery_app_usage_for_past_24));
|
||||
mFooterPreference = screen.findPreference(KEY_FOOTER_PREF);
|
||||
// Removes footer first until usage data is loaded to avoid flashing.
|
||||
if (mFooterPreference != null) {
|
||||
@@ -216,15 +218,6 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
final BatteryHistEntry histEntry = diffEntry.mBatteryHistEntry;
|
||||
final String packageName = histEntry.mPackageName;
|
||||
final boolean isAppEntry = histEntry.isAppEntry();
|
||||
// Checks whether the package is installed or not.
|
||||
boolean isValidPackage = true;
|
||||
if (isAppEntry) {
|
||||
if (mBatteryUtils == null) {
|
||||
mBatteryUtils = BatteryUtils.getInstance(mPrefContext);
|
||||
}
|
||||
isValidPackage = mBatteryUtils.getPackageUid(packageName)
|
||||
!= BatteryUtils.UID_NULL;
|
||||
}
|
||||
mMetricsFeatureProvider.action(
|
||||
mPrefContext,
|
||||
isAppEntry
|
||||
@@ -233,15 +226,12 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
new Pair(ConvertUtils.METRIC_KEY_PACKAGE, packageName),
|
||||
new Pair(ConvertUtils.METRIC_KEY_BATTERY_LEVEL, histEntry.mBatteryLevel),
|
||||
new Pair(ConvertUtils.METRIC_KEY_BATTERY_USAGE, powerPref.getPercent()));
|
||||
Log.d(TAG, String.format("handleClick() label=%s key=%s isValid:%b\n%s",
|
||||
diffEntry.getAppLabel(), histEntry.getKey(), isValidPackage, histEntry));
|
||||
if (isValidPackage) {
|
||||
AdvancedPowerUsageDetail.startBatteryDetailPage(
|
||||
Log.d(TAG, String.format("handleClick() label=%s key=%s enntry=\n%s",
|
||||
diffEntry.getAppLabel(), histEntry.getKey(), histEntry));
|
||||
AdvancedPowerUsageDetail.startBatteryDetailPage(
|
||||
mActivity, mFragment, diffEntry, powerPref.getPercent(),
|
||||
isValidToShowSummary(packageName), getSlotInformation());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -434,6 +424,7 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
pref.setSingleLineTitle(true);
|
||||
// Sets the BatteryDiffEntry to preference for launching detailed page.
|
||||
pref.setBatteryDiffEntry(entry);
|
||||
pref.setEnabled(entry.validForRestriction());
|
||||
setPreferenceSummary(pref, entry);
|
||||
if (!isAdded) {
|
||||
mAppListPrefGroup.addPreference(pref);
|
||||
@@ -627,7 +618,7 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
return true;
|
||||
}
|
||||
|
||||
static List<BatteryDiffEntry> getBatteryLast24HrUsageData(Context context) {
|
||||
public static List<BatteryDiffEntry> getBatteryLast24HrUsageData(Context context) {
|
||||
final long start = System.currentTimeMillis();
|
||||
final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap =
|
||||
FeatureFactory.getFactory(context)
|
||||
|
||||
@@ -39,6 +39,8 @@ public class BatteryDiffEntry {
|
||||
static Locale sCurrentLocale = null;
|
||||
// Caches app label and icon to improve loading performance.
|
||||
static final Map<String, BatteryEntry.NameAndIcon> sResourceCache = new HashMap<>();
|
||||
// Whether a specific item is valid to launch restriction page?
|
||||
static final Map<String, Boolean> sValidForRestriction = new HashMap<>();
|
||||
|
||||
/** A comparator for {@link BatteryDiffEntry} based on consumed percentage. */
|
||||
public static final Comparator<BatteryDiffEntry> COMPARATOR =
|
||||
@@ -60,6 +62,7 @@ public class BatteryDiffEntry {
|
||||
@VisibleForTesting String mAppLabel = null;
|
||||
@VisibleForTesting Drawable mAppIcon = null;
|
||||
@VisibleForTesting boolean mIsLoaded = false;
|
||||
@VisibleForTesting boolean mValidForRestriction = true;
|
||||
|
||||
public BatteryDiffEntry(
|
||||
Context context,
|
||||
@@ -129,6 +132,12 @@ public class BatteryDiffEntry {
|
||||
? mDefaultPackageName : mBatteryHistEntry.mPackageName;
|
||||
}
|
||||
|
||||
/** Whether this item is valid for users to launch restriction page? */
|
||||
public boolean validForRestriction() {
|
||||
loadLabelAndIcon();
|
||||
return mValidForRestriction;
|
||||
}
|
||||
|
||||
/** Whether the current BatteryDiffEntry is system component or not. */
|
||||
public boolean isSystemEntry() {
|
||||
switch (mBatteryHistEntry.mConsumerType) {
|
||||
@@ -146,7 +155,29 @@ public class BatteryDiffEntry {
|
||||
if (mIsLoaded) {
|
||||
return;
|
||||
}
|
||||
// Checks whether we have cached data or not first before fetching.
|
||||
final BatteryEntry.NameAndIcon nameAndIcon = getCache();
|
||||
if (nameAndIcon != null) {
|
||||
mAppLabel = nameAndIcon.name;
|
||||
mAppIcon = nameAndIcon.icon;
|
||||
mAppIconId = nameAndIcon.iconId;
|
||||
}
|
||||
final Boolean validForRestriction = sValidForRestriction.get(getKey());
|
||||
if (validForRestriction != null) {
|
||||
mValidForRestriction = validForRestriction;
|
||||
}
|
||||
// Both nameAndIcon and restriction configuration have cached data.
|
||||
if (nameAndIcon != null && validForRestriction != null) {
|
||||
Log.w(TAG, String.format("cannot find cache data nameAndIcon:%s "
|
||||
+ "validForRestriction:%s", nameAndIcon, validForRestriction));
|
||||
return;
|
||||
}
|
||||
mIsLoaded = true;
|
||||
|
||||
// Configures whether we can launch restriction page or not.
|
||||
updateRestrictionFlagState();
|
||||
sValidForRestriction.put(getKey(), Boolean.valueOf(mValidForRestriction));
|
||||
|
||||
// Loads application icon and label based on consumer type.
|
||||
switch (mBatteryHistEntry.mConsumerType) {
|
||||
case ConvertUtils.CONSUMER_TYPE_USER_BATTERY:
|
||||
@@ -156,6 +187,9 @@ public class BatteryDiffEntry {
|
||||
if (nameAndIconForUser != null) {
|
||||
mAppIcon = nameAndIconForUser.icon;
|
||||
mAppLabel = nameAndIconForUser.name;
|
||||
sResourceCache.put(
|
||||
getKey(),
|
||||
new BatteryEntry.NameAndIcon(mAppLabel, mAppIcon, /*iconId=*/ 0));
|
||||
}
|
||||
break;
|
||||
case ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY:
|
||||
@@ -168,15 +202,12 @@ public class BatteryDiffEntry {
|
||||
mAppIconId = nameAndIconForSystem.iconId;
|
||||
mAppIcon = mContext.getDrawable(nameAndIconForSystem.iconId);
|
||||
}
|
||||
sResourceCache.put(
|
||||
getKey(),
|
||||
new BatteryEntry.NameAndIcon(mAppLabel, mAppIcon, mAppIconId));
|
||||
}
|
||||
break;
|
||||
case ConvertUtils.CONSUMER_TYPE_UID_BATTERY:
|
||||
final BatteryEntry.NameAndIcon nameAndIcon = getCache();
|
||||
if (nameAndIcon != null) {
|
||||
mAppLabel = nameAndIcon.name;
|
||||
mAppIcon = nameAndIcon.icon;
|
||||
break;
|
||||
}
|
||||
loadNameAndIconForUid();
|
||||
// Uses application default icon if we cannot find it from package.
|
||||
if (mAppIcon == null) {
|
||||
@@ -186,13 +217,47 @@ public class BatteryDiffEntry {
|
||||
mAppIcon = getBadgeIconForUser(mAppIcon);
|
||||
if (mAppLabel != null || mAppIcon != null) {
|
||||
sResourceCache.put(
|
||||
mBatteryHistEntry.getKey(),
|
||||
getKey(),
|
||||
new BatteryEntry.NameAndIcon(mAppLabel, mAppIcon, /*iconId=*/ 0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
String getKey() {
|
||||
return mBatteryHistEntry.getKey();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void updateRestrictionFlagState() {
|
||||
mValidForRestriction = true;
|
||||
if (!mBatteryHistEntry.isAppEntry()) {
|
||||
return;
|
||||
}
|
||||
final boolean isValidPackage =
|
||||
BatteryUtils.getInstance(mContext).getPackageUid(getPackageName())
|
||||
!= BatteryUtils.UID_NULL;
|
||||
if (!isValidPackage) {
|
||||
mValidForRestriction = false;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
mValidForRestriction =
|
||||
mContext.getPackageManager().getPackageInfo(
|
||||
getPackageName(),
|
||||
PackageManager.MATCH_DISABLED_COMPONENTS
|
||||
| PackageManager.MATCH_ANY_USER
|
||||
| PackageManager.GET_SIGNATURES
|
||||
| PackageManager.GET_PERMISSIONS)
|
||||
!= null;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, String.format("getPackageInfo() error %s for package=%s",
|
||||
e.getCause(), getPackageName()));
|
||||
mValidForRestriction = false;
|
||||
}
|
||||
}
|
||||
|
||||
private BatteryEntry.NameAndIcon getCache() {
|
||||
final Locale locale = Locale.getDefault();
|
||||
if (sCurrentLocale != locale) {
|
||||
@@ -201,7 +266,7 @@ public class BatteryDiffEntry {
|
||||
sCurrentLocale = locale;
|
||||
clearCache();
|
||||
}
|
||||
return sResourceCache.get(mBatteryHistEntry.getKey());
|
||||
return sResourceCache.get(getKey());
|
||||
}
|
||||
|
||||
private void loadNameAndIconForUid() {
|
||||
@@ -258,7 +323,8 @@ public class BatteryDiffEntry {
|
||||
public String toString() {
|
||||
final StringBuilder builder = new StringBuilder()
|
||||
.append("BatteryDiffEntry{")
|
||||
.append("\n\tname=" + mAppLabel)
|
||||
.append(String.format("\n\tname=%s restrictable=%b",
|
||||
mAppLabel, mValidForRestriction))
|
||||
.append(String.format("\n\tconsume=%.2f%% %f/%f",
|
||||
mPercentOfTotal, mConsumePower, mTotalConsumePower))
|
||||
.append(String.format("\n\tforeground:%s background:%s",
|
||||
@@ -274,6 +340,7 @@ public class BatteryDiffEntry {
|
||||
|
||||
static void clearCache() {
|
||||
sResourceCache.clear();
|
||||
sValidForRestriction.clear();
|
||||
}
|
||||
|
||||
private Drawable getBadgeIconForUser(Drawable icon) {
|
||||
|
||||
@@ -241,7 +241,10 @@ public class BatteryEntry {
|
||||
mBatteryConsumer = null;
|
||||
mIsHidden = false;
|
||||
mPowerComponentId = powerComponentId;
|
||||
mConsumedPower = devicePowerMah - appsPowerMah;
|
||||
mConsumedPower =
|
||||
powerComponentId == BatteryConsumer.POWER_COMPONENT_SCREEN
|
||||
? devicePowerMah
|
||||
: devicePowerMah - appsPowerMah;
|
||||
mUsageDurationMs = usageDurationMs;
|
||||
mConsumerType = ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY;
|
||||
|
||||
@@ -264,12 +267,13 @@ public class BatteryEntry {
|
||||
iconId = R.drawable.ic_power_system;
|
||||
icon = context.getDrawable(iconId);
|
||||
name = powerComponentName;
|
||||
|
||||
mConsumedPower = devicePowerMah - appsPowerMah;
|
||||
mConsumedPower =
|
||||
powerComponentId == BatteryConsumer.POWER_COMPONENT_SCREEN
|
||||
? devicePowerMah
|
||||
: devicePowerMah - appsPowerMah;
|
||||
mConsumerType = ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY;
|
||||
}
|
||||
|
||||
|
||||
public Drawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@@ -22,9 +22,12 @@ import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
|
||||
import static com.android.settings.slices.CustomSliceRegistry.PROVIDER_MODEL_SLICE_URI;
|
||||
|
||||
import android.annotation.ColorInt;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.telephony.SubscriptionManager;
|
||||
@@ -150,11 +153,12 @@ public class ProviderModelSlice extends WifiSlice {
|
||||
final List<WifiSliceItem> disconnectedWifiList = wifiList.stream()
|
||||
.filter(wifiSliceItem -> wifiSliceItem.getConnectedState()
|
||||
!= WifiEntry.CONNECTED_STATE_CONNECTED)
|
||||
.limit(maxListSize)
|
||||
.limit(maxListSize - 1)
|
||||
.collect(Collectors.toList());
|
||||
for (WifiSliceItem item : disconnectedWifiList) {
|
||||
listBuilder.addRow(getWifiSliceItemRow(item));
|
||||
}
|
||||
listBuilder.addRow(getSeeAllRow());
|
||||
}
|
||||
return listBuilder.build();
|
||||
}
|
||||
@@ -252,6 +256,31 @@ public class ProviderModelSlice extends WifiSlice {
|
||||
.setSubtitle(mContext.getText(R.string.to_switch_networks_disconnect_ethernet));
|
||||
}
|
||||
|
||||
protected ListBuilder.RowBuilder getSeeAllRow() {
|
||||
final CharSequence title = mContext.getText(R.string.previous_connected_see_all);
|
||||
final IconCompat icon = getSeeAllIcon();
|
||||
return new ListBuilder.RowBuilder()
|
||||
.setTitleItem(icon, ListBuilder.ICON_IMAGE)
|
||||
.setTitle(title)
|
||||
.setPrimaryAction(getPrimaryAction(icon, title));
|
||||
}
|
||||
|
||||
protected IconCompat getSeeAllIcon() {
|
||||
final Drawable drawable = mContext.getDrawable(R.drawable.ic_arrow_forward);
|
||||
if (drawable != null) {
|
||||
drawable.setTint(
|
||||
Utils.getColorAttrDefaultColor(mContext, android.R.attr.colorControlNormal));
|
||||
return Utils.createIconWithDrawable(drawable);
|
||||
}
|
||||
return Utils.createIconWithDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
|
||||
protected SliceAction getPrimaryAction(IconCompat icon, CharSequence title) {
|
||||
final PendingIntent intent = PendingIntent.getActivity(mContext, 0 /* requestCode */,
|
||||
getIntent(), PendingIntent.FLAG_IMMUTABLE /* flags */);
|
||||
return SliceAction.createDeeplink(intent, icon, ListBuilder.ICON_IMAGE, title);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ListBuilder.RowBuilder getWifiSliceItemRow(WifiSliceItem wifiSliceItem) {
|
||||
final CharSequence title = wifiSliceItem.getTitle();
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.network;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.graphics.drawable.IconCompat;
|
||||
import androidx.slice.Slice;
|
||||
import androidx.slice.builders.ListBuilder;
|
||||
import androidx.slice.builders.ListBuilder.RowBuilder;
|
||||
import androidx.slice.builders.SliceAction;
|
||||
import androidx.slice.core.SliceHints;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.slices.CustomSliceRegistry;
|
||||
import com.android.settings.slices.CustomSliceable;
|
||||
import com.android.settings.slices.SliceBackgroundWorker;
|
||||
import com.android.settings.slices.SliceBroadcastReceiver;
|
||||
|
||||
/**
|
||||
* {@link CustomSliceable} for turning on Wi-Fi, used by generic clients.
|
||||
*/
|
||||
public class TurnOnWifiSlice implements CustomSliceable {
|
||||
|
||||
private static final String TAG = "TurnOnWifiSlice";
|
||||
|
||||
private final Context mContext;
|
||||
private final WifiManager mWifiManager;
|
||||
|
||||
public TurnOnWifiSlice(Context context) {
|
||||
mContext = context;
|
||||
mWifiManager = mContext.getSystemService(WifiManager.class);
|
||||
}
|
||||
|
||||
private static void logd(String s) {
|
||||
Log.d(TAG, s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice getSlice() {
|
||||
if (mWifiManager.isWifiEnabled()) {
|
||||
return null;
|
||||
}
|
||||
final String title = mContext.getText(R.string.turn_on_wifi).toString();
|
||||
final SliceAction primaryAction = SliceAction.create(getBroadcastIntent(mContext),
|
||||
getEndIcon(), ListBuilder.ICON_IMAGE, title);
|
||||
final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY)
|
||||
.addRow(new RowBuilder()
|
||||
.setTitle(title)
|
||||
.addEndItem(getEndIcon(), SliceHints.ICON_IMAGE)
|
||||
.setPrimaryAction(primaryAction));
|
||||
return listBuilder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri getUri() {
|
||||
return CustomSliceRegistry.TURN_ON_WIFI_SLICE_URI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotifyChange(Intent intent) {
|
||||
logd("Action: turn on Wi-Fi networks");
|
||||
mWifiManager.setWifiEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getIntent() {
|
||||
return new Intent(getUri().toString())
|
||||
.setData(getUri())
|
||||
.setClass(mContext, SliceBroadcastReceiver.class);
|
||||
}
|
||||
|
||||
private IconCompat getEndIcon() {
|
||||
final Drawable drawable = mContext.getDrawable(R.drawable.ic_settings_wireless);
|
||||
if (drawable == null) {
|
||||
return Utils.createIconWithDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
drawable.setTintList(Utils.getColorAttr(mContext, android.R.attr.colorAccent));
|
||||
return Utils.createIconWithDrawable(drawable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getBackgroundWorkerClass() {
|
||||
return TurnOnWifiWorker.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Slice background worker {@link SliceBackgroundWorker} is used to listen the Wi-Fi
|
||||
* status change, and then notifies the Slice {@link Uri} to update.
|
||||
*/
|
||||
public static class TurnOnWifiWorker extends SliceBackgroundWorker {
|
||||
|
||||
private final IntentFilter mIntentFilter;
|
||||
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {
|
||||
notifySliceChange();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public TurnOnWifiWorker(Context context, Uri uri) {
|
||||
super(context, uri);
|
||||
mIntentFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSlicePinned() {
|
||||
getContext().registerReceiver(mBroadcastReceiver, mIntentFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSliceUnpinned() {
|
||||
getContext().unregisterReceiver(mBroadcastReceiver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class NetworkProviderWorker extends WifiScanWorker implements
|
||||
DataConnectivityListener.Client, InternetUpdater.InternetChangeListener,
|
||||
SubscriptionsChangeListener.SubscriptionsChangeListenerClient {
|
||||
private static final String TAG = "NetworkProviderWorker";
|
||||
private static final int PROVIDER_MODEL_DEFAULT_EXPANDED_ROW_COUNT = 4;
|
||||
private static final int PROVIDER_MODEL_DEFAULT_EXPANDED_ROW_COUNT = 5;
|
||||
private DataContentObserver mMobileDataObserver;
|
||||
private SignalStrengthListener mSignalStrengthListener;
|
||||
private SubscriptionsChangeListener mSubscriptionsListener;
|
||||
|
||||
@@ -326,7 +326,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc
|
||||
DIALOG_TAG_ENABLE_DSDS_CONFIRMATION,
|
||||
getString(R.string.sim_action_enable_dsds_title),
|
||||
getString(R.string.sim_action_enable_dsds_text),
|
||||
getString(R.string.sim_action_continue),
|
||||
getString(R.string.sim_action_yes),
|
||||
getString(R.string.sim_action_no_thanks));
|
||||
}
|
||||
|
||||
|
||||
@@ -96,10 +96,6 @@ public class ConfigureNotificationSettings extends DashboardFragment implements
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||
Application app, Fragment host) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new RecentNotifyingAppsPreferenceController(
|
||||
context, new NotificationBackend(), IUsageStatsManager.Stub.asInterface(
|
||||
ServiceManager.getService(Context.USAGE_STATS_SERVICE)),
|
||||
context.getSystemService(UserManager.class), app, host));
|
||||
controllers.add(new ShowOnLockScreenNotificationPreferenceController(
|
||||
context, KEY_LOCKSCREEN));
|
||||
controllers.add(new NotificationRingtonePreferenceController(context) {
|
||||
|
||||
@@ -1,301 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.notification;
|
||||
|
||||
import android.app.Application;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.app.usage.IUsageStatsManager;
|
||||
import android.app.usage.UsageEvents;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.service.notification.NotifyingApp;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.IconDrawableFactory;
|
||||
import android.util.Slog;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.applications.AppInfoBase;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.notification.app.AppNotificationSettings;
|
||||
import com.android.settings.widget.PrimarySwitchPreference;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.utils.StringUtil;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
import com.android.settingslib.widget.TwoTargetPreference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This controller displays a list of recently used apps and a "See all" button. If there is
|
||||
* no recently used app, "See all" will be displayed as "Notifications".
|
||||
*/
|
||||
public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceController
|
||||
implements PreferenceControllerMixin {
|
||||
|
||||
private static final String TAG = "RecentNotisCtrl";
|
||||
private static final String KEY_PREF_CATEGORY = "recent_notifications_category";
|
||||
|
||||
@VisibleForTesting
|
||||
static final String KEY_SEE_ALL = "all_notifications";
|
||||
static final String KEY_PLACEHOLDER = "app";
|
||||
private static final int SHOW_RECENT_APP_COUNT = 3;
|
||||
private static final int DAYS = 3;
|
||||
|
||||
private final Fragment mHost;
|
||||
private final PackageManager mPm;
|
||||
private final NotificationBackend mNotificationBackend;
|
||||
private IUsageStatsManager mUsageStatsManager;
|
||||
private final IconDrawableFactory mIconDrawableFactory;
|
||||
|
||||
private Calendar mCal;
|
||||
List<NotifyingApp> mApps;
|
||||
private final ApplicationsState mApplicationsState;
|
||||
|
||||
private PreferenceCategory mCategory;
|
||||
private Preference mSeeAllPref;
|
||||
protected List<Integer> mUserIds;
|
||||
|
||||
public RecentNotifyingAppsPreferenceController(Context context, NotificationBackend backend,
|
||||
IUsageStatsManager usageStatsManager, UserManager userManager,
|
||||
Application app, Fragment host) {
|
||||
this(context, backend, usageStatsManager, userManager,
|
||||
app == null ? null : ApplicationsState.getInstance(app), host);
|
||||
}
|
||||
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
|
||||
RecentNotifyingAppsPreferenceController(Context context, NotificationBackend backend,
|
||||
IUsageStatsManager usageStatsManager, UserManager userManager,
|
||||
ApplicationsState appState, Fragment host) {
|
||||
super(context);
|
||||
mIconDrawableFactory = IconDrawableFactory.newInstance(context);
|
||||
mPm = context.getPackageManager();
|
||||
mHost = host;
|
||||
mApplicationsState = appState;
|
||||
mNotificationBackend = backend;
|
||||
mUsageStatsManager = usageStatsManager;
|
||||
mUserIds = new ArrayList<>();
|
||||
mUserIds.add(mContext.getUserId());
|
||||
int workUserId = Utils.getManagedProfileId(userManager, mContext.getUserId());
|
||||
if (workUserId != UserHandle.USER_NULL) {
|
||||
mUserIds.add(workUserId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return mApplicationsState != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_PREF_CATEGORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNonIndexableKeys(List<String> keys) {
|
||||
PreferenceControllerMixin.super.updateNonIndexableKeys(keys);
|
||||
// Don't index category name into search. It's not actionable.
|
||||
keys.add(KEY_PREF_CATEGORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
mCategory = screen.findPreference(getPreferenceKey());
|
||||
mSeeAllPref = screen.findPreference(KEY_SEE_ALL);
|
||||
super.displayPreference(screen);
|
||||
refreshUi(mCategory.getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
refreshUi(mCategory.getContext());
|
||||
mSeeAllPref.setTitle(mContext.getString(R.string.recent_notifications_see_all_title));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void refreshUi(Context prefContext) {
|
||||
for (int i = 1; i <= SHOW_RECENT_APP_COUNT; i++) {
|
||||
PrimarySwitchPreference app = mCategory.findPreference(KEY_PLACEHOLDER + i);
|
||||
if (app != null) {
|
||||
app.setChecked(true);
|
||||
}
|
||||
}
|
||||
ThreadUtils.postOnBackgroundThread(() -> {
|
||||
reloadData();
|
||||
final List<NotifyingApp> recentApps = getDisplayableRecentAppList();
|
||||
ThreadUtils.postOnMainThread(() -> {
|
||||
if (recentApps != null && !recentApps.isEmpty()) {
|
||||
displayRecentApps(prefContext, recentApps);
|
||||
} else {
|
||||
displayOnlyAllAppsLink();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void reloadData() {
|
||||
mApps = new ArrayList<>();
|
||||
mCal = Calendar.getInstance();
|
||||
mCal.add(Calendar.DAY_OF_YEAR, -DAYS);
|
||||
for (int userId : mUserIds) {
|
||||
UsageEvents events = null;
|
||||
try {
|
||||
events = mUsageStatsManager.queryEventsForUser(mCal.getTimeInMillis(),
|
||||
System.currentTimeMillis(), userId, mContext.getPackageName());
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (events != null) {
|
||||
ArrayMap<String, NotifyingApp> aggregatedStats = new ArrayMap<>();
|
||||
|
||||
UsageEvents.Event event = new UsageEvents.Event();
|
||||
while (events.hasNextEvent()) {
|
||||
events.getNextEvent(event);
|
||||
|
||||
if (event.getEventType() == UsageEvents.Event.NOTIFICATION_INTERRUPTION) {
|
||||
NotifyingApp app =
|
||||
aggregatedStats.get(getKey(userId, event.getPackageName()));
|
||||
if (app == null) {
|
||||
app = new NotifyingApp();
|
||||
aggregatedStats.put(getKey(userId, event.getPackageName()), app);
|
||||
app.setPackage(event.getPackageName());
|
||||
app.setUserId(userId);
|
||||
}
|
||||
if (event.getTimeStamp() > app.getLastNotified()) {
|
||||
app.setLastNotified(event.getTimeStamp());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mApps.addAll(aggregatedStats.values());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getKey(int userId, String pkg) {
|
||||
return userId + "|" + pkg;
|
||||
}
|
||||
|
||||
private void displayOnlyAllAppsLink() {
|
||||
mCategory.setTitle(null);
|
||||
mSeeAllPref.setTitle(R.string.notifications_title);
|
||||
mSeeAllPref.setIcon(null);
|
||||
int prefCount = mCategory.getPreferenceCount();
|
||||
for (int i = prefCount - 1; i >= 0; i--) {
|
||||
final Preference pref = mCategory.getPreference(i);
|
||||
if (!TextUtils.equals(pref.getKey(), KEY_SEE_ALL)) {
|
||||
mCategory.removePreference(pref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void displayRecentApps(Context prefContext, List<NotifyingApp> recentApps) {
|
||||
mCategory.setTitle(R.string.recent_notifications);
|
||||
mSeeAllPref.setSummary(null);
|
||||
mSeeAllPref.setIcon(R.drawable.ic_chevron_right_24dp);
|
||||
|
||||
int keyIndex = 1;
|
||||
final int recentAppsCount = recentApps.size();
|
||||
for (int i = 0; i < recentAppsCount; i++, keyIndex++) {
|
||||
final NotifyingApp app = recentApps.get(i);
|
||||
// Bind recent apps to existing prefs if possible, or create a new pref.
|
||||
final String pkgName = app.getPackage();
|
||||
final ApplicationsState.AppEntry appEntry =
|
||||
mApplicationsState.getEntry(app.getPackage(), app.getUserId());
|
||||
if (appEntry == null || appEntry.label == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PrimarySwitchPreference pref = mCategory.findPreference(KEY_PLACEHOLDER + keyIndex);
|
||||
pref.setTitle(appEntry.label);
|
||||
pref.setIcon(mIconDrawableFactory.getBadgedIcon(appEntry.info));
|
||||
pref.setIconSize(TwoTargetPreference.ICON_SIZE_SMALL);
|
||||
pref.setSummary(StringUtil.formatRelativeTime(mContext,
|
||||
System.currentTimeMillis() - app.getLastNotified(), true));
|
||||
Bundle args = new Bundle();
|
||||
args.putString(AppInfoBase.ARG_PACKAGE_NAME, pkgName);
|
||||
args.putInt(AppInfoBase.ARG_PACKAGE_UID, appEntry.info.uid);
|
||||
pref.setOnPreferenceClickListener(preference -> {
|
||||
new SubSettingLauncher(mHost.getActivity())
|
||||
.setDestination(AppNotificationSettings.class.getName())
|
||||
.setTitleRes(R.string.notifications_title)
|
||||
.setArguments(args)
|
||||
.setUserHandle(new UserHandle(UserHandle.getUserId(appEntry.info.uid)))
|
||||
.setSourceMetricsCategory(
|
||||
SettingsEnums.MANAGE_APPLICATIONS_NOTIFICATIONS)
|
||||
.launch();
|
||||
return true;
|
||||
});
|
||||
pref.setSwitchEnabled(mNotificationBackend.isBlockable(mContext, appEntry.info));
|
||||
pref.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
mNotificationBackend.setNotificationsEnabledForPackage(
|
||||
pkgName, appEntry.info.uid, (Boolean) newValue);
|
||||
return true;
|
||||
});
|
||||
pref.setChecked(
|
||||
!mNotificationBackend.getNotificationsBanned(pkgName, appEntry.info.uid));
|
||||
|
||||
}
|
||||
// If there are less than SHOW_RECENT_APP_COUNT recent apps, remove placeholders
|
||||
for (int i = keyIndex; i <= SHOW_RECENT_APP_COUNT; i++) {
|
||||
mCategory.removePreferenceRecursively(KEY_PLACEHOLDER + i);
|
||||
}
|
||||
}
|
||||
|
||||
private List<NotifyingApp> getDisplayableRecentAppList() {
|
||||
Collections.sort(mApps);
|
||||
List<NotifyingApp> displayableApps = new ArrayList<>(SHOW_RECENT_APP_COUNT);
|
||||
int count = 0;
|
||||
for (NotifyingApp app : mApps) {
|
||||
try {
|
||||
final ApplicationsState.AppEntry appEntry = mApplicationsState.getEntry(
|
||||
app.getPackage(), app.getUserId());
|
||||
if (appEntry == null) {
|
||||
continue;
|
||||
}
|
||||
displayableApps.add(app);
|
||||
count++;
|
||||
if (count >= SHOW_RECENT_APP_COUNT) {
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Slog.e(TAG, "Failed to find app " + app.getPackage() + "/" + app.getUserId(), e);
|
||||
}
|
||||
}
|
||||
return displayableApps;
|
||||
}
|
||||
}
|
||||
@@ -156,6 +156,7 @@ public class NotificationHistoryActivity extends CollapsingToolbarBaseActivity {
|
||||
View recyclerView = mTodayView.findViewById(R.id.apps);
|
||||
recyclerView.setClipToOutline(true);
|
||||
mTodayView.setOutlineProvider(mOutlineProvider);
|
||||
mSnoozeView.setOutlineProvider(mOutlineProvider);
|
||||
// for each package, new header and recycler view
|
||||
for (int i = 0, notificationsSize = notifications.size(); i < notificationsSize; i++) {
|
||||
NotificationHistoryPackage nhp = notifications.get(i);
|
||||
@@ -219,6 +220,11 @@ public class NotificationHistoryActivity extends CollapsingToolbarBaseActivity {
|
||||
}
|
||||
};
|
||||
|
||||
private void configureNotificationList(View recyclerView) {
|
||||
recyclerView.setClipToOutline(true);
|
||||
recyclerView.setOutlineProvider(mOutlineProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -227,9 +233,8 @@ public class NotificationHistoryActivity extends CollapsingToolbarBaseActivity {
|
||||
mTodayView = findViewById(R.id.apps);
|
||||
mSnoozeView = findViewById(R.id.snoozed_list);
|
||||
mDismissView = findViewById(R.id.recently_dismissed_list);
|
||||
View recyclerView = mDismissView.findViewById(R.id.notification_list);
|
||||
recyclerView.setClipToOutline(true);
|
||||
recyclerView.setOutlineProvider(mOutlineProvider);
|
||||
configureNotificationList(mDismissView.findViewById(R.id.notification_list));
|
||||
configureNotificationList(mSnoozeView.findViewById(R.id.notification_list));
|
||||
mHistoryOff = findViewById(R.id.history_off);
|
||||
mHistoryOn = findViewById(R.id.history_on);
|
||||
mHistoryEmpty = findViewById(R.id.history_on_empty);
|
||||
|
||||
@@ -19,8 +19,6 @@ package com.android.settings.panel;
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_PAUSE;
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
|
||||
|
||||
import static com.android.settings.network.NetworkProviderSettings.ACTION_NETWORK_PROVIDER_SETTINGS;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@@ -32,7 +30,6 @@ import android.net.wifi.WifiManager;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerExecutor;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyCallback;
|
||||
@@ -41,6 +38,7 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
|
||||
@@ -64,7 +62,7 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
SubscriptionsChangeListener.SubscriptionsChangeListenerClient {
|
||||
private static final String TAG = "InternetConnectivityPanel";
|
||||
private static final int SUBTITLE_TEXT_NONE = -1;
|
||||
private static final int SUBTITLE_TEXT_WIFI_IS_TURNED_ON = R.string.wifi_is_turned_on_subtitle;
|
||||
private static final int SUBTITLE_TEXT_WIFI_IS_OFF = R.string.wifi_is_off;
|
||||
private static final int SUBTITLE_TEXT_TAP_A_NETWORK_TO_CONNECT =
|
||||
R.string.tap_a_network_to_connect;
|
||||
private static final int SUBTITLE_TEXT_SEARCHING_FOR_NETWORKS =
|
||||
@@ -198,7 +196,6 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
final List<Uri> uris = new ArrayList<>();
|
||||
if (mIsProviderModelEnabled) {
|
||||
uris.add(CustomSliceRegistry.PROVIDER_MODEL_SLICE_URI);
|
||||
uris.add(CustomSliceRegistry.TURN_ON_WIFI_SLICE_URI);
|
||||
} else {
|
||||
uris.add(CustomSliceRegistry.WIFI_SLICE_URI);
|
||||
uris.add(CustomSliceRegistry.MOBILE_DATA_SLICE_URI);
|
||||
@@ -209,9 +206,7 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
|
||||
@Override
|
||||
public Intent getSeeMoreIntent() {
|
||||
return new Intent(mIsProviderModelEnabled
|
||||
? ACTION_NETWORK_PROVIDER_SETTINGS : Settings.ACTION_WIRELESS_SETTINGS)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -221,15 +216,14 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
|
||||
@Override
|
||||
public CharSequence getCustomizedButtonTitle() {
|
||||
if (mInternetUpdater.isAirplaneModeOn() && !mInternetUpdater.isWifiEnabled()) {
|
||||
return null;
|
||||
}
|
||||
return mContext.getText(R.string.settings_button);
|
||||
return mContext.getText(
|
||||
mInternetUpdater.isWifiEnabled() ? R.string.turn_off_wifi : R.string.turn_on_wifi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickCustomizedButton() {
|
||||
mContext.startActivity(getSeeMoreIntent());
|
||||
public void onClickCustomizedButton(FragmentActivity panelActivity) {
|
||||
// Don't finish the panel activity
|
||||
mWifiManager.setWifiEnabled(!mInternetUpdater.isWifiEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -290,15 +284,7 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
return;
|
||||
}
|
||||
updateSubtitleText();
|
||||
|
||||
log("Subtitle:" + mSubtitle);
|
||||
if (mSubtitle != SUBTITLE_TEXT_NONE) {
|
||||
mCallback.onHeaderChanged();
|
||||
} else {
|
||||
// Other situations.
|
||||
// Title: Airplane mode / Internet
|
||||
mCallback.onTitleChanged();
|
||||
}
|
||||
mCallback.onHeaderChanged();
|
||||
mCallback.onCustomizedButtonStateChanged();
|
||||
}
|
||||
|
||||
@@ -310,15 +296,23 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
private void updateSubtitleText() {
|
||||
mSubtitle = SUBTITLE_TEXT_NONE;
|
||||
if (!mInternetUpdater.isWifiEnabled()) {
|
||||
if (!mInternetUpdater.isAirplaneModeOn()) {
|
||||
// When the airplane mode is off and Wi-Fi is disabled.
|
||||
// Sub-Title: Wi-Fi is off
|
||||
log("Airplane mode off + Wi-Fi off.");
|
||||
mSubtitle = SUBTITLE_TEXT_WIFI_IS_OFF;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIsProgressBarVisible) {
|
||||
// When the Wi-Fi scan result callback is received
|
||||
// Sub-Title: Searching for networks...
|
||||
mSubtitle = SUBTITLE_TEXT_SEARCHING_FOR_NETWORKS;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mInternetUpdater.isAirplaneModeOn()) {
|
||||
// When the airplane mode is on and Wi-Fi is enabled.
|
||||
// Title: Airplane mode
|
||||
// Sub-Title: Wi-Fi is turned on
|
||||
log("Airplane mode is on + Wi-Fi on.");
|
||||
mSubtitle = SUBTITLE_TEXT_WIFI_IS_TURNED_ON;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -330,13 +324,6 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIsProgressBarVisible) {
|
||||
// When the Wi-Fi scan result callback is received
|
||||
// Sub-Title: Searching for networks...
|
||||
mSubtitle = SUBTITLE_TEXT_SEARCHING_FOR_NETWORKS;
|
||||
return;
|
||||
}
|
||||
|
||||
// Sub-Title:
|
||||
// show non_carrier_network_unavailable
|
||||
// - while Wi-Fi on + no Wi-Fi item
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.core.graphics.drawable.IconCompat;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.android.settingslib.core.instrumentation.Instrumentable;
|
||||
|
||||
@@ -94,8 +95,11 @@ public interface PanelContent extends Instrumentable {
|
||||
|
||||
/**
|
||||
* Implement the click event for custom button.
|
||||
*
|
||||
* @param panelActivity the FragmentActivity from PanelFragment, the user can decide whether
|
||||
* to finish activity or not.
|
||||
*/
|
||||
default void onClickCustomizedButton() {}
|
||||
default void onClickCustomizedButton(FragmentActivity panelActivity) {}
|
||||
|
||||
/**
|
||||
* Register to start receiving callbacks for custom button events.
|
||||
|
||||
@@ -491,11 +491,11 @@ public class PanelFragment extends Fragment {
|
||||
mPanelClosedKey = PanelClosedKeys.KEY_SEE_MORE;
|
||||
final FragmentActivity activity = getActivity();
|
||||
if (mPanel.isCustomizedButtonUsed()) {
|
||||
mPanel.onClickCustomizedButton();
|
||||
mPanel.onClickCustomizedButton(activity);
|
||||
} else {
|
||||
activity.startActivityForResult(mPanel.getSeeMoreIntent(), 0);
|
||||
activity.finish();
|
||||
}
|
||||
activity.finish();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.android.settings.search;
|
||||
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import com.android.settings.DisplaySettings;
|
||||
import com.android.settings.backup.UserBackupSettingsActivity;
|
||||
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
|
||||
import com.android.settings.connecteddevice.usb.UsbDetailsFragment;
|
||||
@@ -34,7 +33,6 @@ import com.android.settings.notification.zen.ZenModeRestrictNotificationsSetting
|
||||
import com.android.settings.security.SecuritySettings;
|
||||
import com.android.settings.security.screenlock.ScreenLockSettings;
|
||||
import com.android.settings.system.SystemDashboardFragment;
|
||||
import com.android.settings.wallpaper.WallpaperSuggestionActivity;
|
||||
import com.android.settings.wifi.WifiSettings;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -52,8 +50,6 @@ public class CustomSiteMapRegistry {
|
||||
static {
|
||||
CUSTOM_SITE_MAP = new ArrayMap<>();
|
||||
CUSTOM_SITE_MAP.put(ScreenLockSettings.class.getName(), SecuritySettings.class.getName());
|
||||
CUSTOM_SITE_MAP.put(
|
||||
WallpaperSuggestionActivity.class.getName(), DisplaySettings.class.getName());
|
||||
CUSTOM_SITE_MAP.put(
|
||||
WifiSettings.class.getName(), NetworkDashboardFragment.class.getName());
|
||||
CUSTOM_SITE_MAP.put(PowerUsageAdvanced.class.getName(), PowerUsageSummary.class.getName());
|
||||
|
||||
@@ -40,7 +40,6 @@ import com.android.settings.location.LocationSlice;
|
||||
import com.android.settings.media.MediaOutputIndicatorSlice;
|
||||
import com.android.settings.media.RemoteMediaSlice;
|
||||
import com.android.settings.network.ProviderModelSlice;
|
||||
import com.android.settings.network.TurnOnWifiSlice;
|
||||
import com.android.settings.network.telephony.MobileDataSlice;
|
||||
import com.android.settings.notification.zen.ZenModeButtonPreferenceController;
|
||||
import com.android.settings.wifi.calling.WifiCallingSliceHelper;
|
||||
@@ -337,7 +336,6 @@ public class CustomSliceRegistry {
|
||||
sUriToSlice.put(DARK_THEME_SLICE_URI, DarkThemeSlice.class);
|
||||
sUriToSlice.put(REMOTE_MEDIA_SLICE_URI, RemoteMediaSlice.class);
|
||||
sUriToSlice.put(ALWAYS_ON_SLICE_URI, AlwaysOnDisplaySlice.class);
|
||||
sUriToSlice.put(TURN_ON_WIFI_SLICE_URI, TurnOnWifiSlice.class);
|
||||
}
|
||||
|
||||
public static Class<? extends CustomSliceable> getSliceClassByUri(Uri uri) {
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* 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.applications;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.usage.UsageStats;
|
||||
import android.content.Context;
|
||||
import android.os.UserManager;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
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.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class AllAppsInfoPreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private UserManager mUserManager;
|
||||
private AllAppsInfoPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
final Context context = spy(RuntimeEnvironment.application);
|
||||
final Preference preference = new Preference(context);
|
||||
doReturn(mUserManager).when(context).getSystemService(Context.USER_SERVICE);
|
||||
when(mUserManager.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[]{});
|
||||
mController = new AllAppsInfoPreferenceController(context, "test_key");
|
||||
mController.mPreference = preference;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_shouldReturnAVAILABLE() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onReloadDataCompleted_recentAppsSet_hidePreference() {
|
||||
final List<UsageStats> stats = new ArrayList<>();
|
||||
final UsageStats stat1 = new UsageStats();
|
||||
stat1.mLastTimeUsed = System.currentTimeMillis();
|
||||
stat1.mPackageName = "pkg.class";
|
||||
stats.add(stat1);
|
||||
|
||||
mController.onReloadDataCompleted(stats);
|
||||
|
||||
assertThat(mController.mPreference.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onReloadDataCompleted_noRecentAppSet_showPreference() {
|
||||
final List<UsageStats> stats = new ArrayList<>();
|
||||
|
||||
mController.onReloadDataCompleted(stats);
|
||||
|
||||
assertThat(mController.mPreference.isVisible()).isTrue();
|
||||
}
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.usage.UsageStats;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
import com.android.settingslib.widget.AppEntitiesHeaderController;
|
||||
import com.android.settingslib.widget.AppEntityInfo;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
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 org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class RecentAppsPreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private PreferenceScreen mScreen;
|
||||
@Mock
|
||||
private UserManager mUserManager;
|
||||
@Mock
|
||||
private ApplicationsState mAppState;
|
||||
@Mock
|
||||
private PackageManager mPackageManager;
|
||||
@Mock
|
||||
private ApplicationsState.AppEntry mAppEntry;
|
||||
@Mock
|
||||
private ApplicationInfo mApplicationInfo;
|
||||
@Mock
|
||||
private Fragment mFragment;
|
||||
|
||||
private RecentAppsPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
final Context context = spy(RuntimeEnvironment.application);
|
||||
when(context.getApplicationContext()).thenReturn(context);
|
||||
ReflectionHelpers.setStaticField(ApplicationsState.class, "sInstance", mAppState);
|
||||
doReturn(mUserManager).when(context).getSystemService(Context.USER_SERVICE);
|
||||
doReturn(mPackageManager).when(context).getPackageManager();
|
||||
when(mUserManager.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[]{});
|
||||
|
||||
final View appEntitiesHeaderView = LayoutInflater.from(context).inflate(
|
||||
R.layout.app_entities_header, null /* root */);
|
||||
final Preference dividerPreference = new Preference(context);
|
||||
final LayoutPreference recentAppsPreference =
|
||||
spy(new LayoutPreference(context, appEntitiesHeaderView));
|
||||
|
||||
mController = spy(new RecentAppsPreferenceController(context, "test_key"));
|
||||
mController.setFragment(mFragment);
|
||||
|
||||
mController.mAppEntitiesController = mock(AppEntitiesHeaderController.class);
|
||||
mController.mRecentAppsPreference = recentAppsPreference;
|
||||
mController.mDivider = dividerPreference;
|
||||
|
||||
when(mScreen.findPreference(RecentAppsPreferenceController.KEY_DIVIDER))
|
||||
.thenReturn(dividerPreference);
|
||||
when(mScreen.findPreference("test_key")).thenReturn(recentAppsPreference);
|
||||
when(recentAppsPreference.findViewById(R.id.app_entities_header)).thenReturn(
|
||||
appEntitiesHeaderView);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_shouldReturnAVAILABLE_UNSEARCHABLE() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayPreference_shouldSetupAppEntitiesHeaderController() {
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
assertThat(mController.mAppEntitiesController).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onReloadDataCompleted_threeValidRecentOpenAppsSet_setAppEntityThreeTime() {
|
||||
final List<UsageStats> stats = new ArrayList<>();
|
||||
final UsageStats stat1 = new UsageStats();
|
||||
final UsageStats stat2 = new UsageStats();
|
||||
final UsageStats stat3 = new UsageStats();
|
||||
stat1.mLastTimeUsed = System.currentTimeMillis();
|
||||
stat1.mPackageName = "pkg.class";
|
||||
stats.add(stat1);
|
||||
|
||||
stat2.mLastTimeUsed = System.currentTimeMillis();
|
||||
stat2.mPackageName = "pkg.class2";
|
||||
stats.add(stat2);
|
||||
|
||||
stat3.mLastTimeUsed = System.currentTimeMillis();
|
||||
stat3.mPackageName = "pkg.class3";
|
||||
stats.add(stat3);
|
||||
when(mAppState.getEntry(stat1.mPackageName, UserHandle.myUserId()))
|
||||
.thenReturn(mAppEntry);
|
||||
when(mAppState.getEntry(stat2.mPackageName, UserHandle.myUserId()))
|
||||
.thenReturn(mAppEntry);
|
||||
when(mAppState.getEntry(stat3.mPackageName, UserHandle.myUserId()))
|
||||
.thenReturn(mAppEntry);
|
||||
mAppEntry.info = mApplicationInfo;
|
||||
|
||||
mController.onReloadDataCompleted(stats);
|
||||
|
||||
verify(mController.mAppEntitiesController, times(3))
|
||||
.setAppEntity(anyInt(), any(AppEntityInfo.class));
|
||||
assertThat(mController.mRecentAppsPreference.isVisible()).isTrue();
|
||||
assertThat(mController.mDivider.isVisible()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onReloadDataCompleted_noRecentOpenAppsSet_shouldHideRecentAppPreference() {
|
||||
final List<UsageStats> stats = new ArrayList<>();
|
||||
|
||||
mController.onReloadDataCompleted(stats);
|
||||
|
||||
assertThat(mController.mRecentAppsPreference.isVisible()).isFalse();
|
||||
assertThat(mController.mDivider.isVisible()).isFalse();
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,11 @@ public class AppBatteryPreferenceControllerTest {
|
||||
when(mOtherUidBatteryConsumer.getUid()).thenReturn(OTHER_UID);
|
||||
|
||||
mController = spy(new AppBatteryPreferenceController(
|
||||
RuntimeEnvironment.application, mFragment, "package1", null /* lifecycle */));
|
||||
RuntimeEnvironment.application,
|
||||
mFragment,
|
||||
"package1" /* packageName */,
|
||||
0 /* uId */,
|
||||
null /* lifecycle */));
|
||||
mController.mBatteryUtils = mBatteryUtils;
|
||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mBatteryPreference);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class AddDevicePreferenceControllerTest {
|
||||
@Test
|
||||
public void addDevice_bt_resume_on_then_off() {
|
||||
when(mBluetoothAdapter.isEnabled()).thenReturn(true);
|
||||
mAddDevicePreferenceController.updateState();
|
||||
mAddDevicePreferenceController.updateState(mAddDevicePreference);
|
||||
assertTrue(TextUtils.isEmpty(mAddDevicePreference.getSummary()));
|
||||
|
||||
Intent intent = new Intent(BluetoothAdapter.ACTION_STATE_CHANGED);
|
||||
@@ -103,7 +103,7 @@ public class AddDevicePreferenceControllerTest {
|
||||
@Test
|
||||
public void addDevice_bt_resume_off_then_on() {
|
||||
when(mBluetoothAdapter.isEnabled()).thenReturn(false);
|
||||
mAddDevicePreferenceController.updateState();
|
||||
mAddDevicePreferenceController.updateState(mAddDevicePreference);
|
||||
assertThat(mAddDevicePreference.getSummary()).isEqualTo(
|
||||
mContext.getString(R.string.connected_device_add_device_summary));
|
||||
|
||||
@@ -131,9 +131,8 @@ public class AddDevicePreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_bluetoothIsDisabled_unSupported() {
|
||||
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true);
|
||||
when(mBluetoothAdapter.isEnabled()).thenReturn(false);
|
||||
public void getAvailabilityStatus_noBluetoothFeature_unSupported() {
|
||||
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, false);
|
||||
|
||||
assertThat(mAddDevicePreferenceController.getAvailabilityStatus())
|
||||
.isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
*/
|
||||
package com.android.settings.connecteddevice;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
|
||||
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 org.robolectric.Shadows;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplicationPackageManager;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = ShadowApplicationPackageManager.class)
|
||||
public class AddDeviceSummaryPreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private PreferenceScreen mScreen;
|
||||
@Mock
|
||||
private BluetoothAdapter mBluetoothAdapter;
|
||||
|
||||
private Context mContext;
|
||||
private AddDeviceSummaryPreferenceController mAddDeviceSummaryPreferenceController;
|
||||
private RestrictedPreference mAddDevicePreference;
|
||||
private ShadowApplicationPackageManager mPackageManager;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mPackageManager = (ShadowApplicationPackageManager) Shadows.shadowOf(
|
||||
mContext.getPackageManager());
|
||||
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true);
|
||||
|
||||
mAddDeviceSummaryPreferenceController = new AddDeviceSummaryPreferenceController(mContext,
|
||||
"add_bt_devices");
|
||||
ReflectionHelpers.setField(mAddDeviceSummaryPreferenceController,
|
||||
"mBluetoothAdapter", mBluetoothAdapter);
|
||||
|
||||
String key = mAddDeviceSummaryPreferenceController.getPreferenceKey();
|
||||
mAddDevicePreference = new RestrictedPreference(mContext);
|
||||
mAddDevicePreference.setKey(key);
|
||||
when(mScreen.findPreference(key)).thenReturn(mAddDevicePreference);
|
||||
when(mBluetoothAdapter.isEnabled()).thenReturn(false);
|
||||
mAddDeviceSummaryPreferenceController.displayPreference(mScreen);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummary_btOnThenOff_summaryShouldBeShown() {
|
||||
when(mBluetoothAdapter.isEnabled()).thenReturn(true);
|
||||
|
||||
mAddDeviceSummaryPreferenceController.updateState();
|
||||
|
||||
assertTrue(TextUtils.isEmpty(mAddDevicePreference.getSummary()));
|
||||
|
||||
Intent intent = new Intent(BluetoothAdapter.ACTION_STATE_CHANGED);
|
||||
intent.putExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.STATE_OFF);
|
||||
BroadcastReceiver receiver = ReflectionHelpers.getField(
|
||||
mAddDeviceSummaryPreferenceController, "mReceiver");
|
||||
when(mBluetoothAdapter.isEnabled()).thenReturn(false);
|
||||
|
||||
receiver.onReceive(mContext, intent);
|
||||
|
||||
assertThat(mAddDevicePreference.getSummary()).isEqualTo(
|
||||
mContext.getString(R.string.connected_device_add_device_summary));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummary_btOffThenOn_summaryShouldNotBeShown() {
|
||||
when(mBluetoothAdapter.isEnabled()).thenReturn(false);
|
||||
|
||||
mAddDeviceSummaryPreferenceController.updateState();
|
||||
|
||||
assertThat(mAddDevicePreference.getSummary()).isEqualTo(
|
||||
mContext.getString(R.string.connected_device_add_device_summary));
|
||||
|
||||
Intent intent = new Intent(BluetoothAdapter.ACTION_STATE_CHANGED);
|
||||
intent.putExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.STATE_ON);
|
||||
BroadcastReceiver receiver = ReflectionHelpers.getField(
|
||||
mAddDeviceSummaryPreferenceController, "mReceiver");
|
||||
when(mBluetoothAdapter.isEnabled()).thenReturn(true);
|
||||
|
||||
receiver.onReceive(mContext, intent);
|
||||
|
||||
assertTrue(TextUtils.isEmpty(mAddDevicePreference.getSummary()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_notHaveBluetoothFeature_unSupported() {
|
||||
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, false);
|
||||
|
||||
assertThat(mAddDeviceSummaryPreferenceController.getAvailabilityStatus())
|
||||
.isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_haveBluetoothFeature_supported() {
|
||||
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true);
|
||||
|
||||
assertThat(mAddDeviceSummaryPreferenceController.getAvailabilityStatus())
|
||||
.isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_bluetoothIsEnabled_unSupported() {
|
||||
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true);
|
||||
when(mBluetoothAdapter.isEnabled()).thenReturn(true);
|
||||
|
||||
assertThat(mAddDeviceSummaryPreferenceController.getAvailabilityStatus())
|
||||
.isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
}
|
||||
@@ -77,14 +77,14 @@ public class StorageDashboardFragmentTest {
|
||||
CachedStorageValuesHelper helper = mock(CachedStorageValuesHelper.class);
|
||||
PrivateStorageInfo info = new PrivateStorageInfo(0, 0);
|
||||
when(helper.getCachedPrivateStorageInfo()).thenReturn(info);
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> result = new SparseArray<>();
|
||||
when(helper.getCachedAppsStorageResult()).thenReturn(result);
|
||||
SparseArray<StorageAsyncLoader.StorageResult> result = new SparseArray<>();
|
||||
when(helper.getCachedStorageResult()).thenReturn(result);
|
||||
|
||||
mFragment.setCachedStorageValuesHelper(helper);
|
||||
mFragment.initializeCachedValues();
|
||||
|
||||
assertThat(mFragment.getPrivateStorageInfo()).isEqualTo(info);
|
||||
assertThat(mFragment.getAppsStorageResult()).isEqualTo(result);
|
||||
assertThat(mFragment.getStorageResult()).isEqualTo(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -97,20 +97,20 @@ public class StorageDashboardFragmentTest {
|
||||
mFragment.initializeCachedValues();
|
||||
|
||||
assertThat(mFragment.getPrivateStorageInfo()).isNull();
|
||||
assertThat(mFragment.getAppsStorageResult()).isNull();
|
||||
assertThat(mFragment.getStorageResult()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_cacheProviderDoesntProvideValuesIfVolumeInfoMissing() {
|
||||
CachedStorageValuesHelper helper = mock(CachedStorageValuesHelper.class);
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> result = new SparseArray<>();
|
||||
when(helper.getCachedAppsStorageResult()).thenReturn(result);
|
||||
SparseArray<StorageAsyncLoader.StorageResult> result = new SparseArray<>();
|
||||
when(helper.getCachedStorageResult()).thenReturn(result);
|
||||
|
||||
mFragment.setCachedStorageValuesHelper(helper);
|
||||
mFragment.initializeCachedValues();
|
||||
|
||||
assertThat(mFragment.getPrivateStorageInfo()).isNull();
|
||||
assertThat(mFragment.getAppsStorageResult()).isNull();
|
||||
assertThat(mFragment.getStorageResult()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -169,7 +169,7 @@ public class StorageDashboardFragmentTest {
|
||||
mFragment = spy(mFragment);
|
||||
when(mFragment.getView()).thenReturn(fakeView);
|
||||
when(mFragment.getListView()).thenReturn(fakeRecyclerView);
|
||||
mFragment.setAppsStorageResult(new SparseArray<>());
|
||||
mFragment.setStorageResult(new SparseArray<>());
|
||||
|
||||
mFragment.maybeSetLoading(true);
|
||||
|
||||
@@ -185,7 +185,7 @@ public class StorageDashboardFragmentTest {
|
||||
when(mFragment.getView()).thenReturn(fakeView);
|
||||
when(mFragment.getListView()).thenReturn(fakeRecyclerView);
|
||||
|
||||
mFragment.setAppsStorageResult(new SparseArray<>());
|
||||
mFragment.setStorageResult(new SparseArray<>());
|
||||
PrivateStorageInfo storageInfo = new PrivateStorageInfo(0, 0);
|
||||
mFragment.setPrivateStorageInfo(storageInfo);
|
||||
|
||||
@@ -203,4 +203,4 @@ public class StorageDashboardFragmentTest {
|
||||
assertThat(indexRes).isNotNull();
|
||||
assertThat(indexRes.get(0).xmlResId).isEqualTo(mFragment.getPreferenceScreenResId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class StorageItemPreferenceTest {
|
||||
@Test
|
||||
public void testAfterLoad() {
|
||||
mPreference.setStorageSize(MEGABYTE_IN_BYTES * 10, MEGABYTE_IN_BYTES * 100);
|
||||
assertThat(mPreference.getSummary()).isEqualTo("0.01 GB");
|
||||
assertThat(mPreference.getSummary()).isEqualTo("10 MB");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
package com.android.settings.deviceinfo.storage;
|
||||
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.AUDIO_SIZE_KEY;
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.CACHE_APPS_SIZE_KEY;
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.DOCUMENTS_AND_OTHER_SIZE_KEY;
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.EXTERNAL_APP_BYTES;
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper
|
||||
.EXTERNAL_AUDIO_BYTES;
|
||||
@@ -28,15 +30,15 @@ import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper
|
||||
.EXTERNAL_VIDEO_BYTES;
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.FREE_BYTES_KEY;
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.GAME_APPS_SIZE_KEY;
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.MUSIC_APPS_SIZE_KEY;
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.IMAGES_SIZE_KEY;
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.OTHER_APPS_SIZE_KEY;
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.PHOTO_APPS_SIZE_KEY;
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper
|
||||
.SHARED_PREFERENCES_NAME;
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.TIMESTAMP_KEY;
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.TOTAL_BYTES_KEY;
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.TRASH_SIZE_KEY;
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.USER_ID_KEY;
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.VIDEO_APPS_SIZE_KEY;
|
||||
import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.VIDEOS_SIZE_KEY;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -81,9 +83,9 @@ public class CachedStorageValuesHelperTest {
|
||||
mSharedPreferences
|
||||
.edit()
|
||||
.putLong(GAME_APPS_SIZE_KEY, 0)
|
||||
.putLong(MUSIC_APPS_SIZE_KEY, 10)
|
||||
.putLong(VIDEO_APPS_SIZE_KEY, 100)
|
||||
.putLong(PHOTO_APPS_SIZE_KEY, 1000)
|
||||
.putLong(AUDIO_SIZE_KEY, 10)
|
||||
.putLong(VIDEOS_SIZE_KEY, 100)
|
||||
.putLong(IMAGES_SIZE_KEY, 1000)
|
||||
.putLong(OTHER_APPS_SIZE_KEY, 10000)
|
||||
.putLong(CACHE_APPS_SIZE_KEY, 100000)
|
||||
.putLong(EXTERNAL_TOTAL_BYTES, 2)
|
||||
@@ -104,14 +106,16 @@ public class CachedStorageValuesHelperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCachedAppsStorageResult_cachedValuesAreLoaded() {
|
||||
public void getCachedStorageResult_cachedValuesAreLoaded() {
|
||||
when(mMockClock.getCurrentTime()).thenReturn(10001L);
|
||||
mSharedPreferences
|
||||
.edit()
|
||||
.putLong(GAME_APPS_SIZE_KEY, 1)
|
||||
.putLong(MUSIC_APPS_SIZE_KEY, 10)
|
||||
.putLong(VIDEO_APPS_SIZE_KEY, 100)
|
||||
.putLong(PHOTO_APPS_SIZE_KEY, 1000)
|
||||
.putLong(AUDIO_SIZE_KEY, 10)
|
||||
.putLong(VIDEOS_SIZE_KEY, 100)
|
||||
.putLong(IMAGES_SIZE_KEY, 1000)
|
||||
.putLong(DOCUMENTS_AND_OTHER_SIZE_KEY, 1001)
|
||||
.putLong(TRASH_SIZE_KEY, 1002)
|
||||
.putLong(OTHER_APPS_SIZE_KEY, 10000)
|
||||
.putLong(CACHE_APPS_SIZE_KEY, 100000)
|
||||
.putLong(EXTERNAL_TOTAL_BYTES, 222222)
|
||||
@@ -125,15 +129,17 @@ public class CachedStorageValuesHelperTest {
|
||||
.putLong(TIMESTAMP_KEY, 10000L)
|
||||
.apply();
|
||||
|
||||
final SparseArray<StorageAsyncLoader.AppsStorageResult> result =
|
||||
mCachedValuesHelper.getCachedAppsStorageResult();
|
||||
final SparseArray<StorageAsyncLoader.StorageResult> result =
|
||||
mCachedValuesHelper.getCachedStorageResult();
|
||||
|
||||
StorageAsyncLoader.AppsStorageResult primaryResult = result.get(0);
|
||||
StorageAsyncLoader.StorageResult primaryResult = result.get(0);
|
||||
assertThat(primaryResult.gamesSize).isEqualTo(1L);
|
||||
assertThat(primaryResult.musicAppsSize).isEqualTo(10L);
|
||||
assertThat(primaryResult.videoAppsSize).isEqualTo(100L);
|
||||
assertThat(primaryResult.photosAppsSize).isEqualTo(1000L);
|
||||
assertThat(primaryResult.otherAppsSize).isEqualTo(10000L);
|
||||
assertThat(primaryResult.audioSize).isEqualTo(10L);
|
||||
assertThat(primaryResult.videosSize).isEqualTo(100L);
|
||||
assertThat(primaryResult.imagesSize).isEqualTo(1000L);
|
||||
assertThat(primaryResult.documentsAndOtherSize).isEqualTo(1001L);
|
||||
assertThat(primaryResult.trashSize).isEqualTo(1002L);
|
||||
assertThat(primaryResult.allAppsExceptGamesSize).isEqualTo(10000L);
|
||||
assertThat(primaryResult.cacheSize).isEqualTo(100000L);
|
||||
assertThat(primaryResult.externalStats.totalBytes).isEqualTo(222222L);
|
||||
assertThat(primaryResult.externalStats.audioBytes).isEqualTo(22L);
|
||||
@@ -148,9 +154,9 @@ public class CachedStorageValuesHelperTest {
|
||||
mSharedPreferences
|
||||
.edit()
|
||||
.putLong(GAME_APPS_SIZE_KEY, 0)
|
||||
.putLong(MUSIC_APPS_SIZE_KEY, 10)
|
||||
.putLong(VIDEO_APPS_SIZE_KEY, 100)
|
||||
.putLong(PHOTO_APPS_SIZE_KEY, 1000)
|
||||
.putLong(AUDIO_SIZE_KEY, 10)
|
||||
.putLong(VIDEOS_SIZE_KEY, 100)
|
||||
.putLong(IMAGES_SIZE_KEY, 1000)
|
||||
.putLong(OTHER_APPS_SIZE_KEY, 10000)
|
||||
.putLong(CACHE_APPS_SIZE_KEY, 100000)
|
||||
.putLong(EXTERNAL_TOTAL_BYTES, 2)
|
||||
@@ -169,14 +175,14 @@ public class CachedStorageValuesHelperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCachedAppsStorageResult_nullIfDataIsStale() {
|
||||
public void getCachedStorageResult_nullIfDataIsStale() {
|
||||
when(mMockClock.getCurrentTime()).thenReturn(10000000L);
|
||||
mSharedPreferences
|
||||
.edit()
|
||||
.putLong(GAME_APPS_SIZE_KEY, 0)
|
||||
.putLong(MUSIC_APPS_SIZE_KEY, 10)
|
||||
.putLong(VIDEO_APPS_SIZE_KEY, 100)
|
||||
.putLong(PHOTO_APPS_SIZE_KEY, 1000)
|
||||
.putLong(AUDIO_SIZE_KEY, 10)
|
||||
.putLong(VIDEOS_SIZE_KEY, 100)
|
||||
.putLong(IMAGES_SIZE_KEY, 1000)
|
||||
.putLong(OTHER_APPS_SIZE_KEY, 10000)
|
||||
.putLong(CACHE_APPS_SIZE_KEY, 100000)
|
||||
.putLong(EXTERNAL_TOTAL_BYTES, 2)
|
||||
@@ -190,8 +196,8 @@ public class CachedStorageValuesHelperTest {
|
||||
.putLong(TIMESTAMP_KEY, 10000L)
|
||||
.apply();
|
||||
|
||||
final SparseArray<StorageAsyncLoader.AppsStorageResult> result =
|
||||
mCachedValuesHelper.getCachedAppsStorageResult();
|
||||
final SparseArray<StorageAsyncLoader.StorageResult> result =
|
||||
mCachedValuesHelper.getCachedStorageResult();
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
@@ -201,9 +207,9 @@ public class CachedStorageValuesHelperTest {
|
||||
mSharedPreferences
|
||||
.edit()
|
||||
.putLong(GAME_APPS_SIZE_KEY, 0)
|
||||
.putLong(MUSIC_APPS_SIZE_KEY, 10)
|
||||
.putLong(VIDEO_APPS_SIZE_KEY, 100)
|
||||
.putLong(PHOTO_APPS_SIZE_KEY, 1000)
|
||||
.putLong(AUDIO_SIZE_KEY, 10)
|
||||
.putLong(VIDEOS_SIZE_KEY, 100)
|
||||
.putLong(IMAGES_SIZE_KEY, 1000)
|
||||
.putLong(OTHER_APPS_SIZE_KEY, 10000)
|
||||
.putLong(CACHE_APPS_SIZE_KEY, 100000)
|
||||
.putLong(EXTERNAL_TOTAL_BYTES, 2)
|
||||
@@ -222,14 +228,14 @@ public class CachedStorageValuesHelperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCachedAppsStorageResult_nullIfWrongUser() {
|
||||
public void getCachedStorageResult_nullIfWrongUser() {
|
||||
when(mMockClock.getCurrentTime()).thenReturn(10001L);
|
||||
mSharedPreferences
|
||||
.edit()
|
||||
.putLong(GAME_APPS_SIZE_KEY, 0)
|
||||
.putLong(MUSIC_APPS_SIZE_KEY, 10)
|
||||
.putLong(VIDEO_APPS_SIZE_KEY, 100)
|
||||
.putLong(PHOTO_APPS_SIZE_KEY, 1000)
|
||||
.putLong(AUDIO_SIZE_KEY, 10)
|
||||
.putLong(VIDEOS_SIZE_KEY, 100)
|
||||
.putLong(IMAGES_SIZE_KEY, 1000)
|
||||
.putLong(OTHER_APPS_SIZE_KEY, 10000)
|
||||
.putLong(CACHE_APPS_SIZE_KEY, 100000)
|
||||
.putLong(EXTERNAL_TOTAL_BYTES, 2)
|
||||
@@ -243,8 +249,8 @@ public class CachedStorageValuesHelperTest {
|
||||
.putLong(TIMESTAMP_KEY, 10000L)
|
||||
.apply();
|
||||
|
||||
final SparseArray<StorageAsyncLoader.AppsStorageResult> result =
|
||||
mCachedValuesHelper.getCachedAppsStorageResult();
|
||||
final SparseArray<StorageAsyncLoader.StorageResult> result =
|
||||
mCachedValuesHelper.getCachedStorageResult();
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
@@ -255,9 +261,9 @@ public class CachedStorageValuesHelperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCachedAppsStorageResult_nullIfEmpty() {
|
||||
final SparseArray<StorageAsyncLoader.AppsStorageResult> result =
|
||||
mCachedValuesHelper.getCachedAppsStorageResult();
|
||||
public void getCachedStorageResult_nullIfEmpty() {
|
||||
final SparseArray<StorageAsyncLoader.StorageResult> result =
|
||||
mCachedValuesHelper.getCachedStorageResult();
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
@@ -266,13 +272,13 @@ public class CachedStorageValuesHelperTest {
|
||||
when(mMockClock.getCurrentTime()).thenReturn(10000L);
|
||||
final StorageStatsSource.ExternalStorageStats externalStats =
|
||||
new StorageStatsSource.ExternalStorageStats(22222L, 2L, 20L, 200L, 2000L);
|
||||
final StorageAsyncLoader.AppsStorageResult result =
|
||||
new StorageAsyncLoader.AppsStorageResult();
|
||||
final StorageAsyncLoader.StorageResult result =
|
||||
new StorageAsyncLoader.StorageResult();
|
||||
result.gamesSize = 1L;
|
||||
result.musicAppsSize = 10L;
|
||||
result.videoAppsSize = 100L;
|
||||
result.photosAppsSize = 1000L;
|
||||
result.otherAppsSize = 10000L;
|
||||
result.audioSize = 10L;
|
||||
result.videosSize = 100L;
|
||||
result.imagesSize = 1000L;
|
||||
result.allAppsExceptGamesSize = 10000L;
|
||||
result.cacheSize = 100000L;
|
||||
result.externalStats = externalStats;
|
||||
final PrivateStorageInfo info = new PrivateStorageInfo(1000L, 6000L);
|
||||
@@ -280,9 +286,9 @@ public class CachedStorageValuesHelperTest {
|
||||
mCachedValuesHelper.cacheResult(info, result);
|
||||
|
||||
assertThat(mSharedPreferences.getLong(GAME_APPS_SIZE_KEY, -1)).isEqualTo(1L);
|
||||
assertThat(mSharedPreferences.getLong(MUSIC_APPS_SIZE_KEY, -1)).isEqualTo(10L);
|
||||
assertThat(mSharedPreferences.getLong(VIDEO_APPS_SIZE_KEY, -1)).isEqualTo(100L);
|
||||
assertThat(mSharedPreferences.getLong(PHOTO_APPS_SIZE_KEY, -1)).isEqualTo(1000L);
|
||||
assertThat(mSharedPreferences.getLong(AUDIO_SIZE_KEY, -1)).isEqualTo(10L);
|
||||
assertThat(mSharedPreferences.getLong(VIDEOS_SIZE_KEY, -1)).isEqualTo(100L);
|
||||
assertThat(mSharedPreferences.getLong(IMAGES_SIZE_KEY, -1)).isEqualTo(1000L);
|
||||
assertThat(mSharedPreferences.getLong(OTHER_APPS_SIZE_KEY, -1)).isEqualTo(10000L);
|
||||
assertThat(mSharedPreferences.getLong(CACHE_APPS_SIZE_KEY, -1)).isEqualTo(100000L);
|
||||
assertThat(mSharedPreferences.getLong(EXTERNAL_TOTAL_BYTES, -1)).isEqualTo(22222L);
|
||||
|
||||
@@ -103,7 +103,7 @@ public class SecondaryUserControllerTest {
|
||||
verify(mGroup).addPreference(argumentCaptor.capture());
|
||||
|
||||
final Preference preference = argumentCaptor.getValue();
|
||||
assertThat(preference.getSummary()).isEqualTo("0.01 GB");
|
||||
assertThat(preference.getSummary()).isEqualTo("10 MB");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -201,9 +201,9 @@ public class SecondaryUserControllerTest {
|
||||
mPrimaryUser.name = TEST_NAME;
|
||||
mPrimaryUser.id = 10;
|
||||
mController.displayPreference(mScreen);
|
||||
final StorageAsyncLoader.AppsStorageResult userResult =
|
||||
new StorageAsyncLoader.AppsStorageResult();
|
||||
final SparseArray<StorageAsyncLoader.AppsStorageResult> result = new SparseArray<>();
|
||||
final StorageAsyncLoader.StorageResult userResult =
|
||||
new StorageAsyncLoader.StorageResult();
|
||||
final SparseArray<StorageAsyncLoader.StorageResult> result = new SparseArray<>();
|
||||
userResult.externalStats =
|
||||
new StorageStatsSource.ExternalStorageStats(
|
||||
MEGABYTE_IN_BYTES * 30,
|
||||
@@ -217,7 +217,7 @@ public class SecondaryUserControllerTest {
|
||||
verify(mGroup).addPreference(argumentCaptor.capture());
|
||||
final Preference preference = argumentCaptor.getValue();
|
||||
|
||||
assertThat(preference.getSummary()).isEqualTo("0.03 GB");
|
||||
assertThat(preference.getSummary()).isEqualTo("30 MB");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
package com.android.settings.deviceinfo.storage;
|
||||
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications.EXTRA_WORK_ID;
|
||||
import static com.android.settings.utils.FileSizeFormatter.GIGABYTE_IN_BYTES;
|
||||
import static com.android.settings.utils.FileSizeFormatter.KILOBYTE_IN_BYTES;
|
||||
import static com.android.settings.utils.FileSizeFormatter.MEGABYTE_IN_BYTES;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -336,12 +338,14 @@ public class StorageItemPreferenceControllerTest {
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
|
||||
mController.setUsedSize(MEGABYTE_IN_BYTES * 970); // There should 870MB attributed.
|
||||
final StorageAsyncLoader.AppsStorageResult result =
|
||||
new StorageAsyncLoader.AppsStorageResult();
|
||||
final StorageAsyncLoader.StorageResult result = new StorageAsyncLoader.StorageResult();
|
||||
result.gamesSize = MEGABYTE_IN_BYTES * 80;
|
||||
result.videoAppsSize = MEGABYTE_IN_BYTES * 160;
|
||||
result.musicAppsSize = MEGABYTE_IN_BYTES * 40;
|
||||
result.otherAppsSize = MEGABYTE_IN_BYTES * 90;
|
||||
result.imagesSize = MEGABYTE_IN_BYTES * 350;
|
||||
result.videosSize = GIGABYTE_IN_BYTES * 30;
|
||||
result.audioSize = MEGABYTE_IN_BYTES * 40;
|
||||
result.documentsAndOtherSize = MEGABYTE_IN_BYTES * 50;
|
||||
result.trashSize = KILOBYTE_IN_BYTES * 100;
|
||||
result.allAppsExceptGamesSize = MEGABYTE_IN_BYTES * 90;
|
||||
result.externalStats =
|
||||
new StorageStatsSource.ExternalStorageStats(
|
||||
MEGABYTE_IN_BYTES * 500, // total
|
||||
@@ -349,17 +353,18 @@ public class StorageItemPreferenceControllerTest {
|
||||
MEGABYTE_IN_BYTES * 150, // video
|
||||
MEGABYTE_IN_BYTES * 200, 0); // image
|
||||
|
||||
final SparseArray<StorageAsyncLoader.AppsStorageResult> results = new SparseArray<>();
|
||||
final SparseArray<StorageAsyncLoader.StorageResult> results = new SparseArray<>();
|
||||
results.put(0, result);
|
||||
mController.onLoadFinished(results, 0);
|
||||
|
||||
assertThat(mController.mImagesPreference.getSummary().toString()).isEqualTo("0.35 GB");
|
||||
assertThat(mController.mVideosPreference.getSummary().toString()).isEqualTo("0.16 GB");
|
||||
assertThat(mController.mAudioPreference.getSummary().toString()).isEqualTo("0.14 GB");
|
||||
assertThat(mController.mAppsPreference.getSummary().toString()).isEqualTo("0.09 GB");
|
||||
assertThat(mController.mGamesPreference.getSummary().toString()).isEqualTo("0.08 GB");
|
||||
assertThat(mController.mImagesPreference.getSummary().toString()).isEqualTo("350 MB");
|
||||
assertThat(mController.mVideosPreference.getSummary().toString()).isEqualTo("30 GB");
|
||||
assertThat(mController.mAudioPreference.getSummary().toString()).isEqualTo("40 MB");
|
||||
assertThat(mController.mAppsPreference.getSummary().toString()).isEqualTo("90 MB");
|
||||
assertThat(mController.mGamesPreference.getSummary().toString()).isEqualTo("80 MB");
|
||||
assertThat(mController.mDocumentsAndOtherPreference.getSummary().toString())
|
||||
.isEqualTo("0.05 GB");
|
||||
.isEqualTo("50 MB");
|
||||
assertThat(mController.mTrashPreference.getSummary().toString()).isEqualTo("100 kB");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -307,6 +307,7 @@ public final class BatteryChartPreferenceControllerTest {
|
||||
doReturn(appLabel).when(mBatteryDiffEntry).getAppLabel();
|
||||
doReturn(PREF_KEY).when(mBatteryHistEntry).getKey();
|
||||
doReturn(null).when(mAppListGroup).findPreference(PREF_KEY);
|
||||
doReturn(false).when(mBatteryDiffEntry).validForRestriction();
|
||||
|
||||
mBatteryChartPreferenceController.addPreferenceToScreen(
|
||||
Arrays.asList(mBatteryDiffEntry));
|
||||
@@ -324,6 +325,7 @@ public final class BatteryChartPreferenceControllerTest {
|
||||
assertThat(pref.getOrder()).isEqualTo(1);
|
||||
assertThat(pref.getBatteryDiffEntry()).isSameInstanceAs(mBatteryDiffEntry);
|
||||
assertThat(pref.isSingleLineTitle()).isTrue();
|
||||
assertThat(pref.isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -353,7 +355,7 @@ public final class BatteryChartPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandlePreferenceTreeClick_validPackageName_returnTrue() {
|
||||
public void testHandlePreferenceTreeClick_forAppEntry_returnTrue() {
|
||||
doReturn(false).when(mBatteryHistEntry).isAppEntry();
|
||||
doReturn(mBatteryDiffEntry).when(mPowerGaugePreference).getBatteryDiffEntry();
|
||||
|
||||
@@ -371,15 +373,13 @@ public final class BatteryChartPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandlePreferenceTreeClick_appEntryWithInvalidPackage_returnFalse() {
|
||||
public void testHandlePreferenceTreeClick_forSystemEntry_returnTrue() {
|
||||
mBatteryChartPreferenceController.mBatteryUtils = mBatteryUtils;
|
||||
doReturn(true).when(mBatteryHistEntry).isAppEntry();
|
||||
doReturn(BatteryUtils.UID_NULL).when(mBatteryUtils)
|
||||
.getPackageUid(mBatteryHistEntry.mPackageName);
|
||||
doReturn(mBatteryDiffEntry).when(mPowerGaugePreference).getBatteryDiffEntry();
|
||||
|
||||
assertThat(mBatteryChartPreferenceController.handlePreferenceTreeClick(
|
||||
mPowerGaugePreference)).isFalse();
|
||||
mPowerGaugePreference)).isTrue();
|
||||
verify(mMetricsFeatureProvider)
|
||||
.action(
|
||||
mContext,
|
||||
|
||||
@@ -17,12 +17,15 @@ package com.android.settings.fuelgauge;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.BatteryConsumer;
|
||||
@@ -56,11 +59,13 @@ public final class BatteryDiffEntryTest {
|
||||
@Mock private Drawable mockDrawable2;
|
||||
@Mock private Drawable mockBadgedDrawable;
|
||||
@Mock private BatteryHistEntry mBatteryHistEntry;
|
||||
@Mock private PackageInfo mockPackageInfo;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
doReturn(mContext).when(mContext).getApplicationContext();
|
||||
doReturn(mockUserManager).when(mContext).getSystemService(UserManager.class);
|
||||
doReturn(mockPackageManager).when(mContext).getPackageManager();
|
||||
BatteryDiffEntry.clearCache();
|
||||
@@ -110,6 +115,7 @@ public final class BatteryDiffEntryTest {
|
||||
|
||||
@Test
|
||||
public void testLoadLabelAndIcon_forSystemBattery_returnExpectedResult() {
|
||||
final String expectedName = "Ambient display";
|
||||
// Generates fake testing data.
|
||||
final ContentValues values = getContentValuesWithType(
|
||||
ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY);
|
||||
@@ -119,13 +125,22 @@ public final class BatteryDiffEntryTest {
|
||||
|
||||
final BatteryDiffEntry entry = createBatteryDiffEntry(10, batteryHistEntry);
|
||||
|
||||
assertThat(entry.getAppLabel()).isEqualTo("Ambient display");
|
||||
assertThat(entry.getAppLabel()).isEqualTo(expectedName);
|
||||
assertThat(entry.getAppIconId()).isEqualTo(R.drawable.ic_settings_aod);
|
||||
assertThat(BatteryDiffEntry.sResourceCache).isEmpty();
|
||||
assertThat(BatteryDiffEntry.sResourceCache).hasSize(1);
|
||||
// Verifies the app label in the cache.
|
||||
final BatteryEntry.NameAndIcon nameAndIcon =
|
||||
BatteryDiffEntry.sResourceCache.get(entry.getKey());
|
||||
assertThat(nameAndIcon.name).isEqualTo(expectedName);
|
||||
assertThat(nameAndIcon.iconId).isEqualTo(R.drawable.ic_settings_aod);
|
||||
// Verifies the restrictable flag in the cache.
|
||||
assertThat(entry.mValidForRestriction).isTrue();
|
||||
assertThat(BatteryDiffEntry.sValidForRestriction.get(entry.getKey())).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadLabelAndIcon_forUserBattery_returnExpectedResult() {
|
||||
final String expectedName = "Removed user";
|
||||
doReturn(null).when(mockUserManager).getUserInfo(1001);
|
||||
// Generates fake testing data.
|
||||
final ContentValues values = getContentValuesWithType(
|
||||
@@ -135,10 +150,18 @@ public final class BatteryDiffEntryTest {
|
||||
|
||||
final BatteryDiffEntry entry = createBatteryDiffEntry(10, batteryHistEntry);
|
||||
|
||||
assertThat(entry.getAppLabel()).isEqualTo("Removed user");
|
||||
assertThat(entry.getAppLabel()).isEqualTo(expectedName);
|
||||
assertThat(entry.getAppIcon()).isNull();
|
||||
assertThat(entry.getAppIconId()).isEqualTo(0);
|
||||
assertThat(BatteryDiffEntry.sResourceCache).isEmpty();
|
||||
assertThat(BatteryDiffEntry.sResourceCache).hasSize(1);
|
||||
// Verifies the app label in the cache.
|
||||
final BatteryEntry.NameAndIcon nameAndIcon =
|
||||
BatteryDiffEntry.sResourceCache.get(entry.getKey());
|
||||
assertThat(nameAndIcon.name).isEqualTo(expectedName);
|
||||
assertThat(nameAndIcon.iconId).isEqualTo(0);
|
||||
// Verifies the restrictable flag in the cache.
|
||||
assertThat(entry.mValidForRestriction).isTrue();
|
||||
assertThat(BatteryDiffEntry.sValidForRestriction.get(entry.getKey())).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -162,8 +185,11 @@ public final class BatteryDiffEntryTest {
|
||||
assertThat(BatteryDiffEntry.sResourceCache).hasSize(1);
|
||||
// Verifies the app label in the cache.
|
||||
final BatteryEntry.NameAndIcon nameAndIcon =
|
||||
BatteryDiffEntry.sResourceCache.get(batteryHistEntry.getKey());
|
||||
BatteryDiffEntry.sResourceCache.get(entry.getKey());
|
||||
assertThat(nameAndIcon.name).isEqualTo(expectedAppLabel);
|
||||
// Verifies the restrictable flag in the cache.
|
||||
assertThat(entry.mValidForRestriction).isFalse();
|
||||
assertThat(BatteryDiffEntry.sValidForRestriction.get(entry.getKey())).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -179,7 +205,7 @@ public final class BatteryDiffEntryTest {
|
||||
assertThat(BatteryDiffEntry.sResourceCache).hasSize(1);
|
||||
// Verifies the app label in the cache.
|
||||
final BatteryEntry.NameAndIcon nameAndIcon =
|
||||
BatteryDiffEntry.sResourceCache.get(batteryHistEntry.getKey());
|
||||
BatteryDiffEntry.sResourceCache.get(entry.getKey());
|
||||
assertThat(nameAndIcon.name).isEqualTo(expectedAppLabel);
|
||||
}
|
||||
|
||||
@@ -225,10 +251,24 @@ public final class BatteryDiffEntryTest {
|
||||
assertThat(BatteryDiffEntry.sResourceCache).hasSize(1);
|
||||
// Verifies the app label in the cache.
|
||||
final BatteryEntry.NameAndIcon nameAndIcon =
|
||||
BatteryDiffEntry.sResourceCache.get(entry.mBatteryHistEntry.getKey());
|
||||
BatteryDiffEntry.sResourceCache.get(entry.getKey());
|
||||
assertThat(nameAndIcon.icon).isEqualTo(mockBadgedDrawable);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClearCache_clearDataForResourcesAndFlags() {
|
||||
BatteryDiffEntry.sResourceCache.put(
|
||||
"fake application key",
|
||||
new BatteryEntry.NameAndIcon("app label", null, /*iconId=*/ 0));
|
||||
BatteryDiffEntry.sValidForRestriction.put(
|
||||
"fake application key", Boolean.valueOf(false));
|
||||
|
||||
BatteryDiffEntry.clearCache();
|
||||
|
||||
assertThat(BatteryDiffEntry.sResourceCache).isEmpty();
|
||||
assertThat(BatteryDiffEntry.sValidForRestriction).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClearCache_switchLocale_clearCacheIconAndLabel() throws Exception {
|
||||
final int userId = UserHandle.getUserId(1001);
|
||||
@@ -248,7 +288,7 @@ public final class BatteryDiffEntryTest {
|
||||
assertThat(entry2.getAppIcon()).isEqualTo(mockDrawable2);
|
||||
// Verifies the cache is updated into the new drawable.
|
||||
final BatteryEntry.NameAndIcon nameAndIcon =
|
||||
BatteryDiffEntry.sResourceCache.get(entry2.mBatteryHistEntry.getKey());
|
||||
BatteryDiffEntry.sResourceCache.get(entry2.getKey());
|
||||
assertThat(nameAndIcon.icon).isEqualTo(mockDrawable2);
|
||||
}
|
||||
|
||||
@@ -297,6 +337,40 @@ public final class BatteryDiffEntryTest {
|
||||
assertThat(entry.isSystemEntry()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateRestrictionFlagState_updateFlagAsExpected() throws Exception {
|
||||
final String expectedAppLabel = "fake app label";
|
||||
final String fakePackageName = "com.fake.google.com";
|
||||
final ContentValues values = getContentValuesWithType(
|
||||
ConvertUtils.CONSUMER_TYPE_UID_BATTERY);
|
||||
values.put("uid", /*invalid uid*/ 10001);
|
||||
values.put("packageName", fakePackageName);
|
||||
final BatteryDiffEntry entry =
|
||||
createBatteryDiffEntry(10, new BatteryHistEntry(values));
|
||||
|
||||
entry.updateRestrictionFlagState();
|
||||
// Sets false if the app entry cannot be found.
|
||||
assertThat(entry.mValidForRestriction).isFalse();
|
||||
|
||||
doReturn(BatteryUtils.UID_NULL).when(mockPackageManager).getPackageUid(
|
||||
entry.getPackageName(), PackageManager.GET_META_DATA);
|
||||
entry.updateRestrictionFlagState();
|
||||
// Sets false if the app is invalid package name.
|
||||
assertThat(entry.mValidForRestriction).isFalse();
|
||||
|
||||
doReturn(1000).when(mockPackageManager).getPackageUid(
|
||||
entry.getPackageName(), PackageManager.GET_META_DATA);
|
||||
entry.updateRestrictionFlagState();
|
||||
// Sets false if the app PackageInfo cannot be found.
|
||||
assertThat(entry.mValidForRestriction).isFalse();
|
||||
|
||||
doReturn(mockPackageInfo).when(mockPackageManager).getPackageInfo(
|
||||
eq(entry.getPackageName()), anyInt());
|
||||
entry.updateRestrictionFlagState();
|
||||
// Sets true if package is valid and PackageInfo can be found.
|
||||
assertThat(entry.mValidForRestriction).isTrue();
|
||||
}
|
||||
|
||||
private BatteryDiffEntry createBatteryDiffEntry(
|
||||
int consumerType, long uid, boolean isHidden) {
|
||||
final ContentValues values = getContentValuesWithType(consumerType);
|
||||
|
||||
@@ -1,389 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.notification;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.usage.IUsageStatsManager;
|
||||
import android.app.usage.UsageEvents;
|
||||
import android.app.usage.UsageEvents.Event;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Parcel;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.service.notification.NotifyingApp;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.widget.PrimarySwitchPreference;
|
||||
import com.android.settingslib.applications.AppUtils;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
import com.android.settingslib.applications.instantapps.InstantAppDataProvider;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class RecentNotifyingAppsPreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private PreferenceScreen mScreen;
|
||||
@Mock
|
||||
private PreferenceCategory mCategory;
|
||||
private PrimarySwitchPreference mApp1;
|
||||
private PrimarySwitchPreference mApp2;
|
||||
private PrimarySwitchPreference mApp3;
|
||||
@Mock
|
||||
private Preference mSeeAllPref;
|
||||
@Mock
|
||||
private UserManager mUserManager;
|
||||
@Mock
|
||||
private ApplicationsState mAppState;
|
||||
@Mock
|
||||
private PackageManager mPackageManager;
|
||||
@Mock
|
||||
private ApplicationsState.AppEntry mAppEntry;
|
||||
@Mock
|
||||
private ApplicationInfo mApplicationInfo;
|
||||
@Mock
|
||||
private NotificationBackend mBackend;
|
||||
@Mock
|
||||
private Fragment mHost;
|
||||
@Mock
|
||||
private FragmentActivity mActivity;
|
||||
@Mock
|
||||
private IUsageStatsManager mIUsageStatsManager;
|
||||
|
||||
private Context mContext;
|
||||
private RecentNotifyingAppsPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
|
||||
doReturn(mPackageManager).when(mContext).getPackageManager();
|
||||
when(mUserManager.getProfileIdsWithDisabled(0)).thenReturn(new int[] {0});
|
||||
|
||||
mController = new RecentNotifyingAppsPreferenceController(
|
||||
mContext, mBackend, mIUsageStatsManager, mUserManager, mAppState, mHost);
|
||||
when(mScreen.findPreference(anyString())).thenReturn(mCategory);
|
||||
mApp1 = new PrimarySwitchPreference(mContext);
|
||||
mApp1.setKey("app1");
|
||||
mApp2 = new PrimarySwitchPreference(mContext);
|
||||
mApp2.setKey("app2");
|
||||
mApp3 = new PrimarySwitchPreference(mContext);
|
||||
mApp3.setKey("app3");
|
||||
when(mCategory.findPreference("app1")).thenReturn(mApp1);
|
||||
when(mCategory.findPreference("app2")).thenReturn(mApp2);
|
||||
when(mCategory.findPreference("app3")).thenReturn(mApp3);
|
||||
|
||||
when(mScreen.findPreference(RecentNotifyingAppsPreferenceController.KEY_SEE_ALL))
|
||||
.thenReturn(mSeeAllPref);
|
||||
when(mCategory.getContext()).thenReturn(mContext);
|
||||
when(mHost.getActivity()).thenReturn(mActivity);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAlwaysAvailable() {
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onDisplayAndUpdateState_shouldRefreshUi() {
|
||||
mController = spy(new RecentNotifyingAppsPreferenceController(
|
||||
mContext, null, mIUsageStatsManager, mUserManager, (ApplicationsState) null, null));
|
||||
|
||||
doNothing().when(mController).refreshUi(mContext);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
mController.updateState(mCategory);
|
||||
|
||||
verify(mController, times(2)).refreshUi(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(qualifiers = "mcc999")
|
||||
public void display_shouldNotShowRecents_showAppInfoPreference() {
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
verify(mCategory, never()).addPreference(any(Preference.class));
|
||||
verify(mCategory).setTitle(null);
|
||||
verify(mSeeAllPref).setTitle(R.string.notifications_title);
|
||||
verify(mSeeAllPref).setIcon(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void display_showRecents() throws Exception {
|
||||
List<Event> events = new ArrayList<>();
|
||||
Event app = new Event();
|
||||
app.mEventType = Event.NOTIFICATION_INTERRUPTION;
|
||||
app.mPackage = "a";
|
||||
app.mTimeStamp = System.currentTimeMillis();
|
||||
events.add(app);
|
||||
Event app1 = new Event();
|
||||
app1.mEventType = Event.NOTIFICATION_INTERRUPTION;
|
||||
app1.mPackage = "com.android.settings";
|
||||
app1.mTimeStamp = System.currentTimeMillis();
|
||||
events.add(app1);
|
||||
Event app2 = new Event();
|
||||
app2.mEventType = Event.NOTIFICATION_INTERRUPTION;
|
||||
app2.mPackage = "pkg.class2";
|
||||
app2.mTimeStamp = System.currentTimeMillis() - 1000;
|
||||
events.add(app2);
|
||||
ApplicationsState.AppEntry app1Entry = mock(ApplicationsState.AppEntry.class);
|
||||
ApplicationsState.AppEntry app2Entry = mock(ApplicationsState.AppEntry.class);
|
||||
app1Entry.info = mApplicationInfo;
|
||||
app1Entry.label = "app 1";
|
||||
app2Entry.info = mApplicationInfo;
|
||||
app2Entry.label = "app 2";
|
||||
|
||||
// app1, app2 are valid apps. app3 is invalid.
|
||||
when(mAppState.getEntry(app.getPackageName(), UserHandle.myUserId()))
|
||||
.thenReturn(app1Entry);
|
||||
when(mAppState.getEntry(app1.getPackageName(), UserHandle.myUserId()))
|
||||
.thenReturn(app2Entry);
|
||||
when(mAppState.getEntry(app2.getPackageName(), UserHandle.myUserId()))
|
||||
.thenReturn(null);
|
||||
when(mPackageManager.resolveActivity(any(Intent.class), anyInt())).thenReturn(
|
||||
new ResolveInfo());
|
||||
|
||||
UsageEvents usageEvents = getUsageEvents(
|
||||
new String[] {app.getPackageName(), app1.getPackageName(), app2.getPackageName()},
|
||||
events);
|
||||
when(mIUsageStatsManager.queryEventsForUser(anyLong(), anyLong(), anyInt(), anyString()))
|
||||
.thenReturn(usageEvents);
|
||||
|
||||
mAppEntry.info = mApplicationInfo;
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
verify(mCategory).setTitle(R.string.recent_notifications);
|
||||
// Only add app1 & app2. app3 skipped because it's invalid app.
|
||||
assertThat(mApp1.getTitle()).isEqualTo(app1Entry.label);
|
||||
assertThat(mApp2.getTitle()).isEqualTo(app2Entry.label);
|
||||
|
||||
verify(mCategory).removePreferenceRecursively(mApp3.getKey());
|
||||
|
||||
verify(mSeeAllPref).setSummary(null);
|
||||
verify(mSeeAllPref).setIcon(R.drawable.ic_chevron_right_24dp);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void display_noCrashIfLessThan3() throws Exception {
|
||||
List<Event> events = new ArrayList<>();
|
||||
Event app = new Event();
|
||||
app.mEventType = Event.NOTIFICATION_INTERRUPTION;
|
||||
app.mPackage = "a";
|
||||
app.mTimeStamp = System.currentTimeMillis();
|
||||
events.add(app);
|
||||
ApplicationsState.AppEntry app1Entry = mock(ApplicationsState.AppEntry.class);
|
||||
app1Entry.info = mApplicationInfo;
|
||||
app1Entry.label = "app 1";
|
||||
|
||||
when(mAppState.getEntry(app.getPackageName(), UserHandle.myUserId()))
|
||||
.thenReturn(app1Entry);
|
||||
when(mPackageManager.resolveActivity(any(Intent.class), anyInt())).thenReturn(
|
||||
new ResolveInfo());
|
||||
|
||||
UsageEvents usageEvents = getUsageEvents(
|
||||
new String[] {app.getPackageName()},
|
||||
events);
|
||||
when(mIUsageStatsManager.queryEventsForUser(anyLong(), anyLong(), anyInt(), anyString()))
|
||||
.thenReturn(usageEvents);
|
||||
|
||||
mAppEntry.info = mApplicationInfo;
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
verify(mCategory).setTitle(R.string.recent_notifications);
|
||||
// Only add app1 & app2. app3 skipped because it's invalid app.
|
||||
assertThat(mApp1.getTitle()).isEqualTo(app1Entry.label);
|
||||
|
||||
verify(mCategory).removePreferenceRecursively("app2");
|
||||
|
||||
mController.refreshUi(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void display_showRecentsWithInstantApp() throws Exception {
|
||||
List<Event> events = new ArrayList<>();
|
||||
Event app = new Event();
|
||||
app.mEventType = Event.NOTIFICATION_INTERRUPTION;
|
||||
app.mPackage = "com.foo.bar";
|
||||
app.mTimeStamp = System.currentTimeMillis();
|
||||
events.add(app);
|
||||
Event app1 = new Event();
|
||||
app1.mEventType = Event.NOTIFICATION_INTERRUPTION;
|
||||
app1.mPackage = "com.foo.barinstant";
|
||||
app1.mTimeStamp = System.currentTimeMillis() - 200;
|
||||
events.add(app1);
|
||||
UsageEvents usageEvents = getUsageEvents(
|
||||
new String[] {"com.foo.bar", "com.foo.barinstant"}, events);
|
||||
when(mIUsageStatsManager.queryEventsForUser(anyLong(), anyLong(), anyInt(), anyString()))
|
||||
.thenReturn(usageEvents);
|
||||
|
||||
ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class);
|
||||
ApplicationsState.AppEntry app1Entry = mock(ApplicationsState.AppEntry.class);
|
||||
appEntry.info = mApplicationInfo;
|
||||
appEntry.label = "app 1";
|
||||
app1Entry.info = mApplicationInfo;
|
||||
app1Entry.label = "app 2";
|
||||
|
||||
when(mAppState.getEntry(
|
||||
app.getPackageName(), UserHandle.myUserId())).thenReturn(appEntry);
|
||||
when(mAppState.getEntry(
|
||||
app1.getPackageName(), UserHandle.myUserId())).thenReturn(app1Entry);
|
||||
|
||||
// Only the regular app app1 should have its intent resolve.
|
||||
when(mPackageManager.resolveActivity(argThat(intentMatcher(app.getPackageName())),
|
||||
anyInt())).thenReturn(new ResolveInfo());
|
||||
|
||||
// Make sure app2 is considered an instant app.
|
||||
ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
|
||||
(InstantAppDataProvider) (ApplicationInfo info) -> {
|
||||
if (info == app1Entry.info) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
assertThat(mApp1.getTitle()).isEqualTo(appEntry.label);
|
||||
assertThat(mApp1.getSummary()).isEqualTo("Just now");
|
||||
assertThat(mApp2.getTitle()).isEqualTo(app1Entry.label);
|
||||
|
||||
verify(mCategory).removePreferenceRecursively(mApp3.getKey());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reloadData() throws Exception {
|
||||
when(mUserManager.getProfileIdsWithDisabled(0)).thenReturn(new int[] {0, 10});
|
||||
|
||||
mController = new RecentNotifyingAppsPreferenceController(
|
||||
mContext, mBackend, mIUsageStatsManager, mUserManager, mAppState, mHost);
|
||||
|
||||
List<Event> events = new ArrayList<>();
|
||||
Event app = new Event();
|
||||
app.mEventType = Event.NOTIFICATION_INTERRUPTION;
|
||||
app.mPackage = "b";
|
||||
app.mTimeStamp = 1;
|
||||
events.add(app);
|
||||
Event app1 = new Event();
|
||||
app1.mEventType = Event.MAX_EVENT_TYPE;
|
||||
app1.mPackage = "com.foo.bar";
|
||||
app1.mTimeStamp = 10;
|
||||
events.add(app1);
|
||||
UsageEvents usageEvents = getUsageEvents(
|
||||
new String[] {"b", "com.foo.bar"}, events);
|
||||
when(mIUsageStatsManager.queryEventsForUser(anyLong(), anyLong(), eq(0), anyString()))
|
||||
.thenReturn(usageEvents);
|
||||
|
||||
List<Event> events10 = new ArrayList<>();
|
||||
Event app10 = new Event();
|
||||
app10.mEventType = Event.NOTIFICATION_INTERRUPTION;
|
||||
app10.mPackage = "a";
|
||||
app10.mTimeStamp = 2;
|
||||
events10.add(app10);
|
||||
Event app10a = new Event();
|
||||
app10a.mEventType = Event.NOTIFICATION_INTERRUPTION;
|
||||
app10a.mPackage = "a";
|
||||
app10a.mTimeStamp = 20;
|
||||
events10.add(app10a);
|
||||
UsageEvents usageEvents10 = getUsageEvents(
|
||||
new String[] {"a"}, events10);
|
||||
when(mIUsageStatsManager.queryEventsForUser(anyLong(), anyLong(), eq(10), anyString()))
|
||||
.thenReturn(usageEvents10);
|
||||
|
||||
mController.reloadData();
|
||||
|
||||
assertThat(mController.mApps.size()).isEqualTo(2);
|
||||
boolean foundPkg0 = false;
|
||||
boolean foundPkg10 = false;
|
||||
for (NotifyingApp notifyingApp : mController.mApps) {
|
||||
if (notifyingApp.getLastNotified() == 20
|
||||
&& notifyingApp.getPackage().equals("a")
|
||||
&& notifyingApp.getUserId() == 10) {
|
||||
foundPkg10 = true;
|
||||
}
|
||||
if (notifyingApp.getLastNotified() == 1
|
||||
&& notifyingApp.getPackage().equals("b")
|
||||
&& notifyingApp.getUserId() == 0) {
|
||||
foundPkg0 = true;
|
||||
}
|
||||
}
|
||||
assertThat(foundPkg0).isTrue();
|
||||
assertThat(foundPkg10).isTrue();
|
||||
}
|
||||
|
||||
private static ArgumentMatcher<Preference> summaryMatches(String expected) {
|
||||
return preference -> TextUtils.equals(expected, preference.getSummary());
|
||||
}
|
||||
|
||||
// Used for matching an intent with a specific package name.
|
||||
private static ArgumentMatcher<Intent> intentMatcher(String packageName) {
|
||||
return intent -> packageName.equals(intent.getPackage());
|
||||
}
|
||||
|
||||
private UsageEvents getUsageEvents(String[] pkgs, List<Event> events) {
|
||||
UsageEvents usageEvents = new UsageEvents(events, pkgs);
|
||||
Parcel parcel = Parcel.obtain();
|
||||
parcel.setDataPosition(0);
|
||||
usageEvents.writeToParcel(parcel, 0);
|
||||
parcel.setDataPosition(0);
|
||||
return UsageEvents.CREATOR.createFromParcel(parcel);
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import static android.app.AppOpsManager.OPSTR_AUTO_REVOKE_PERMISSIONS_IF_UNUSED;
|
||||
import static android.provider.DeviceConfig.NAMESPACE_APP_HIBERNATION;
|
||||
|
||||
import static com.android.settings.Utils.PROPERTY_APP_HIBERNATION_ENABLED;
|
||||
import static com.android.settings.Utils.PROPERTY_HIBERNATION_TARGETS_PRE_S_APPS;
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -143,4 +144,18 @@ public class HibernationSwitchPreferenceControllerTest {
|
||||
|
||||
verify(mPreference).setChecked(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_exemptedByDefaultPackageOverriddenByPreSFlag_shouldCheck() {
|
||||
DeviceConfig.setProperty(NAMESPACE_APP_HIBERNATION, PROPERTY_HIBERNATION_TARGETS_PRE_S_APPS,
|
||||
"true", true /* makeDefault */);
|
||||
when(mAppOpsManager.unsafeCheckOpNoThrow(
|
||||
eq(OPSTR_AUTO_REVOKE_PERMISSIONS_IF_UNUSED), anyInt(), eq(EXEMPTED_PACKAGE_NAME)))
|
||||
.thenReturn(MODE_DEFAULT);
|
||||
mController.setPackage(EXEMPTED_PACKAGE_NAME);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,22 +101,22 @@ public class StorageAsyncLoaderTest {
|
||||
addPackage(PACKAGE_NAME_1, 0, 1, 10, ApplicationInfo.CATEGORY_UNDEFINED);
|
||||
addPackage(PACKAGE_NAME_2, 0, 100, 1000, ApplicationInfo.CATEGORY_UNDEFINED);
|
||||
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> result = mLoader.loadInBackground();
|
||||
SparseArray<StorageAsyncLoader.StorageResult> result = mLoader.loadInBackground();
|
||||
|
||||
assertThat(result.size()).isEqualTo(1);
|
||||
assertThat(result.get(PRIMARY_USER_ID).gamesSize).isEqualTo(0L);
|
||||
assertThat(result.get(PRIMARY_USER_ID).otherAppsSize).isEqualTo(1111L);
|
||||
assertThat(result.get(PRIMARY_USER_ID).allAppsExceptGamesSize).isEqualTo(1111L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGamesAreFiltered() throws Exception {
|
||||
addPackage(PACKAGE_NAME_1, 0, 1, 10, ApplicationInfo.CATEGORY_GAME);
|
||||
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> result = mLoader.loadInBackground();
|
||||
SparseArray<StorageAsyncLoader.StorageResult> result = mLoader.loadInBackground();
|
||||
|
||||
assertThat(result.size()).isEqualTo(1);
|
||||
assertThat(result.get(PRIMARY_USER_ID).gamesSize).isEqualTo(11L);
|
||||
assertThat(result.get(PRIMARY_USER_ID).otherAppsSize).isEqualTo(0);
|
||||
assertThat(result.get(PRIMARY_USER_ID).allAppsExceptGamesSize).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -125,21 +125,21 @@ public class StorageAsyncLoaderTest {
|
||||
addPackage(PACKAGE_NAME_1, 0, 1, 10, ApplicationInfo.CATEGORY_UNDEFINED);
|
||||
info.flags = ApplicationInfo.FLAG_IS_GAME;
|
||||
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> result = mLoader.loadInBackground();
|
||||
SparseArray<StorageAsyncLoader.StorageResult> result = mLoader.loadInBackground();
|
||||
|
||||
assertThat(result.size()).isEqualTo(1);
|
||||
assertThat(result.get(PRIMARY_USER_ID).gamesSize).isEqualTo(11L);
|
||||
assertThat(result.get(PRIMARY_USER_ID).otherAppsSize).isEqualTo(0);
|
||||
assertThat(result.get(PRIMARY_USER_ID).allAppsExceptGamesSize).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCacheIsNotIgnored() throws Exception {
|
||||
addPackage(PACKAGE_NAME_1, 100, 1, 10, ApplicationInfo.CATEGORY_UNDEFINED);
|
||||
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> result = mLoader.loadInBackground();
|
||||
SparseArray<StorageAsyncLoader.StorageResult> result = mLoader.loadInBackground();
|
||||
|
||||
assertThat(result.size()).isEqualTo(1);
|
||||
assertThat(result.get(PRIMARY_USER_ID).otherAppsSize).isEqualTo(111L);
|
||||
assertThat(result.get(PRIMARY_USER_ID).allAppsExceptGamesSize).isEqualTo(111L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -152,7 +152,7 @@ public class StorageAsyncLoaderTest {
|
||||
when(mSource.getExternalStorageStats(anyString(), eq(new UserHandle(SECONDARY_USER_ID))))
|
||||
.thenReturn(new StorageStatsSource.ExternalStorageStats(10, 3, 3, 4, 0));
|
||||
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> result = mLoader.loadInBackground();
|
||||
SparseArray<StorageAsyncLoader.StorageResult> result = mLoader.loadInBackground();
|
||||
|
||||
assertThat(result.size()).isEqualTo(2);
|
||||
assertThat(result.get(PRIMARY_USER_ID).externalStats.totalBytes).isEqualTo(9L);
|
||||
@@ -165,21 +165,10 @@ public class StorageAsyncLoaderTest {
|
||||
addPackage(PACKAGE_NAME_1, 100, 1, 10, ApplicationInfo.CATEGORY_UNDEFINED);
|
||||
systemApp.flags = ApplicationInfo.FLAG_SYSTEM & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
|
||||
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> result = mLoader.loadInBackground();
|
||||
SparseArray<StorageAsyncLoader.StorageResult> result = mLoader.loadInBackground();
|
||||
|
||||
assertThat(result.size()).isEqualTo(1);
|
||||
assertThat(result.get(PRIMARY_USER_ID).otherAppsSize).isEqualTo(111L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVideoAppsAreFiltered() throws Exception {
|
||||
addPackage(PACKAGE_NAME_1, 0, 1, 10, ApplicationInfo.CATEGORY_VIDEO);
|
||||
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> result = mLoader.loadInBackground();
|
||||
|
||||
assertThat(result.size()).isEqualTo(1);
|
||||
// Code size is not included for file based video category.
|
||||
assertThat(result.get(PRIMARY_USER_ID).videoAppsSize).isEqualTo(10L);
|
||||
assertThat(result.get(PRIMARY_USER_ID).allAppsExceptGamesSize).isEqualTo(111L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -191,44 +180,20 @@ public class StorageAsyncLoaderTest {
|
||||
when(mSource.getStatsForPackage(anyString(), anyString(), any(UserHandle.class)))
|
||||
.thenThrow(new NameNotFoundException());
|
||||
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> result = mLoader.loadInBackground();
|
||||
SparseArray<StorageAsyncLoader.StorageResult> result = mLoader.loadInBackground();
|
||||
|
||||
// Should not crash.
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPackageIsNotDoubleCounted() throws Exception {
|
||||
UserInfo info = new UserInfo();
|
||||
info.id = SECONDARY_USER_ID;
|
||||
mUsers.add(info);
|
||||
when(mSource.getExternalStorageStats(anyString(), eq(UserHandle.SYSTEM)))
|
||||
.thenReturn(new StorageStatsSource.ExternalStorageStats(9, 2, 3, 4, 0));
|
||||
when(mSource.getExternalStorageStats(anyString(), eq(new UserHandle(SECONDARY_USER_ID))))
|
||||
.thenReturn(new StorageStatsSource.ExternalStorageStats(10, 3, 3, 4, 0));
|
||||
addPackage(PACKAGE_NAME_1, 0, 1, 10, ApplicationInfo.CATEGORY_VIDEO);
|
||||
ArrayList<ApplicationInfo> secondaryUserApps = new ArrayList<>();
|
||||
ApplicationInfo appInfo = new ApplicationInfo();
|
||||
appInfo.packageName = PACKAGE_NAME_1;
|
||||
appInfo.category = ApplicationInfo.CATEGORY_VIDEO;
|
||||
secondaryUserApps.add(appInfo);
|
||||
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> result = mLoader.loadInBackground();
|
||||
|
||||
assertThat(result.size()).isEqualTo(2);
|
||||
// Code size is not included for file based video category.
|
||||
assertThat(result.get(PRIMARY_USER_ID).videoAppsSize).isEqualTo(10L);
|
||||
// No code size for the second user.
|
||||
assertThat(result.get(SECONDARY_USER_ID).videoAppsSize).isEqualTo(10L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCacheOveragesAreCountedAsFree() throws Exception {
|
||||
addPackage(PACKAGE_NAME_1, DEFAULT_QUOTA + 100, 1, 10, ApplicationInfo.CATEGORY_UNDEFINED);
|
||||
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> result = mLoader.loadInBackground();
|
||||
SparseArray<StorageAsyncLoader.StorageResult> result = mLoader.loadInBackground();
|
||||
|
||||
assertThat(result.size()).isEqualTo(1);
|
||||
assertThat(result.get(PRIMARY_USER_ID).otherAppsSize).isEqualTo(DEFAULT_QUOTA + 11);
|
||||
assertThat(result.get(PRIMARY_USER_ID).allAppsExceptGamesSize)
|
||||
.isEqualTo(DEFAULT_QUOTA + 11);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -237,10 +202,10 @@ public class StorageAsyncLoaderTest {
|
||||
addPackage(PACKAGE_NAME_2, 0, 1, 10, ApplicationInfo.CATEGORY_VIDEO);
|
||||
addPackage(PACKAGE_NAME_3, 0, 1, 10, ApplicationInfo.CATEGORY_AUDIO);
|
||||
|
||||
SparseArray<StorageAsyncLoader.AppsStorageResult> result = mLoader.loadInBackground();
|
||||
SparseArray<StorageAsyncLoader.StorageResult> result = mLoader.loadInBackground();
|
||||
|
||||
assertThat(result.size()).isEqualTo(1);
|
||||
assertThat(result.get(PRIMARY_USER_ID).otherAppsSize).isEqualTo(33L);
|
||||
assertThat(result.get(PRIMARY_USER_ID).allAppsExceptGamesSize).isEqualTo(33L);
|
||||
}
|
||||
|
||||
private ApplicationInfo addPackage(String packageName, long cacheSize, long codeSize,
|
||||
|
||||
@@ -153,6 +153,7 @@ public class ProviderModelSliceTest {
|
||||
|
||||
assertThat(slice).isNotNull();
|
||||
verify(mListBuilder, times(1)).addRow(mMockCarrierRowBuild);
|
||||
assertThat(mMockProviderModelSlice.hasSeeAllRow()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -166,11 +167,12 @@ public class ProviderModelSliceTest {
|
||||
|
||||
assertThat(slice).isNotNull();
|
||||
verify(mListBuilder, times(1)).addRow(mMockCarrierRowBuild);
|
||||
assertThat(mMockProviderModelSlice.hasSeeAllRow()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void getSlice_haveTwoWifiAndOneCarrier_getCarrierAndTwoWiFi() {
|
||||
public void getSlice_haveTwoWifiAndOneCarrier_getCarrierAndTwoWiFiAndSeeAll() {
|
||||
mWifiList.clear();
|
||||
mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1",
|
||||
WifiEntry.CONNECTED_STATE_CONNECTED, "wifi1_key", true);
|
||||
@@ -185,12 +187,13 @@ public class ProviderModelSliceTest {
|
||||
|
||||
assertThat(slice).isNotNull();
|
||||
verify(mListBuilder, times(1)).addRow(mMockCarrierRowBuild);
|
||||
verify(mListBuilder, times(3)).addRow(any(ListBuilder.RowBuilder.class));
|
||||
verify(mListBuilder, times(4)).addRow(any(ListBuilder.RowBuilder.class));
|
||||
assertThat(mMockProviderModelSlice.hasSeeAllRow()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void getSlice_haveOneConnectedWifiAndTwoDisconnectedWifiAndNoCarrier_getTwoRow() {
|
||||
public void getSlice_haveOneConnectedWifiAndTwoDisconnectedWifiAndNoCarrier_getFourRow() {
|
||||
mWifiList.clear();
|
||||
mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1",
|
||||
WifiEntry.CONNECTED_STATE_CONNECTED, "wifi1_key", true);
|
||||
@@ -207,12 +210,13 @@ public class ProviderModelSliceTest {
|
||||
final Slice slice = mMockProviderModelSlice.getSlice();
|
||||
|
||||
assertThat(slice).isNotNull();
|
||||
verify(mListBuilder, times(3)).addRow(any(ListBuilder.RowBuilder.class));
|
||||
verify(mListBuilder, times(4)).addRow(any(ListBuilder.RowBuilder.class));
|
||||
assertThat(mMockProviderModelSlice.hasSeeAllRow()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void getSlice_haveTwoDisconnectedWifiAndNoCarrier_getTwoRow() {
|
||||
public void getSlice_haveTwoDisconnectedWifiAndNoCarrier_getThreeRow() {
|
||||
mWifiList.clear();
|
||||
mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1",
|
||||
WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi1_key", true);
|
||||
@@ -226,12 +230,13 @@ public class ProviderModelSliceTest {
|
||||
final Slice slice = mMockProviderModelSlice.getSlice();
|
||||
|
||||
assertThat(slice).isNotNull();
|
||||
verify(mListBuilder, times(2)).addRow(any(ListBuilder.RowBuilder.class));
|
||||
verify(mListBuilder, times(3)).addRow(any(ListBuilder.RowBuilder.class));
|
||||
assertThat(mMockProviderModelSlice.hasSeeAllRow()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void getSlice_haveEthernetAndCarrierAndTwoDisconnectedWifi_getFourRow() {
|
||||
public void getSlice_haveEthernetAndCarrierAndTwoDisconnectedWifi_getFiveRow() {
|
||||
mWifiList.clear();
|
||||
mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1",
|
||||
WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi1_key", true);
|
||||
@@ -249,12 +254,13 @@ public class ProviderModelSliceTest {
|
||||
assertThat(slice).isNotNull();
|
||||
assertThat(mMockProviderModelSlice.hasCreateEthernetRow()).isTrue();
|
||||
verify(mListBuilder, times(1)).addRow(mMockCarrierRowBuild);
|
||||
verify(mListBuilder, times(4)).addRow(any(ListBuilder.RowBuilder.class));
|
||||
verify(mListBuilder, times(5)).addRow(any(ListBuilder.RowBuilder.class));
|
||||
assertThat(mMockProviderModelSlice.hasSeeAllRow()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void getSlice_haveEthernetAndCarrierAndConnectedWifiAndDisconnectedWifi_getFourRow() {
|
||||
public void getSlice_haveEthernetAndCarrierAndConnectedWifiAndDisconnectedWifi_getFiveRow() {
|
||||
mWifiList.clear();
|
||||
mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1",
|
||||
WifiEntry.CONNECTED_STATE_CONNECTED, "wifi1_key", true);
|
||||
@@ -272,7 +278,8 @@ public class ProviderModelSliceTest {
|
||||
assertThat(slice).isNotNull();
|
||||
assertThat(mMockProviderModelSlice.hasCreateEthernetRow()).isTrue();
|
||||
verify(mListBuilder, times(1)).addRow(mMockCarrierRowBuild);
|
||||
verify(mListBuilder, times(4)).addRow(any(ListBuilder.RowBuilder.class));
|
||||
verify(mListBuilder, times(5)).addRow(any(ListBuilder.RowBuilder.class));
|
||||
assertThat(mMockProviderModelSlice.hasSeeAllRow()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -334,6 +341,7 @@ public class ProviderModelSliceTest {
|
||||
public class MockProviderModelSlice extends ProviderModelSlice {
|
||||
private MockNetworkProviderWorker mNetworkProviderWorker;
|
||||
private boolean mHasCreateEthernetRow;
|
||||
private boolean mHasSeeAllRow;
|
||||
|
||||
MockProviderModelSlice(Context context, MockNetworkProviderWorker networkProviderWorker) {
|
||||
super(context);
|
||||
@@ -356,9 +364,19 @@ public class ProviderModelSliceTest {
|
||||
return super.createEthernetRow();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ListBuilder.RowBuilder getSeeAllRow() {
|
||||
mHasSeeAllRow = true;
|
||||
return super.getSeeAllRow();
|
||||
}
|
||||
|
||||
public boolean hasCreateEthernetRow() {
|
||||
return mHasCreateEthernetRow;
|
||||
}
|
||||
|
||||
public boolean hasSeeAllRow() {
|
||||
return mHasSeeAllRow;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.network;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.wifi.WifiManager;
|
||||
|
||||
import androidx.slice.SliceProvider;
|
||||
import androidx.slice.widget.SliceLiveData;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class TurnOnWifiSliceTest {
|
||||
|
||||
@Rule
|
||||
public MockitoRule mMocks = MockitoJUnit.rule();
|
||||
@Mock
|
||||
private WifiManager mWifiManager;
|
||||
|
||||
private Context mContext;
|
||||
private TurnOnWifiSlice mSlice;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
||||
|
||||
// Set-up specs for SliceMetadata.
|
||||
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
|
||||
mSlice = new TurnOnWifiSlice(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSlice_wifiEnabled_shouldBeNull() {
|
||||
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||
|
||||
assertThat(mSlice.getSlice()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSlice_wifiDisabled_shouldBeNotNull() {
|
||||
when(mWifiManager.isWifiEnabled()).thenReturn(false);
|
||||
|
||||
assertThat(mSlice.getSlice()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onNotifyChange_shouldSetWifiEnabled() {
|
||||
Intent intent = mSlice.getIntent();
|
||||
|
||||
mSlice.onNotifyChange(intent);
|
||||
|
||||
verify(mWifiManager).setWifiEnabled(true);
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Handler;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
@@ -61,19 +62,22 @@ public class InternetConnectivityPanelTest {
|
||||
ApplicationProvider.getApplicationContext(), "provider_internet_settings");
|
||||
public static final String TITLE_APM = ResourcesUtils.getResourcesString(
|
||||
ApplicationProvider.getApplicationContext(), "airplane_mode");
|
||||
public static final String SUBTITLE_WIFI_IS_TURNED_ON = ResourcesUtils.getResourcesString(
|
||||
ApplicationProvider.getApplicationContext(), "wifi_is_turned_on_subtitle");
|
||||
public static final String SUBTITLE_TEXT_WIFI_IS_OFF =
|
||||
ResourcesUtils.getResourcesString(ApplicationProvider.getApplicationContext(),
|
||||
"wifi_is_off");
|
||||
public static final String SUBTITLE_TEXT_TAP_A_NETWORK_TO_CONNECT =
|
||||
ResourcesUtils.getResourcesString(ApplicationProvider.getApplicationContext(),
|
||||
"tap_a_network_to_connect");
|
||||
public static final String BUTTON_SETTINGS = ResourcesUtils.getResourcesString(
|
||||
ApplicationProvider.getApplicationContext(), "settings_button");
|
||||
public static final String SUBTITLE_NON_CARRIER_NETWORK_UNAVAILABLE =
|
||||
ResourcesUtils.getResourcesString(ApplicationProvider.getApplicationContext(),
|
||||
"non_carrier_network_unavailable");
|
||||
public static final String SUBTITLE_ALL_NETWORK_UNAVAILABLE =
|
||||
ResourcesUtils.getResourcesString(ApplicationProvider.getApplicationContext(),
|
||||
"all_network_unavailable");
|
||||
public static final String BUTTON_TURN_ON_WIFI = ResourcesUtils.getResourcesString(
|
||||
ApplicationProvider.getApplicationContext(), "turn_on_wifi");
|
||||
public static final String BUTTON_TURN_OFF_WIFI = ResourcesUtils.getResourcesString(
|
||||
ApplicationProvider.getApplicationContext(), "turn_off_wifi");
|
||||
|
||||
@Rule
|
||||
public final MockitoRule mMocks = MockitoJUnit.rule();
|
||||
@@ -87,6 +91,8 @@ public class InternetConnectivityPanelTest {
|
||||
private WifiManager mWifiManager;
|
||||
@Mock
|
||||
private ProviderModelSliceHelper mProviderModelSliceHelper;
|
||||
@Mock
|
||||
private FragmentActivity mPanelActivity;
|
||||
|
||||
private Context mContext;
|
||||
private InternetConnectivityPanel mPanel;
|
||||
@@ -128,13 +134,21 @@ public class InternetConnectivityPanelTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSubTitle_apmOnWifiOn_shouldWifiIsTurnedOn() {
|
||||
public void getSubTitle_apmOnWifiOn_shouldBeNull() {
|
||||
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
|
||||
doReturn(true).when(mInternetUpdater).isWifiEnabled();
|
||||
|
||||
assertThat(mPanel.getSubTitle()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSubTitle_apmOffWifiOff_wifiIsOn() {
|
||||
doReturn(false).when(mInternetUpdater).isAirplaneModeOn();
|
||||
doReturn(false).when(mInternetUpdater).isWifiEnabled();
|
||||
|
||||
mPanel.updatePanelTitle();
|
||||
|
||||
assertThat(mPanel.getSubTitle()).isEqualTo(SUBTITLE_WIFI_IS_TURNED_ON);
|
||||
assertThat(mPanel.getSubTitle()).isEqualTo(SUBTITLE_TEXT_WIFI_IS_OFF);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -190,26 +204,17 @@ public class InternetConnectivityPanelTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCustomizedButtonTitle_apmOff_shouldBeSettings() {
|
||||
doReturn(false).when(mInternetUpdater).isAirplaneModeOn();
|
||||
|
||||
assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_SETTINGS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCustomizedButtonTitle_apmOnWifiOff_shouldBeNull() {
|
||||
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
|
||||
public void getCustomizedButtonTitle_wifiOff_turnOnWifi() {
|
||||
doReturn(false).when(mInternetUpdater).isWifiEnabled();
|
||||
|
||||
assertThat(mPanel.getCustomizedButtonTitle()).isNull();
|
||||
assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_TURN_ON_WIFI);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCustomizedButtonTitle_apmOnWifiOn_shouldBeSettings() {
|
||||
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
|
||||
public void getCustomizedButtonTitle_wifiOn_turnOffWifi() {
|
||||
doReturn(true).when(mInternetUpdater).isWifiEnabled();
|
||||
|
||||
assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_SETTINGS);
|
||||
assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_TURN_OFF_WIFI);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -227,92 +232,60 @@ public class InternetConnectivityPanelTest {
|
||||
public void getSlices_providerModelEnabled_containsNecessarySlices() {
|
||||
List<Uri> uris = mPanel.getSlices();
|
||||
|
||||
assertThat(uris).containsExactly(
|
||||
CustomSliceRegistry.PROVIDER_MODEL_SLICE_URI,
|
||||
CustomSliceRegistry.TURN_ON_WIFI_SLICE_URI);
|
||||
assertThat(uris).containsExactly(CustomSliceRegistry.PROVIDER_MODEL_SLICE_URI);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSeeMoreIntent_notNull() {
|
||||
assertThat(mPanel.getSeeMoreIntent()).isNotNull();
|
||||
public void getSeeMoreIntent_shouldBeNull() {
|
||||
assertThat(mPanel.getSeeMoreIntent()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onAirplaneModeOn_apmOff_onTitleChanged() {
|
||||
doReturn(false).when(mInternetUpdater).isAirplaneModeOn();
|
||||
clearInvocations(mPanelContentCallback);
|
||||
|
||||
mPanel.onAirplaneModeChanged(false);
|
||||
|
||||
verify(mPanelContentCallback).onTitleChanged();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onAirplaneModeOn_apmOnWifiOff_onTitleChanged() {
|
||||
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
|
||||
doReturn(false).when(mInternetUpdater).isWifiEnabled();
|
||||
clearInvocations(mPanelContentCallback);
|
||||
|
||||
mPanel.onAirplaneModeChanged(true);
|
||||
|
||||
verify(mPanelContentCallback).onTitleChanged();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onAirplaneModeOn_apmOnWifiOn_onHeaderChanged() {
|
||||
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
|
||||
public void onClickCustomizedButton_wifiOn_setWifiOff() {
|
||||
doReturn(true).when(mInternetUpdater).isWifiEnabled();
|
||||
|
||||
mPanel.onClickCustomizedButton(mPanelActivity);
|
||||
|
||||
verify(mWifiManager).setWifiEnabled(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onClickCustomizedButton_wifiOff_setWifiOn() {
|
||||
doReturn(false).when(mInternetUpdater).isWifiEnabled();
|
||||
|
||||
mPanel.onClickCustomizedButton(mPanelActivity);
|
||||
|
||||
verify(mWifiManager).setWifiEnabled(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onClickCustomizedButton_shouldNotFinishActivity() {
|
||||
mPanel.onClickCustomizedButton(mPanelActivity);
|
||||
|
||||
verify(mPanelActivity, never()).finish();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updatePanelTitle_onHeaderChanged() {
|
||||
clearInvocations(mPanelContentCallback);
|
||||
|
||||
mPanel.onAirplaneModeChanged(true);
|
||||
mPanel.updatePanelTitle();
|
||||
|
||||
verify(mPanelContentCallback).onHeaderChanged();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onAirplaneModeOn_onCustomizedButtonStateChanged() {
|
||||
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
|
||||
public void onWifiEnabledChanged_wifiOff_onCustomizedButtonStateChanged() {
|
||||
doReturn(false).when(mInternetUpdater).isWifiEnabled();
|
||||
clearInvocations(mPanelContentCallback);
|
||||
|
||||
mPanel.onAirplaneModeChanged(true);
|
||||
mPanel.onWifiEnabledChanged(false);
|
||||
|
||||
verify(mPanelContentCallback).onCustomizedButtonStateChanged();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onWifiEnabledChanged_apmOff_onTitleChanged() {
|
||||
doReturn(false).when(mInternetUpdater).isAirplaneModeOn();
|
||||
clearInvocations(mPanelContentCallback);
|
||||
|
||||
mPanel.onWifiEnabledChanged(false);
|
||||
|
||||
verify(mPanelContentCallback).onTitleChanged();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onWifiEnabledChanged_apmOnWifiOff_onTitleChanged() {
|
||||
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
|
||||
doReturn(false).when(mInternetUpdater).isWifiEnabled();
|
||||
clearInvocations(mPanelContentCallback);
|
||||
|
||||
mPanel.onWifiEnabledChanged(true);
|
||||
|
||||
verify(mPanelContentCallback).onTitleChanged();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onWifiEnabledChanged_apmOnWifiOn_onHeaderChanged() {
|
||||
doReturn(true).when(mInternetUpdater).isAirplaneModeOn();
|
||||
doReturn(true).when(mInternetUpdater).isWifiEnabled();
|
||||
clearInvocations(mPanelContentCallback);
|
||||
|
||||
mPanel.onWifiEnabledChanged(true);
|
||||
|
||||
verify(mPanelContentCallback).onHeaderChanged();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onWifiEnabledChanged_onCustomizedButtonStateChanged() {
|
||||
public void onWifiEnabledChanged_wifiOn_onCustomizedButtonStateChanged() {
|
||||
doReturn(true).when(mInternetUpdater).isWifiEnabled();
|
||||
clearInvocations(mPanelContentCallback);
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.DisplaySettings;
|
||||
import com.android.settings.backup.UserBackupSettingsActivity;
|
||||
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
|
||||
import com.android.settings.connecteddevice.usb.UsbDetailsFragment;
|
||||
@@ -36,7 +35,6 @@ import com.android.settings.notification.zen.ZenModeRestrictNotificationsSetting
|
||||
import com.android.settings.security.SecuritySettings;
|
||||
import com.android.settings.security.screenlock.ScreenLockSettings;
|
||||
import com.android.settings.system.SystemDashboardFragment;
|
||||
import com.android.settings.wallpaper.WallpaperSuggestionActivity;
|
||||
import com.android.settings.wifi.WifiSettings;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -51,13 +49,6 @@ public class CustomSiteMapRegistryTest {
|
||||
.isEqualTo(SecuritySettings.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldContainWallpaperSuggestionActivityPairs() {
|
||||
assertThat(CustomSiteMapRegistry.CUSTOM_SITE_MAP.get(
|
||||
WallpaperSuggestionActivity.class.getName()))
|
||||
.isEqualTo(DisplaySettings.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldContainWifiSettingsPairs() {
|
||||
assertThat(CustomSiteMapRegistry.CUSTOM_SITE_MAP.get(WifiSettings.class.getName()))
|
||||
|
||||
Reference in New Issue
Block a user