Merge "Remove period on "Fingerprint added" screen" into pi-dev
diff --git a/res/color/white_disabled.xml b/res/color/white_disabled.xml
deleted file mode 100644
index 17008a8..0000000
--- a/res/color/white_disabled.xml
+++ /dev/null
@@ -1,20 +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.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:color="@android:color/white"
- android:alpha="?android:attr/disabledAlpha" />
-</selector>
diff --git a/res/drawable/data_usage_progress.xml b/res/drawable/color_bar_progress.xml
similarity index 72%
rename from res/drawable/data_usage_progress.xml
rename to res/drawable/color_bar_progress.xml
index 46b9a12..d277467 100644
--- a/res/drawable/data_usage_progress.xml
+++ b/res/drawable/color_bar_progress.xml
@@ -16,19 +16,19 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape android:shape="rectangle"
- android:tint="?android:attr/colorControlActivated">
- <corners android:radius="5dp" />
+ android:tint="@*android:color/config_progress_background_tint">
+ <corners android:radius="@*android:dimen/config_progressBarCornerRadius" />
<size android:height="10dp" />
- <solid android:color="@color/white_disabled" />
+ <solid android:color="@*android:color/white_disabled_material" />
</shape>
- </item>
+ </item>r
<item android:id="@android:id/secondaryProgress">
<scale android:scaleWidth="100%">
<shape android:shape="rectangle"
android:tint="?android:attr/colorControlActivated">
- <corners android:radius="5dp" />
+ <corners android:radius="@*android:dimen/config_progressBarCornerRadius" />
<size android:height="10dp" />
- <solid android:color="@color/white_disabled" />
+ <solid android:color="@*android:color/white_disabled_material" />
</shape>
</scale>
</item>
@@ -36,9 +36,9 @@
<scale android:scaleWidth="100%">
<shape android:shape="rectangle"
android:tint="?android:attr/colorControlActivated">
- <corners android:radius="5dp" />
+ <corners android:radius="@*android:dimen/config_progressBarCornerRadius" />
<size android:height="10dp" />
- <solid android:color="@android:color/black" />
+ <solid android:color="@android:color/white" />
</shape>
</scale>
</item>
diff --git a/res/drawable/ring_progress.xml b/res/drawable/ring_progress.xml
index 02fcd5b..346ff5f 100644
--- a/res/drawable/ring_progress.xml
+++ b/res/drawable/ring_progress.xml
@@ -22,7 +22,7 @@
android:thickness="@dimen/ring_progress_bar_thickness"
android:useLevel="false"
android:tint="?android:colorControlNormal">
- <solid android:color="@color/white_disabled" />
+ <solid android:color="@*android:color/white_disabled_material" />
</shape>
</item>
<item android:id="@android:id/progress">
diff --git a/res/layout/data_usage_summary_preference.xml b/res/layout/data_usage_summary_preference.xml
index 384ed8c..bd13d80 100644
--- a/res/layout/data_usage_summary_preference.xml
+++ b/res/layout/data_usage_summary_preference.xml
@@ -18,7 +18,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingTop="24dp"
+ android:paddingTop="22dp"
android:paddingBottom="32dp"
android:paddingStart="@dimen/preference_no_icon_padding_start"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
@@ -31,8 +31,7 @@
android:id="@+id/usage_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceListItemSecondary"
- android:textColor="?android:attr/textColorSecondary"
+ android:textColor="?android:attr/colorAccent"
android:text="@string/data_usage_title" />
<LinearLayout
@@ -40,7 +39,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
- android:paddingBottom="4dp"
android:orientation="horizontal">
<TextView android:id="@+id/data_usage_view"
@@ -70,15 +68,14 @@
android:id="@+id/determinateBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
- android:layout_height="10dp"
- android:progressDrawable="@drawable/data_usage_progress"/>
+ android:layout_height="wrap_content"
+ android:progressDrawable="@drawable/color_bar_progress"/>
<LinearLayout
android:id="@+id/label_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="4dp"
- android:paddingBottom="8dp"
android:orientation="horizontal">
<TextView android:id="@android:id/text1"
@@ -100,32 +97,38 @@
</LinearLayout>
- <TextView
- android:id="@+id/cycle_left_time"
- android:paddingTop="4dp"
+ <LinearLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content" />
+ android:layout_height="wrap_content"
+ android:paddingTop="12dp"
+ android:orientation="vertical">
- <TextView
- android:id="@+id/carrier_and_update"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
+ <TextView
+ android:id="@+id/data_limits"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textColor="?android:attr/textColorSecondary" />
+
+ <TextView
+ android:id="@+id/cycle_left_time"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <TextView
+ android:id="@+id/carrier_and_update"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ </LinearLayout>
<Button
android:id="@+id/launch_mdp_app_button"
- android:paddingTop="12dp"
+ android:layout_marginTop="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="left"
+ android:layout_gravity="start"
android:text="@string/launch_mdp_app_text"
style="@style/ActionPrimaryButton" />
- <TextView
- android:id="@+id/data_limits"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingBottom="5dp"
- android:textColor="?android:attr/textColorSecondary" />
-
</LinearLayout>
diff --git a/res/layout/master_clear.xml b/res/layout/master_clear.xml
index d328478..c1e224f 100644
--- a/res/layout/master_clear.xml
+++ b/res/layout/master_clear.xml
@@ -116,6 +116,7 @@
</LinearLayout>
</LinearLayout>
<include layout="@layout/reset_esim_checkbox"
+ android:layout_marginTop="40dp"
android:id="@+id/erase_esim_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
diff --git a/res/layout/preference_widget_radiobutton.xml b/res/layout/preference_widget_radiobutton.xml
index b3ec43d..b35e644 100644
--- a/res/layout/preference_widget_radiobutton.xml
+++ b/res/layout/preference_widget_radiobutton.xml
@@ -21,5 +21,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
+ android:background="@null"
android:focusable="false"
android:clickable="false" />
diff --git a/res/layout/reset_esim_checkbox.xml b/res/layout/reset_esim_checkbox.xml
index d830bf4..fb15fe6 100644
--- a/res/layout/reset_esim_checkbox.xml
+++ b/res/layout/reset_esim_checkbox.xml
@@ -30,6 +30,7 @@
android:paddingEnd="@dimen/reset_checkbox_padding_end"
android:focusable="false"
android:clickable="false"
+ android:checked="true"
android:duplicateParentState="true" />
<LinearLayout
diff --git a/res/layout/running_processes_header.xml b/res/layout/running_processes_header.xml
index ac31543..a696b38 100644
--- a/res/layout/running_processes_header.xml
+++ b/res/layout/running_processes_header.xml
@@ -36,11 +36,12 @@
android:gravity="left|center_vertical"
android:text="@string/running_processes_header_title" />
- <view class="com.android.settings.widget.LinearColorBar"
+ <ProgressBar
android:id="@+id/color_bar"
+ style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
- android:layout_height="16sp"
- android:orientation="horizontal" />
+ android:layout_height="wrap_content"
+ android:progressDrawable="@drawable/color_bar_progress"/>
<LinearLayout
android:layout_width="match_parent"
diff --git a/res/layout/settings_summary_preference.xml b/res/layout/settings_summary_preference.xml
index 1340571..ae3b70d 100644
--- a/res/layout/settings_summary_preference.xml
+++ b/res/layout/settings_summary_preference.xml
@@ -42,11 +42,12 @@
android:paddingBottom="5dp"
android:maxLines="10" />
- <com.android.settings.widget.LinearColorBar
+ <ProgressBar
android:id="@+id/color_bar"
+ style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
- android:layout_height="28dp"
- />
+ android:layout_height="wrap_content"
+ android:progressDrawable="@drawable/color_bar_progress"/>
<LinearLayout
android:id="@+id/label_bar"
diff --git a/res/values-sw400dp/config.xml b/res/values-sw320dp/config.xml
similarity index 100%
rename from res/values-sw400dp/config.xml
rename to res/values-sw320dp/config.xml
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index e326dbe..5c3dc8f 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1070,7 +1070,7 @@
</string-array>
<string-array name="wifi_metered_entries">
- <item>Use network preference</item>
+ <item>Detect automatically</item>
<item>Treat as metered</item>
<item>Treat as unmetered</item>
</string-array>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 98ea269..5810569 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -401,6 +401,10 @@
<!-- Summary of checkbox for disabling Bluetooth inband ringing in Development Settings -->
<string name="bluetooth_disable_inband_ringing_summary">Don’t play custom phone ringtones on Bluetooth headsets</string>
+ <!-- Title for Bluetooth device group with media capability group [CHAR LIMIT=none]-->
+ <string name="connected_device_available_media_title">Available media devices</string>
+ <!-- Title for Bluetooth device group with media capability group [CHAR LIMIT=none]-->
+ <string name="connected_device_available_call_title">Available call devices</string>
<!-- Title for connected device group [CHAR LIMIT=none]-->
<string name="connected_device_connected_title">Currently connected</string>
<!-- Title for connected device group [CHAR LIMIT=none]-->
@@ -411,6 +415,8 @@
<string name="connected_device_add_device_summary">Bluetooth will turn on to enable pairing</string>
<!-- Title for other connection preferences [CHAR LIMIT=none]-->
<string name="connected_device_connections_title">Connection preferences</string>
+ <!-- Title for Bluetooth preference to open paired but no connection list [CHAR LIMIT=none]-->
+ <string name="connected_device_previously_connected_title">Previously connected devices</string>
<!-- Date & time settings screen title -->
<string name="date_and_time">Date & time</string>
@@ -805,7 +811,7 @@
<!-- Text shown for the title of the lockdown option -->
<string name="lockdown_settings_title">Show lockdown option</string>
<!-- Text shown for the description of the lockdown option -->
- <string name="lockdown_settings_summary">Display power button option that turns off extended access and fingerprint unlocking.</string>
+ <string name="lockdown_settings_summary">Display power button option that turns off Smart Lock, fingerprint unlocking, and notifications on the lock screen</string>
<!-- Text shown for summary of owner info setting (if none set) [CHAR LIMIT=40]-->
<string name="owner_info_settings_summary">None</string>
<!-- Description of how many characters are used in owner info [CHAR LIMIT=40]-->
@@ -3218,7 +3224,7 @@
<!-- SD card & phone storage settings screen, message on screen after user selects Reset network settings [CHAR LIMIT=NONE] -->
<string name="reset_network_desc">This will reset all network settings, including:\n\n<li>Wi\u2011Fi</li>\n<li>Mobile data</li>\n<li>Bluetooth</li>"</string>
<!-- SD card & phone storage settings screen, title for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=NONE] -->
- <string name="reset_esim_title">Also reset eSIMs</string>
+ <string name="reset_esim_title">Also reset eSIM</string>
<!-- SD card & phone storage settings screen, message for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=NONE] -->
<string name="reset_esim_desc">Erase all eSIMs on the phone. You\u2019ll have to contact your carrier to redownload your eSIMs. This will not cancel your mobile service plan.</string>
<!-- SD card & phone storage settings screen, button on screen after user selects Reset network settings -->
@@ -3268,7 +3274,7 @@
<!-- SD card & phone storage settings screen, description for check box to erase USB storage [CHAR LIMIT=NONE] -->
<string name="erase_external_storage_description" product="default">Erase all the data on the SD card, such as music or photos</string>
<!-- SD card & phone storage settings screen, label for check box to erase all the carriers information on the embedded SIM card [CHAR LIMIT=30] -->
- <string name="erase_esim_storage">Erase eSIMs</string>
+ <string name="erase_esim_storage">Erase eSIM</string>
<!-- SD card & phone storage settings screen, description for check box to erase eSIMs for default devices [CHAR LIMIT=NONE] -->
<string name="erase_esim_storage_description" product="default">Erase all eSIMs on the phone. This will not cancel your mobile service plan.</string>
<!-- SD card & phone storage settings screen, description for check box to erase eSIMs for tablets [CHAR LIMIT=NONE] -->
@@ -4428,6 +4434,10 @@
<string name="accessibility_summary_state_enabled">On</string>
<!-- Preference's state when disabled. -->
<string name="accessibility_summary_state_disabled">Off</string>
+ <!-- Accessibility service's preference's state when enabled but not running (like maybe it crashed). -->
+ <string name="accessibility_summary_state_stopped">Not working. Tap for info.</string>
+ <!-- Accessibility service's description when enabled but not running (like maybe it crashed). -->
+ <string name="accessibility_description_state_stopped">This service is malfunctioning.</string>
<!-- Title for the preference to show a tile for a particular feature in the Quick Settings pane. [CHAR LIMIT=NONE] -->
<string name="enable_quick_setting">Show in Quick Settings</string>
@@ -4932,6 +4942,16 @@
<!-- Summary for auto restriction toggle -->
<string name="battery_auto_restriction_summary">Prevent apps from using extra battery in the background</string>
+ <!-- Summary for battery manager when it is on -->
+ <string name="battery_manager_on">On / Restricting apps automatically</string>
+ <!-- Summary for battery manager when it is off -->
+ <string name="battery_manager_off">Off</string>
+ <!-- Summary for battery manager, showing app restricted -->
+ <plurals name="battery_manager_app_restricted">
+ <item quantity="one">%1$d app restricted</item>
+ <item quantity="other">%1$d apps restricted</item>
+ </plurals>
+
<!-- Title for force stop dialog [CHAR LIMIT=30] -->
<string name="dialog_stop_title">Stop app?</string>
<!-- Message body for force stop dialog [CHAR LIMIT=NONE] -->
@@ -5188,7 +5208,7 @@
<string name="battery_saver_auto_title">Turn on automatically</string>
<!-- Battery saver: Label for seekbar to change battery saver threshold [CHAR_LIMIT=40] -->
- <string name="battery_saver_seekbar_title">Turn on automatically at <xliff:g id="percent">%1$s</xliff:g></string>
+ <string name="battery_saver_seekbar_title">Turn on at <xliff:g id="percent">%1$s</xliff:g></string>
<!-- Used in the Battery Saver settings screen to control turning on/off the feature entirely -->
<string name="battery_saver_master_switch_title">Use Battery Saver</string>
@@ -7154,6 +7174,9 @@
<!-- Configure Notifications: Title for the option controlling notifications on the lockscreen. [CHAR LIMIT=30] -->
<string name="lock_screen_notifications_title">On lock screen</string>
+ <!-- Configure Notifications: Title for the option controlling notifications for work profile. [CHAR LIMIT=30] -->
+ <string name="locked_work_profile_notification_title">When work profile is locked</string>
+
<!-- Configure Notifications: Value for lockscreen notifications: all information will be
shown in notifications shown on a secure lock screen
[CHAR LIMIT=50] -->
@@ -7184,10 +7207,6 @@
[CHAR LIMIT=50] -->
<string name="lock_screen_notifications_summary_hide_profile">Hide sensitive work content</string>
- <!-- Configure Notifications: Value for lockscreen notifications: work notifications will not appear on a secure lock screen
- [CHAR LIMIT=50] -->
- <string name="lock_screen_notifications_summary_disable_profile">Don\u2019t show work notifications at all</string>
-
<!-- Security > Choose PIN/PW/Pattern > Notification redaction interstitial: Message asking the user how they want their profile notifications to appear when the device is locked [CHAR LIMIT=NONE] -->
<string name="lock_screen_notifications_interstitial_message_profile">When your device is locked, how do you want profile notifications to show?</string>
@@ -8368,8 +8387,6 @@
<string name="system_alert_window_access_title">Display over other apps</string>
<!-- Label for setting which controls whether app can display over other apps [CHAR LIMIT=45] -->
<string name="permit_draw_overlay">Allow display over other apps</string>
- <!-- Link to the apps page for SYSTEM_ALERT_WINDOW settings [CHAR LIMIT=45] -->
- <string name="app_overlay_permission_preference">App display on top permission</string>
<!-- Description of allowing overlay setting [CHAR LIMIT=NONE] -->
<string name="allow_overlay_description">Allow this app to display on top of other apps you\u2019re using. It may interfere with your use of those apps or change the way they seem to appear or behave.</string>
@@ -8411,8 +8428,6 @@
<string name="write_settings_title">Can modify system settings</string>
<!-- Main settings screen item's title to go into the write system settings screen [CHAR LIMIT=30] -->
<string name="write_system_settings">Modify system settings</string>
- <!-- Link to the apps page for WRITE_SETTINGS settings [CHAR LIMIT=52] -->
- <string name="write_settings_preference">App modify system settings permission</string>
<!-- Label for setting which controls whether app can write system settings [CHAR LIMIT=45] -->
<string name="permit_write_settings">Allow modifying system settings</string>
<!-- Description of the write system settings [CHAR LIMIT=NONE] -->
@@ -8582,7 +8597,7 @@
<string name="condition_airplane_title">Airplane mode is on</string>
<!-- Summary of condition that airplane mode is on [CHAR LIMIT=NONE] -->
- <string name="condition_airplane_summary">Wi-Fi, Bluetooth, and mobile network are turned off. You can\'t make phone calls or connect to the internet.</string>
+ <string name="condition_airplane_summary">When airplane mode is turned on, Wi\u2011Fi, Bluetooth, and mobile network are turned off. Wi\u2011Fi and Bluetooth can be turned back on.</string>
<!-- Title of condition that do not disturb is on [CHAR LIMIT=36] -->
<string name="condition_zen_title">Do Not Disturb is on</string>
@@ -8811,7 +8826,7 @@
<string name="no_carrier_update_text">Updated <xliff:g name="time" example="3m">%1$s</xliff:g></string>
<!-- Button to launch external data plan app [CHAR LIMIT=30] -->
- <string name="launch_mdp_app_text">VIEW PLAN</string>
+ <string name="launch_mdp_app_text">View plan</string>
<!-- Name of Data Saver screens [CHAR LIMIT=30] -->
<string name="data_saver_title">Data saver</string>
@@ -8893,6 +8908,9 @@
<!-- [CHAR LIMIT=30] Title for dialog for setting to control the default spell checker -->
<string name="choose_spell_checker">Choose spell checker</string>
+ <!-- [CHAR LIMIT=45] Title for the master switch for spell checker, turning off will disable entire spell check feature. -->
+ <string name="spell_checker_master_switch_title">Use spell checker</string>
+
<!-- [CHAR LIMIT=30] Label for the placeholder of the current spell checker name. Used when no spell checker is currently selected. -->
<string name="spell_checker_not_selected">Not selected</string>
@@ -9531,6 +9549,9 @@
<!-- Summary for media output settings when the media stream is being captured by something else. -->
<string name="media_output_summary_unavailable">Unavailable</string>
+ <!-- Title for HFP(hands free profile) output switch button in settings. -->
+ <string name="take_call_on_title">Take call on</string>
+
<!-- Title for battery Suggestion. (tablet) [CHAR LIMIT=46] -->
<string name="battery_suggestion_title" product="tablet" >Improve tablet\'s battery life</string>
<!-- Title for battery Suggestion. (device) [CHAR LIMIT=46] -->
diff --git a/res/xml/app_ops_permissions_details.xml b/res/xml/app_ops_permissions_details.xml
index 743090f..cb8711c 100644
--- a/res/xml/app_ops_permissions_details.xml
+++ b/res/xml/app_ops_permissions_details.xml
@@ -21,9 +21,6 @@
android:key="app_ops_settings_switch" />
<Preference
- android:key="app_ops_settings_preference" />
-
- <Preference
android:key="app_ops_settings_description"
android:selectable="false" />
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index 598b110..d7153ef 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -89,10 +89,9 @@
<com.android.settings.RestrictedListPreference
android:key="lock_screen_notifications_profile"
- android:title="@string/lock_screen_notifications_title"
+ android:title="@string/locked_work_profile_notification_title"
android:summary="@string/summary_placeholder"
android:order="24"/>
-
</PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/date_time_prefs.xml b/res/xml/date_time_prefs.xml
index 5219caa..bc11908 100644
--- a/res/xml/date_time_prefs.xml
+++ b/res/xml/date_time_prefs.xml
@@ -58,7 +58,7 @@
android:fragment="com.android.settings.datetime.ZonePicker"
android:key="timezone"
android:title="@string/date_time_set_timezone"
- android:summary="GMT-8:00"
+ android:summary="@string/summary_placeholder"
settings:userRestriction="no_config_date_time" />
</PreferenceCategory>
diff --git a/res/xml/draw_overlay_permissions_details.xml b/res/xml/draw_overlay_permissions_details.xml
index 699086f..3e7bec5 100644
--- a/res/xml/draw_overlay_permissions_details.xml
+++ b/res/xml/draw_overlay_permissions_details.xml
@@ -23,10 +23,6 @@
android:title="@string/permit_draw_overlay"/>
<Preference
- android:key="app_ops_settings_preference"
- android:title="@string/app_overlay_permission_preference"/>
-
- <Preference
android:summary="@string/allow_overlay_description"
android:selectable="false"/>
diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml
index d616bb6..22079bf 100644
--- a/res/xml/location_settings.xml
+++ b/res/xml/location_settings.xml
@@ -31,33 +31,37 @@
android:selectable="true"
android:fragment="com.android.settings.location.RecentLocationRequestSeeAllFragment"/>
- <!-- This preference category gets removed if new_recent_location_ui is disabled -->
- <Preference
- android:key="app_level_permissions"
- android:title="@string/location_app_level_permissions"
- settings:allowDividerAbove="true">
- <intent android:action="android.intent.action.MANAGE_PERMISSION_APPS">
- <extra android:name="android.intent.extra.PERMISSION_NAME"
- android:value="android.permission-group.LOCATION" />
- </intent>
- </Preference>
-
- <Preference
- android:key="location_scanning"
- android:title="@string/location_scanning_screen_title"
- android:fragment="com.android.settings.location.ScanningSettings"/>
-
- <!-- This preference gets removed if there is no managed profile -->
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="managed_profile_location_switch"
- android:title="@string/managed_profile_location_switch_title"
- settings:useAdminDisabledSummary="true"
- android:enabled="false"
- android:selectable="true" />
-
<PreferenceCategory
- android:key="location_services"
- android:title="@string/location_category_location_services"/>
+ android:key="location_advanced_settings"
+ settings:initialExpandedChildrenCount="1">
+
+ <!-- This preference category gets removed if new_recent_location_ui is disabled -->
+ <Preference
+ android:key="app_level_permissions"
+ android:title="@string/location_app_level_permissions">
+ <intent android:action="android.intent.action.MANAGE_PERMISSION_APPS">
+ <extra android:name="android.intent.extra.PERMISSION_NAME"
+ android:value="android.permission-group.LOCATION" />
+ </intent>
+ </Preference>
+
+ <Preference
+ android:key="location_scanning"
+ android:title="@string/location_scanning_screen_title"
+ android:fragment="com.android.settings.location.ScanningSettings"/>
+
+ <!-- This preference gets removed if there is no managed profile -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="managed_profile_location_switch"
+ android:title="@string/managed_profile_location_switch_title"
+ settings:useAdminDisabledSummary="true"
+ android:enabled="false"
+ android:selectable="true" />
+
+ <PreferenceCategory
+ android:key="location_services"
+ android:title="@string/location_category_location_services"/>
+ </PreferenceCategory>
<PreferenceCategory
android:key="location_footer"
diff --git a/res/xml/power_usage_summary.xml b/res/xml/power_usage_summary.xml
index ac96151..1f3e415 100644
--- a/res/xml/power_usage_summary.xml
+++ b/res/xml/power_usage_summary.xml
@@ -33,16 +33,18 @@
<PreferenceCategory
android:key="power_management">
- <com.android.settings.widget.MasterSwitchPreference
+ <Preference
android:fragment="com.android.settings.fuelgauge.batterysaver.BatterySaverSettings"
android:key="battery_saver_summary"
android:title="@string/battery_saver"
- settings:controller="com.android.settings.fuelgauge.BatterySaverController"/>
+ settings:controller="com.android.settings.fuelgauge.BatterySaverController"
+ settings:platform_slice="true"/>
<Preference
android:fragment="com.android.settings.fuelgauge.SmartBatterySettings"
android:key="smart_battery_manager"
- android:title="@string/smart_battery_manager_title"/>
+ android:title="@string/smart_battery_manager_title"
+ settings:controller="com.android.settings.fuelgauge.batterytip.BatteryManagerPreferenceController"/>
<SwitchPreference
android:key="battery_percentage"
diff --git a/res/xml/security_lockscreen_settings.xml b/res/xml/security_lockscreen_settings.xml
index 3d3bfd0..5b313b3 100644
--- a/res/xml/security_lockscreen_settings.xml
+++ b/res/xml/security_lockscreen_settings.xml
@@ -46,7 +46,7 @@
<com.android.settings.RestrictedListPreference
android:key="security_setting_lock_screen_notif_work"
- android:title="@string/lock_screen_notifications_title"
+ android:title="@string/locked_work_profile_notification_title"
android:summary="@string/summary_placeholder" />
</PreferenceCategory>
diff --git a/res/xml/write_system_settings_permissions_details.xml b/res/xml/write_system_settings_permissions_details.xml
index 39d69833..82a6931 100644
--- a/res/xml/write_system_settings_permissions_details.xml
+++ b/res/xml/write_system_settings_permissions_details.xml
@@ -23,10 +23,6 @@
android:title="@string/permit_write_settings"/>
<Preference
- android:key="app_ops_settings_preference"
- android:title="@string/write_settings_preference"/>
-
- <Preference
android:summary="@string/write_settings_description"
android:selectable="false"/>
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index 46e0d41..766c6ae 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -357,7 +357,9 @@
return false;
}
ContentResolver cr = context.getContentResolver();
- return Settings.Global.getInt(cr, Settings.Global.EUICC_PROVISIONED, 0) != 0;
+ return Settings.Global.getInt(cr, Settings.Global.EUICC_PROVISIONED, 0) != 0
+ || Settings.Global.getInt(
+ cr, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
}
@VisibleForTesting
diff --git a/src/com/android/settings/SummaryPreference.java b/src/com/android/settings/SummaryPreference.java
index 23965ee..dbe036a 100644
--- a/src/com/android/settings/SummaryPreference.java
+++ b/src/com/android/settings/SummaryPreference.java
@@ -20,10 +20,9 @@
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
+import android.widget.ProgressBar;
import android.widget.TextView;
-import com.android.settings.widget.LinearColorBar;
-
/**
* Provides a summary of a setting page in a preference. Such as memory or data usage.
*/
@@ -33,8 +32,6 @@
private String mAmount;
private String mUnits;
- private int mLeft, mMiddle, mRight;
- private boolean mColorsSet = false;
private boolean mChartEnabled = true;
private float mLeftRatio, mMiddleRatio, mRightRatio;
private String mStartLabel;
@@ -81,26 +78,17 @@
notifyChanged();
}
- public void setColors(int left, int middle, int right) {
- mLeft = left;
- mMiddle = middle;
- mRight = right;
- mColorsSet = true;
- notifyChanged();
- }
-
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
- final LinearColorBar colorBar = holder.itemView.findViewById(R.id.color_bar);
+ final ProgressBar colorBar = holder.itemView.findViewById(R.id.color_bar);
if (mChartEnabled) {
colorBar.setVisibility(View.VISIBLE);
- colorBar.setRatios(mLeftRatio, mMiddleRatio, mRightRatio);
- if (mColorsSet) {
- colorBar.setColors(mLeft, mMiddle, mRight);
- }
+ int progress = (int) (mLeftRatio * 100);
+ colorBar.setProgress(progress);
+ colorBar.setSecondaryProgress(progress + (int) (mMiddleRatio * 100));
} else {
colorBar.setVisibility(View.GONE);
}
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 1091aea..5460946 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -976,8 +976,8 @@
public static Drawable getBadgedIcon(IconDrawableFactory iconDrawableFactory,
PackageManager packageManager, String packageName, int userId) {
try {
- final ApplicationInfo appInfo = packageManager.getApplicationInfo(packageName,
- PackageManager.GET_META_DATA);
+ final ApplicationInfo appInfo = packageManager.getApplicationInfoAsUser(
+ packageName, PackageManager.GET_META_DATA, userId);
return iconDrawableFactory.getBadgedIcon(appInfo, userId);
} catch (PackageManager.NameNotFoundException e) {
return packageManager.getDefaultActivityIcon();
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 2292ca2..ae36e0a 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -211,7 +211,6 @@
private SwitchPreference mToggleDisableAnimationsPreference;
private SwitchPreference mToggleMasterMonoPreference;
private ListPreference mSelectLongPressTimeoutPreference;
- private Preference mNoServicesMessagePreference;
private Preference mCaptioningPreferenceScreen;
private Preference mDisplayMagnificationPreferenceScreen;
private Preference mFontSizePreferenceScreen;
@@ -495,12 +494,12 @@
List<AccessibilityServiceInfo> installedServices =
accessibilityManager.getInstalledAccessibilityServiceList();
+ List<AccessibilityServiceInfo> enabledServiceInfos = accessibilityManager
+ .getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
Set<ComponentName> enabledServices = AccessibilityUtils.getEnabledServicesFromSettings(
getActivity());
List<String> permittedServices = mDpm.getPermittedAccessibilityServices(
UserHandle.myUserId());
- final boolean accessibilityEnabled = Settings.Secure.getInt(getContentResolver(),
- Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1;
PreferenceCategory downloadedServicesCategory =
mCategoryToPrefCategoryMap.get(CATEGORY_DOWNLOADED_SERVICES);
@@ -513,7 +512,7 @@
final AccessibilityServiceInfo info = installedServices.get(i);
final ResolveInfo resolveInfo = info.getResolveInfo();
- RestrictedPreference preference =
+ final RestrictedPreference preference =
new RestrictedPreference(downloadedServicesCategory.getContext());
final String title = resolveInfo.loadLabel(getPackageManager()).toString();
@@ -524,32 +523,44 @@
icon = resolveInfo.loadIcon(getPackageManager());
}
- ServiceInfo serviceInfo = resolveInfo.serviceInfo;
- String packageName = serviceInfo.packageName;
- ComponentName componentName = new ComponentName(packageName, serviceInfo.name);
+ final ServiceInfo serviceInfo = resolveInfo.serviceInfo;
+ final String packageName = serviceInfo.packageName;
+ final ComponentName componentName = new ComponentName(packageName, serviceInfo.name);
preference.setKey(componentName.flattenToString());
preference.setTitle(title);
Utils.setSafeIcon(preference, icon);
- final boolean serviceEnabled = accessibilityEnabled
- && enabledServices.contains(componentName);
- final String serviceState = serviceEnabled ?
- getString(R.string.accessibility_summary_state_enabled) :
- getString(R.string.accessibility_summary_state_disabled);
- final CharSequence serviceSummary = info.loadSummary(getPackageManager());
- final String stateSummaryCombo = getString(
- R.string.preference_summary_default_combination,
- serviceState, serviceSummary);
- preference.setSummary((TextUtils.isEmpty(serviceSummary)) ? serviceState
- : stateSummaryCombo);
+ final boolean serviceEnabled = enabledServices.contains(componentName);
+ String description = info.loadDescription(getPackageManager());
+ if (TextUtils.isEmpty(description)) {
+ description = getString(R.string.accessibility_service_default_description);
+ }
+
+ if (serviceEnabled && AccessibilityUtils.hasServiceCrashed(
+ packageName, serviceInfo.name, enabledServiceInfos)) {
+ // Update the summaries for services that have crashed.
+ preference.setSummary(R.string.accessibility_summary_state_stopped);
+ description = getString(R.string.accessibility_description_state_stopped);
+ } else {
+ final String serviceState = serviceEnabled ?
+ getString(R.string.accessibility_summary_state_enabled) :
+ getString(R.string.accessibility_summary_state_disabled);
+ final CharSequence serviceSummary = info.loadSummary(getPackageManager());
+ final String stateSummaryCombo = getString(
+ R.string.preference_summary_default_combination,
+ serviceState, serviceSummary);
+ preference.setSummary((TextUtils.isEmpty(serviceSummary)) ? serviceState
+ : stateSummaryCombo);
+ }
// Disable all accessibility services that are not permitted.
- boolean serviceAllowed =
+ final boolean serviceAllowed =
permittedServices == null || permittedServices.contains(packageName);
if (!serviceAllowed && !serviceEnabled) {
- EnforcedAdmin admin = RestrictedLockUtils.checkIfAccessibilityServiceDisallowed(
- getActivity(), packageName, UserHandle.myUserId());
+ final EnforcedAdmin admin =
+ RestrictedLockUtils.checkIfAccessibilityServiceDisallowed(
+ getActivity(), packageName, UserHandle.myUserId());
if (admin != null) {
preference.setDisabledByAdmin(admin);
} else {
@@ -562,19 +573,14 @@
preference.setFragment(ToggleAccessibilityServicePreferenceFragment.class.getName());
preference.setPersistent(true);
- Bundle extras = preference.getExtras();
+ final Bundle extras = preference.getExtras();
extras.putString(EXTRA_PREFERENCE_KEY, preference.getKey());
extras.putBoolean(EXTRA_CHECKED, serviceEnabled);
extras.putString(EXTRA_TITLE, title);
extras.putParcelable(EXTRA_RESOLVE_INFO, resolveInfo);
-
- String description = info.loadDescription(getPackageManager());
- if (TextUtils.isEmpty(description)) {
- description = getString(R.string.accessibility_service_default_description);
- }
extras.putString(EXTRA_SUMMARY, description);
- String settingsClassName = info.getSettingsActivityName();
+ final String settingsClassName = info.getSettingsActivityName();
if (!TextUtils.isEmpty(settingsClassName)) {
extras.putString(EXTRA_SETTINGS_TITLE,
getString(R.string.accessibility_menu_item_settings));
@@ -595,7 +601,7 @@
// If the user has not installed any additional services, hide the category.
if (downloadedServicesCategory.getPreferenceCount() == 0) {
- PreferenceScreen screen = getPreferenceScreen();
+ final PreferenceScreen screen = getPreferenceScreen();
screen.removePreference(downloadedServicesCategory);
}
}
diff --git a/src/com/android/settings/applications/RunningProcessesView.java b/src/com/android/settings/applications/RunningProcessesView.java
index 650f56c..d714c5f 100644
--- a/src/com/android/settings/applications/RunningProcessesView.java
+++ b/src/com/android/settings/applications/RunningProcessesView.java
@@ -20,6 +20,8 @@
import android.app.Dialog;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.content.res.ColorStateList;
+import android.graphics.PorterDuff;
import android.os.Bundle;
import android.os.SystemClock;
import android.os.UserHandle;
@@ -36,6 +38,7 @@
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListView;
+import android.widget.ProgressBar;
import android.widget.TextView;
import com.android.internal.util.MemInfoReader;
@@ -43,7 +46,6 @@
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.widget.LinearColorBar;
import java.util.ArrayList;
import java.util.Collections;
@@ -75,7 +77,7 @@
ListView mListView;
View mHeader;
ServiceListAdapter mAdapter;
- LinearColorBar mColorBar;
+ ProgressBar mColorBar;
TextView mBackgroundProcessPrefix;
TextView mAppsProcessPrefix;
TextView mForegroundProcessPrefix;
@@ -385,9 +387,9 @@
Formatter.formatShortFileSize(getContext(), highRam));
mForegroundProcessText.setText(getResources().getString(
R.string.running_processes_header_ram, sizeStr));
- mColorBar.setRatios(highRam/(float)totalRam,
- medRam/(float)totalRam,
- lowRam/(float)totalRam);
+ int progress = (int) ((highRam/(float) totalRam) * 100);
+ mColorBar.setProgress(progress);
+ mColorBar.setSecondaryProgress(progress + (int) ((medRam/(float) totalRam) * 100));
}
}
}
@@ -446,17 +448,22 @@
mListView.setAdapter(mAdapter);
mHeader = inflater.inflate(R.layout.running_processes_header, null);
mListView.addHeaderView(mHeader, null, false /* set as not selectable */);
- mColorBar = (LinearColorBar)mHeader.findViewById(R.id.color_bar);
+ mColorBar = mHeader.findViewById(R.id.color_bar);
final Context context = getContext();
- mColorBar.setColors(context.getColor(R.color.running_processes_system_ram),
- Utils.getColorAccent(context),
- context.getColor(R.color.running_processes_free_ram));
- mBackgroundProcessPrefix = (TextView)mHeader.findViewById(R.id.freeSizePrefix);
- mAppsProcessPrefix = (TextView)mHeader.findViewById(R.id.appsSizePrefix);
- mForegroundProcessPrefix = (TextView)mHeader.findViewById(R.id.systemSizePrefix);
- mBackgroundProcessText = (TextView)mHeader.findViewById(R.id.freeSize);
- mAppsProcessText = (TextView)mHeader.findViewById(R.id.appsSize);
- mForegroundProcessText = (TextView)mHeader.findViewById(R.id.systemSize);
+ mColorBar.setProgressTintList(
+ ColorStateList.valueOf(context.getColor(R.color.running_processes_system_ram)));
+ mColorBar.setSecondaryProgressTintList(
+ ColorStateList.valueOf(Utils.getColorAccent(context)));
+ mColorBar.setSecondaryProgressTintMode(PorterDuff.Mode.SRC);
+ mColorBar.setProgressBackgroundTintList(
+ ColorStateList.valueOf(context.getColor(R.color.running_processes_free_ram)));
+ mColorBar.setProgressBackgroundTintMode(PorterDuff.Mode.SRC);
+ mBackgroundProcessPrefix = mHeader.findViewById(R.id.freeSizePrefix);
+ mAppsProcessPrefix = mHeader.findViewById(R.id.appsSizePrefix);
+ mForegroundProcessPrefix = mHeader.findViewById(R.id.systemSizePrefix);
+ mBackgroundProcessText = mHeader.findViewById(R.id.freeSize);
+ mAppsProcessText = mHeader.findViewById(R.id.appsSize);
+ mForegroundProcessText = mHeader.findViewById(R.id.systemSize);
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
mAm.getMemoryInfo(memInfo);
diff --git a/src/com/android/settings/applications/UsageAccessDetails.java b/src/com/android/settings/applications/UsageAccessDetails.java
index c172137..fdb20c9 100644
--- a/src/com/android/settings/applications/UsageAccessDetails.java
+++ b/src/com/android/settings/applications/UsageAccessDetails.java
@@ -45,7 +45,6 @@
private static final String KEY_APP_OPS_PREFERENCE_SCREEN = "app_ops_preference_screen";
private static final String KEY_APP_OPS_SETTINGS_SWITCH = "app_ops_settings_switch";
- private static final String KEY_APP_OPS_SETTINGS_PREFS = "app_ops_settings_preference";
private static final String KEY_APP_OPS_SETTINGS_DESC = "app_ops_settings_description";
// Use a bridge to get the usage stats but don't initialize it to connect with all state.
@@ -53,7 +52,6 @@
private AppStateUsageBridge mUsageBridge;
private AppOpsManager mAppOpsManager;
private SwitchPreference mSwitchPref;
- private Preference mUsagePrefs;
private Preference mUsageDesc;
private Intent mSettingsIntent;
private UsageState mUsageState;
@@ -70,16 +68,13 @@
addPreferencesFromResource(R.xml.app_ops_permissions_details);
mSwitchPref = (SwitchPreference) findPreference(KEY_APP_OPS_SETTINGS_SWITCH);
- mUsagePrefs = findPreference(KEY_APP_OPS_SETTINGS_PREFS);
mUsageDesc = findPreference(KEY_APP_OPS_SETTINGS_DESC);
getPreferenceScreen().setTitle(R.string.usage_access);
mSwitchPref.setTitle(R.string.permit_usage_access);
- mUsagePrefs.setTitle(R.string.app_usage_preference);
mUsageDesc.setSummary(R.string.usage_access_description);
mSwitchPref.setOnPreferenceChangeListener(this);
- mUsagePrefs.setOnPreferenceClickListener(this);
mSettingsIntent = new Intent(Intent.ACTION_MAIN)
.addCategory(Settings.INTENT_CATEGORY_USAGE_ACCESS_CONFIG)
@@ -88,16 +83,6 @@
@Override
public boolean onPreferenceClick(Preference preference) {
- if (preference == mUsagePrefs) {
- if (mSettingsIntent != null) {
- try {
- getActivity().startActivityAsUser(mSettingsIntent, new UserHandle(mUserId));
- } catch (ActivityNotFoundException e) {
- Log.w(TAG, "Unable to launch app usage access settings " + mSettingsIntent, e);
- }
- }
- return true;
- }
return false;
}
@@ -150,14 +135,10 @@
boolean hasAccess = mUsageState.isPermissible();
mSwitchPref.setChecked(hasAccess);
mSwitchPref.setEnabled(mUsageState.permissionDeclared);
- mUsagePrefs.setEnabled(hasAccess);
ResolveInfo resolveInfo = mPm.resolveActivityAsUser(mSettingsIntent,
PackageManager.GET_META_DATA, mUserId);
if (resolveInfo != null) {
- if (findPreference(KEY_APP_OPS_SETTINGS_PREFS) == null) {
- getPreferenceScreen().addPreference(mUsagePrefs);
- }
Bundle metaData = resolveInfo.activityInfo.metaData;
mSettingsIntent.setComponent(new ComponentName(resolveInfo.activityInfo.packageName,
resolveInfo.activityInfo.name));
@@ -166,10 +147,6 @@
mSwitchPref.setSummary(
metaData.getString(Settings.METADATA_USAGE_ACCESS_REASON));
}
- } else {
- if (findPreference(KEY_APP_OPS_SETTINGS_PREFS) != null) {
- getPreferenceScreen().removePreference(mUsagePrefs);
- }
}
return true;
diff --git a/src/com/android/settings/applications/appinfo/DrawOverlayDetails.java b/src/com/android/settings/applications/appinfo/DrawOverlayDetails.java
index 5cdc47e..bff6669 100644
--- a/src/com/android/settings/applications/appinfo/DrawOverlayDetails.java
+++ b/src/com/android/settings/applications/appinfo/DrawOverlayDetails.java
@@ -49,7 +49,6 @@
OnPreferenceClickListener {
private static final String KEY_APP_OPS_SETTINGS_SWITCH = "app_ops_settings_switch";
- private static final String KEY_APP_OPS_SETTINGS_PREFS = "app_ops_settings_preference";
private static final String LOG_TAG = "DrawOverlayDetails";
private static final int [] APP_OPS_OP_CODE = {
@@ -61,7 +60,6 @@
private AppStateOverlayBridge mOverlayBridge;
private AppOpsManager mAppOpsManager;
private SwitchPreference mSwitchPref;
- private Preference mOverlayPrefs;
private Intent mSettingsIntent;
private OverlayState mOverlayState;
@@ -76,11 +74,9 @@
// find preferences
addPreferencesFromResource(R.xml.draw_overlay_permissions_details);
mSwitchPref = (SwitchPreference) findPreference(KEY_APP_OPS_SETTINGS_SWITCH);
- mOverlayPrefs = findPreference(KEY_APP_OPS_SETTINGS_PREFS);
// install event listeners
mSwitchPref.setOnPreferenceChangeListener(this);
- mOverlayPrefs.setOnPreferenceClickListener(this);
mSettingsIntent = new Intent(Intent.ACTION_MAIN)
.setAction(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
@@ -109,17 +105,6 @@
@Override
public boolean onPreferenceClick(Preference preference) {
- if (preference == mOverlayPrefs) {
- if (mSettingsIntent != null) {
- try {
- getActivity().startActivityAsUser(mSettingsIntent, new UserHandle(mUserId));
- } catch (ActivityNotFoundException e) {
- Log.w(LOG_TAG, "Unable to launch app draw overlay settings " + mSettingsIntent,
- e);
- }
- }
- return true;
- }
return false;
}
@@ -159,15 +144,9 @@
mSwitchPref.setChecked(isAllowed);
// you cannot ask a user to grant you a permission you did not have!
mSwitchPref.setEnabled(mOverlayState.permissionDeclared && mOverlayState.controlEnabled);
- mOverlayPrefs.setEnabled(isAllowed);
ResolveInfo resolveInfo = mPm.resolveActivityAsUser(mSettingsIntent,
PackageManager.GET_META_DATA, mUserId);
- if (resolveInfo == null) {
- if (findPreference(KEY_APP_OPS_SETTINGS_PREFS) != null) {
- getPreferenceScreen().removePreference(mOverlayPrefs);
- }
- }
return true;
}
diff --git a/src/com/android/settings/applications/appinfo/WriteSettingsDetails.java b/src/com/android/settings/applications/appinfo/WriteSettingsDetails.java
index a65de32..b77fbcb 100644
--- a/src/com/android/settings/applications/appinfo/WriteSettingsDetails.java
+++ b/src/com/android/settings/applications/appinfo/WriteSettingsDetails.java
@@ -45,7 +45,6 @@
private static final String KEY_APP_OPS_PREFERENCE_SCREEN = "app_ops_preference_screen";
private static final String KEY_APP_OPS_SETTINGS_SWITCH = "app_ops_settings_switch";
- private static final String KEY_APP_OPS_SETTINGS_PREFS = "app_ops_settings_preference";
private static final String LOG_TAG = "WriteSettingsDetails";
private static final int [] APP_OPS_OP_CODE = {
@@ -57,7 +56,6 @@
private AppStateWriteSettingsBridge mAppBridge;
private AppOpsManager mAppOpsManager;
private SwitchPreference mSwitchPref;
- private Preference mWriteSettingsPrefs;
private Intent mSettingsIntent;
private WriteSettingsState mWriteSettingsState;
@@ -71,10 +69,8 @@
addPreferencesFromResource(R.xml.write_system_settings_permissions_details);
mSwitchPref = (SwitchPreference) findPreference(KEY_APP_OPS_SETTINGS_SWITCH);
- mWriteSettingsPrefs = findPreference(KEY_APP_OPS_SETTINGS_PREFS);
mSwitchPref.setOnPreferenceChangeListener(this);
- mWriteSettingsPrefs.setOnPreferenceClickListener(this);
mSettingsIntent = new Intent(Intent.ACTION_MAIN)
.addCategory(Settings.INTENT_CATEGORY_USAGE_ACCESS_CONFIG)
@@ -83,16 +79,6 @@
@Override
public boolean onPreferenceClick(Preference preference) {
- if (preference == mWriteSettingsPrefs) {
- if (mSettingsIntent != null) {
- try {
- getActivity().startActivityAsUser(mSettingsIntent, new UserHandle(mUserId));
- } catch (ActivityNotFoundException e) {
- Log.w(LOG_TAG, "Unable to launch write system settings " + mSettingsIntent, e);
- }
- }
- return true;
- }
return false;
}
@@ -142,15 +128,9 @@
mSwitchPref.setChecked(canWrite);
// you can't ask a user for a permission you didn't even declare!
mSwitchPref.setEnabled(mWriteSettingsState.permissionDeclared);
- mWriteSettingsPrefs.setEnabled(canWrite);
ResolveInfo resolveInfo = mPm.resolveActivityAsUser(mSettingsIntent,
PackageManager.GET_META_DATA, mUserId);
- if (resolveInfo == null) {
- if (getPreferenceScreen().findPreference(KEY_APP_OPS_SETTINGS_PREFS) != null) {
- getPreferenceScreen().removePreference(mWriteSettingsPrefs);
- }
- }
return true;
}
diff --git a/src/com/android/settings/applications/defaultapps/DefaultHomePreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultHomePreferenceController.java
index 6f37797..02409b2 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultHomePreferenceController.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultHomePreferenceController.java
@@ -91,6 +91,9 @@
@Override
protected Intent getSettingIntent(DefaultAppInfo info) {
+ if (info == null) {
+ return null;
+ }
final String packageName;
if (info.componentName != null) {
packageName = info.componentName.getPackageName();
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
index 6376347..993ff47 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
@@ -88,29 +88,8 @@
public boolean onPreferenceClick(Preference preference) {
final CachedBluetoothDevice device =
((BluetoothDevicePreference) preference).getBluetoothDevice();
- if (device == null) {
- return false;
- }
-
- // Set the device as active per profile only if the device supports that profile
- // TODO: The active device selector location might change in the future
Log.i(TAG, "OnPreferenceClickListener: device=" + device);
- boolean result = false;
- A2dpProfile a2dpProfile = mLocalManager.getProfileManager().getA2dpProfile();
- if ((a2dpProfile != null) && device.isConnectedProfile(a2dpProfile)) {
- if (a2dpProfile.setActiveDevice(device.getDevice())) {
- Log.i(TAG, "OnPreferenceClickListener: A2DP active device=" + device);
- result = true;
- }
- }
- HeadsetProfile headsetProfile = mLocalManager.getProfileManager().getHeadsetProfile();
- if ((headsetProfile != null) && device.isConnectedProfile(headsetProfile)) {
- if (headsetProfile.setActiveDevice(device.getDevice())) {
- Log.i(TAG, "OnPreferenceClickListener: Headset active device=" + device);
- result = true;
- }
- }
- return result;
+ return device.setActive();
}
}
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 0cbc539..dbe8fba 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -53,6 +53,7 @@
import com.android.settings.applications.appops.BackgroundCheckSummary;
import com.android.settings.applications.assist.ManageAssist;
import com.android.settings.applications.manageapplications.ManageApplications;
+import com.android.settings.backup.ToggleBackupSettingFragment;
import com.android.settings.bluetooth.BluetoothDeviceDetailsFragment;
import com.android.settings.bluetooth.BluetoothSettings;
import com.android.settings.connecteddevice.AdvancedConnectedDeviceDashboardFragment;
@@ -257,6 +258,7 @@
BluetoothDeviceDetailsFragment.class.getName(),
DataUsageList.class.getName(),
DirectoryAccessDetails.class.getName(),
+ ToggleBackupSettingFragment.class.getName(),
};
public static final String[] SETTINGS_FOR_RESTRICTED = {
diff --git a/src/com/android/settings/datausage/DataUsageSummary.java b/src/com/android/settings/datausage/DataUsageSummary.java
index b05d180..dbc3e59 100644
--- a/src/com/android/settings/datausage/DataUsageSummary.java
+++ b/src/com/android/settings/datausage/DataUsageSummary.java
@@ -129,14 +129,6 @@
}
@Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- if (UserManager.get(getContext()).isAdminUser()) {
- inflater.inflate(R.menu.data_usage, menu);
- }
- super.onCreateOptionsMenu(menu, inflater);
- }
-
- @Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.data_usage_menu_cellular_networks: {
diff --git a/src/com/android/settings/datausage/DataUsageSummaryPreference.java b/src/com/android/settings/datausage/DataUsageSummaryPreference.java
index 43ebecc..2c61e21 100644
--- a/src/com/android/settings/datausage/DataUsageSummaryPreference.java
+++ b/src/com/android/settings/datausage/DataUsageSummaryPreference.java
@@ -129,14 +129,15 @@
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
-
+ ProgressBar bar = (ProgressBar) holder.findViewById(R.id.determinateBar);
if (mChartEnabled && (!TextUtils.isEmpty(mStartLabel) || !TextUtils.isEmpty(mEndLabel))) {
+ bar.setVisibility(View.VISIBLE);
holder.findViewById(R.id.label_bar).setVisibility(View.VISIBLE);
- ProgressBar bar = (ProgressBar) holder.findViewById(R.id.determinateBar);
bar.setProgress((int) (mProgress * 100));
((TextView) holder.findViewById(android.R.id.text1)).setText(mStartLabel);
((TextView) holder.findViewById(android.R.id.text2)).setText(mEndLabel);
} else {
+ bar.setVisibility(View.GONE);
holder.findViewById(R.id.label_bar).setVisibility(View.GONE);
}
diff --git a/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceController.java b/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceController.java
index 21bd4b7..c117b9a 100644
--- a/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceController.java
@@ -15,7 +15,6 @@
package com.android.settings.fuelgauge;
import android.app.AppOpsManager;
-import android.app.Fragment;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.os.UserManager;
@@ -24,6 +23,7 @@
import com.android.settings.R;
import com.android.settings.Utils;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.fuelgauge.batterytip.AppInfo;
import com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment;
@@ -51,17 +51,17 @@
DevicePolicyManagerWrapper mDpm;
@VisibleForTesting
BatteryUtils mBatteryUtils;
- private Fragment mFragment;
+ private InstrumentedPreferenceFragment mFragment;
private String mTargetPackage;
private PowerWhitelistBackend mPowerWhitelistBackend;
- public BackgroundActivityPreferenceController(Context context, Fragment fragment,
- int uid, String packageName) {
+ public BackgroundActivityPreferenceController(Context context,
+ InstrumentedPreferenceFragment fragment, int uid, String packageName) {
this(context, fragment, uid, packageName, PowerWhitelistBackend.getInstance());
}
@VisibleForTesting
- BackgroundActivityPreferenceController(Context context, Fragment fragment,
+ BackgroundActivityPreferenceController(Context context, InstrumentedPreferenceFragment fragment,
int uid, String packageName, PowerWhitelistBackend backend) {
super(context);
mPowerWhitelistBackend = backend;
@@ -137,7 +137,8 @@
? new UnrestrictAppTip(BatteryTip.StateType.NEW, appInfo)
: new RestrictAppTip(BatteryTip.StateType.NEW, appInfo);
- final BatteryTipDialogFragment dialogFragment = BatteryTipDialogFragment.newInstance(tip);
+ final BatteryTipDialogFragment dialogFragment = BatteryTipDialogFragment.newInstance(tip,
+ mFragment.getMetricsCategory());
dialogFragment.setTargetFragment(mFragment, 0 /* requestCode */);
dialogFragment.show(mFragment.getFragmentManager(), TAG);
}
diff --git a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
index de01533..b5b98c35 100644
--- a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
@@ -482,6 +482,7 @@
notAvailable = new Preference(mPrefContext);
notAvailable.setKey(NOT_AVAILABLE);
notAvailable.setTitle(R.string.power_usage_not_available);
+ notAvailable.setSelectable(false);
mAppListGroup.addPreference(notAvailable);
}
}
diff --git a/src/com/android/settings/fuelgauge/BatterySaverController.java b/src/com/android/settings/fuelgauge/BatterySaverController.java
index f139f31..086cdde 100644
--- a/src/com/android/settings/fuelgauge/BatterySaverController.java
+++ b/src/com/android/settings/fuelgauge/BatterySaverController.java
@@ -22,24 +22,24 @@
import android.os.PowerManager;
import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.Utils;
-import com.android.settings.core.TogglePreferenceController;
+import com.android.settings.core.BasePreferenceController;
import com.android.settings.dashboard.conditional.BatterySaverCondition;
import com.android.settings.dashboard.conditional.ConditionManager;
-import com.android.settings.widget.MasterSwitchPreference;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
-public class BatterySaverController extends TogglePreferenceController
+public class BatterySaverController extends BasePreferenceController
implements LifecycleObserver, OnStart, OnStop, BatterySaverReceiver.BatterySaverListener {
private static final String KEY_BATTERY_SAVER = "battery_saver_summary";
private final BatterySaverReceiver mBatteryStateChangeReceiver;
private final PowerManager mPowerManager;
- private MasterSwitchPreference mBatterySaverPref;
+ private Preference mBatterySaverPref;
public BatterySaverController(Context context) {
super(context, KEY_BATTERY_SAVER);
@@ -62,24 +62,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mBatterySaverPref = (MasterSwitchPreference) screen.findPreference(KEY_BATTERY_SAVER);
- }
-
- @Override
- public boolean setChecked(boolean isChecked) {
- mBatterySaverPref.setChecked(isChecked);
- if (!mPowerManager.setPowerSaveMode(isChecked)) {
- return false;
- }
-
- refreshConditionManager();
- updateSummary();
- return true;
- }
-
- @Override
- public boolean isChecked() {
- return mPowerManager.isPowerSaveMode();
+ mBatterySaverPref = screen.findPreference(KEY_BATTERY_SAVER);
}
@Override
@@ -89,6 +72,7 @@
, true, mObserver);
mBatteryStateChangeReceiver.setListening(true);
+ updateSummary();
}
@Override
@@ -130,12 +114,10 @@
@Override
public void onPowerSaveModeChanged() {
- mBatterySaverPref.setChecked(mPowerManager.isPowerSaveMode());
updateSummary();
}
@Override
public void onBatteryChanged(boolean pluggedIn) {
- mBatterySaverPref.setSwitchEnabled(!pluggedIn);
}
}
diff --git a/src/com/android/settings/fuelgauge/BatteryUtils.java b/src/com/android/settings/fuelgauge/BatteryUtils.java
index 2b79855..3c493b9 100644
--- a/src/com/android/settings/fuelgauge/BatteryUtils.java
+++ b/src/com/android/settings/fuelgauge/BatteryUtils.java
@@ -397,7 +397,7 @@
public void setForceAppStandby(int uid, String packageName,
int mode) {
- final boolean isPreOApp = isLegacyApp(packageName);
+ final boolean isPreOApp = isPreOApp(packageName);
if (isPreOApp) {
// Control whether app could run in the background if it is pre O app
mAppOpsManager.setMode(AppOpsManager.OP_RUN_IN_BACKGROUND, uid, packageName, mode);
@@ -483,7 +483,7 @@
return 0;
}
- public boolean isLegacyApp(final String packageName) {
+ public boolean isPreOApp(final String packageName) {
try {
ApplicationInfo info = mPackageManager.getApplicationInfo(packageName,
PackageManager.GET_META_DATA);
diff --git a/src/com/android/settings/fuelgauge/RestrictAppPreferenceController.java b/src/com/android/settings/fuelgauge/RestrictAppPreferenceController.java
index 02a2cf6..100c5f6 100644
--- a/src/com/android/settings/fuelgauge/RestrictAppPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/RestrictAppPreferenceController.java
@@ -22,14 +22,13 @@
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
-import com.android.internal.util.CollectionUtils;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.fuelgauge.batterytip.AppInfo;
+import com.android.settings.fuelgauge.batterytip.BatteryTipUtils;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -65,26 +64,7 @@
public void updateState(Preference preference) {
super.updateState(preference);
- final List<AppOpsManager.PackageOps> packageOpsList = mAppOpsManager.getPackagesForOps(
- new int[]{AppOpsManager.OP_RUN_ANY_IN_BACKGROUND});
- mAppInfos = new ArrayList<>();
-
- for (int i = 0, size = CollectionUtils.size(packageOpsList); i < size; i++) {
- final AppOpsManager.PackageOps packageOps = packageOpsList.get(i);
- final List<AppOpsManager.OpEntry> entries = packageOps.getOps();
- for (int j = 0; j < entries.size(); j++) {
- AppOpsManager.OpEntry ent = entries.get(j);
- if (ent.getOp() != AppOpsManager.OP_RUN_ANY_IN_BACKGROUND) {
- continue;
- }
- if (ent.getMode() != AppOpsManager.MODE_ALLOWED) {
- mAppInfos.add(new AppInfo.Builder()
- .setPackageName(packageOps.getPackageName())
- .setUid(packageOps.getUid())
- .build());
- }
- }
- }
+ mAppInfos = BatteryTipUtils.getRestrictedAppsList(mAppOpsManager);
final int num = mAppInfos.size();
// Enable the preference if some apps already been restricted, otherwise disable it
diff --git a/src/com/android/settings/fuelgauge/RestrictedAppDetails.java b/src/com/android/settings/fuelgauge/RestrictedAppDetails.java
index 631fd06..e75112c 100644
--- a/src/com/android/settings/fuelgauge/RestrictedAppDetails.java
+++ b/src/com/android/settings/fuelgauge/RestrictedAppDetails.java
@@ -131,8 +131,8 @@
final CheckBoxPreference checkBoxPreference = new AppCheckBoxPreference(context);
final AppInfo appInfo = mAppInfos.get(i);
try {
- final ApplicationInfo applicationInfo = mPackageManager.getApplicationInfo(
- appInfo.packageName, 0 /* flags */);
+ final ApplicationInfo applicationInfo = mPackageManager.getApplicationInfoAsUser(
+ appInfo.packageName, 0 /* flags */, UserHandle.getUserId(appInfo.uid));
checkBoxPreference.setChecked(true);
checkBoxPreference.setTitle(mPackageManager.getApplicationLabel(applicationInfo));
checkBoxPreference.setIcon(
diff --git a/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobService.java b/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobService.java
index 5d0e71d..c2af02a 100644
--- a/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobService.java
+++ b/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobService.java
@@ -127,7 +127,7 @@
&& !isSystemUid(uid)) {
if (anomalyType == StatsManagerConfig.AnomalyType.EXCESSIVE_BG) {
// TODO(b/72385333): check battery percentage draining in batterystats
- if (batteryUtils.isLegacyApp(packageName) && batteryUtils.isAppHeavilyUsed(
+ if (batteryUtils.isPreOApp(packageName) && batteryUtils.isAppHeavilyUsed(
batteryStatsHelper, userManager, uid,
policy.excessiveBgDrainPercentage)) {
Log.e(TAG, "Excessive detected uid=" + uid);
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryManagerPreferenceController.java b/src/com/android/settings/fuelgauge/batterytip/BatteryManagerPreferenceController.java
new file mode 100644
index 0000000..087f983
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryManagerPreferenceController.java
@@ -0,0 +1,75 @@
+/*
+ * 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.fuelgauge.batterytip;
+
+import android.app.AppOpsManager;
+import android.content.Context;
+import android.provider.Settings;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
+import com.android.settings.overlay.FeatureFactory;
+
+/**
+ * Preference controller to control the battery manager
+ */
+public class BatteryManagerPreferenceController extends BasePreferenceController {
+ private static final String KEY_BATTERY_MANAGER = "smart_battery_manager";
+ private static final int ON = 1;
+ private PowerUsageFeatureProvider mPowerUsageFeatureProvider;
+ private AppOpsManager mAppOpsManager;
+
+ public BatteryManagerPreferenceController(Context context) {
+ super(context, KEY_BATTERY_MANAGER);
+ mPowerUsageFeatureProvider = FeatureFactory.getFactory(
+ context).getPowerUsageFeatureProvider(context);
+ mAppOpsManager = context.getSystemService(AppOpsManager.class);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ final int num = BatteryTipUtils.getRestrictedAppsList(mAppOpsManager).size();
+ final String setting = mPowerUsageFeatureProvider.isSmartBatterySupported()
+ ? Settings.Global.APP_STANDBY_ENABLED
+ : Settings.Global.APP_AUTO_RESTRICTION_ENABLED;
+ final boolean featureOn =
+ Settings.Global.getInt(mContext.getContentResolver(), setting, ON) == ON;
+
+ updateSummary(preference, featureOn, num);
+ }
+
+ @VisibleForTesting
+ void updateSummary(Preference preference, boolean featureOn, int num) {
+ if (num > 0) {
+ preference.setSummary(mContext.getResources().getQuantityString(
+ R.plurals.battery_manager_app_restricted, num, num));
+ } else if (featureOn) {
+ preference.setSummary(R.string.battery_manager_on);
+ } else {
+ preference.setSummary(R.string.battery_manager_off);
+ }
+ }
+}
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
index cb508b3..de88279 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
@@ -51,15 +51,19 @@
DialogInterface.OnClickListener {
private static final String ARG_BATTERY_TIP = "battery_tip";
+ private static final String ARG_METRICS_KEY = "metrics_key";
@VisibleForTesting
BatteryTip mBatteryTip;
+ @VisibleForTesting
+ int mMetricsKey;
- public static BatteryTipDialogFragment newInstance(BatteryTip batteryTip) {
+ public static BatteryTipDialogFragment newInstance(BatteryTip batteryTip, int metricsKey) {
BatteryTipDialogFragment dialogFragment = new BatteryTipDialogFragment();
Bundle args = new Bundle(1);
args.putParcelable(ARG_BATTERY_TIP, batteryTip);
+ args.putInt(ARG_METRICS_KEY, metricsKey);
dialogFragment.setArguments(args);
return dialogFragment;
@@ -71,6 +75,7 @@
final Context context = getContext();
mBatteryTip = bundle.getParcelable(ARG_BATTERY_TIP);
+ mMetricsKey = bundle.getInt(ARG_METRICS_KEY);
switch (mBatteryTip.getType()) {
case BatteryTip.TipType.SUMMARY:
@@ -163,7 +168,7 @@
(SettingsActivity) getActivity(),
(InstrumentedPreferenceFragment) getTargetFragment());
if (action != null) {
- action.handlePositiveAction();
+ action.handlePositiveAction(mMetricsKey);
}
lsn.onBatteryTipHandled(mBatteryTip);
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
index 9e47782..76c65e0 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
@@ -118,14 +118,14 @@
if (batteryTip != null) {
if (batteryTip.shouldShowDialog()) {
BatteryTipDialogFragment dialogFragment = BatteryTipDialogFragment.newInstance(
- batteryTip);
+ batteryTip, mFragment.getMetricsCategory());
dialogFragment.setTargetFragment(mFragment, REQUEST_ANOMALY_ACTION);
dialogFragment.show(mFragment.getFragmentManager(), TAG);
} else {
final BatteryTipAction action = BatteryTipUtils.getActionForBatteryTip(batteryTip,
mSettingsActivity, mFragment);
if (action != null) {
- action.handlePositiveAction();
+ action.handlePositiveAction(mFragment.getMetricsCategory());
}
if (mBatteryTipListener != null) {
mBatteryTipListener.onBatteryTipHandled(batteryTip);
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtils.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtils.java
index e9e30de..a217989 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtils.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtils.java
@@ -16,11 +16,14 @@
package com.android.settings.fuelgauge.batterytip;
+import android.app.AppOpsManager;
import android.app.PendingIntent;
import android.app.StatsManager;
import android.content.Context;
import android.content.Intent;
+import android.support.annotation.NonNull;
+import com.android.internal.util.CollectionUtils;
import com.android.settings.SettingsActivity;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.fuelgauge.batterytip.actions.BatterySaverAction;
@@ -33,6 +36,9 @@
import com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip;
import com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Utility class for {@link BatteryTip}
*/
@@ -40,6 +46,35 @@
private static final int REQUEST_CODE = 0;
/**
+ * Get a list of restricted apps with {@link AppOpsManager#OP_RUN_ANY_IN_BACKGROUND}
+ */
+ @NonNull
+ public static List<AppInfo> getRestrictedAppsList(AppOpsManager appOpsManager) {
+ final List<AppOpsManager.PackageOps> packageOpsList = appOpsManager.getPackagesForOps(
+ new int[]{AppOpsManager.OP_RUN_ANY_IN_BACKGROUND});
+ final List<AppInfo> appInfos = new ArrayList<>();
+
+ for (int i = 0, size = CollectionUtils.size(packageOpsList); i < size; i++) {
+ final AppOpsManager.PackageOps packageOps = packageOpsList.get(i);
+ final List<AppOpsManager.OpEntry> entries = packageOps.getOps();
+ for (int j = 0, entriesSize = entries.size(); j < entriesSize; j++) {
+ AppOpsManager.OpEntry entry = entries.get(j);
+ if (entry.getOp() != AppOpsManager.OP_RUN_ANY_IN_BACKGROUND) {
+ continue;
+ }
+ if (entry.getMode() != AppOpsManager.MODE_ALLOWED) {
+ appInfos.add(new AppInfo.Builder()
+ .setPackageName(packageOps.getPackageName())
+ .setUid(packageOps.getUid())
+ .build());
+ }
+ }
+ }
+
+ return appInfos;
+ }
+
+ /**
* Get a corresponding action based on {@code batteryTip}
* @param batteryTip used to detect which action to choose
* @param settingsActivity used to populate {@link BatteryTipAction}
diff --git a/src/com/android/settings/fuelgauge/batterytip/actions/BatterySaverAction.java b/src/com/android/settings/fuelgauge/batterytip/actions/BatterySaverAction.java
index 310d3f8..bb52623 100644
--- a/src/com/android/settings/fuelgauge/batterytip/actions/BatterySaverAction.java
+++ b/src/com/android/settings/fuelgauge/batterytip/actions/BatterySaverAction.java
@@ -19,6 +19,8 @@
import android.content.Context;
import android.os.PowerManager;
+import com.android.internal.logging.nano.MetricsProto;
+
public class BatterySaverAction extends BatteryTipAction {
private PowerManager mPowerManager;
@@ -31,7 +33,9 @@
* Handle the action when user clicks positive button
*/
@Override
- public void handlePositiveAction() {
+ public void handlePositiveAction(int metricsKey) {
mPowerManager.setPowerSaveMode(true);
+ mMetricsFeatureProvider.action(mContext,
+ MetricsProto.MetricsEvent.ACTION_TIP_TURN_ON_BATTERY_SAVER, metricsKey);
}
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/actions/BatteryTipAction.java b/src/com/android/settings/fuelgauge/batterytip/actions/BatteryTipAction.java
index 1bf08b7..0ae2c14 100644
--- a/src/com/android/settings/fuelgauge/batterytip/actions/BatteryTipAction.java
+++ b/src/com/android/settings/fuelgauge/batterytip/actions/BatteryTipAction.java
@@ -18,6 +18,7 @@
import android.content.Context;
+import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
/**
@@ -25,13 +26,15 @@
*/
public abstract class BatteryTipAction {
protected Context mContext;
+ protected MetricsFeatureProvider mMetricsFeatureProvider;
public BatteryTipAction(Context context) {
mContext = context;
+ mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
}
/**
* Handle the action when user clicks positive button
*/
- public abstract void handlePositiveAction();
+ public abstract void handlePositiveAction(int metricsKey);
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/actions/OpenRestrictAppFragmentAction.java b/src/com/android/settings/fuelgauge/batterytip/actions/OpenRestrictAppFragmentAction.java
index 77bf861..afb80f2 100644
--- a/src/com/android/settings/fuelgauge/batterytip/actions/OpenRestrictAppFragmentAction.java
+++ b/src/com/android/settings/fuelgauge/batterytip/actions/OpenRestrictAppFragmentAction.java
@@ -18,6 +18,7 @@
import android.app.Fragment;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.SettingsActivity;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.fuelgauge.BatteryUtils;
@@ -49,7 +50,9 @@
* Handle the action when user clicks positive button
*/
@Override
- public void handlePositiveAction() {
+ public void handlePositiveAction(int metricsKey) {
+ mMetricsFeatureProvider.action(mContext,
+ MetricsProto.MetricsEvent.ACTION_TIP_OPEN_APP_RESTRICTION_PAGE, metricsKey);
final List<AppInfo> mAppInfos = mRestrictAppTip.getRestrictAppList();
RestrictedAppDetails.startRestrictedAppDetails(mSettingsActivity, mFragment,
mAppInfos);
diff --git a/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppAction.java b/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppAction.java
index 37f4b2a..0009451 100644
--- a/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppAction.java
+++ b/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppAction.java
@@ -19,7 +19,10 @@
import android.app.AppOpsManager;
import android.content.Context;
import android.support.annotation.VisibleForTesting;
+import android.util.Pair;
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.internal.util.CollectionUtils;
import com.android.settings.fuelgauge.BatteryUtils;
import com.android.settings.fuelgauge.batterytip.AnomalyDatabaseHelper;
import com.android.settings.fuelgauge.batterytip.AppInfo;
@@ -49,14 +52,28 @@
* Handle the action when user clicks positive button
*/
@Override
- public void handlePositiveAction() {
+ public void handlePositiveAction(int metricsKey) {
final List<AppInfo> appInfos = mRestrictAppTip.getRestrictAppList();
for (int i = 0, size = appInfos.size(); i < size; i++) {
- final String packageName = appInfos.get(i).packageName;
+ final AppInfo appInfo = appInfos.get(i);
+ final String packageName = appInfo.packageName;
// Force app standby, then app can't run in the background
mBatteryUtils.setForceAppStandby(mBatteryUtils.getPackageUid(packageName), packageName,
AppOpsManager.MODE_IGNORED);
+ if (CollectionUtils.isEmpty(appInfo.anomalyTypes)) {
+ // Only log context if there is no anomaly type
+ mMetricsFeatureProvider.action(mContext,
+ MetricsProto.MetricsEvent.ACTION_TIP_RESTRICT_APP, packageName,
+ Pair.create(MetricsProto.MetricsEvent.FIELD_CONTEXT, metricsKey));
+ } else {
+ for (int type : appInfo.anomalyTypes) {
+ mMetricsFeatureProvider.action(mContext,
+ MetricsProto.MetricsEvent.ACTION_TIP_RESTRICT_APP, packageName,
+ Pair.create(MetricsProto.MetricsEvent.FIELD_CONTEXT, metricsKey),
+ Pair.create(MetricsProto.MetricsEvent.FIELD_ANOMALY_TYPE, type));
+ }
+ }
}
mBatteryDatabaseManager.updateAnomalies(appInfos, AnomalyDatabaseHelper.State.HANDLED);
diff --git a/src/com/android/settings/fuelgauge/batterytip/actions/SmartBatteryAction.java b/src/com/android/settings/fuelgauge/batterytip/actions/SmartBatteryAction.java
index 750ece9..4892591 100644
--- a/src/com/android/settings/fuelgauge/batterytip/actions/SmartBatteryAction.java
+++ b/src/com/android/settings/fuelgauge/batterytip/actions/SmartBatteryAction.java
@@ -18,6 +18,7 @@
import android.app.Fragment;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.core.SubSettingLauncher;
@@ -38,7 +39,9 @@
* Handle the action when user clicks positive button
*/
@Override
- public void handlePositiveAction() {
+ public void handlePositiveAction(int metricsKey) {
+ mMetricsFeatureProvider.action(mContext,
+ MetricsProto.MetricsEvent.ACTION_TIP_OPEN_SMART_BATTERY, metricsKey);
new SubSettingLauncher(mSettingsActivity)
.setSourceMetricsCategory(mFragment instanceof Instrumentable
? ((Instrumentable) mFragment).getMetricsCategory()
diff --git a/src/com/android/settings/fuelgauge/batterytip/actions/UnrestrictAppAction.java b/src/com/android/settings/fuelgauge/batterytip/actions/UnrestrictAppAction.java
index 16812f6..fab7b01 100644
--- a/src/com/android/settings/fuelgauge/batterytip/actions/UnrestrictAppAction.java
+++ b/src/com/android/settings/fuelgauge/batterytip/actions/UnrestrictAppAction.java
@@ -18,7 +18,10 @@
import android.app.AppOpsManager;
import android.content.Context;
+import android.support.annotation.VisibleForTesting;
+import android.util.Pair;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.fuelgauge.BatteryUtils;
import com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip;
@@ -27,7 +30,8 @@
*/
public class UnrestrictAppAction extends BatteryTipAction {
private UnrestrictAppTip mUnRestrictAppTip;
- private BatteryUtils mBatteryUtils;
+ @VisibleForTesting
+ BatteryUtils mBatteryUtils;
public UnrestrictAppAction(Context context, UnrestrictAppTip tip) {
super(context);
@@ -39,10 +43,13 @@
* Handle the action when user clicks positive button
*/
@Override
- public void handlePositiveAction() {
+ public void handlePositiveAction(int metricsKey) {
final String packageName = mUnRestrictAppTip.getPackageName();
// Clear force app standby, then app can run in the background
mBatteryUtils.setForceAppStandby(mBatteryUtils.getPackageUid(packageName), packageName,
AppOpsManager.MODE_ALLOWED);
+ mMetricsFeatureProvider.action(mContext,
+ MetricsProto.MetricsEvent.ACTION_TIP_UNRESTRICT_APP, packageName, Pair.create(
+ MetricsProto.MetricsEvent.FIELD_CONTEXT, metricsKey));
}
}
diff --git a/src/com/android/settings/inputmethod/SpellCheckersSettings.java b/src/com/android/settings/inputmethod/SpellCheckersSettings.java
index 3a3f443..5231021 100644
--- a/src/com/android/settings/inputmethod/SpellCheckersSettings.java
+++ b/src/com/android/settings/inputmethod/SpellCheckersSettings.java
@@ -92,7 +92,10 @@
@Override
public void onResume() {
super.onResume();
- mSwitchBar = ((SettingsActivity)getActivity()).getSwitchBar();
+ mSwitchBar = ((SettingsActivity) getActivity()).getSwitchBar();
+ mSwitchBar.setSwitchBarText(
+ R.string.spell_checker_master_switch_title,
+ R.string.spell_checker_master_switch_title);
mSwitchBar.show();
mSwitchBar.addOnSwitchChangeListener(this);
updatePreferenceScreen();
@@ -131,7 +134,7 @@
final Preference preference = screen.getPreference(index);
preference.setEnabled(isSpellCheckerEnabled);
if (preference instanceof SpellCheckerPreference) {
- final SpellCheckerPreference pref = (SpellCheckerPreference)preference;
+ final SpellCheckerPreference pref = (SpellCheckerPreference) preference;
pref.setSelected(mCurrentSci);
}
}
@@ -173,8 +176,13 @@
}
}
- private static int convertSubtypeIndexToDialogItemId(final int index) { return index + 1; }
- private static int convertDialogItemIdToSubtypeIndex(final int item) { return item - 1; }
+ private static int convertSubtypeIndexToDialogItemId(final int index) {
+ return index + 1;
+ }
+
+ private static int convertDialogItemIdToSubtypeIndex(final int item) {
+ return item - 1;
+ }
private void showChooseLanguageDialog() {
if (mDialog != null && mDialog.isShowing()) {
@@ -191,7 +199,7 @@
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.phone_language);
final int subtypeCount = currentSci.getSubtypeCount();
- final CharSequence[] items = new CharSequence[subtypeCount + 1 /* default */ ];
+ final CharSequence[] items = new CharSequence[subtypeCount + 1 /* default */];
items[ITEM_ID_USE_SYSTEM_LANGUAGE] = getSpellCheckerSubtypeLabel(currentSci, null);
int checkedItemId = ITEM_ID_USE_SYSTEM_LANGUAGE;
for (int index = 0; index < subtypeCount; ++index) {
diff --git a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
index bf821db..1845fef 100644
--- a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
+++ b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
@@ -19,6 +19,7 @@
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS;
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS;
+import android.app.admin.DevicePolicyManager;
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
@@ -59,7 +60,7 @@
private RestrictedListPreference mLockscreen;
private RestrictedListPreference mLockscreenProfile;
- private final int mProfileChallengeUserId;
+ private final int mProfileUserId;
private final boolean mSecure;
private final boolean mSecureProfile;
@@ -78,29 +79,24 @@
mWorkSettingCategoryKey = workSettingCategoryKey;
mWorkSettingKey = workSettingKey;
- mProfileChallengeUserId = Utils.getManagedProfileId(
- UserManager.get(context), UserHandle.myUserId());
+ mProfileUserId = Utils.getManagedProfileId(UserManager.get(context), UserHandle.myUserId());
final LockPatternUtils utils = FeatureFactory.getFactory(context)
.getSecurityFeatureProvider()
.getLockPatternUtils(context);
mSecure = utils.isSecure(UserHandle.myUserId());
- mSecureProfile = (mProfileChallengeUserId != UserHandle.USER_NULL)
- && (utils.isSecure(mProfileChallengeUserId)
- || (!utils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId) && mSecure));
+ mSecureProfile = (mProfileUserId != UserHandle.USER_NULL) && utils.isSecure(mProfileUserId);
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mLockscreen =
- (RestrictedListPreference) screen.findPreference(mSettingKey);
+ mLockscreen = (RestrictedListPreference) screen.findPreference(mSettingKey);
if (mLockscreen == null) {
Log.i(TAG, "Preference not found: " + mSettingKey);
return;
}
- if (mProfileChallengeUserId != UserHandle.USER_NULL) {
- mLockscreenProfile = (RestrictedListPreference) screen.findPreference(
- mWorkSettingKey);
+ if (mProfileUserId != UserHandle.USER_NULL) {
+ mLockscreenProfile = (RestrictedListPreference) screen.findPreference(mWorkSettingKey);
} else {
setVisible(screen, mWorkSettingKey, false /* visible */);
setVisible(screen, mWorkSettingCategoryKey, false /* visible */);
@@ -178,9 +174,6 @@
KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
}
- entries.add(mContext.getString(R.string.lock_screen_notifications_summary_disable_profile));
- values.add(Integer.toString(R.string.lock_screen_notifications_summary_disable_profile));
-
mLockscreenProfile.setEntries(entries.toArray(new CharSequence[entries.size()]));
mLockscreenProfile.setEntryValues(values.toArray(new CharSequence[values.size()]));
updateLockscreenNotificationsForProfile();
@@ -221,23 +214,17 @@
final String key = preference.getKey();
if (TextUtils.equals(mWorkSettingKey, key)) {
if (Utils.startQuietModeDialogIfNecessary(mContext, UserManager.get(mContext),
- mProfileChallengeUserId)) {
+ mProfileUserId)) {
return false;
}
final int val = Integer.parseInt((String) newValue);
if (val == mLockscreenSelectedValueProfile) {
return false;
}
- final boolean enabled =
- val != R.string.lock_screen_notifications_summary_disable_profile;
- final boolean show =
- val == R.string.lock_screen_notifications_summary_show_profile;
+ final boolean show = val == R.string.lock_screen_notifications_summary_show_profile;
Settings.Secure.putIntForUser(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
- show ? 1 : 0, mProfileChallengeUserId);
- Settings.Secure.putIntForUser(mContext.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
- enabled ? 1 : 0, mProfileChallengeUserId);
+ show ? 1 : 0, mProfileUserId);
mLockscreenSelectedValueProfile = val;
return true;
} else if (TextUtils.equals(mSettingKey, key)) {
@@ -245,8 +232,7 @@
if (val == mLockscreenSelectedValue) {
return false;
}
- final boolean enabled =
- val != R.string.lock_screen_notifications_summary_disable;
+ final boolean enabled = val != R.string.lock_screen_notifications_summary_disable;
final boolean show = val == R.string.lock_screen_notifications_summary_show;
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, show ? 1 : 0);
@@ -268,10 +254,10 @@
new RestrictedListPreference.RestrictedItem(entry, entryValue, admin);
mLockscreen.addRestrictedItem(item);
}
- if (mProfileChallengeUserId != UserHandle.USER_NULL) {
+ if (mProfileUserId != UserHandle.USER_NULL) {
RestrictedLockUtils.EnforcedAdmin profileAdmin =
RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
- mContext, keyguardNotificationFeatures, mProfileChallengeUserId);
+ mContext, keyguardNotificationFeatures, mProfileUserId);
if (profileAdmin != null && mLockscreenProfile != null) {
RestrictedListPreference.RestrictedItem item =
new RestrictedListPreference.RestrictedItem(
@@ -282,13 +268,13 @@
}
public static int getSummaryResource(Context context) {
- final boolean enabled = getLockscreenNotificationsEnabled(context, UserHandle.myUserId());
+ final boolean enabled = getLockscreenNotificationsEnabled(context);
final boolean secure = FeatureFactory.getFactory(context)
.getSecurityFeatureProvider()
.getLockPatternUtils(context)
.isSecure(UserHandle.myUserId());
final boolean allowPrivate = !secure
- || getLockscreenAllowPrivateNotifications(context, UserHandle.myUserId());
+ || getAllowPrivateNotifications(context, UserHandle.myUserId());
return !enabled ? R.string.lock_screen_notifications_summary_disable :
allowPrivate ? R.string.lock_screen_notifications_summary_show :
R.string.lock_screen_notifications_summary_hide;
@@ -303,30 +289,34 @@
mLockscreen.setValue(Integer.toString(mLockscreenSelectedValue));
}
+ private boolean adminAllowsUnredactedNotifications(int userId) {
+ final int dpmFlags = mContext.getSystemService(DevicePolicyManager.class)
+ .getKeyguardDisabledFeatures(null/* admin */, userId);
+ return (dpmFlags & KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS) == 0;
+ }
+
private void updateLockscreenNotificationsForProfile() {
- if (mProfileChallengeUserId == UserHandle.USER_NULL) {
+ if (mProfileUserId == UserHandle.USER_NULL) {
return;
}
if (mLockscreenProfile == null) {
return;
}
- final boolean enabled = getLockscreenNotificationsEnabled(mContext,mProfileChallengeUserId);
- final boolean allowPrivate = !mSecureProfile
- || getLockscreenAllowPrivateNotifications(mContext, mProfileChallengeUserId);
+ final boolean allowPrivate = adminAllowsUnredactedNotifications(mProfileUserId) &&
+ (!mSecureProfile || getAllowPrivateNotifications(mContext, mProfileUserId));
mLockscreenProfile.setSummary("%s");
- mLockscreenSelectedValueProfile = !enabled
- ? R.string.lock_screen_notifications_summary_disable_profile
- : (allowPrivate ? R.string.lock_screen_notifications_summary_show_profile
- : R.string.lock_screen_notifications_summary_hide_profile);
+ mLockscreenSelectedValueProfile = allowPrivate
+ ? R.string.lock_screen_notifications_summary_show_profile
+ : R.string.lock_screen_notifications_summary_hide_profile;
mLockscreenProfile.setValue(Integer.toString(mLockscreenSelectedValueProfile));
}
- private static boolean getLockscreenNotificationsEnabled(Context context, int userId) {
- return Settings.Secure.getIntForUser(context.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, userId) != 0;
+ private static boolean getLockscreenNotificationsEnabled(Context context) {
+ return Settings.Secure.getInt(context.getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
}
- private static boolean getLockscreenAllowPrivateNotifications(Context context, int userId) {
+ private static boolean getAllowPrivateNotifications(Context context, int userId) {
return Settings.Secure.getIntForUser(context.getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, userId) != 0;
}
@@ -356,7 +346,7 @@
super.onChange(selfChange, uri);
if (LOCK_SCREEN_PRIVATE_URI.equals(uri) || LOCK_SCREEN_SHOW_URI.equals(uri)) {
updateLockscreenNotifications();
- if (mProfileChallengeUserId != UserHandle.USER_NULL) {
+ if (mProfileUserId != UserHandle.USER_NULL) {
updateLockscreenNotificationsForProfile();
}
}
diff --git a/src/com/android/settings/notification/RedactionInterstitial.java b/src/com/android/settings/notification/RedactionInterstitial.java
index 93c14c7..12fc796 100644
--- a/src/com/android/settings/notification/RedactionInterstitial.java
+++ b/src/com/android/settings/notification/RedactionInterstitial.java
@@ -119,12 +119,12 @@
getContext(), getActivity().getIntent().getExtras());
if (UserManager.get(getContext()).isManagedProfile(mUserId)) {
((TextView) view.findViewById(R.id.message))
- .setText(R.string.lock_screen_notifications_interstitial_message_profile);
+ .setText(R.string.lock_screen_notifications_interstitial_message_profile);
mShowAllButton.setText(R.string.lock_screen_notifications_summary_show_profile);
mRedactSensitiveButton
- .setText(R.string.lock_screen_notifications_summary_hide_profile);
- ((RadioButton) view.findViewById(R.id.hide_all))
- .setText(R.string.lock_screen_notifications_summary_disable_profile);
+ .setText(R.string.lock_screen_notifications_summary_hide_profile);
+
+ ((RadioButton) view.findViewById(R.id.hide_all)).setVisibility(View.GONE);
}
final Button button = (Button) view.findViewById(R.id.redaction_done_button);
@@ -164,10 +164,11 @@
}
private void loadFromSettings() {
- final boolean enabled = Settings.Secure.getIntForUser(getContentResolver(),
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, mUserId) != 0;
+ final boolean managed = UserManager.get(getContext()).isManagedProfile(mUserId);
+ final boolean enabled = !managed || Settings.Secure.getIntForUser(getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, mUserId) != 0;
final boolean show = Settings.Secure.getIntForUser(getContentResolver(),
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, mUserId) != 0;
+ Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, mUserId) != 0;
int checkedButtonId = R.id.hide_all;
if (enabled) {
diff --git a/src/com/android/settings/slices/SliceBuilderUtils.java b/src/com/android/settings/slices/SliceBuilderUtils.java
index a1f27d1..49972a8 100644
--- a/src/com/android/settings/slices/SliceBuilderUtils.java
+++ b/src/com/android/settings/slices/SliceBuilderUtils.java
@@ -26,6 +26,7 @@
import android.net.Uri;
import android.provider.SettingsSlicesContract;
import android.text.TextUtils;
+import android.util.Pair;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
@@ -92,6 +93,38 @@
}
/**
+ * Splits the Settings Slice Uri path into its two expected components:
+ * - intent/action
+ * - key
+ * <p>
+ * Examples of valid paths are:
+ * - intent/wifi
+ * - intent/bluetooth
+ * - action/wifi
+ * - action/accessibility/servicename
+ *
+ * @param uri of the Slice. Follows pattern outlined in {@link SettingsSliceProvider}.
+ * @return Pair whose first element {@code true} if the path is prepended with "action", and
+ * second is a key.
+ */
+ public static Pair<Boolean, String> getPathData(Uri uri) {
+ final String path = uri.getPath();
+ final String[] split = path.split("/", 3);
+
+ // Split should be: [{}, SLICE_TYPE, KEY].
+ // Example: "/action/wifi" -> [{}, "action", "wifi"]
+ // "/action/longer/path" -> [{}, "action", "longer/path"]
+ if (split.length != 3) {
+ throw new IllegalArgumentException("Uri (" + uri + ") has incomplete path: " + path);
+ }
+
+ final boolean isInline = TextUtils.equals(SettingsSlicesContract.PATH_SETTING_ACTION,
+ split[1]);
+
+ return new Pair<>(isInline, split[2]);
+ }
+
+ /**
* Looks at the {@link SliceData#preferenceController} from {@param sliceData} and attempts to
* build an {@link AbstractPreferenceController}.
*/
diff --git a/src/com/android/settings/slices/SlicesDatabaseAccessor.java b/src/com/android/settings/slices/SlicesDatabaseAccessor.java
index acd296b..82b3506 100644
--- a/src/com/android/settings/slices/SlicesDatabaseAccessor.java
+++ b/src/com/android/settings/slices/SlicesDatabaseAccessor.java
@@ -24,6 +24,7 @@
import android.content.Context;
import android.os.Binder;
+import android.util.Pair;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.slices.SlicesDatabaseHelper.IndexColumns;
@@ -35,7 +36,7 @@
*/
public class SlicesDatabaseAccessor {
- public static final String[] SELECT_COLUMNS = {
+ public static final String[] SELECT_COLUMNS_ALL = {
IndexColumns.KEY,
IndexColumns.TITLE,
IndexColumns.SUMMARY,
@@ -43,8 +44,13 @@
IndexColumns.ICON_RESOURCE,
IndexColumns.FRAGMENT,
IndexColumns.CONTROLLER,
+ IndexColumns.PLATFORM_SLICE,
+ IndexColumns.SLICE_TYPE,
};
+ // Cursor value for boolean true
+ private final int TRUE = 1;
+
Context mContext;
public SlicesDatabaseAccessor(Context context) {
@@ -58,9 +64,9 @@
* Used when building a {@link Slice}.
*/
public SliceData getSliceDataFromUri(Uri uri) {
- String key = uri.getLastPathSegment();
- Cursor cursor = getIndexedSliceData(key);
- return buildSliceData(cursor, uri);
+ Pair<Boolean, String> pathData = SliceBuilderUtils.getPathData(uri);
+ Cursor cursor = getIndexedSliceData(pathData.second /* key */);
+ return buildSliceData(cursor, uri, pathData.first /* isIntentOnly */);
}
/**
@@ -70,18 +76,18 @@
*/
public SliceData getSliceDataFromKey(String key) {
Cursor cursor = getIndexedSliceData(key);
- return buildSliceData(cursor, null /* uri */);
+ return buildSliceData(cursor, null /* uri */, false /* isInlineOnly */);
}
private Cursor getIndexedSliceData(String path) {
verifyIndexing();
- final String whereClause = buildWhereClause();
+ final String whereClause = buildKeyMatchWhereClause();
final SlicesDatabaseHelper helper = SlicesDatabaseHelper.getInstance(mContext);
final SQLiteDatabase database = helper.getReadableDatabase();
final String[] selection = new String[]{path};
- Cursor resultCursor = database.query(TABLE_SLICES_INDEX, SELECT_COLUMNS, whereClause,
+ Cursor resultCursor = database.query(TABLE_SLICES_INDEX, SELECT_COLUMNS_ALL, whereClause,
selection, null /* groupBy */, null /* having */, null /* orderBy */);
int numResults = resultCursor.getCount();
@@ -99,13 +105,13 @@
return resultCursor;
}
- private String buildWhereClause() {
+ private String buildKeyMatchWhereClause() {
return new StringBuilder(IndexColumns.KEY)
.append(" = ?")
.toString();
}
- private SliceData buildSliceData(Cursor cursor, Uri uri) {
+ private SliceData buildSliceData(Cursor cursor, Uri uri, boolean isInlineOnly) {
final String key = cursor.getString(cursor.getColumnIndex(IndexColumns.KEY));
final String title = cursor.getString(cursor.getColumnIndex(IndexColumns.TITLE));
final String summary = cursor.getString(cursor.getColumnIndex(IndexColumns.SUMMARY));
@@ -116,6 +122,14 @@
cursor.getColumnIndex(IndexColumns.FRAGMENT));
final String controllerClassName = cursor.getString(
cursor.getColumnIndex(IndexColumns.CONTROLLER));
+ final boolean isPlatformDefined = cursor.getInt(
+ cursor.getColumnIndex(IndexColumns.PLATFORM_SLICE)) == TRUE;
+ int sliceType = cursor.getInt(
+ cursor.getColumnIndex(IndexColumns.SLICE_TYPE));
+
+ if (!isInlineOnly) {
+ sliceType = SliceData.SliceType.INTENT;
+ }
return new SliceData.Builder()
.setKey(key)
@@ -126,6 +140,8 @@
.setFragmentName(fragmentClassName)
.setPreferenceControllerClassName(controllerClassName)
.setUri(uri)
+ .setPlatformDefined(isPlatformDefined)
+ .setSliceType(sliceType)
.build();
}
diff --git a/src/com/android/settings/slices/SlicesDatabaseHelper.java b/src/com/android/settings/slices/SlicesDatabaseHelper.java
index 627c62e..4334665 100644
--- a/src/com/android/settings/slices/SlicesDatabaseHelper.java
+++ b/src/com/android/settings/slices/SlicesDatabaseHelper.java
@@ -78,6 +78,16 @@
* {@link com.android.settings.core.BasePreferenceController}.
*/
String CONTROLLER = "controller";
+
+ /**
+ * Boolean flag, {@code true} when the Slice is officially platform-supported.
+ */
+ String PLATFORM_SLICE = "platform_slice";
+
+ /**
+ * {@link SliceData.SliceType} representing the inline type of the result.
+ */
+ String SLICE_TYPE = "slice_type";
}
private static final String CREATE_SLICES_TABLE =
@@ -96,6 +106,10 @@
IndexColumns.FRAGMENT +
", " +
IndexColumns.CONTROLLER +
+ ", " +
+ IndexColumns.PLATFORM_SLICE +
+ ", " +
+ IndexColumns.SLICE_TYPE+
");";
private final Context mContext;
diff --git a/src/com/android/settings/slices/SlicesIndexer.java b/src/com/android/settings/slices/SlicesIndexer.java
index a92388a..d7de7bc 100644
--- a/src/com/android/settings/slices/SlicesIndexer.java
+++ b/src/com/android/settings/slices/SlicesIndexer.java
@@ -108,6 +108,8 @@
values.put(IndexColumns.ICON_RESOURCE, dataRow.getIconResource());
values.put(IndexColumns.FRAGMENT, dataRow.getFragmentClassName());
values.put(IndexColumns.CONTROLLER, dataRow.getPreferenceController());
+ values.put(IndexColumns.PLATFORM_SLICE, dataRow.isPlatformDefined());
+ values.put(IndexColumns.SLICE_TYPE, dataRow.getSliceType());
database.replaceOrThrow(Tables.TABLE_SLICES_INDEX, null /* nullColumnHack */,
values);
diff --git a/src/com/android/settings/widget/LinearColorBar.java b/src/com/android/settings/widget/LinearColorBar.java
deleted file mode 100644
index df1403e..0000000
--- a/src/com/android/settings/widget/LinearColorBar.java
+++ /dev/null
@@ -1,195 +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.widget;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Rect;
-import android.util.AttributeSet;
-import android.util.DisplayMetrics;
-import android.widget.LinearLayout;
-
-import com.android.settings.Utils;
-
-/**
- * @Deprecated Use {@link android.widget.ProgressBar} instead.
- */
-public class LinearColorBar extends LinearLayout {
-
- static final int RIGHT_COLOR = 0xffced7db;
- static final int GRAY_COLOR = 0xff555555;
- static final int WHITE_COLOR = 0xffffffff;
-
- private float mRedRatio;
- private float mYellowRatio;
- private float mGreenRatio;
-
- private int mLeftColor;
- private int mMiddleColor;
- private int mRightColor = RIGHT_COLOR;
-
- private int mColoredRegions = REGION_RED | REGION_YELLOW | REGION_GREEN;
-
- final Rect mRect = new Rect();
- final Paint mPaint = new Paint();
-
- int mLineWidth;
-
- int mLastRegion;
-
- final Paint mColorGradientPaint = new Paint();
- final Paint mEdgeGradientPaint = new Paint();
-
- public static final int REGION_RED = 1 << 0;
- public static final int REGION_YELLOW = 1 << 1;
- public static final int REGION_GREEN = 1 << 2;
-
- public LinearColorBar(Context context, AttributeSet attrs) {
- super(context, attrs);
- setWillNotDraw(false);
- mPaint.setStyle(Paint.Style.FILL);
- mColorGradientPaint.setStyle(Paint.Style.FILL);
- mColorGradientPaint.setAntiAlias(true);
- mEdgeGradientPaint.setStyle(Paint.Style.STROKE);
- mLineWidth = getResources().getDisplayMetrics().densityDpi >= DisplayMetrics.DENSITY_HIGH
- ? 2 : 1;
- mEdgeGradientPaint.setStrokeWidth(mLineWidth);
- mEdgeGradientPaint.setAntiAlias(true);
- mLeftColor = mMiddleColor = Utils.getColorAccent(context);
- }
-
- public void setRatios(float red, float yellow, float green) {
- mRedRatio = red;
- mYellowRatio = yellow;
- mGreenRatio = green;
- invalidate();
- }
-
- public void setColors(int red, int yellow, int green) {
- mLeftColor = red;
- mMiddleColor = yellow;
- mRightColor = green;
- updateIndicator();
- invalidate();
- }
-
- private void updateIndicator() {
- int off = getPaddingTop() - getPaddingBottom();
- if (off < 0) off = 0;
- mRect.top = off;
- mRect.bottom = getHeight();
- }
-
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- super.onSizeChanged(w, h, oldw, oldh);
- updateIndicator();
- }
-
- @Override
- protected void dispatchSetPressed(boolean pressed) {
- invalidate();
- }
-
- private int pickColor(int color, int region) {
- if (isPressed() && (mLastRegion & region) != 0) {
- return WHITE_COLOR;
- }
- if ((mColoredRegions & region) == 0) {
- return GRAY_COLOR;
- }
- return color;
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
-
- final int width = getWidth();
-
- if (!isLayoutRtl()) {
- drawLtr(canvas, width);
- } else {
- drawRtl(canvas, width);
- }
- }
-
- private void drawLtr(Canvas canvas, int width) {
- int start = 0;
- int end = start + (int) (width * mRedRatio);
- int end2 = end + (int) (width * mYellowRatio);
-
- if (start < end) {
- mRect.left = start;
- mRect.right = end;
- mPaint.setColor(pickColor(mLeftColor, REGION_RED));
- canvas.drawRect(mRect, mPaint);
- start = end;
- }
-
- end = end2;
-
- if (start < end) {
- mRect.left = start;
- mRect.right = end;
- mPaint.setColor(pickColor(mMiddleColor, REGION_YELLOW));
- canvas.drawRect(mRect, mPaint);
- start = end;
- }
-
- end = width;
- if (start < end) {
- mRect.left = start;
- mRect.right = end;
- mPaint.setColor(pickColor(mRightColor, REGION_GREEN));
- canvas.drawRect(mRect, mPaint);
- }
- }
-
- private void drawRtl(Canvas canvas, int width) {
- int start = width;
- int end = start - (int) (width * mRedRatio);
- int end2 = end - (int) (width * mYellowRatio);
-
- if (start > end) {
- mRect.left = end;
- mRect.right = start;
- mPaint.setColor(pickColor(mLeftColor, REGION_RED));
- canvas.drawRect(mRect, mPaint);
- start = end;
- }
-
- end = end2;
-
- if (start > end) {
- mRect.left = end;
- mRect.right = start;
- mPaint.setColor(pickColor(mMiddleColor, REGION_YELLOW));
- canvas.drawRect(mRect, mPaint);
- start = end;
- }
-
- end = 0;
- if (start > end) {
- mRect.left = end;
- mRect.right = start;
- mPaint.setColor(pickColor(mRightColor, REGION_GREEN));
- canvas.drawRect(mRect, mPaint);
- }
- }
-}
\ No newline at end of file
diff --git a/src/com/android/settings/widget/RadioButtonPreference.java b/src/com/android/settings/widget/RadioButtonPreference.java
index cf5921e..d386698 100644
--- a/src/com/android/settings/widget/RadioButtonPreference.java
+++ b/src/com/android/settings/widget/RadioButtonPreference.java
@@ -20,7 +20,9 @@
import android.support.v4.content.res.TypedArrayUtils;
import android.support.v7.preference.CheckBoxPreference;
import android.support.v7.preference.PreferenceViewHolder;
+import android.text.TextUtils;
import android.util.AttributeSet;
+import android.view.View;
import android.widget.TextView;
import com.android.settings.R;
@@ -72,6 +74,12 @@
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
+ View summaryContainer = view.findViewById(R.id.summary_container);
+ if (summaryContainer != null) {
+ summaryContainer.setVisibility(
+ TextUtils.isEmpty(getSummary()) ? View.GONE : View.VISIBLE);
+ }
+
TextView title = (TextView) view.findViewById(android.R.id.title);
if (title != null) {
title.setSingleLine(false);
diff --git a/tests/robotests/src/com/android/settings/MasterClearTest.java b/tests/robotests/src/com/android/settings/MasterClearTest.java
index dc956aa..64dab16 100644
--- a/tests/robotests/src/com/android/settings/MasterClearTest.java
+++ b/tests/robotests/src/com/android/settings/MasterClearTest.java
@@ -45,6 +45,7 @@
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.Button;
+import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.ScrollView;
@@ -142,27 +143,43 @@
@Test
public void testShowWipeEuicc_euiccDisabled() {
- prepareEuiccState(false /* isEuiccEnabled */, true /* isEuiccProvisioned */);
+ prepareEuiccState(
+ false /* isEuiccEnabled */,
+ true /* isEuiccProvisioned */,
+ false /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isFalse();
}
@Test
public void testShowWipeEuicc_euiccEnabled_unprovisioned() {
- prepareEuiccState(true /* isEuiccEnabled */, false /* isEuiccProvisioned */);
+ prepareEuiccState(
+ true /* isEuiccEnabled */,
+ false /* isEuiccProvisioned */,
+ false /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isFalse();
}
@Test
public void testShowWipeEuicc_euiccEnabled_provisioned() {
- prepareEuiccState(true /* isEuiccEnabled */, true /* isEuiccProvisioned */);
+ prepareEuiccState(
+ true /* isEuiccEnabled */,
+ true /* isEuiccProvisioned */,
+ false /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isTrue();
}
- private void prepareEuiccState(boolean isEuiccEnabled, boolean isEuiccProvisioned) {
- doReturn(mActivity).when(mMasterClear).getContext();
- doReturn(isEuiccEnabled).when(mMasterClear).isEuiccEnabled(any());
- ContentResolver cr = mActivity.getContentResolver();
- Settings.Global.putInt(cr, Settings.Global.EUICC_PROVISIONED, isEuiccProvisioned ? 1 : 0);
+ @Test
+ public void testShowWipeEuicc_developerMode_unprovisioned() {
+ prepareEuiccState(
+ true /* isEuiccEnabled */,
+ false /* isEuiccProvisioned */,
+ true /* isDeveloper */);
+ assertThat(mMasterClear.showWipeEuicc()).isTrue();
+ }
+
+ @Test
+ public void testEsimRecheckBoxDefaultChecked() {
+ assertThat(((CheckBox) mContentView.findViewById(R.id.erase_esim)).isChecked()).isTrue();
}
@Test
@@ -373,6 +390,16 @@
verify(viewTreeObserver, never()).removeOnGlobalLayoutListener(mMasterClear);
}
+ private void prepareEuiccState(
+ boolean isEuiccEnabled, boolean isEuiccProvisioned, boolean isDeveloper) {
+ doReturn(mActivity).when(mMasterClear).getContext();
+ doReturn(isEuiccEnabled).when(mMasterClear).isEuiccEnabled(any());
+ ContentResolver cr = mActivity.getContentResolver();
+ Settings.Global.putInt(cr, Settings.Global.EUICC_PROVISIONED, isEuiccProvisioned ? 1 : 0);
+ Settings.Global.putInt(
+ cr, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, isDeveloper ? 1 : 0);
+ }
+
private void initScrollView(int height, int scrollY, int childBottom) {
when(mScrollView.getHeight()).thenReturn(height);
when(mScrollView.getScrollY()).thenReturn(scrollY);
diff --git a/tests/robotests/src/com/android/settings/SummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/SummaryPreferenceTest.java
index 9ca93f5..9352d4b 100644
--- a/tests/robotests/src/com/android/settings/SummaryPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/SummaryPreferenceTest.java
@@ -25,13 +25,16 @@
import android.widget.TextView;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.robolectric.annotation.Config;
import org.robolectric.RuntimeEnvironment;
@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = SettingsShadowResourcesImpl.class)
public class SummaryPreferenceTest {
private PreferenceViewHolder mHolder;
diff --git a/tests/robotests/src/com/android/settings/UtilsTest.java b/tests/robotests/src/com/android/settings/UtilsTest.java
index a2b1892..fcd40aa 100644
--- a/tests/robotests/src/com/android/settings/UtilsTest.java
+++ b/tests/robotests/src/com/android/settings/UtilsTest.java
@@ -17,6 +17,9 @@
package com.android.settings;
import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.doReturn;
@@ -188,12 +191,13 @@
@Test
public void testGetBadgedIcon_usePackageNameAndUserId()
throws PackageManager.NameNotFoundException {
- doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfo(PACKAGE_NAME,
- PackageManager.GET_META_DATA);
+ doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfoAsUser(
+ PACKAGE_NAME, PackageManager.GET_META_DATA, USER_ID);
Utils.getBadgedIcon(mIconDrawableFactory, mPackageManager, PACKAGE_NAME, USER_ID);
// Verify that it uses the correct user id
+ verify(mPackageManager).getApplicationInfoAsUser(eq(PACKAGE_NAME), anyInt(), eq(USER_ID));
verify(mIconDrawableFactory).getBadgedIcon(mApplicationInfo, USER_ID);
}
}
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePreferenceControllerTest.java
index 2aa2fa6..a9cfa01 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePreferenceControllerTest.java
@@ -89,6 +89,13 @@
}
@Test
+ public void getDefaultApp_noDefaultHome_shouldReturnNull() {
+ when(mPackageManager.getHomeActivities(anyList())).thenReturn(null);
+
+ assertThat(mController.getDefaultAppInfo()).isNull();
+ }
+
+ @Test
public void updateState_noDefaultApp_shouldAskPackageManagerForOnlyApp() {
when(mPackageManager.getHomeActivities(anyList())).thenReturn(null);
mController.updateState(mock(Preference.class));
@@ -152,4 +159,11 @@
.thenReturn(Arrays.asList(mock(ResolveInfo.class), mock(ResolveInfo.class)));
assertThat(mController.getSettingIntent(mController.getDefaultAppInfo())).isNull();
}
+
+ @Test
+ public void testGetSettingIntent_noDefauldHome_shouldReturnNull() {
+ when(mPackageManager.getHomeActivities(anyList())).thenReturn(null);
+ assertThat(mController.getSettingIntent(mController.getDefaultAppInfo())).isNull();
+ }
+
}
diff --git a/tests/robotests/src/com/android/settings/core/PreferenceXmlParserUtilTest.java b/tests/robotests/src/com/android/settings/core/PreferenceXmlParserUtilsTest.java
similarity index 99%
rename from tests/robotests/src/com/android/settings/core/PreferenceXmlParserUtilTest.java
rename to tests/robotests/src/com/android/settings/core/PreferenceXmlParserUtilsTest.java
index 458bc02..c96cebd 100644
--- a/tests/robotests/src/com/android/settings/core/PreferenceXmlParserUtilTest.java
+++ b/tests/robotests/src/com/android/settings/core/PreferenceXmlParserUtilsTest.java
@@ -48,7 +48,7 @@
* with another preference with a matchin replacement attribute.
*/
@RunWith(SettingsRobolectricTestRunner.class)
-public class PreferenceXmlParserUtilTest {
+public class PreferenceXmlParserUtilsTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
index 58e42a0..bfa296b 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
@@ -228,6 +228,7 @@
bindViewHolder();
assertThat(mLabelBar.getVisibility()).isEqualTo(View.GONE);
+ assertThat(mProgressBar.getVisibility()).isEqualTo(View.GONE);
}
@Test
@@ -236,6 +237,7 @@
bindViewHolder();
assertThat(mLabelBar.getVisibility()).isEqualTo(View.GONE);
+ assertThat(mProgressBar.getVisibility()).isEqualTo(View.GONE);
}
@Test
@@ -245,6 +247,7 @@
bindViewHolder();
assertThat(mLabelBar.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(mProgressBar.getVisibility()).isEqualTo(View.VISIBLE);
}
diff --git a/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollEnrollingTest.java b/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollEnrollingTest.java
index c9ed3a5..b9a6b10 100644
--- a/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollEnrollingTest.java
+++ b/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollEnrollingTest.java
@@ -36,6 +36,7 @@
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import com.android.settings.testutils.shadow.ShadowUtils;
import com.android.settings.testutils.shadow.ShadowVibrator;
import com.android.settings.wrapper.FingerprintManagerWrapper;
@@ -54,7 +55,10 @@
import java.util.concurrent.TimeUnit;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = {ShadowUtils.class, ShadowVibrator.class})
+@Config(shadows = {
+ SettingsShadowResourcesImpl.class,
+ ShadowUtils.class,
+ ShadowVibrator.class})
public class FingerprintEnrollEnrollingTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverControllerTest.java
index 965684e..8924fa7 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverControllerTest.java
@@ -15,16 +15,21 @@
*/
package com.android.settings.fuelgauge;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.content.ContentResolver;
import android.content.Context;
import android.os.PowerManager;
+import android.support.v7.preference.Preference;
+import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.widget.MasterSwitchPreference;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
@@ -38,15 +43,19 @@
public class BatterySaverControllerTest {
@Mock
- private MasterSwitchPreference mBatterySaverPref;
+ private Preference mBatterySaverPref;
@Mock
private PowerManager mPowerManager;
@Mock
private Context mContext;
@Mock
- private Lifecycle mLifecycle;
+ private ContentResolver mContentResolver;
+
private BatterySaverController mBatterySaverController;
+ private static final String SAVER_ON_SUMMARY = "saver-on";
+ private static final String SAVER_OFF_SUMMARY = "saver-off";
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
@@ -55,54 +64,27 @@
ReflectionHelpers.setField(mBatterySaverController, "mPowerManager", mPowerManager);
ReflectionHelpers.setField(mBatterySaverController, "mBatterySaverPref", mBatterySaverPref);
doNothing().when(mBatterySaverController).refreshConditionManager();
+
+ when(mContext.getContentResolver()).thenReturn(mContentResolver);
+
+ when(mContext.getString(anyInt(), any(Object.class)))
+ .thenAnswer((inv) -> "str-" + inv.getArgument(0));
+
+ when(mContext.getString(eq(R.string.battery_saver_on_summary), any(Object.class)))
+ .thenReturn(SAVER_ON_SUMMARY);
+ when(mContext.getString(eq(R.string.battery_saver_off_summary), any(Object.class)))
+ .thenReturn(SAVER_OFF_SUMMARY);
}
@Test
- public void testOnPreferenceChange_TurnOnBatterySaver_BatterySaverOn() {
- testOnPreferenceChangeInner(true);
+ public void testOnPreferenceChange_onStart() {
+ mBatterySaverController.onStart();
+ verify(mBatterySaverPref).setSummary(eq(SAVER_OFF_SUMMARY));
}
@Test
- public void testOnPreferenceChange_TurnOffBatterySaver_BatterySaverOff() {
- testOnPreferenceChangeInner(false);
- }
-
- @Test
- public void testUpdateState_SaverModeOn_PreferenceChecked() {
- testUpdateStateInner(true);
- }
-
- @Test
- public void testUpdateState_SaverModeOff_PreferenceUnChecked() {
- testUpdateStateInner(false);
- }
-
- @Test
- public void testOnBatteryChanged_pluggedIn_setDisable() {
- mBatterySaverController.onBatteryChanged(true /* pluggedIn */);
-
- verify(mBatterySaverPref).setSwitchEnabled(false);
- }
-
- @Test
- public void testOnBatteryChanged_notPluggedIn_setEnable() {
- mBatterySaverController.onBatteryChanged(false /* pluggedIn */);
-
- verify(mBatterySaverPref).setSwitchEnabled(true);
- }
-
- private void testOnPreferenceChangeInner(final boolean saverOn) {
- when(mPowerManager.setPowerSaveMode(saverOn)).thenReturn(true);
- when(mPowerManager.isPowerSaveMode()).thenReturn(!saverOn);
-
- mBatterySaverController.onPreferenceChange(mBatterySaverPref, saverOn);
- verify(mPowerManager).setPowerSaveMode(saverOn);
- }
-
- private void testUpdateStateInner(final boolean saverOn) {
- when(mPowerManager.isPowerSaveMode()).thenReturn(saverOn);
-
- mBatterySaverController.updateState(mBatterySaverPref);
- verify(mBatterySaverPref).setChecked(saverOn);
+ public void testOnPreferenceChange_onPowerSaveModeChanged() {
+ mBatterySaverController.onPowerSaveModeChanged();
+ verify(mBatterySaverPref).setSummary(eq(SAVER_OFF_SUMMARY));
}
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
index 6518b8e..8b1076d 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
@@ -516,12 +516,12 @@
@Test
public void testIsLegacyApp_SdkLowerThanO_ReturnTrue() {
- assertThat(mBatteryUtils.isLegacyApp(LOW_SDK_PACKAGE)).isTrue();
+ assertThat(mBatteryUtils.isPreOApp(LOW_SDK_PACKAGE)).isTrue();
}
@Test
public void testIsLegacyApp_SdkLargerOrEqualThanO_ReturnFalse() {
- assertThat(mBatteryUtils.isLegacyApp(HIGH_SDK_PACKAGE)).isFalse();
+ assertThat(mBatteryUtils.isPreOApp(HIGH_SDK_PACKAGE)).isFalse();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/RestrictedAppDetailsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/RestrictedAppDetailsTest.java
index 261acad..94a6903 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/RestrictedAppDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/RestrictedAppDetailsTest.java
@@ -21,13 +21,13 @@
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
+import android.os.UserHandle;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceManager;
@@ -54,7 +54,8 @@
public class RestrictedAppDetailsTest {
private static final String PACKAGE_NAME = "com.android.app";
- private static final int UID = 234;
+ private static final int USER_ID = 10;
+ private static final int UID = UserHandle.getUid(USER_ID, 234);
private static final String APP_NAME = "app";
@Mock
@@ -99,7 +100,8 @@
@Test
public void testRefreshUi_displayPreference() throws Exception {
- doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfo(PACKAGE_NAME, 0);
+ doReturn(mApplicationInfo).when(mPackageManager)
+ .getApplicationInfoAsUser(PACKAGE_NAME, 0, USER_ID);
doReturn(APP_NAME).when(mPackageManager).getApplicationLabel(mApplicationInfo);
mRestrictedAppDetails.refreshUi();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySeekBarPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySeekBarPreferenceControllerTest.java
index 72dde96..63b9742 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySeekBarPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySeekBarPreferenceControllerTest.java
@@ -85,7 +85,7 @@
mController.updateState(mPreference);
assertThat(mPreference.isVisible()).isTrue();
- assertThat(mPreference.getTitle()).isEqualTo("Turn on automatically at 20%");
+ assertThat(mPreference.getTitle()).isEqualTo("Turn on at 20%");
assertThat(mPreference.getProgress()).isEqualTo(TRIGGER_LEVEL);
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryManagerPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryManagerPreferenceControllerTest.java
new file mode 100644
index 0000000..8b4c017
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryManagerPreferenceControllerTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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.fuelgauge.batterytip;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.app.AppOpsManager;
+import android.content.Context;
+import android.provider.Settings;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class BatteryManagerPreferenceControllerTest {
+ private static final int ON = 1;
+ private static final int OFF = 0;
+
+ @Mock
+ private AppOpsManager mAppOpsManager;
+
+
+ private Context mContext;
+ private Preference mPreference;
+ private FakeFeatureFactory mFeatureFactory;
+ private BatteryManagerPreferenceController mController;
+
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mContext = spy(RuntimeEnvironment.application);
+ when(mContext.getSystemService(AppOpsManager.class)).thenReturn(mAppOpsManager);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
+ mPreference = new Preference(mContext);
+ mController = new BatteryManagerPreferenceController(mContext);
+ }
+
+ @Test
+ public void updateState_smartBatteryOnWithRestrictApps_showSummary() {
+ mController.updateSummary(mPreference, true /* smartBatteryOn */, 2);
+
+ assertThat(mPreference.getSummary()).isEqualTo("2 apps restricted");
+ }
+
+ @Test
+ public void updateState_smartBatteryOnWithoutRestriction_showSummary() {
+ when(mFeatureFactory.powerUsageFeatureProvider.isSmartBatterySupported()).thenReturn(true);
+ Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.APP_STANDBY_ENABLED,
+ ON);
+
+ mController.updateState(mPreference);
+
+ assertThat(mPreference.getSummary()).isEqualTo("On / Restricting apps automatically");
+ }
+
+ @Test
+ public void updateState_smartBatteryOff_showSummary() {
+ when(mFeatureFactory.powerUsageFeatureProvider.isSmartBatterySupported()).thenReturn(true);
+ Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.APP_STANDBY_ENABLED,
+ OFF);
+
+ mController.updateState(mPreference);
+
+ assertThat(mPreference.getSummary()).isEqualTo("Off");
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
index f09e569..d32e026 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
@@ -59,6 +59,7 @@
private static final String DISPLAY_NAME = "app";
private static final long SCREEN_TIME_MS = DateUtils.HOUR_IN_MILLIS;
private static final long AVERAGE_TIME_MS = DateUtils.HOUR_IN_MILLIS;
+ private static final int METRICS_KEY = 1;
private BatteryTipDialogFragment mDialogFragment;
private Context mContext;
@@ -102,7 +103,7 @@
public void testOnCreateDialog_highUsageTip_fireHighUsageDialog() {
Robolectric.getForegroundThreadScheduler().pause();
- mDialogFragment = BatteryTipDialogFragment.newInstance(mHighUsageTip);
+ mDialogFragment = BatteryTipDialogFragment.newInstance(mHighUsageTip, METRICS_KEY);
FragmentTestUtil.startFragment(mDialogFragment);
@@ -117,7 +118,7 @@
@Test
public void testOnCreateDialog_restrictOneAppTip_fireRestrictOneAppDialog() {
- mDialogFragment = BatteryTipDialogFragment.newInstance(mRestrictedOneAppTip);
+ mDialogFragment = BatteryTipDialogFragment.newInstance(mRestrictedOneAppTip, METRICS_KEY);
FragmentTestUtil.startFragment(mDialogFragment);
@@ -134,7 +135,8 @@
public void testOnCreateDialog_restrictTwoAppsTip_fireRestrictTwoAppsDialog() {
Robolectric.getForegroundThreadScheduler().pause();
- mDialogFragment = BatteryTipDialogFragment.newInstance(mRestrictTwoAppsTip);
+ mDialogFragment = BatteryTipDialogFragment.newInstance(mRestrictTwoAppsTip, METRICS_KEY);
+
FragmentTestUtil.startFragment(mDialogFragment);
@@ -161,7 +163,7 @@
final RestrictAppTip restrictSixAppsTip = new RestrictAppTip(BatteryTip.StateType.NEW,
appInfos);
- mDialogFragment = BatteryTipDialogFragment.newInstance(restrictSixAppsTip);
+ mDialogFragment = BatteryTipDialogFragment.newInstance(restrictSixAppsTip, METRICS_KEY);
FragmentTestUtil.startFragment(mDialogFragment);
@@ -178,7 +180,8 @@
@Test
public void testOnCreateDialog_unRestrictAppTip_fireUnRestrictDialog() {
- mDialogFragment = BatteryTipDialogFragment.newInstance(mUnrestrictAppTip);
+ mDialogFragment = BatteryTipDialogFragment.newInstance(mUnrestrictAppTip, METRICS_KEY);
+ ShadowUtils.setApplicationLabel(PACKAGE_NAME, DISPLAY_NAME);
FragmentTestUtil.startFragment(mDialogFragment);
@@ -193,7 +196,7 @@
@Test
public void testOnCreateDialog_summaryTipWithEstimation_fireDialogWithEstimation() {
doReturn(AVERAGE_TIME_MS).when(mSummaryTip).getAverageTimeMs();
- mDialogFragment = BatteryTipDialogFragment.newInstance(mSummaryTip);
+ mDialogFragment = BatteryTipDialogFragment.newInstance(mSummaryTip, METRICS_KEY);
FragmentTestUtil.startFragment(mDialogFragment);
@@ -207,7 +210,7 @@
@Test
public void testOnCreateDialog_summaryTipWithoutEstimation_fireDialogWithoutEstimation() {
- mDialogFragment = BatteryTipDialogFragment.newInstance(mSummaryTip);
+ mDialogFragment = BatteryTipDialogFragment.newInstance(mSummaryTip, METRICS_KEY);
FragmentTestUtil.startFragment(mDialogFragment);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceControllerTest.java
index 612f569..1e754c8 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceControllerTest.java
@@ -37,6 +37,7 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.SettingsActivity;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.SummaryTip;
import com.android.settings.testutils.FakeFeatureFactory;
@@ -70,6 +71,8 @@
private SettingsActivity mSettingsActivity;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private PreferenceManager mPreferenceManager;
+ @Mock
+ private InstrumentedPreferenceFragment mFragment;
private Context mContext;
private PreferenceGroup mPreferenceGroup;
@@ -98,7 +101,7 @@
mNewBatteryTips.add(new SummaryTip(BatteryTip.StateType.INVISIBLE, AVERAGE_TIME_MS));
mBatteryTipPreferenceController = new BatteryTipPreferenceController(mContext, KEY_PREF,
- mSettingsActivity, null, mBatteryTipListener);
+ mSettingsActivity, mFragment, mBatteryTipListener);
mBatteryTipPreferenceController.mPreferenceGroup = mPreferenceGroup;
mBatteryTipPreferenceController.mPrefContext = mContext;
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppActionTest.java
index 8934dfa..0e06765 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppActionTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppActionTest.java
@@ -20,12 +20,16 @@
import static org.mockito.Mockito.verify;
import android.app.AppOpsManager;
+import android.content.Context;
+import android.util.Pair;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.fuelgauge.BatteryUtils;
import com.android.settings.fuelgauge.batterytip.AppInfo;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip;
import com.android.settings.testutils.DatabaseTestUtils;
+import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.After;
@@ -44,21 +48,32 @@
private static final String PACKAGE_NAME_1 = "com.android.app1";
private static final String PACKAGE_NAME_2 = "com.android.app2";
+ private static final int ANOMALY_WAKEUP = 0;
+ private static final int ANOMALY_BT = 1;
+ private static final int METRICS_KEY = 1;
@Mock
private BatteryUtils mBatteryUtils;
private RestrictAppAction mRestrictAppAction;
+ private FakeFeatureFactory mFeatureFactory;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
final List<AppInfo> mAppInfos = new ArrayList<>();
- mAppInfos.add(new AppInfo.Builder().setPackageName(PACKAGE_NAME_1).build());
- mAppInfos.add(new AppInfo.Builder().setPackageName(PACKAGE_NAME_2).build());
+ mAppInfos.add(new AppInfo.Builder()
+ .setPackageName(PACKAGE_NAME_1)
+ .build());
+ mAppInfos.add(new AppInfo.Builder()
+ .setPackageName(PACKAGE_NAME_2)
+ .addAnomalyType(ANOMALY_BT)
+ .addAnomalyType(ANOMALY_WAKEUP)
+ .build());
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mRestrictAppAction = new RestrictAppAction(RuntimeEnvironment.application,
- new RestrictAppTip(BatteryTip.StateType.NEW, mAppInfos));
+ new RestrictAppTip(BatteryTip.StateType.NEW, mAppInfos));
mRestrictAppAction.mBatteryUtils = mBatteryUtils;
}
@@ -69,11 +84,22 @@
@Test
public void testHandlePositiveAction() {
- mRestrictAppAction.handlePositiveAction();
+ mRestrictAppAction.handlePositiveAction(METRICS_KEY);
verify(mBatteryUtils)
- .setForceAppStandby(anyInt(), eq(PACKAGE_NAME_1), eq(AppOpsManager.MODE_IGNORED));
+ .setForceAppStandby(anyInt(), eq(PACKAGE_NAME_1), eq(AppOpsManager.MODE_IGNORED));
verify(mBatteryUtils)
- .setForceAppStandby(anyInt(), eq(PACKAGE_NAME_2), eq(AppOpsManager.MODE_IGNORED));
+ .setForceAppStandby(anyInt(), eq(PACKAGE_NAME_2), eq(AppOpsManager.MODE_IGNORED));
+ verify(mFeatureFactory.metricsFeatureProvider).action(RuntimeEnvironment.application,
+ MetricsProto.MetricsEvent.ACTION_TIP_RESTRICT_APP, PACKAGE_NAME_1, Pair.create(
+ MetricsProto.MetricsEvent.FIELD_CONTEXT, METRICS_KEY));
+ verify(mFeatureFactory.metricsFeatureProvider).action(RuntimeEnvironment.application,
+ MetricsProto.MetricsEvent.ACTION_TIP_RESTRICT_APP, PACKAGE_NAME_2,
+ Pair.create(MetricsProto.MetricsEvent.FIELD_CONTEXT, METRICS_KEY),
+ Pair.create(MetricsProto.MetricsEvent.FIELD_ANOMALY_TYPE, ANOMALY_WAKEUP));
+ verify(mFeatureFactory.metricsFeatureProvider).action(RuntimeEnvironment.application,
+ MetricsProto.MetricsEvent.ACTION_TIP_RESTRICT_APP, PACKAGE_NAME_2,
+ Pair.create(MetricsProto.MetricsEvent.FIELD_CONTEXT, METRICS_KEY),
+ Pair.create(MetricsProto.MetricsEvent.FIELD_ANOMALY_TYPE, ANOMALY_BT));
}
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/UnrestrictAppActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/UnrestrictAppActionTest.java
new file mode 100644
index 0000000..f176324
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/UnrestrictAppActionTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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.fuelgauge.batterytip.actions;
+
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.verify;
+
+import android.app.AppOpsManager;
+import android.util.Pair;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.fuelgauge.BatteryUtils;
+import com.android.settings.fuelgauge.batterytip.AppInfo;
+import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
+import com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip;
+import com.android.settings.testutils.DatabaseTestUtils;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class UnrestrictAppActionTest {
+
+ private static final String PACKAGE_NAME_1 = "com.android.app1";
+ private static final int METRICS_KEY = 1;
+
+ @Mock
+ private BatteryUtils mBatteryUtils;
+ private UnrestrictAppAction mUnrestrictAppAction;
+ private FakeFeatureFactory mFeatureFactory;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ final AppInfo appInfo = new AppInfo.Builder().setPackageName(PACKAGE_NAME_1).build();
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
+
+ mUnrestrictAppAction = new UnrestrictAppAction(RuntimeEnvironment.application,
+ new UnrestrictAppTip(BatteryTip.StateType.NEW, appInfo));
+ mUnrestrictAppAction.mBatteryUtils = mBatteryUtils;
+ }
+
+ @After
+ public void cleanUp() {
+ DatabaseTestUtils.clearDb(RuntimeEnvironment.application);
+ }
+
+ @Test
+ public void testHandlePositiveAction() {
+ mUnrestrictAppAction.handlePositiveAction(METRICS_KEY);
+
+ verify(mBatteryUtils)
+ .setForceAppStandby(anyInt(), eq(PACKAGE_NAME_1), eq(AppOpsManager.MODE_ALLOWED));
+ verify(mFeatureFactory.metricsFeatureProvider).action(RuntimeEnvironment.application,
+ MetricsProto.MetricsEvent.ACTION_TIP_UNRESTRICT_APP, PACKAGE_NAME_1, Pair.create(
+ MetricsProto.MetricsEvent.FIELD_CONTEXT, METRICS_KEY));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
index c63f1c2..e07351c 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
@@ -107,6 +107,7 @@
assertThat(drawable.getCreatedFromResId()).isEqualTo(R.drawable.ic_fingerprint_header);
}
+ @Config(qualifiers = "sw300dp")
@Test
public void smallScreens_shouldHideIcon() {
ChooseLockPattern activity = createActivity(true);
diff --git a/tests/robotests/src/com/android/settings/password/SetupChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/password/SetupChooseLockPatternTest.java
index ab08a90..a98db11 100644
--- a/tests/robotests/src/com/android/settings/password/SetupChooseLockPatternTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetupChooseLockPatternTest.java
@@ -17,6 +17,7 @@
package com.android.settings.password;
import static com.google.common.truth.Truth.assertThat;
+
import static org.robolectric.RuntimeEnvironment.application;
import android.app.Activity;
@@ -46,10 +47,6 @@
import org.robolectric.shadows.ShadowAlertDialog;
import org.robolectric.shadows.ShadowPackageManager;
import org.robolectric.util.ReflectionHelpers;
-import org.robolectric.util.ReflectionHelpers.ClassParameter;
-
-import java.util.Collections;
-import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(shadows = {
@@ -89,7 +86,6 @@
assertThat(componentEnabled).isEqualTo(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}
- @Config(qualifiers = "sw400dp")
@Test
public void selectPattern_shouldHideOptionsButton() {
Button button = mActivity.findViewById(R.id.screen_lock_options);
@@ -114,6 +110,7 @@
assertThat(count).named("List items shown").isEqualTo(3);
}
+ @Config(qualifiers = "sw300dp")
@Test
public void smallScreens_shouldHideScreenLockOptions() {
Button button = mActivity.findViewById(R.id.screen_lock_options);
diff --git a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
index 8ddd48a..d54d16f 100644
--- a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
@@ -82,7 +82,7 @@
@Test
public void testInitialSliceReturned_emptySlice() {
- insertSpecialCase(INTENT_PATH);
+ insertSpecialCase(KEY);
Uri uri = SliceBuilderUtils.getUri(INTENT_PATH, false);
Slice slice = mProvider.onBindSlice(uri);
@@ -93,7 +93,7 @@
@Test
public void testLoadSlice_returnsSliceFromAccessor() {
insertSpecialCase(KEY);
- Uri uri = SliceBuilderUtils.getUri(KEY, false);
+ Uri uri = SliceBuilderUtils.getUri(INTENT_PATH, false);
mProvider.loadSlice(uri);
SliceData data = mProvider.mSliceDataCache.get(uri);
diff --git a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
index 39b381d..869ba48 100644
--- a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
@@ -24,6 +24,7 @@
import android.content.Context;
import android.net.Uri;
import android.provider.SettingsSlicesContract;
+import android.util.Pair;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
@@ -188,6 +189,59 @@
assertThat(summary).isEqualTo(data.getScreenTitle());
}
+ @Test
+ public void getPathData_splitsIntentUri() {
+ Uri uri = new Uri.Builder()
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_INTENT)
+ .appendPath(KEY)
+ .build();
+
+ Pair<Boolean, String> pathPair = SliceBuilderUtils.getPathData(uri);
+
+ assertThat(pathPair.first).isFalse();
+ assertThat(pathPair.second).isEqualTo(KEY);
+ }
+
+ @Test
+ public void getPathData_splitsActionUri() {
+ Uri uri = new Uri.Builder()
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+ .appendPath(KEY)
+ .build();
+
+ Pair<Boolean, String> pathPair = SliceBuilderUtils.getPathData(uri);
+
+ assertThat(pathPair.first).isTrue();
+ assertThat(pathPair.second).isEqualTo(KEY);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void getPathData_noKey_returnsNull() {
+ Uri uri = new Uri.Builder()
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+ .build();
+
+ SliceBuilderUtils.getPathData(uri);
+ }
+
+ @Test
+ public void getPathData_extraArg_returnsNull() {
+ Uri uri = new Uri.Builder()
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+ .appendPath(KEY)
+ .appendPath(KEY)
+ .build();
+
+ Pair<Boolean, String> pathPair = SliceBuilderUtils.getPathData(uri);
+
+ assertThat(pathPair.first).isTrue();
+ assertThat(pathPair.second).isEqualTo(KEY + "/" + KEY);
+ }
+
private SliceData getDummyData() {
return getDummyData(PREF_CONTROLLER, SUMMARY);
}
diff --git a/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java b/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java
index 331058c..77c9891 100644
--- a/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java
@@ -89,8 +89,9 @@
@Test
public void testGetSliceFromUri_validUri_validSliceReturned() {
String key = "key";
+ String path = "intent/" + key;
insertSpecialCase(key);
- Uri uri = SliceBuilderUtils.getUri(key, false);
+ Uri uri = SliceBuilderUtils.getUri(path, false);
SliceData data = mAccessor.getSliceDataFromUri(uri);
@@ -106,8 +107,7 @@
@Test(expected = IllegalStateException.class)
public void testGetSliceFromUri_invalidUri_errorThrown() {
- Uri uri = SliceBuilderUtils.getUri("durr", false);
-
+ Uri uri = SliceBuilderUtils.getUri("intent/durr", false);
mAccessor.getSliceDataFromUri(uri);
}
diff --git a/tests/robotests/src/com/android/settings/slices/SlicesDatabaseHelperTest.java b/tests/robotests/src/com/android/settings/slices/SlicesDatabaseHelperTest.java
index 7d1b401..98ab2a1 100644
--- a/tests/robotests/src/com/android/settings/slices/SlicesDatabaseHelperTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SlicesDatabaseHelperTest.java
@@ -68,7 +68,9 @@
IndexColumns.SCREENTITLE,
IndexColumns.ICON_RESOURCE,
IndexColumns.FRAGMENT,
- IndexColumns.CONTROLLER
+ IndexColumns.CONTROLLER,
+ IndexColumns.PLATFORM_SLICE,
+ IndexColumns.SLICE_TYPE,
};
assertThat(columnNames).isEqualTo(expectedNames);
diff --git a/tests/robotests/src/com/android/settings/slices/SlicesIndexerTest.java b/tests/robotests/src/com/android/settings/slices/SlicesIndexerTest.java
index ca198cb..2af9c79 100644
--- a/tests/robotests/src/com/android/settings/slices/SlicesIndexerTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SlicesIndexerTest.java
@@ -50,6 +50,8 @@
private final int ICON = 1234; // I declare a thumb war
private final Uri URI = Uri.parse("content://com.android.settings.slices/test");
private final String PREF_CONTROLLER = "com.android.settings.slices.tester";
+ private final boolean PLATFORM_DEFINED = true;
+ private final int SLICE_TYPE = SliceData.SliceType.SLIDER;
private Context mContext;
@@ -109,10 +111,22 @@
cursor.moveToFirst();
for (int i = 0; i < sliceData.size(); i++) {
- assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.KEY)))
- .isEqualTo(KEYS[i]);
- assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.TITLE)))
- .isEqualTo(TITLES[i]);
+ assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.KEY))).isEqualTo(
+ KEYS[i]);
+ assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.TITLE))).isEqualTo(
+ TITLES[i]);
+ assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.FRAGMENT))).isEqualTo(
+ FRAGMENT_NAME);
+ assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.SCREENTITLE))).isEqualTo(
+ SCREEN_TITLE);
+ assertThat(cursor.getInt(cursor.getColumnIndex(IndexColumns.ICON_RESOURCE))).isEqualTo(
+ ICON);
+ assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.CONTROLLER))).isEqualTo(
+ PREF_CONTROLLER);
+ assertThat(cursor.getInt(cursor.getColumnIndex(IndexColumns.PLATFORM_SLICE))).isEqualTo(
+ 1 /* true */);
+ assertThat(cursor.getInt(cursor.getColumnIndex(IndexColumns.SLICE_TYPE))).isEqualTo(
+ SLICE_TYPE);
cursor.moveToNext();
}
}
@@ -126,15 +140,17 @@
}
private List<SliceData> getDummyIndexableData() {
- final SliceData.Builder builder = new SliceData.Builder()
- .setSummary(SUMMARY)
- .setScreenTitle(SCREEN_TITLE)
- .setFragmentName(FRAGMENT_NAME)
- .setIcon(ICON)
- .setUri(URI)
- .setPreferenceControllerClassName(PREF_CONTROLLER);
-
final List<SliceData> sliceData = new ArrayList<>();
+ final SliceData.Builder builder = new SliceData.Builder()
+ .setSummary(SUMMARY)
+ .setScreenTitle(SCREEN_TITLE)
+ .setFragmentName(FRAGMENT_NAME)
+ .setIcon(ICON)
+ .setUri(URI)
+ .setPreferenceControllerClassName(PREF_CONTROLLER)
+ .setPlatformDefined(PLATFORM_DEFINED)
+ .setSliceType(SLICE_TYPE);
+
for (int i = 0; i < KEYS.length; i++) {
builder.setKey(KEYS[i]).setTitle(TITLES[i]);
sliceData.add(builder.build());
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java
index 361b7b3..3fb8e2d 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java
@@ -52,6 +52,11 @@
id = R.drawable.ic_expand_more_inverse;
} else if (id == R.drawable.selectable_card_grey) {
id = R.drawable.ic_expand_more_inverse;
+ } else if (id == R.drawable.color_bar_progress
+ || id == R.drawable.ring_progress) {
+ // color_bar_progress and ring_progress use hidden resources, so just use the regular
+ // progress_horizontal drawable
+ id = android.R.drawable.progress_horizontal;
}
return super.loadDrawable(wrapper, value, id, density, theme);
}
diff --git a/tests/robotests/src/com/android/settings/widget/LinearColorBarTest.java b/tests/robotests/src/com/android/settings/widget/LinearColorBarTest.java
deleted file mode 100644
index e2c82c2..0000000
--- a/tests/robotests/src/com/android/settings/widget/LinearColorBarTest.java
+++ /dev/null
@@ -1,83 +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.widget;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.graphics.Canvas;
-
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-import org.robolectric.shadows.ShadowCanvas;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class LinearColorBarTest {
-
- private static final int HEIGHT = 100;
- private static final int WIDTH = 100;
-
- private Context mContext;
- private LinearColorBar mLinearColorBar;
- private Canvas mCanvas;
-
- @Before
- public void setUp() {
- mContext = RuntimeEnvironment.application;
- mLinearColorBar = spy(new LinearColorBar(mContext, null /* attrs */));
- when(mLinearColorBar.getHeight()).thenReturn(HEIGHT);
- when(mLinearColorBar.getWidth()).thenReturn(WIDTH);
- mLinearColorBar.setRatios(0.2f, 0.4f, 0.4f);
- mLinearColorBar.setColors(1, 2, 3);
- mCanvas = new Canvas();
- }
-
- @Test
- public void draw_ltr_showStartFromLeft() {
- mLinearColorBar.onDraw(mCanvas);
-
- final ShadowCanvas shadowCanvas = Shadows.shadowOf(mCanvas);
- assertThat(shadowCanvas.getRectPaintHistoryCount()).isEqualTo(3);
-
- // 3 boxes, takes space of 20%, 40%, 40% of the the WIDTH correspondingly.
- assertThat(shadowCanvas.getDrawnRect(0).left).isWithin(0.01f).of(0);
- assertThat(shadowCanvas.getDrawnRect(1).left).isWithin(0.01f).of(20);
- assertThat(shadowCanvas.getDrawnRect(2).left).isWithin(0.01f).of(60);
- }
-
- @Test
- public void draw_rtl_showStartFromRight() {
- when(mLinearColorBar.isLayoutRtl()).thenReturn(true);
-
- mLinearColorBar.onDraw(mCanvas);
-
- final ShadowCanvas shadowCanvas = Shadows.shadowOf(mCanvas);
- assertThat(shadowCanvas.getRectPaintHistoryCount()).isEqualTo(3);
-
- // 3 boxes, takes space of 20%, 40%, 40% of the the WIDTH correspondingly.
- assertThat(shadowCanvas.getDrawnRect(0).right).isWithin(0.01f).of(100);
- assertThat(shadowCanvas.getDrawnRect(1).right).isWithin(0.01f).of(80);
- assertThat(shadowCanvas.getDrawnRect(2).right).isWithin(0.01f).of(40);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/widget/RadioButtonPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/RadioButtonPreferenceTest.java
new file mode 100644
index 0000000..e8a705c
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/widget/RadioButtonPreferenceTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.widget;
+
+import static junit.framework.Assert.assertEquals;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import android.app.Application;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.view.View;
+
+import com.android.settings.R;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class RadioButtonPreferenceTest {
+
+ private Application mContext;
+ private RadioButtonPreference mPreference;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mPreference = new RadioButtonPreference(mContext);
+ }
+
+ @Test
+ public void summary_containerShouldBeVisible() {
+ mPreference.setSummary("some summary");
+ View summaryContainer = new View(mContext);
+ View view = mock(View.class);
+ when(view.findViewById(R.id.summary_container)).thenReturn(summaryContainer);
+ PreferenceViewHolder preferenceViewHolder =
+ PreferenceViewHolder.createInstanceForTests(view);
+ mPreference.onBindViewHolder(preferenceViewHolder);
+ assertEquals(View.VISIBLE, summaryContainer.getVisibility());
+ }
+
+ @Test
+ public void emptySummary_containerShouldBeGone() {
+ mPreference.setSummary("");
+ View summaryContainer = new View(mContext);
+ View view = mock(View.class);
+ when(view.findViewById(R.id.summary_container)).thenReturn(summaryContainer);
+ PreferenceViewHolder preferenceViewHolder =
+ PreferenceViewHolder.createInstanceForTests(view);
+ mPreference.onBindViewHolder(preferenceViewHolder);
+ assertEquals(View.GONE, summaryContainer.getVisibility());
+ }
+
+ @Test
+ public void nullSummary_containerShouldBeGone() {
+ mPreference.setSummary(null);
+ View summaryContainer = new View(mContext);
+ View view = mock(View.class);
+ when(view.findViewById(R.id.summary_container)).thenReturn(summaryContainer);
+ PreferenceViewHolder preferenceViewHolder =
+ PreferenceViewHolder.createInstanceForTests(view);
+ mPreference.onBindViewHolder(preferenceViewHolder);
+ assertEquals(View.GONE, summaryContainer.getVisibility());
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/widget/RingProgressBarTest.java b/tests/robotests/src/com/android/settings/widget/RingProgressBarTest.java
index d14203d..8dc78a5 100644
--- a/tests/robotests/src/com/android/settings/widget/RingProgressBarTest.java
+++ b/tests/robotests/src/com/android/settings/widget/RingProgressBarTest.java
@@ -22,6 +22,7 @@
import android.view.View.MeasureSpec;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import org.junit.Before;
import org.junit.Test;
@@ -29,6 +30,7 @@
import org.robolectric.RuntimeEnvironment;
@RunWith(SettingsRobolectricTestRunner.class)
+@org.robolectric.annotation.Config(shadows = SettingsShadowResourcesImpl.class)
public class RingProgressBarTest {
private Context mContext = RuntimeEnvironment.application;
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiMeteredPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiMeteredPreferenceControllerTest.java
index d568004..b3e5cb5 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiMeteredPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiMeteredPreferenceControllerTest.java
@@ -81,6 +81,6 @@
mPreferenceController.updateState(mDropDownPreference);
- assertThat(mDropDownPreference.getEntry()).isEqualTo("Use network preference");
+ assertThat(mDropDownPreference.getEntry()).isEqualTo("Detect automatically");
}
}
diff --git a/tests/uitests/AndroidTest.xml b/tests/uitests/AndroidTest.xml
index fbeea2d..4f9e377 100644
--- a/tests/uitests/AndroidTest.xml
+++ b/tests/uitests/AndroidTest.xml
@@ -14,11 +14,13 @@
limitations under the License.
-->
<configuration description="Run Android Settings Functional UI Tests.">
- <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
+ <option name="test-suite-tag" value="apct" />
+ <option name="test-suite-tag" value="apct-instrumentation" />
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
<option name="test-file-name" value="SettingsUITests.apk" />
</target_preparer>
- <option name="test-suite-tag" value="apct" />
<option name="test-tag" value="SettingsUITests" />
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="com.android.settings.ui" />
diff --git a/tests/uitests/src/com/android/settings/ui/inputmethods/SpellCheckerSettingsUITest.java b/tests/uitests/src/com/android/settings/ui/inputmethods/SpellCheckerSettingsUITest.java
new file mode 100644
index 0000000..78c6f8c
--- /dev/null
+++ b/tests/uitests/src/com/android/settings/ui/inputmethods/SpellCheckerSettingsUITest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.ui.inputmethods;
+
+import static com.android.settings.ui.testutils.SettingsTestUtils.TIMEOUT;
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.Instrumentation;
+import android.content.Intent;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import android.support.test.uiautomator.By;
+import android.support.test.uiautomator.UiDevice;
+import android.support.test.uiautomator.UiObject2;
+import android.support.test.uiautomator.Until;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class SpellCheckerSettingsUITest {
+
+ private Instrumentation mInstrumentation;
+ private Intent mIntent;
+ private UiDevice mUiDevice;
+
+ @Before
+ public void setUp() {
+ mInstrumentation = InstrumentationRegistry.getInstrumentation();
+ mUiDevice = UiDevice.getInstance(mInstrumentation);
+ mIntent = new Intent().setClassName("com.android.settings",
+ "com.android.settings.Settings$SpellCheckersSettingsActivity")
+ .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ }
+
+ @Test
+ public void launchSettings_hasSwitchBar() {
+ mInstrumentation.getContext().startActivity(mIntent);
+ final UiObject2 switchBar =
+ mUiDevice.wait(Until.findObject(By.text("Use spell checker")), TIMEOUT);
+
+ assertThat(switchBar).isNotNull();
+ }
+}
diff --git a/tests/unit/AndroidTest.xml b/tests/unit/AndroidTest.xml
index b74c1e3..34be41f 100644
--- a/tests/unit/AndroidTest.xml
+++ b/tests/unit/AndroidTest.xml
@@ -14,11 +14,13 @@
limitations under the License.
-->
<configuration description="Runs Settings Test Cases.">
- <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
+ <option name="test-suite-tag" value="apct" />
+ <option name="test-suite-tag" value="apct-instrumentation" />
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
<option name="test-file-name" value="SettingsUnitTests.apk" />
</target_preparer>
- <option name="test-suite-tag" value="apct" />
<option name="test-tag" value="SettingsUnitTests" />
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="com.android.settings.tests.unit" />