Merge "Revert "Update for 1.0.0-beta1"" into pi-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c9045d8..a94938e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -87,6 +87,7 @@
<uses-permission android:name="android.permission.DELETE_PACKAGES"/>
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name="android.permission.MANAGE_APP_OPS_RESTRICTIONS"/>
+ <uses-permission android:name="android.permission.MANAGE_APP_OPS_MODES" />
<uses-permission android:name="android.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS"/>
<uses-permission android:name="android.permission.READ_PRINT_SERVICES" />
<uses-permission android:name="android.permission.NETWORK_SETTINGS" />
@@ -746,7 +747,7 @@
android:taskAffinity="com.android.settings"
android:parentActivityName="Settings">
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.notification.ZenModeBlockedEffectsSetting" />
+ android:value="com.android.settings.notification.ZenModeBlockedEffectsSettings" />
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
android:value="true" />
</activity>
diff --git a/res/drawable/data_usage_progress.xml b/res/drawable/data_usage_progress.xml
new file mode 100644
index 0000000..46b9a12
--- /dev/null
+++ b/res/drawable/data_usage_progress.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<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" />
+ <size android:height="10dp" />
+ <solid android:color="@color/white_disabled" />
+ </shape>
+ </item>
+ <item android:id="@android:id/secondaryProgress">
+ <scale android:scaleWidth="100%">
+ <shape android:shape="rectangle"
+ android:tint="?android:attr/colorControlActivated">
+ <corners android:radius="5dp" />
+ <size android:height="10dp" />
+ <solid android:color="@color/white_disabled" />
+ </shape>
+ </scale>
+ </item>
+ <item android:id="@android:id/progress">
+ <scale android:scaleWidth="100%">
+ <shape android:shape="rectangle"
+ android:tint="?android:attr/colorControlActivated">
+ <corners android:radius="5dp" />
+ <size android:height="10dp" />
+ <solid android:color="@android:color/black" />
+ </shape>
+ </scale>
+ </item>
+</layer-list>
diff --git a/res/layout/data_usage_summary_preference.xml b/res/layout/data_usage_summary_preference.xml
index 445e7cd..eda8a81 100644
--- a/res/layout/data_usage_summary_preference.xml
+++ b/res/layout/data_usage_summary_preference.xml
@@ -18,6 +18,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:paddingTop="24dp"
+ android:paddingBottom="32dp"
android:paddingStart="@dimen/preference_no_icon_padding_start"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:orientation="vertical"
@@ -31,36 +33,50 @@
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="?android:attr/textColorSecondary"
- android:paddingBottom="5dp"
android:text="@string/data_usage_title" />
- <TextView
- android:id="@android:id/title"
+ <LinearLayout
+ android:id="@+id/usage_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="5dp"
- android:fontFamily="@*android:string/config_headlineFontFamily"
- android:textColor="?android:attr/colorAccent"
- android:textAppearance="@android:style/TextAppearance.Material.Large" />
+ android:paddingTop="12dp"
+ android:paddingBottom="4dp"
+ android:orientation="horizontal">
- <TextView
- android:id="@android:id/summary"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceListItemSecondary"
- android:textColor="?android:attr/textColorSecondary"
- android:paddingBottom="5dp" />
+ <TextView android:id="@+id/data_usage_view"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:fontFamily="@*android:string/config_headlineFontFamily"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="?android:attr/colorAccent" />
- <com.android.settings.widget.LinearColorBar
- android:id="@+id/color_bar"
+ <Space
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" />
+
+ <TextView android:id="@+id/data_remaining_view"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:fontFamily="@*android:string/config_headlineFontFamily"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="?android:attr/colorAccent" />
+
+ </LinearLayout>
+
+ <android.widget.ProgressBar
+ android:id="@+id/determinateBar"
+ style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
- android:layout_height="28dp" />
+ android:layout_height="10dp"
+ android:progressDrawable="@drawable/data_usage_progress"/>
<LinearLayout
android:id="@+id/label_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingTop="2dp"
+ android:paddingTop="4dp"
+ android:paddingBottom="8dp"
android:orientation="horizontal">
<TextView android:id="@android:id/text1"
@@ -84,18 +100,18 @@
<TextView
android:id="@+id/cycle_left_time"
+ android:paddingTop="4dp"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingBottom="5dp" />
+ android:layout_height="wrap_content" />
<TextView
android:id="@+id/carrier_and_update"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingBottom="5dp" />
+ android:layout_height="wrap_content" />
<Button
android:id="@+id/launch_mdp_app_button"
+ android:paddingTop="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
@@ -106,7 +122,8 @@
android:id="@+id/data_limits"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingBottom="5dp" />
+ android:paddingBottom="5dp"
+ android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
diff --git a/res/layout/instant_app_buttons.xml b/res/layout/instant_app_buttons.xml
index 1ef9f41..f80ac10 100644
--- a/res/layout/instant_app_buttons.xml
+++ b/res/layout/instant_app_buttons.xml
@@ -48,11 +48,16 @@
<Space
android:layout_width="16dp"
android:layout_height="wrap_content" />
- <Button
- android:id="@+id/clear_data"
+ <FrameLayout
android:layout_width="0dp"
android:layout_weight="1"
- android:layout_height="wrap_content"
- android:layout_marginBottom="4dp"
- android:text="@string/clear_instant_app_data"/>
+ android:layout_height="wrap_content">
+ <Button
+ android:id="@+id/clear_data"
+ style="@style/ActionSecondaryButton"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="4dp"
+ android:text="@string/clear_instant_app_data"/>
+ </FrameLayout>
</LinearLayout>
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index 2c4a1ed..9f8d035 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -21,6 +21,7 @@
android:scrollIndicators="top|bottom">
<LinearLayout
+ android:id="@+id/l_wifidialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 185732d..9f2fe1b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1136,25 +1136,25 @@
<!-- Security Picker --><skip />
- <!-- Title for suggested actions for screen lock [CHAR LIMIT=34] -->
- <string name="suggested_lock_settings_title">Set screen lock for security</string>
+ <!-- Title for suggested actions for screen lock [CHAR LIMIT=46] -->
+ <string name="suggested_lock_settings_title">Secure your phone</string>
- <!-- Summary for suggested actions for screen lock (tablet) -->
- <string name="suggested_lock_settings_summary" product="tablet">Prevent others from using your tablet</string>
- <!-- Summary for suggested actions for screen lock (device) -->
- <string name="suggested_lock_settings_summary" product="device">Prevent others from using your device</string>
- <!-- Summary for suggested actions for screen lock (phone) -->
- <string name="suggested_lock_settings_summary" product="default">Prevent others from using your phone</string>
+ <!-- Summary for suggested actions for screen lock (tablet) [CHAR LIMIT=55] -->
+ <string name="suggested_lock_settings_summary" product="tablet">Set screen lock to protect tablet</string>
+ <!-- Summary for suggested actions for screen lock (device) [CHAR LIMIT=55] -->
+ <string name="suggested_lock_settings_summary" product="device">Set screen lock to protect device</string>
+ <!-- Summary for suggested actions for screen lock (phone) [CHAR LIMIT=55] -->
+ <string name="suggested_lock_settings_summary" product="default">Set screen lock to protect phone</string>
- <!-- Title for suggested actions for settings up a fingerprint lock [CHAR LIMIT=34] -->
+ <!-- Title for suggested actions for settings up a fingerprint lock [CHAR LIMIT=46] -->
<string name="suggested_fingerprint_lock_settings_title">Unlock with fingerprint</string>
- <!-- Summary for suggested actions for settings up a fingerprint lock (tablet) -->
- <string name="suggested_fingerprint_lock_settings_summary" product="tablet">Unlock with your fingerprint</string>
- <!-- Summary for suggested actions for settings up a fingerprint lock (device) -->
- <string name="suggested_fingerprint_lock_settings_summary" product="device">Unlock with your fingerprint</string>
- <!-- Summary for suggested actions for settings up a fingerprint lock (phone) -->
- <string name="suggested_fingerprint_lock_settings_summary" product="default">Unlock with your fingerprint</string>
+ <!-- Summary for suggested actions for settings up a fingerprint lock (tablet) [CHAR LIMIT=55] -->
+ <string name="suggested_fingerprint_lock_settings_summary" product="tablet"></string>
+ <!-- Summary for suggested actions for settings up a fingerprint lock (device) [CHAR LIMIT=55] -->
+ <string name="suggested_fingerprint_lock_settings_summary" product="device"></string>
+ <!-- Summary for suggested actions for settings up a fingerprint lock (phone) [CHAR LIMIT=55] -->
+ <string name="suggested_fingerprint_lock_settings_summary" product="default"></string>
<!-- Title for security picker to choose the unlock method: None/Pattern/PIN/Password [CHAR LIMIT=22] -->
<string name="lock_settings_picker_title">Choose screen lock</string>
@@ -2251,10 +2251,10 @@
<!-- Wireless networks, item title to go into the WFC settings [CHAR LIMIT=30] -->
<string name="wifi_calling_settings_title">Wi-Fi calling</string>
- <!-- Title of suggestion to turn on wifi calling [CHAR LIMIT=30] -->
- <string name="wifi_calling_suggestion_title">Extend call coverage with Wi\u2011Fi</string>
- <!-- Summary of suggestion to turn on wifi calling [CHAR LIMIT=60] -->
- <string name="wifi_calling_suggestion_summary">Turn on Wi\u2011Fi calling</string>
+ <!-- Title of suggestion to turn on wifi calling [CHAR LIMIT=46] -->
+ <string name="wifi_calling_suggestion_title">Extend calls with Wi\u2011Fi</string>
+ <!-- Summary of suggestion to turn on wifi calling [CHAR LIMIT=55] -->
+ <string name="wifi_calling_suggestion_summary">Turn on Wi\u2011Fi calling to extend coverage</string>
<!-- Title of WFC preference item [CHAR LIMIT=30] -->
<string name="wifi_calling_mode_title">Calling preference</string>
<!-- Title of WFC preference selection dialog [CHAR LIMIT=30] -->
@@ -2532,9 +2532,9 @@
<string name="wallpaper_settings_summary_default">Default</string>
<!-- Wallpaper settings summary when wallpaper has been updated [CHAR LIMIT=NONE] -->
<string name="wallpaper_settings_summary_custom">Custom</string>
- <!-- Wallpaper suggestion title [CHAR LIMIT=30] -->
+ <!-- Wallpaper suggestion title [CHAR LIMIT=46] -->
<string name="wallpaper_suggestion_title">Change wallpaper</string>
- <!-- Wallpaper suggestion title [CHAR LIMIT=60] -->
+ <!-- Wallpaper suggestion summary [CHAR LIMIT=55] -->
<string name="wallpaper_suggestion_summary">Personalize your screen</string>
<!-- Wallpaper settings fragment title [CHAR LIMIT=30] -->
<string name="wallpaper_settings_fragment_title">Choose wallpaper from</string>
@@ -3402,14 +3402,11 @@
<!-- [CHAR LIMIT=130] Preference title for Wi-Fi always scanning -->
<string name="location_scanning_wifi_always_scanning_title">Wi\u2011Fi scanning</string>
<!-- Preference description text for Wi-Fi always scanning -->
- <string name="location_scanning_wifi_always_scanning_description">Improve location by allowing
- system apps and services to detect Wi\u2011Fi networks at any time.</string>
+ <string name="location_scanning_wifi_always_scanning_description">Allow apps and services to scan for Wi\u2011Fi networks at any time, even when Wi\u2011Fi is off. This can be used, for example, to improve location-based features and services.</string>
<!-- [CHAR LIMIT=130] Description text for Bluetooth always scanning -->
<string name="location_scanning_bluetooth_always_scanning_title">Bluetooth scanning</string>
<!-- Description text for Bluetooth always scanning -->
- <string name="location_scanning_bluetooth_always_scanning_description">
- Improve location by allowing system apps and services to detect Bluetooth devices at any
- time.</string>
+ <string name="location_scanning_bluetooth_always_scanning_description">Allow apps and services to scan for nearby devices at any time, even when Bluetooth is off. This can be used, for example, to improve location-based features and services.</string>
<!-- [CHAR LIMIT=30] Security & location settings screen, setting check box label for Google location service (cell ID, wifi, etc.) -->
<string name="location_network_based">Wi\u2011Fi & mobile network location</string>
@@ -4728,7 +4725,7 @@
<string name="power_charge_remaining"><xliff:g id="until_charged">%1$s</xliff:g> to charge</string>
<!-- Title for the background activity setting, which allows a user to control whether an app can run in the background [CHAR_LIMIT=40] -->
- <string name="background_activity_title">Restricted</string>
+ <string name="background_activity_title">Battery restrictions</string>
<!-- Summary for the background activity [CHAR_LIMIT=120] -->
<string name="background_activity_summary">Allow the app to run in the background</string>
<!-- Summary for the background activity when it is on [CHAR_LIMIT=120] -->
@@ -4879,8 +4876,12 @@
<item quantity="one">Restrict app?</item>
<item quantity="other">Restrict %1$d apps?</item>
</plurals>
- <!-- Message for battery tip dialog to show the restrict app list [CHAR LIMIT=NONE] -->
- <string name="battery_tip_restrict_app_dialog_message">To save battery, you can stop this app from running in the background when it’s not being used.</string>
+ <!-- Message for battery tip dialog to show the info to restrict the app [CHAR LIMIT=NONE] -->
+ <string name="battery_tip_restrict_app_dialog_message">To save battery, stop <xliff:g id="app">%1$s</xliff:g> from using battery in the background.</string>
+ <!-- Message for battery tip dialog to show the info to restrict the app, below it app list will be shown as a view [CHAR LIMIT=NONE] -->
+ <string name="battery_tip_restrict_apps_less_than_5_dialog_message">To save battery, stop these apps from using battery in the background.\n\nApps:\n</string>
+ <!-- Message for battery tip dialog to show the info to restrict the app, below it app list will be shown as raw string[CHAR LIMIT=NONE] -->
+ <string name="battery_tip_restrict_apps_more_than_5_dialog_message">To save battery, stop these apps from using battery in the background.\n\nApps:\n<xliff:g id="app_list">%1$s</xliff:g>.</string>
<!-- OK button for battery tip dialog to show the restrict app list [CHAR LIMIT=NONE] -->
<string name="battery_tip_restrict_app_dialog_ok">Restrict</string>
<!-- Title for dialog to remove restriction for the app [CHAR LIMIT=NONE] -->
@@ -4892,6 +4893,11 @@
<!-- CANCEL button for dialog to remove restriction for app [CHAR LIMIT=NONE] -->
<string name="battery_tip_unrestrict_app_dialog_cancel">Not now</string>
+ <!-- Message for battery tip dialog to show the battery summary -->
+ <string name="battery_tip_dialog_summary_message">Based on your usage, your battery usually lasts about <xliff:g id="time_duration">%1$s</xliff:g> when fully charged.\n\nIf you need to extend your battery life, turn on Battery Saver.</string>
+ <!-- Message for battery tip dialog to show the battery summary -->
+ <string name="battery_tip_dialog_summary_message_no_estimation">If you need to extend your battery life, turn on Battery Saver</string>
+
<!-- Title for the smart battery manager preference [CHAR LIMIT=NONE] -->
<string name="smart_battery_manager_title">Smart battery manager</string>
<!-- Title for the smart battery toggle [CHAR LIMIT=NONE] -->
@@ -6944,10 +6950,10 @@
<!-- Do not disturb: Title for a specific zen mode automatic rule in settings. [CHAR LIMIT=30] -->
<string name="zen_mode_automatic_rule_settings_page_title">Automatic rule</string>
- <!-- Do not disturb: Title for the zen mode automation option Suggestion. [CHAR LIMIT=34] -->
+ <!-- Do not disturb: Title for the zen mode automation option Suggestion. [CHAR LIMIT=46] -->
<string name="zen_mode_automation_suggestion_title">Silence phone at certain times</string>
- <!-- Do not disturb: Summary for the zen mode automation option Suggestion. [CHAR LIMIT=NONE] -->
+ <!-- Do not disturb: Summary for the zen mode automation option Suggestion. [CHAR LIMIT=55] -->
<string name="zen_mode_automation_suggestion_summary">Set Do Not Disturb rules</string>
<!-- Do not disturb: Switch toggle to toggle whether to use an automatic dnd rule or not [CHAR LIMIT=40] -->
@@ -6999,6 +7005,11 @@
<!-- Do not disturb: what to block summary, all effects -->
<string name="zen_mode_block_effect_summary_all">Sound, vibration, and visual signs of notifications</string>
+ <!-- Do not disturb: Zen mode no sounds are exceptions to bypass do not disturb-->
+ <string name="zen_mode_no_exceptions">None</string>
+ <!-- Do not disturb: Zen mode catch all "other" sounds can bypass do not disturb -->
+ <string name="zen_mode_other_options">other options</string>
+
<!-- Do not disturb: Button to add new automatic rule to DND. [CHAR LIMIT=30] -->
<string name="zen_mode_add">Add</string>
@@ -7592,8 +7603,8 @@
<!-- [CHAR LIMIT=50] Zen mode settings: Media option -->
<string name="zen_mode_media">Media</string>
- <!-- [CHAR LIMIT=50] Zen mode settings: System option which includes sounds such as touch and charging sounds -->
- <string name="zen_mode_system">Touch and charging sounds</string>
+ <!-- [CHAR LIMIT=50] Zen mode settings: System option which includes sounds such as touch sounds -->
+ <string name="zen_mode_system">Touch sounds</string>
<!-- [CHAR LIMIT=50] Zen mode settings: Reminders option -->
<string name="zen_mode_reminders">Reminders</string>
@@ -7745,9 +7756,9 @@
<string name="encryption_interstitial_no">No</string>
<!-- Label to say yes to the question of whether app is restricted. [CHAR LIMIT=20] -->
- <string name="restricted_true_label">Yes</string>
+ <string name="restricted_true_label">On / Background usage restricted</string>
<!-- Label to say no to the question of whether app is restricted. [CHAR LIMIT=20] -->
- <string name="restricted_false_label">No</string>
+ <string name="restricted_false_label">Off / Uses battery in background</string>
<!-- Title for encryption dialog that disables TalkBack. [CHAR_LIMIT=25] -->
<string name="encrypt_talkback_dialog_require_pin">Require PIN?</string>
@@ -8575,10 +8586,10 @@
<!-- Summary of condition that work mode is off [CHAR LIMIT=NONE] -->
<string name="condition_work_summary">Apps, background sync, and other features related to your work profile are turned off.</string>
- <!-- Night display: Title for the night display option Suggestion (renamed "Night Light" with title caps). [CHAR LIMIT=30] -->
+ <!-- Night display: Title for the night display option Suggestion (renamed "Night Light" with title caps). [CHAR LIMIT=46] -->
<string name="night_display_suggestion_title">Set Night Light schedule</string>
- <!-- Night display: Summary for the night display option Suggestion (renamed "Night Light" with title caps). [CHAR LIMIT=NONE] -->
+ <!-- Night display: Summary for the night display option Suggestion (renamed "Night Light" with title caps). [CHAR LIMIT=55] -->
<string name="night_display_suggestion_summary">Automatically tint screen every night</string>
<!-- Title of condition that night display is on (renamed "Night Light" with title caps). [CHAR LIMIT=30] -->
@@ -8647,6 +8658,9 @@
<!-- Label for cellular data usage in data usage screen [CHAR LIMIT=60] -->
<string name="cellular_data_usage">Mobile data usage</string>
+ <!-- App data usage, as seen from the platform, in data usage screen [CHAR LIMIT=60] -->
+ <string name="app_cellular_data_usage">App data usage</string>
+
<!-- Label for wifi data usage in data usage screen [CHAR LIMIT=60] -->
<string name="wifi_data_usage">Wi-Fi data usage</string>
@@ -8674,12 +8688,21 @@
<!-- Format for a summary describing the amount of data before the user is warned or limited [CHAR LIMIT=NONE] -->
<string name="cell_warning_and_limit"><xliff:g name="amount" example="1 GB">%1$s</xliff:g> Data warning / <xliff:g name="amount" example="2 GB">%2$s</xliff:g> Data limit</string>
- <!-- Title of button and screen for billing cycle preferences [CHAR LIMIT=30] -->
+ <!-- Title of button and screen for billing cycle preferences [CHAR LIMIT=40] -->
<string name="billing_cycle">Data warning & limit</string>
- <!-- Title of button for application usage cycle preferences [CHAR LIMIT=30] -->
+ <!-- Title of button for application usage cycle preferences [CHAR LIMIT=40] -->
<string name="app_usage_cycle">App data usage cycle</string>
+ <!-- Format for a summary describing the amount of data before the user is warned [CHAR LIMIT=NONE] -->
+ <string name="cell_data_warning"><xliff:g name="amount" example="1 GB">^1</xliff:g> data warning</string>
+
+ <!-- Format for a summary describing the amount of data the limit is set to [CHAR LIMIT=NONE] -->
+ <string name="cell_data_limit"><xliff:g name="amount" example="1 GB">^1</xliff:g> data limit</string>
+
+ <!-- Format for a summary describing the amount of data before the user is warned or limited [CHAR LIMIT=NONE] -->
+ <string name="cell_data_warning_and_limit"><xliff:g name="amount" example="1 GB">^1</xliff:g> data warning / <xliff:g name="amount" example="2 GB">^2</xliff:g> data limit</string>
+
<!-- Summary describing when the billing cycle for their phone carrier starts [CHAR LIMIT=NONE] -->
<string name="billing_cycle_fragment_summary">Monthly on day <xliff:g name="day_of_month" example="17">%1$s</xliff:g></string>
@@ -8704,6 +8727,9 @@
<!-- Label for button to set the amount of data before user is warned about usage [CHAR LIMIT=30] -->
<string name="data_warning">Data warning</string>
+ <!-- Label for footnote on Data warning and limit page to warn of device discrepancies -->
+ <string name="data_warning_footnote">Data warning and data limit are measured by your device. This may be different from carrier data.</string>
+
<!-- Label for switch about whether to limit how much data can be used [CHAR LIMIT=30] -->
<string name="set_data_limit">Set data limit</string>
@@ -8729,14 +8755,26 @@
<!-- Data usage title text [CHAR LIMIT=30] -->
<string name="data_usage_title">Primary data</string>
- <!-- Data usage string [CHAR LIMIT=30] -->
+ <!-- Data usage remaining string [CHAR LIMIT=30] -->
<string name="data_used"><xliff:g name="bytes" example="2 GB">^1</xliff:g> used</string>
- <!-- Optional part of data usage showing the remaining amount [CHAR LIMIT=30] -->
- <string name="data_remaining"><xliff:g name="bytes" example="2 GB">, ^1</xliff:g> left</string>
+ <!-- Data usage over limit string [CHAR LIMIT=30] -->
+ <string name="data_overusage"><xliff:g name="bytes" example="2 GB">^1</xliff:g> over</string>
- <!-- Informational text about time left in billing cycle [CHAR LIMIT=30] -->
- <string name="cycle_left_time_text"><xliff:g name="time" example="2d">%1$s</xliff:g> left in this cycle</string>
+ <!-- Optional part of data usage showing the remaining amount [CHAR LIMIT=30] -->
+ <string name="data_remaining"><xliff:g name="bytes" example="2 GB">^1</xliff:g> left</string>
+
+ <!-- Informational text about time left in billing cycle [CHAR LIMIT=60] -->
+ <string name="cycle_left_multiple_days"><xliff:g name="time" example="2d">%d</xliff:g> days left</string>
+
+ <!-- Informational text about time left in billing cycle [CHAR LIMIT=60] -->
+ <plurals name="billing_cycle_days_left">
+ <item quantity="one">%d day left</item>
+ <item quantity="other">%d days left</item>
+ </plurals>
+
+ <!-- Informational text about time left in billing cycle [CHAR LIMIT=60] -->
+ <string name="billing_cycle_less_than_one_day_left">Less than 1 day left</string>
<!-- Informational text about carrier and update time [CHAR LIMIT=30] -->
<string name="carrier_and_update_text">Updated by <xliff:g name="carrier" example="T-mobile">%1$s</xliff:g> <xliff:g name="time" example="3m">%2$s</xliff:g></string>
@@ -8786,10 +8824,10 @@
<!-- Summary of the preference controlling whether the device encryption *password* must be entered before being able to start the device. [CHAR LIMIT=NONE]-->
<string name="lockpattern_settings_require_password_before_startup_summary">Require password to start up your device. While off, this device can\'t receive calls, messages, notifications, or alarms.</string>
- <!-- Title for suggestion adding more fingerprints [CHAR LIMIT=30] -->
+ <!-- Title for suggestion adding more fingerprints [CHAR LIMIT=46] -->
<string name="suggestion_additional_fingerprints">Add another fingerprint</string>
- <!-- Summary for suggestion adding more fingerprints [CHAR LIMIT=60] -->
+ <!-- Summary for suggestion adding more fingerprints [CHAR LIMIT=55] -->
<string name="suggestion_additional_fingerprints_summary">Unlock with a different finger</string>
<!-- Summary of battery saver when on [CHAR LIMIT=NONE] -->
@@ -9470,4 +9508,13 @@
<!-- 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 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] -->
+ <string name="battery_suggestion_title" product="device" >Improve device\'s battery life</string>
+ <!-- Title for battery Suggestion. (phone) [CHAR LIMIT=46] -->
+ <string name="battery_suggestion_title" product="default" >Improve phone\'s battery life</string>
+ <!-- Summary for battery Suggestion. [CHAR LIMIT=55] -->
+ <string name="battery_suggestion_summary"></string>
+
</resources>
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index b5bfc49..9500e24 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -20,41 +20,41 @@
android:title="@string/sound_settings"
android:key="sound_settings"
settings:keywords="@string/keywords_sounds"
- settings:initialExpandedChildrenCount="6">
+ settings:initialExpandedChildrenCount="7">
<!-- Media volume -->
<com.android.settings.notification.VolumeSeekBarPreference
android:key="media_volume"
android:icon="@*android:drawable/ic_audio_media"
android:title="@string/media_volume_option_title"
- android:order="-106"/>
+ android:order="-170"/>
<!-- Alarm volume -->
<com.android.settings.notification.VolumeSeekBarPreference
android:key="alarm_volume"
android:icon="@*android:drawable/ic_audio_alarm"
android:title="@string/alarm_volume_option_title"
- android:order="-105"/>
+ android:order="-160"/>
<!-- Ring volume -->
<com.android.settings.notification.VolumeSeekBarPreference
android:key="ring_volume"
android:icon="@*android:drawable/ic_audio_ring_notif"
android:title="@string/ring_volume_option_title"
- android:order="-104"/>
+ android:order="-150"/>
<!-- Notification volume -->
<com.android.settings.notification.VolumeSeekBarPreference
android:key="notification_volume"
android:icon="@*android:drawable/ic_audio_ring_notif"
android:title="@string/notification_volume_option_title"
- android:order="-103"/>
+ android:order="-140"/>
<!-- Also vibrate for calls -->
<SwitchPreference
android:key="vibrate_when_ringing"
android:title="@string/vibrate_when_ringing_title"
- android:order="-102"/>
+ android:order="-130"/>
<!-- Interruptions -->
<com.android.settingslib.RestrictedPreference
@@ -64,7 +64,7 @@
settings:keywords="@string/keywords_sounds_and_notifications_interruptions"
android:fragment="com.android.settings.notification.ZenModeSettings"
settings:allowDividerAbove="true"
- android:order="-101"/>
+ android:order="-120"/>
<!-- Phone ringtone -->
<com.android.settings.DefaultRingtonePreference
@@ -83,7 +83,7 @@
android:dialogTitle="@string/notification_ringtone_title"
android:summary="@string/summary_placeholder"
android:ringtoneType="notification"
- android:order="-99"/>
+ android:order="-90"/>
<!-- Default alarm ringtone -->
<com.android.settings.DefaultRingtonePreference
@@ -93,7 +93,7 @@
android:summary="@string/summary_placeholder"
android:persistent="false"
android:ringtoneType="alarm"
- android:order="-98"/>
+ android:order="-80"/>
<!-- Other sounds -->
<PreferenceCategory
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 2a55829..1091aea 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -48,6 +48,7 @@
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.VectorDrawable;
import android.hardware.fingerprint.FingerprintManager;
import android.net.ConnectivityManager;
import android.net.LinkProperties;
@@ -929,7 +930,7 @@
*/
public static void setSafeIcon(Preference pref, Drawable icon) {
Drawable safeIcon = icon;
- if (icon != null) {
+ if ((icon != null) && !(icon instanceof VectorDrawable)) {
safeIcon = getSafeDrawable(icon, 500, 500);
}
pref.setIcon(safeIcon);
diff --git a/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java b/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java
index 5b45cfa..a8a960f 100644
--- a/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java
+++ b/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java
@@ -26,7 +26,9 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.graphics.drawable.Drawable;
import android.os.Binder;
import android.os.Bundle;
@@ -34,7 +36,6 @@
import android.os.UserHandle;
import android.provider.Settings;
import android.text.TextUtils;
-import android.util.IconDrawableFactory;
import android.view.accessibility.AccessibilityManager;
import com.android.internal.accessibility.AccessibilityShortcutController;
@@ -45,7 +46,6 @@
import com.android.settings.widget.RadioButtonPickerFragment;
import com.android.settings.widget.RadioButtonPreference;
import com.android.settingslib.accessibility.AccessibilityUtils;
-import com.android.settingslib.applications.DefaultAppInfo;
import com.android.settingslib.widget.CandidateInfo;
import com.android.settingslib.wrapper.PackageManagerWrapper;
@@ -71,13 +71,11 @@
@Override
protected List<? extends CandidateInfo> getCandidates() {
final Context context = getContext();
- final PackageManager pm = context.getPackageManager();
final AccessibilityManager accessibilityManager = context
.getSystemService(AccessibilityManager.class);
final List<AccessibilityServiceInfo> installedServices =
accessibilityManager.getInstalledAccessibilityServiceList();
final int numInstalledServices = installedServices.size();
- final PackageManagerWrapper pmw = new PackageManagerWrapper(context.getPackageManager());
final List<CandidateInfo> candidates = new ArrayList<>(numInstalledServices);
Map<ComponentName, ToggleableFrameworkFeatureInfo> frameworkFeatureInfoMap =
@@ -95,10 +93,7 @@
iconId, componentName.flattenToString()));
}
for (int i = 0; i < numInstalledServices; i++) {
- final AccessibilityServiceInfo installedServiceInfo = installedServices.get(i);
- candidates.add(new DefaultAppInfo(context, pmw, UserHandle.myUserId(),
- installedServiceInfo.getComponentName(),
- (String) installedServiceInfo.loadSummary(pm), true /* enabled */));
+ candidates.add(new ServiceCandidateInfo(installedServices.get(i)));
}
return candidates;
@@ -196,9 +191,9 @@
}
private class FrameworkCandidateInfo extends CandidateInfo {
- ToggleableFrameworkFeatureInfo mToggleableFrameworkFeatureInfo;
- int mIconResId;
- String mKey;
+ final ToggleableFrameworkFeatureInfo mToggleableFrameworkFeatureInfo;
+ final int mIconResId;
+ final String mKey;
public FrameworkCandidateInfo(
ToggleableFrameworkFeatureInfo frameworkFeatureInfo, int iconResId, String key) {
@@ -223,4 +218,49 @@
return mKey;
}
}
+
+ private class ServiceCandidateInfo extends CandidateInfo {
+ final AccessibilityServiceInfo mServiceInfo;
+
+ public ServiceCandidateInfo(AccessibilityServiceInfo serviceInfo) {
+ super(true /* enabled */);
+ mServiceInfo = serviceInfo;
+ }
+
+ @Override
+ public CharSequence loadLabel() {
+ final PackageManagerWrapper pmw =
+ new PackageManagerWrapper(getContext().getPackageManager());
+ final CharSequence label =
+ mServiceInfo.getResolveInfo().serviceInfo.loadLabel(pmw.getPackageManager());
+ if (label != null) {
+ return label;
+ }
+
+ final ComponentName componentName = mServiceInfo.getComponentName();
+ if (componentName != null) {
+ try {
+ final ApplicationInfo appInfo = pmw.getApplicationInfoAsUser(
+ componentName.getPackageName(), 0, UserHandle.myUserId());
+ return appInfo.loadLabel(pmw.getPackageManager());
+ } catch (PackageManager.NameNotFoundException e) {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Drawable loadIcon() {
+ final ResolveInfo resolveInfo = mServiceInfo.getResolveInfo();
+ return (resolveInfo.getIconResource() == 0)
+ ? getContext().getDrawable(R.mipmap.ic_accessibility_generic)
+ : resolveInfo.loadIcon(getContext().getPackageManager());
+ }
+
+ @Override
+ public String getKey() {
+ return mServiceInfo.getComponentName().flattenToString();
+ }
+ }
}
diff --git a/src/com/android/settings/datausage/BillingCycleSettings.java b/src/com/android/settings/datausage/BillingCycleSettings.java
index 34d18e9..8cec3e7 100644
--- a/src/com/android/settings/datausage/BillingCycleSettings.java
+++ b/src/com/android/settings/datausage/BillingCycleSettings.java
@@ -91,6 +91,8 @@
mEnableDataLimit = (SwitchPreference) findPreference(KEY_SET_DATA_LIMIT);
mEnableDataLimit.setOnPreferenceChangeListener(this);
mDataLimit = findPreference(KEY_DATA_LIMIT);
+
+ mFooterPreferenceMixin.createFooterPreference().setTitle(R.string.data_warning_footnote);
}
@Override
diff --git a/src/com/android/settings/datausage/DataUsagePreference.java b/src/com/android/settings/datausage/DataUsagePreference.java
index ecc5be6..da2d52a 100644
--- a/src/com/android/settings/datausage/DataUsagePreference.java
+++ b/src/com/android/settings/datausage/DataUsagePreference.java
@@ -23,9 +23,11 @@
import android.support.v7.preference.Preference;
import android.text.format.Formatter;
import android.util.AttributeSet;
+import android.util.FeatureFlagUtils;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
+import com.android.settings.core.FeatureFlags;
import com.android.settings.core.SubSettingLauncher;
import com.android.settingslib.net.DataUsageController;
@@ -53,8 +55,13 @@
mSubId = subId;
DataUsageController controller = new DataUsageController(getContext());
DataUsageController.DataUsageInfo usageInfo = controller.getDataUsageInfo(mTemplate);
- setSummary(getContext().getString(R.string.data_usage_template,
- Formatter.formatFileSize(getContext(), usageInfo.usageLevel), usageInfo.period));
+ if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.DATA_USAGE_SETTINGS_V2)) {
+ setTitle(getContext().getString(R.string.app_cellular_data_usage));
+ } else {
+ setTitle(getContext().getString(R.string.cellular_data_usage));
+ setSummary(getContext().getString(R.string.data_usage_template,
+ Formatter.formatFileSize(getContext(), usageInfo.usageLevel), usageInfo.period));
+ }
setIntent(getIntent());
}
@@ -67,10 +74,14 @@
.setArguments(args)
.setDestination(DataUsageList.class.getName())
.setSourceMetricsCategory(MetricsProto.MetricsEvent.VIEW_UNKNOWN);
- if (mTitleRes > 0) {
- launcher.setTitle(mTitleRes);
+ if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.DATA_USAGE_SETTINGS_V2)) {
+ launcher.setTitle(getContext().getString(R.string.app_cellular_data_usage));
} else {
+ if (mTitleRes > 0) {
+ launcher.setTitle(mTitleRes);
+ } else {
launcher.setTitle(getTitle());
+ }
}
return launcher.toIntent();
}
diff --git a/src/com/android/settings/datausage/DataUsageSummary.java b/src/com/android/settings/datausage/DataUsageSummary.java
index 2d50589..6d9ef38 100644
--- a/src/com/android/settings/datausage/DataUsageSummary.java
+++ b/src/com/android/settings/datausage/DataUsageSummary.java
@@ -234,12 +234,17 @@
static CharSequence formatUsage(Context context, String template, long usageLevel) {
final float LARGER_SIZE = 1.25f * 1.25f; // (1/0.8)^2
final float SMALLER_SIZE = 1.0f / LARGER_SIZE; // 0.8^2
+ return formatUsage(context, template, usageLevel, LARGER_SIZE, SMALLER_SIZE);
+ }
+
+ static CharSequence formatUsage(Context context, String template, long usageLevel,
+ float larger, float smaller) {
final int FLAGS = Spannable.SPAN_INCLUSIVE_INCLUSIVE;
final Formatter.BytesResult usedResult = Formatter.formatBytes(context.getResources(),
usageLevel, Formatter.FLAG_CALCULATE_ROUNDED);
final SpannableString enlargedValue = new SpannableString(usedResult.value);
- enlargedValue.setSpan(new RelativeSizeSpan(LARGER_SIZE), 0, enlargedValue.length(), FLAGS);
+ enlargedValue.setSpan(new RelativeSizeSpan(larger), 0, enlargedValue.length(), FLAGS);
final SpannableString amountTemplate = new SpannableString(
context.getString(com.android.internal.R.string.fileSizeSuffix)
@@ -248,7 +253,7 @@
enlargedValue, usedResult.units);
final SpannableString fullTemplate = new SpannableString(template);
- fullTemplate.setSpan(new RelativeSizeSpan(SMALLER_SIZE), 0, fullTemplate.length(), FLAGS);
+ fullTemplate.setSpan(new RelativeSizeSpan(smaller), 0, fullTemplate.length(), FLAGS);
return TextUtils.expandTemplate(fullTemplate,
BidiFormatter.getInstance().unicodeWrap(formattedUsage.toString()));
}
diff --git a/src/com/android/settings/datausage/DataUsageSummaryPreference.java b/src/com/android/settings/datausage/DataUsageSummaryPreference.java
index d886154..e8715aa 100644
--- a/src/com/android/settings/datausage/DataUsageSummaryPreference.java
+++ b/src/com/android/settings/datausage/DataUsageSummaryPreference.java
@@ -18,23 +18,40 @@
import android.content.Context;
import android.content.Intent;
+import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
+import android.text.TextUtils;
+import android.text.format.Formatter;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
+import android.widget.ProgressBar;
import android.widget.TextView;
import com.android.settings.R;
-import com.android.settings.SummaryPreference;
+import com.android.settingslib.Utils;
import com.android.settingslib.utils.StringUtil;
import java.util.Objects;
+import java.util.concurrent.TimeUnit;
/**
* Provides a summary of data usage.
*/
-public class DataUsageSummaryPreference extends SummaryPreference {
+public class DataUsageSummaryPreference extends Preference {
+ private static final long MILLIS_IN_A_DAY = TimeUnit.DAYS.toMillis(1);
+ private static final long WARNING_AGE = TimeUnit.HOURS.toMillis(6L);
+ private boolean mChartEnabled = true;
+ private String mStartLabel;
+ private String mEndLabel;
+
+ /** large vs small size is 36/16 ~ 2.25 */
+ private static final float LARGER_FONT_RATIO = 2.25f;
+ private static final float SMALLER_FONT_RATIO = 1.0f;
+
+ private boolean mDefaultTextColorSet;
+ private int mDefaultTextColor;
private int mNumPlans;
/** The ending time of the billing cycle in milliseconds since epoch. */
private long mCycleEndTimeMs;
@@ -45,6 +62,19 @@
private String mLimitInfoText;
private Intent mLaunchIntent;
+ /** Progress to display on ProgressBar */
+ private float mProgress;
+ private boolean mHasMobileData;
+
+ /**
+ * The size of the first registered plan if one exists or the size of the warning if it is set.
+ * -1 if no information is available.
+ */
+ private long mDataplanSize;
+
+ /** The number of bytes used since the start of the cycle. */
+ private long mDataplanUse;
+
public DataUsageSummaryPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setLayoutResource(R.layout.data_usage_summary_preference);
@@ -57,6 +87,11 @@
}
}
+ public void setProgress(float progress) {
+ mProgress = progress;
+ notifyChanged();
+ }
+
public void setUsageInfo(long cycleEnd, long snapshotTime, CharSequence carrierName,
int numPlans, Intent launchIntent) {
mCycleEndTimeMs = cycleEnd;
@@ -67,20 +102,50 @@
notifyChanged();
}
+ public void setChartEnabled(boolean enabled) {
+ if (mChartEnabled != enabled) {
+ mChartEnabled = enabled;
+ notifyChanged();
+ }
+ }
+
+ public void setLabels(String start, String end) {
+ mStartLabel = start;
+ mEndLabel = end;
+ notifyChanged();
+ }
+
+ void setUsageNumbers(long used, long dataPlanSize, boolean hasMobileData) {
+ mDataplanUse = used;
+ mDataplanSize = dataPlanSize;
+ mHasMobileData = hasMobileData;
+ notifyChanged();
+ }
+
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
+
+ if (mChartEnabled && (!TextUtils.isEmpty(mStartLabel) || !TextUtils.isEmpty(mEndLabel))) {
+ 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 {
+ holder.findViewById(R.id.label_bar).setVisibility(View.GONE);
+ }
+
+ updateDataUsageLabels(holder);
+
TextView usageTitle = (TextView) holder.findViewById(R.id.usage_title);
usageTitle.setVisibility(mNumPlans > 1 ? View.VISIBLE : View.GONE);
- TextView cycleTime = (TextView) holder.findViewById(R.id.cycle_left_time);
- cycleTime.setText(getContext().getString(R.string.cycle_left_time_text,
- StringUtil.formatElapsedTime(getContext(),
- mCycleEndTimeMs - System.currentTimeMillis(),false /* withSeconds */)));
+ updateCycleTimeText(holder);
- TextView carrierInfo = (TextView) holder.findViewById(R.id.carrier_and_update);
- setCarrierInfo(carrierInfo, mCarrierName, mSnapshotTimeMs);
+
+ updateCarrierInfo((TextView) holder.findViewById(R.id.carrier_and_update));
Button launchButton = (Button) holder.findViewById(R.id.launch_mdp_app_button);
launchButton.setOnClickListener((view) -> {
@@ -98,18 +163,61 @@
limitInfo.setText(mLimitInfoText);
}
- private void setCarrierInfo(TextView carrierInfo, CharSequence carrierName, long updateAge) {
- if (mNumPlans > 0 && updateAge >= 0L) {
+
+ private void updateDataUsageLabels(PreferenceViewHolder holder) {
+ TextView usageNumberField = (TextView) holder.findViewById(R.id.data_usage_view);
+ usageNumberField.setText(TextUtils.expandTemplate(
+ getContext().getString(R.string.data_used),
+ Formatter.formatFileSize(getContext(), mDataplanUse)));
+ if (mHasMobileData && mNumPlans >= 0 && mDataplanSize > 0L) {
+ TextView usageRemainingField = (TextView) holder.findViewById(R.id.data_remaining_view);
+ long dataRemaining = mDataplanSize - mDataplanUse;
+ if (dataRemaining >= 0) {
+ usageRemainingField.setText(
+ TextUtils.expandTemplate(getContext().getText(R.string.data_remaining),
+ Formatter.formatFileSize(getContext(), dataRemaining)));
+ } else {
+ usageRemainingField.setText(
+ TextUtils.expandTemplate(getContext().getText(R.string.data_overusage),
+ Formatter.formatFileSize(getContext(), -dataRemaining)));
+ }
+ }
+ }
+
+ private void updateCycleTimeText(PreferenceViewHolder holder) {
+ float daysLeft =
+ ((float) mCycleEndTimeMs - System.currentTimeMillis()) / MILLIS_IN_A_DAY;
+ if (daysLeft < 0) {
+ daysLeft = 0;
+ }
+
+ TextView cycleTime = (TextView) holder.findViewById(R.id.cycle_left_time);
+ cycleTime.setText(
+ (daysLeft > 0 && daysLeft < 1)
+ ? getContext().getString(R.string.billing_cycle_less_than_one_day_left)
+ : getContext().getResources().getQuantityString(
+ R.plurals.billing_cycle_days_left, (int) daysLeft, (int) daysLeft));
+ }
+
+
+ private void updateCarrierInfo(TextView carrierInfo) {
+ if (mNumPlans > 0 && mSnapshotTimeMs >= 0L) {
+ long updateAge = System.currentTimeMillis() - mSnapshotTimeMs;
carrierInfo.setVisibility(View.VISIBLE);
- if (carrierName != null) {
+ if (mCarrierName != null) {
carrierInfo.setText(getContext().getString(R.string.carrier_and_update_text,
- carrierName, StringUtil.formatRelativeTime(
+ mCarrierName, StringUtil.formatRelativeTime(
getContext(), updateAge, false /* withSeconds */)));
} else {
carrierInfo.setText(getContext().getString(R.string.no_carrier_update_text,
StringUtil.formatRelativeTime(
getContext(), updateAge, false /* withSeconds */)));
}
+
+ carrierInfo.setTextColor(
+ updateAge <= WARNING_AGE
+ ? Utils.getColorAttr(getContext(), android.R.attr.textColorPrimary)
+ : Utils.getColorAttr(getContext(), android.R.attr.colorError));
} else {
carrierInfo.setVisibility(View.GONE);
}
diff --git a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
index 11da829..6deced7 100644
--- a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
+++ b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
@@ -37,6 +37,7 @@
import com.android.internal.util.CollectionUtils;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.FeatureFlags;
import com.android.settingslib.NetworkPolicyEditor;
import com.android.settingslib.net.DataUsageController;
@@ -164,29 +165,24 @@
refreshDataplanInfo(info);
}
- if (mDataplanCount == 0 && (info.warningLevel > 0 || info.limitLevel > 0)) {
- final String warning = Formatter.formatFileSize(mContext, info.warningLevel);
- final String limit = Formatter.formatFileSize(mContext, info.limitLevel);
- summaryPreference.setLimitInfo(mContext.getString(info.limitLevel <= 0
- ? R.string.cell_warning_only
- : R.string.cell_warning_and_limit, warning, limit));
+ if (info.warningLevel > 0 && info.limitLevel > 0) {
+ summaryPreference.setLimitInfo(TextUtils.expandTemplate(
+ mContext.getText(R.string.cell_data_warning_and_limit),
+ Formatter.formatFileSize(mContext, info.warningLevel),
+ Formatter.formatFileSize(mContext, info.limitLevel)).toString());
+ } else if (info.warningLevel > 0) {
+ summaryPreference.setLimitInfo(TextUtils.expandTemplate(
+ mContext.getText(R.string.cell_data_warning),
+ Formatter.formatFileSize(mContext, info.warningLevel)).toString());
+ } else if (info.limitLevel > 0) {
+ summaryPreference.setLimitInfo(TextUtils.expandTemplate(
+ mContext.getText(R.string.cell_data_limit),
+ Formatter.formatFileSize(mContext, info.limitLevel)).toString());
} else {
summaryPreference.setLimitInfo(null);
}
- final StringBuilder title = new StringBuilder();
- if (mHasMobileData) {
- title.append(formatUsage(mContext, mContext.getString(R.string.data_used),
- mDataplanUse));
- if (mDataplanCount >= 0 && mDataplanSize > 0L) {
- title.append(formatUsage(mContext, mContext.getString(R.string.data_remaining),
- mDataplanSize - mDataplanUse));
- }
- } else {
- title.append(formatUsage(mContext, mContext.getString(mDataUsageTemplate),
- mDataplanUse));
- }
- summaryPreference.setTitle(title.toString());
+ summaryPreference.setUsageNumbers(mDataplanUse, mDataplanSize, mHasMobileData);
if (mDataplanSize <= 0) {
summaryPreference.setChartEnabled(false);
@@ -194,13 +190,19 @@
summaryPreference.setChartEnabled(true);
summaryPreference.setLabels(Formatter.formatFileSize(mContext, 0 /* sizeBytes */),
Formatter.formatFileSize(mContext, mDataplanSize));
- summaryPreference.setRatios(mDataplanUse / (float) mDataplanSize, 0 /* middle */,
- (mDataplanSize - mDataplanUse) / (float) mDataplanSize);
+ summaryPreference.setProgress(mDataplanUse / (float) mDataplanSize);
}
summaryPreference.setUsageInfo(mCycleEnd, mSnapshotTime, mCarrierName,
mDataplanCount, mManageSubscriptionIntent);
}
+ private String getLimitText(long limit, int textId) {
+ if (limit <= 0) {
+ return null;
+ }
+ return mContext.getString(textId, Formatter.formatFileSize(mContext, limit));
+ }
+
// TODO(b/70950124) add test for this method once the robolectric shadow run script is
// completed (b/3526807)
private void refreshDataplanInfo(DataUsageController.DataUsageInfo info) {
@@ -232,7 +234,7 @@
mCycleStart = rule.start.toEpochSecond() * 1000L;
mCycleEnd = rule.end.toEpochSecond() * 1000L;
}
- mSnapshotTime = System.currentTimeMillis() - primaryPlan.getDataUsageTime();
+ mSnapshotTime = primaryPlan.getDataUsageTime();
}
}
mManageSubscriptionIntent =
diff --git a/src/com/android/settings/fuelgauge/RestrictAppPreferenceController.java b/src/com/android/settings/fuelgauge/RestrictAppPreferenceController.java
index e41a94b..02a2cf6 100644
--- a/src/com/android/settings/fuelgauge/RestrictAppPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/RestrictAppPreferenceController.java
@@ -67,17 +67,26 @@
final List<AppOpsManager.PackageOps> packageOpsList = mAppOpsManager.getPackagesForOps(
new int[]{AppOpsManager.OP_RUN_ANY_IN_BACKGROUND});
- final int num = CollectionUtils.size(packageOpsList);
mAppInfos = new ArrayList<>();
- for (int i = 0; i < num; i++) {
+ for (int i = 0, size = CollectionUtils.size(packageOpsList); i < size; i++) {
final AppOpsManager.PackageOps packageOps = packageOpsList.get(i);
- mAppInfos.add(new AppInfo.Builder()
- .setPackageName(packageOps.getPackageName())
- .setUid(packageOps.getUid())
- .build());
+ 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());
+ }
+ }
}
+ final int num = mAppInfos.size();
// Enable the preference if some apps already been restricted, otherwise disable it
preference.setEnabled(num > 0);
preference.setSummary(
diff --git a/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobService.java b/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobService.java
index 83a79bc..5d0e71d 100644
--- a/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobService.java
+++ b/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobService.java
@@ -31,8 +31,9 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.os.Process;
import android.os.StatsDimensionsValue;
-import android.os.SystemPropertiesProto;
+import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
@@ -122,7 +123,8 @@
final boolean smartBatteryOn = Settings.Global.getInt(contentResolver,
Settings.Global.APP_STANDBY_ENABLED, ON) == ON;
final String packageName = batteryUtils.getPackageName(uid);
- if (!powerWhitelistBackend.isSysWhitelisted(packageName)) {
+ if (!powerWhitelistBackend.isSysWhitelistedExceptIdle(packageName)
+ && !isSystemUid(uid)) {
if (anomalyType == StatsManagerConfig.AnomalyType.EXCESSIVE_BG) {
// TODO(b/72385333): check battery percentage draining in batterystats
if (batteryUtils.isLegacyApp(packageName) && batteryUtils.isAppHeavilyUsed(
@@ -156,7 +158,7 @@
* 3. Bluetooth anomaly: 3:{1:{1:{1:10140|}|}|}
*/
@VisibleForTesting
- final int extractUidFromStatsDimensionsValue(StatsDimensionsValue statsDimensionsValue) {
+ int extractUidFromStatsDimensionsValue(StatsDimensionsValue statsDimensionsValue) {
//TODO(b/73172999): Add robo test for this method
if (statsDimensionsValue == null) {
return UID_NULL;
@@ -178,4 +180,9 @@
return UID_NULL;
}
+
+ private boolean isSystemUid(int uid) {
+ final int appUid = UserHandle.getAppId(uid);
+ return appUid >= Process.ROOT_UID && appUid < Process.FIRST_APPLICATION_UID;
+ }
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
index 9e172de..a7d542c 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
@@ -32,11 +32,13 @@
import com.android.settings.Utils;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settings.fuelgauge.Estimate;
import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController.BatteryTipListener;
import com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.HighUsageTip;
import com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip;
+import com.android.settings.fuelgauge.batterytip.tips.SummaryTip;
import com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip;
import com.android.settingslib.utils.StringUtil;
@@ -72,9 +74,18 @@
switch (mBatteryTip.getType()) {
case BatteryTip.TipType.SUMMARY:
- case BatteryTip.TipType.LOW_BATTERY:
- //TODO(b/70570352): add dialog
- return null;
+ final long averageTimeMs = ((SummaryTip) mBatteryTip).getAverageTimeMs();
+ final String message = context.getString(
+ averageTimeMs == Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN
+ ? R.string.battery_tip_dialog_summary_message_no_estimation
+ : R.string.battery_tip_dialog_summary_message,
+ StringUtil.formatElapsedTime(context, averageTimeMs,
+ false /* withSeconds */));
+
+ return new AlertDialog.Builder(context)
+ .setMessage(message)
+ .setPositiveButton(android.R.string.ok, null)
+ .create();
case BatteryTip.TipType.HIGH_DEVICE_USAGE:
final HighUsageTip highUsageTip = (HighUsageTip) mBatteryTip;
final RecyclerView view = (RecyclerView) LayoutInflater.from(context).inflate(
@@ -96,21 +107,30 @@
final RestrictAppTip restrictAppTip = (RestrictAppTip) mBatteryTip;
final List<AppInfo> restrictedAppList = restrictAppTip.getRestrictAppList();
final int num = restrictedAppList.size();
+ final CharSequence appLabel = Utils.getApplicationLabel(context,
+ restrictedAppList.get(0).packageName);
final AlertDialog.Builder builder = new AlertDialog.Builder(context)
.setTitle(context.getResources().getQuantityString(
R.plurals.battery_tip_restrict_app_dialog_title, num, num))
- .setMessage(getString(R.string.battery_tip_restrict_app_dialog_message))
.setPositiveButton(R.string.battery_tip_restrict_app_dialog_ok, this)
.setNegativeButton(android.R.string.cancel, null);
-
- // TODO(b/72385333): consider building dialog with 5+ apps when strings are done
- if (num > 1) {
+ if (num == 1) {
+ builder.setMessage(
+ getString(R.string.battery_tip_restrict_app_dialog_message, appLabel));
+ } else if (num <= 5) {
+ builder.setMessage(
+ getString(
+ R.string.battery_tip_restrict_apps_less_than_5_dialog_message));
final RecyclerView restrictionView = (RecyclerView) LayoutInflater.from(
context).inflate(R.layout.recycler_view, null);
restrictionView.setLayoutManager(new LinearLayoutManager(context));
restrictionView.setAdapter(new HighUsageAdapter(context, restrictedAppList));
builder.setView(restrictionView);
+ } else {
+ builder.setMessage(context.getString(
+ R.string.battery_tip_restrict_apps_more_than_5_dialog_message,
+ restrictAppTip.getRestrictAppsString(context)));
}
return builder.create();
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
index ebb4790..5efc04a 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
@@ -22,6 +22,7 @@
import com.android.internal.os.BatteryStatsHelper;
import com.android.settings.fuelgauge.BatteryInfo;
import com.android.settings.fuelgauge.BatteryUtils;
+import com.android.settings.fuelgauge.Estimate;
import com.android.settings.fuelgauge.batterytip.detectors.EarlyWarningDetector;
import com.android.settings.fuelgauge.batterytip.detectors.HighUsageDetector;
import com.android.settings.fuelgauge.batterytip.detectors.LowBatteryDetector;
@@ -70,7 +71,7 @@
tips.add(new HighUsageDetector(context, policy, mBatteryStatsHelper).detect());
tips.add(new SmartBatteryDetector(policy, context.getContentResolver()).detect());
tips.add(new EarlyWarningDetector(policy, context).detect());
- tips.add(new SummaryDetector(policy).detect());
+ tips.add(new SummaryDetector(policy, batteryInfo.averageTimeToDischarge).detect());
tips.add(new RestrictAppDetector(context, policy).detect());
Collections.sort(tips);
@@ -83,7 +84,8 @@
private List<BatteryTip> getFakeData() {
final List<BatteryTip> tips = new ArrayList<>();
- tips.add(new SummaryTip(BatteryTip.StateType.NEW));
+ tips.add(new SummaryTip(BatteryTip.StateType.NEW,
+ Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN));
tips.add(new LowBatteryTip(BatteryTip.StateType.NEW));
return tips;
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
index d2af589..9e47782 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
@@ -27,6 +27,7 @@
import com.android.settings.SettingsActivity;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.InstrumentedPreferenceFragment;
+import com.android.settings.fuelgauge.Estimate;
import com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.SummaryTip;
@@ -82,7 +83,8 @@
mPreferenceGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
// Add summary tip in advance to avoid UI flakiness
- final SummaryTip summaryTip = new SummaryTip(BatteryTip.StateType.NEW);
+ final SummaryTip summaryTip = new SummaryTip(BatteryTip.StateType.NEW,
+ Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN);
mPreferenceGroup.addPreference(summaryTip.buildPreference(mPrefContext));
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/detectors/SummaryDetector.java b/src/com/android/settings/fuelgauge/batterytip/detectors/SummaryDetector.java
index a45dc09..0a20aac 100644
--- a/src/com/android/settings/fuelgauge/batterytip/detectors/SummaryDetector.java
+++ b/src/com/android/settings/fuelgauge/batterytip/detectors/SummaryDetector.java
@@ -26,9 +26,11 @@
*/
public class SummaryDetector implements BatteryTipDetector {
private BatteryTipPolicy mPolicy;
+ private long mAverageTimeMs;
- public SummaryDetector(BatteryTipPolicy policy) {
+ public SummaryDetector(BatteryTipPolicy policy, long averageTimeMs) {
mPolicy = policy;
+ mAverageTimeMs = averageTimeMs;
}
@Override
@@ -37,6 +39,6 @@
final int state = mPolicy.summaryEnabled
? BatteryTip.StateType.NEW
: BatteryTip.StateType.INVISIBLE;
- return new SummaryTip(state);
+ return new SummaryTip(state, mAverageTimeMs);
}
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTip.java
index 566cbfa..9c3a9bd 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTip.java
@@ -17,8 +17,9 @@
package com.android.settings.fuelgauge.batterytip.tips;
import android.content.Context;
-import android.content.res.Resources;
+import android.icu.text.ListFormatter;
import android.os.Parcel;
+import android.text.TextUtils;
import android.util.Pair;
import com.android.internal.annotations.VisibleForTesting;
@@ -72,7 +73,7 @@
return mState == StateType.HANDLED
? context.getString(R.string.battery_tip_restrict_handled_summary)
: context.getResources().getQuantityString(R.plurals.battery_tip_restrict_summary,
- num, appLabel, num);
+ num, appLabel, num);
}
@Override
@@ -118,6 +119,19 @@
return mRestrictAppList;
}
+ /**
+ * Construct the app list string(e.g. app1, app2, and app3)
+ */
+ public CharSequence getRestrictAppsString(Context context) {
+ final List<CharSequence> appLabels = new ArrayList<>();
+ for (int i = 0, size = mRestrictAppList.size(); i < size; i++) {
+ appLabels.add(Utils.getApplicationLabel(context,
+ mRestrictAppList.get(i).packageName));
+ }
+
+ return ListFormatter.getInstance().format(appLabels);
+ }
+
@Override
public String toString() {
final StringBuilder stringBuilder = new StringBuilder(super.toString());
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/SummaryTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/SummaryTip.java
index 8993754..8ed8692 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/SummaryTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/SummaryTip.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
+import android.support.annotation.VisibleForTesting;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
@@ -28,13 +29,17 @@
* Tip to show general summary about battery life
*/
public class SummaryTip extends BatteryTip {
+ private long mAverageTimeMs;
- public SummaryTip(@StateType int state) {
- super(TipType.SUMMARY, state, false /* showDialog */);
+ public SummaryTip(@StateType int state, long averageTimeMs) {
+ super(TipType.SUMMARY, state, true /* showDialog */);
+ mAverageTimeMs = averageTimeMs;
}
- private SummaryTip(Parcel in) {
+ @VisibleForTesting
+ SummaryTip(Parcel in) {
super(in);
+ mAverageTimeMs = in.readLong();
}
@Override
@@ -58,11 +63,21 @@
}
@Override
+ public void writeToParcel(Parcel dest, int flags) {
+ super.writeToParcel(dest, flags);
+ dest.writeLong(mAverageTimeMs);
+ }
+
+ @Override
public void log(Context context, MetricsFeatureProvider metricsFeatureProvider) {
metricsFeatureProvider.action(context, MetricsProto.MetricsEvent.ACTION_SUMMARY_TIP,
mState);
}
+ public long getAverageTimeMs() {
+ return mAverageTimeMs;
+ }
+
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public BatteryTip createFromParcel(Parcel in) {
return new SummaryTip(in);
diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index b143b42..2718756 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -94,31 +94,29 @@
};
String getBehaviorSettingSummary(Policy policy, int zenMode) {
- List<String> enabledCategories;
+ List<String> enabledCategories = getEnabledCategories(policy);
- if (zenMode == Settings.Global.ZEN_MODE_NO_INTERRUPTIONS) {
- return mContext.getString(R.string.zen_mode_behavior_total_silence);
- } else if (zenMode == Settings.Global.ZEN_MODE_ALARMS) {
- return mContext.getString(R.string.zen_mode_behavior_alarms_only);
- } else {
- enabledCategories = getEnabledCategories(policy);
- }
-
- // no sound categories can bypass dnd
int numCategories = enabledCategories.size();
if (numCategories == 0) {
- return mContext.getString(R.string.zen_mode_behavior_total_silence);
+ return mContext.getString(R.string.zen_mode_no_exceptions);
+ } else if (numCategories == 1) {
+ return enabledCategories.get(0);
+ } else if (numCategories == 2) {
+ return mContext.getString(R.string.join_two_items, enabledCategories.get(0),
+ enabledCategories.get(1).toLowerCase());
+ } else if (numCategories == 3){
+ String secondaryText = mContext.getString(R.string.join_two_unrelated_items,
+ enabledCategories.get(0), enabledCategories.get(1).toLowerCase());
+ return mContext.getString(R.string.join_two_items, secondaryText,
+ enabledCategories.get(2).toLowerCase());
+ } else {
+ String secondaryText = mContext.getString(R.string.join_many_items_middle,
+ enabledCategories.get(0), enabledCategories.get(1).toLowerCase());
+ secondaryText = mContext.getString(R.string.join_many_items_middle, secondaryText,
+ enabledCategories.get(2).toLowerCase());
+ return mContext.getString(R.string.join_many_items_last, secondaryText,
+ mContext.getString(R.string.zen_mode_other_options));
}
-
- // only alarms and media can bypass dnd
- if (numCategories == 2 &&
- isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_ALARMS) &&
- isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_MEDIA)) {
- return mContext.getString(R.string.zen_mode_behavior_alarms_only);
- }
-
- // custom
- return mContext.getString(R.string.zen_mode_behavior_summary_custom);
}
String getSoundSummary() {
diff --git a/src/com/android/settings/widget/LinearColorBar.java b/src/com/android/settings/widget/LinearColorBar.java
index b3e685e..df1403e 100644
--- a/src/com/android/settings/widget/LinearColorBar.java
+++ b/src/com/android/settings/widget/LinearColorBar.java
@@ -26,6 +26,9 @@
import com.android.settings.Utils;
+/**
+ * @Deprecated Use {@link android.widget.ProgressBar} instead.
+ */
public class LinearColorBar extends LinearLayout {
static final int RIGHT_COLOR = 0xffced7db;
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index d7b4299..cf26f8a 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -363,6 +363,9 @@
if (mConfigUi.getSubmitButton() != null) {
enableSubmitIfAppropriate();
}
+
+ // After done view show and hide, request focus from parent view
+ mView.findViewById(R.id.l_wifidialog).requestFocus();
}
@VisibleForTesting
@@ -1216,6 +1219,11 @@
}
}
+ @VisibleForTesting
+ KeyStore getKeyStore() {
+ return KeyStore.getInstance();
+ }
+
private void loadCertificates(
Spinner spinner,
String prefix,
@@ -1232,8 +1240,12 @@
if (showUsePreinstalledCertOption) {
certs.add(mUseSystemCertsString);
}
- certs.addAll(
- Arrays.asList(KeyStore.getInstance().list(prefix, android.os.Process.WIFI_UID)));
+ try {
+ certs.addAll(
+ Arrays.asList(getKeyStore().list(prefix, android.os.Process.WIFI_UID)));
+ } catch (Exception e) {
+ Log.e(TAG, "can't get the certificate list from KeyStore");
+ }
certs.add(noCertificateString);
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
index 6f2accd..6f170a0 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
@@ -203,9 +203,6 @@
// not show notification, we are changing result code here.
setResultCode(Activity.RESULT_CANCELED);
- // UX requirement is to disable WFC in case of "permanent" registration failures.
- mSwitch.setChecked(false);
-
showAlert(intent);
}
}
diff --git a/src/com/android/settings/wifi/tether/WifiTetherAutoOffPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherAutoOffPreferenceController.java
index 5fa4e25..8fdae80 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherAutoOffPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherAutoOffPreferenceController.java
@@ -38,7 +38,7 @@
@Override
public void updateState(Preference preference) {
final boolean settingsOn = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.SOFT_AP_TIMEOUT_ENABLED, 0) != 0;
+ Settings.Global.SOFT_AP_TIMEOUT_ENABLED, 1) != 0;
((SwitchPreference) preference).setChecked(settingsOn);
}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
index eb94d8d..1914250 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
@@ -90,12 +90,12 @@
final Intent intent = new Intent();
- when(mDataUsageController.getDataUsageInfo()).thenReturn(info);
+ when(mDataUsageController.getDataUsageInfo(any())).thenReturn(info);
mController.setPlanValues(1 /* dataPlanCount */, LIMIT1, USAGE1);
mController.setCarrierValues(CARRIER_NAME, now - UPDATE_BACKOFF_MS, info.cycleEnd, intent);
mController.updateState(mSummaryPreference);
- verify(mSummaryPreference).setLimitInfo(null);
+ verify(mSummaryPreference).setLimitInfo("500 MB data warning / 1.00 GB data limit");
verify(mSummaryPreference).setUsageInfo(info.cycleEnd, now - UPDATE_BACKOFF_MS,
CARRIER_NAME, 1 /* numPlans */, intent);
verify(mSummaryPreference).setChartEnabled(true);
@@ -113,7 +113,7 @@
mController.setCarrierValues(CARRIER_NAME, now - UPDATE_BACKOFF_MS, info.cycleEnd, intent);
mController.updateState(mSummaryPreference);
- verify(mSummaryPreference).setLimitInfo("500 MB Data warning / 1.00 GB Data limit");
+ verify(mSummaryPreference).setLimitInfo("500 MB data warning / 1.00 GB data limit");
verify(mSummaryPreference).setUsageInfo(info.cycleEnd, now - UPDATE_BACKOFF_MS,
CARRIER_NAME, 0 /* numPlans */, intent);
verify(mSummaryPreference).setChartEnabled(true);
@@ -130,7 +130,7 @@
info.cycleEnd, null /* intent */);
mController.updateState(mSummaryPreference);
- verify(mSummaryPreference).setLimitInfo("500 MB Data warning / 1.00 GB Data limit");
+ verify(mSummaryPreference).setLimitInfo("500 MB data warning / 1.00 GB data limit");
verify(mSummaryPreference).setUsageInfo(
info.cycleEnd,
-1L /* snapshotTime */,
@@ -152,7 +152,7 @@
info.cycleEnd, null /* intent */);
mController.updateState(mSummaryPreference);
- verify(mSummaryPreference).setLimitInfo("500 MB Data warning / 1.00 GB Data limit");
+ verify(mSummaryPreference).setLimitInfo("500 MB data warning / 1.00 GB data limit");
verify(mSummaryPreference).setUsageInfo(
info.cycleEnd,
-1L /* snapshotTime */,
@@ -162,6 +162,74 @@
verify(mSummaryPreference).setChartEnabled(false);
}
+ @Test
+ public void testSummaryUpdate_noLimitNoWarning() {
+ final long now = System.currentTimeMillis();
+ final DataUsageController.DataUsageInfo info = createTestDataUsageInfo(now);
+ info.warningLevel = 0L;
+ info.limitLevel = 0L;
+
+ final Intent intent = new Intent();
+
+ when(mDataUsageController.getDataUsageInfo(any())).thenReturn(info);
+ mController.setPlanValues(0 /* dataPlanCount */, LIMIT1, USAGE1);
+ mController.setCarrierValues(CARRIER_NAME, now - UPDATE_BACKOFF_MS, info.cycleEnd, intent);
+
+ mController.updateState(mSummaryPreference);
+ verify(mSummaryPreference).setLimitInfo(null);
+ }
+
+ @Test
+ public void testSummaryUpdate_warningOnly() {
+ final long now = System.currentTimeMillis();
+ final DataUsageController.DataUsageInfo info = createTestDataUsageInfo(now);
+ info.warningLevel = 1000000L;
+ info.limitLevel = 0L;
+
+ final Intent intent = new Intent();
+
+ when(mDataUsageController.getDataUsageInfo(any())).thenReturn(info);
+ mController.setPlanValues(0 /* dataPlanCount */, LIMIT1, USAGE1);
+ mController.setCarrierValues(CARRIER_NAME, now - UPDATE_BACKOFF_MS, info.cycleEnd, intent);
+
+ mController.updateState(mSummaryPreference);
+ verify(mSummaryPreference).setLimitInfo("1.00 MB data warning");
+ }
+
+ @Test
+ public void testSummaryUpdate_limitOnly() {
+ final long now = System.currentTimeMillis();
+ final DataUsageController.DataUsageInfo info = createTestDataUsageInfo(now);
+ info.warningLevel = 0L;
+ info.limitLevel = 1000000L;
+
+ final Intent intent = new Intent();
+
+ when(mDataUsageController.getDataUsageInfo(any())).thenReturn(info);
+ mController.setPlanValues(0 /* dataPlanCount */, LIMIT1, USAGE1);
+ mController.setCarrierValues(CARRIER_NAME, now - UPDATE_BACKOFF_MS, info.cycleEnd, intent);
+
+ mController.updateState(mSummaryPreference);
+ verify(mSummaryPreference).setLimitInfo("1.00 MB data limit");
+ }
+
+ @Test
+ public void testSummaryUpdate_limitAndWarning() {
+ final long now = System.currentTimeMillis();
+ final DataUsageController.DataUsageInfo info = createTestDataUsageInfo(now);
+ info.warningLevel = 1000000L;
+ info.limitLevel = 1000000L;
+
+ final Intent intent = new Intent();
+
+ when(mDataUsageController.getDataUsageInfo(any())).thenReturn(info);
+ mController.setPlanValues(0 /* dataPlanCount */, LIMIT1, USAGE1);
+ mController.setCarrierValues(CARRIER_NAME, now - UPDATE_BACKOFF_MS, info.cycleEnd, intent);
+
+ mController.updateState(mSummaryPreference);
+ verify(mSummaryPreference).setLimitInfo("1.00 MB data warning / 1.00 MB data limit");
+ }
+
private DataUsageController.DataUsageInfo createTestDataUsageInfo(long now) {
DataUsageController.DataUsageInfo info = new DataUsageController.DataUsageInfo();
info.carrier = CARRIER_NAME;
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
index ecd556d..638ee79 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
@@ -16,20 +16,22 @@
package com.android.settings.datausage;
-import static com.google.common.truth.Truth.assertThat;
-
import android.content.Context;
import android.content.Intent;
import android.support.v7.preference.PreferenceViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.ProgressBar;
import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
+import com.android.settingslib.Utils;
import com.android.settingslib.utils.StringUtil;
+import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
@@ -38,6 +40,10 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import java.util.concurrent.TimeUnit;
+
+import static com.google.common.truth.Truth.assertThat;
+
@RunWith(SettingsRobolectricTestRunner.class)
@Config(shadows = SettingsShadowResourcesImpl.class)
public class DataUsageSummaryPreferenceTest {
@@ -53,7 +59,13 @@
private TextView mCycleTime;
private TextView mCarrierInfo;
private TextView mDataLimits;
+ private TextView mDataUsed;
+ private TextView mDataRemaining;
private Button mLaunchButton;
+ private LinearLayout mLabelBar;
+ private TextView mLabel1;
+ private TextView mLabel2;
+ private ProgressBar mProgressBar;
private long mCycleEnd;
private long mUpdateTime;
@@ -111,6 +123,31 @@
}
@Test
+ public void testSetUsageInfo_withRecentCarrierUpdate_doesNotSetCarrierInfoWarningColor() {
+ final long updateTime = System.currentTimeMillis() - TimeUnit.HOURS.toMillis(1);
+ mCarrierInfo = (TextView) mHolder.findViewById(R.id.carrier_and_update);
+ mSummaryPreference.setUsageInfo(mCycleEnd, updateTime, DUMMY_CARRIER, 1 /* numPlans */,
+ new Intent());
+
+ bindViewHolder();
+ assertThat(mCarrierInfo.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(mCarrierInfo.getCurrentTextColor()).isEqualTo(
+ Utils.getColorAttr(mContext, android.R.attr.textColorPrimary));
+ }
+
+ @Test
+ public void testSetUsageInfo_withStaleCarrierUpdate_setsCarrierInfoWarningColor() {
+ final long updateTime = System.currentTimeMillis() - TimeUnit.HOURS.toMillis(7);
+ mSummaryPreference.setUsageInfo(mCycleEnd, updateTime, DUMMY_CARRIER, 1 /* numPlans */,
+ new Intent());
+
+ bindViewHolder();
+ assertThat(mCarrierInfo.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(mCarrierInfo.getCurrentTextColor()).isEqualTo(
+ Utils.getColorAttr(mContext, android.R.attr.colorError));
+ }
+
+ @Test
public void testSetUsageInfo_withNoDataPlans_usageTitleNotShown() {
mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
new Intent());
@@ -129,16 +166,41 @@
}
@Test
- public void testSetUsageInfo_cycleRemainingTimeShown() {
- mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
+ public void testSetUsageInfo_cycleRemainingTimeIsLessOneDay() {
+ // just under one day
+ final long cycleEnd = System.currentTimeMillis() + TimeUnit.HOURS.toMillis(23);
+ mSummaryPreference.setUsageInfo(cycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
new Intent());
- String cyclePrefix = StringUtil.formatElapsedTime(mContext, CYCLE_DURATION_MILLIS,
- false /* withSeconds */).toString();
- String text = mContext.getString(R.string.cycle_left_time_text, cyclePrefix);
bindViewHolder();
assertThat(mCycleTime.getVisibility()).isEqualTo(View.VISIBLE);
- assertThat(mCycleTime.getText()).isEqualTo(text);
+ assertThat(mCycleTime.getText()).isEqualTo(
+ mContext.getString(R.string.billing_cycle_less_than_one_day_left));
+ }
+
+ @Test
+ public void testSetUsageInfo_cycleRemainingTimeNegativeDaysLeft_shouldDisplayZeroDays() {
+ final long cycleEnd = System.currentTimeMillis() - 1L;
+ mSummaryPreference.setUsageInfo(cycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
+ new Intent());
+
+ bindViewHolder();
+ assertThat(mCycleTime.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(mCycleTime.getText()).isEqualTo(
+ mContext.getResources().getQuantityString(R.plurals.billing_cycle_days_left, 0, 0));
+ }
+
+ @Test
+ public void testSetUsageInfo_cycleRemainingTimeDaysLeft_shouldUsePlurals() {
+ final int daysLeft = 3;
+ final long cycleEnd = System.currentTimeMillis() + TimeUnit.DAYS.toMillis(daysLeft)
+ + TimeUnit.HOURS.toMillis(1);
+ mSummaryPreference.setUsageInfo(cycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
+ new Intent());
+
+ bindViewHolder();
+ assertThat(mCycleTime.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(mCycleTime.getText()).isEqualTo(daysLeft + " days left");
}
@Test
@@ -159,12 +221,91 @@
assertThat(mDataLimits.getVisibility()).isEqualTo(View.GONE);
}
+ @Test
+ public void testSetChartEnabledFalse_hidesLabelBar() {
+ setValidLabels();
+ mSummaryPreference.setChartEnabled(false);
+
+ bindViewHolder();
+ assertThat(mLabelBar.getVisibility()).isEqualTo(View.GONE);
+ }
+
+ @Test
+ public void testSetEmptyLabels_hidesLabelBar() {
+ mSummaryPreference.setLabels("", "");
+
+ bindViewHolder();
+ assertThat(mLabelBar.getVisibility()).isEqualTo(View.GONE);
+ }
+
+ @Test
+ public void testLabelBar_isVisible_whenLabelsSet() {
+ setValidLabels();
+ //mChartEnabled defaults to true
+
+ bindViewHolder();
+ assertThat(mLabelBar.getVisibility()).isEqualTo(View.VISIBLE);
+ }
+
+
+ @Test
+ public void testSetProgress_updatesProgressBar() {
+ setValidLabels();
+ mSummaryPreference.setProgress(.5f);
+
+ bindViewHolder();
+ assertThat(mProgressBar.getProgress()).isEqualTo(50);
+ }
+
+ private void setValidLabels() {
+ mSummaryPreference.setLabels("0.0 GB", "5.0 GB");
+ }
+
+ @Test
+ public void testSetUsageAndRemainingInfo_withUsageInfo_dataUsageAndRemainingShown() {
+ mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 1 /* numPlans */,
+ new Intent());
+ mSummaryPreference.setUsageNumbers(1000000L, 10000000L, true);
+
+ bindViewHolder();
+ assertThat(mDataUsed.getText().toString()).isEqualTo("1.00 MB used");
+ assertThat(mDataRemaining.getText().toString()).isEqualTo("9.00 MB left");
+ }
+
+ @Test
+ public void testSetUsageInfo_withDataOverusage() {
+ mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 1 /* numPlans */,
+ new Intent());
+ mSummaryPreference.setUsageNumbers(11_000_000L, 10_000_000L, true);
+
+ bindViewHolder();
+ assertThat(mDataUsed.getText().toString()).isEqualTo("11.00 MB used");
+ assertThat(mDataRemaining.getText().toString()).isEqualTo("1.00 MB over");
+ }
+
+ @Test
+ public void testSetUsageInfo_withUsageInfo_dataUsageShown() {
+ mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
+ new Intent());
+ mSummaryPreference.setUsageNumbers(1000000L, -1L, true);
+
+ bindViewHolder();
+ assertThat(mDataUsed.getText().toString()).isEqualTo("1.00 MB used");
+ assertThat(mDataRemaining.getText()).isEqualTo("");
+ }
+
private void bindViewHolder() {
mSummaryPreference.onBindViewHolder(mHolder);
mUsageTitle = (TextView) mHolder.findViewById(R.id.usage_title);
mCycleTime = (TextView) mHolder.findViewById(R.id.cycle_left_time);
mCarrierInfo = (TextView) mHolder.findViewById(R.id.carrier_and_update);
mDataLimits = (TextView) mHolder.findViewById(R.id.data_limits);
+ mDataUsed = (TextView) mHolder.findViewById(R.id.data_usage_view);
+ mDataRemaining = (TextView) mHolder.findViewById(R.id.data_remaining_view);
mLaunchButton = (Button) mHolder.findViewById(R.id.launch_mdp_app_button);
+ mLabelBar = (LinearLayout) mHolder.findViewById(R.id.label_bar);
+ mLabel1 = (TextView) mHolder.findViewById(R.id.text1);
+ mLabel2 = (TextView) mHolder.findViewById(R.id.text2);
+ mProgressBar = (ProgressBar) mHolder.findViewById(R.id.determinateBar);
}
}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java b/tests/robotests/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java
index 4a624b7..0359cfc 100644
--- a/tests/robotests/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java
@@ -73,13 +73,13 @@
CountryTimeZones US = mock(CountryTimeZones.class);
when(US.getCountryIso()).thenReturn("us");
when(US.getTimeZoneMappings()).thenReturn(Arrays.asList(
- TimeZoneMapping.createForTests("Unknown/Secret_City", true),
- TimeZoneMapping.createForTests("Unknown/Secret_City2", false)
+ TimeZoneMapping.createForTests("Unknown/Secret_City", true, null /* notUsedAfter */),
+ TimeZoneMapping.createForTests("Unknown/Secret_City2", false, null /* notUsedAfter */)
));
CountryTimeZones GB = mock(CountryTimeZones.class);
when(GB.getCountryIso()).thenReturn("gb");
when(GB.getTimeZoneMappings()).thenReturn(Collections.singletonList(
- TimeZoneMapping.createForTests("Unknown/Secret_City", true)
+ TimeZoneMapping.createForTests("Unknown/Secret_City", true, null /* notUsedAfter */)
));
when(mCountryZonesFinder.lookupCountryTimeZonesForZoneId("Unknown/Secret_City"))
.thenReturn(Arrays.asList(US, GB));
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceControllerTest.java
index ee8e798..9deec6b 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceControllerTest.java
@@ -174,7 +174,7 @@
mController.updateSummary(mPreference);
- assertThat(mPreference.getSummary()).isEqualTo("No");
+ assertThat(mPreference.getSummary()).isEqualTo("Off / Uses battery in background");
}
@Test
@@ -184,7 +184,7 @@
mController.updateSummary(mPreference);
- assertThat(mPreference.getSummary()).isEqualTo("Yes");
+ assertThat(mPreference.getSummary()).isEqualTo("On / Background usage restricted");
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
index c9c82c2..57eff56 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
@@ -18,7 +18,9 @@
import static com.android.settings.SettingsActivity.EXTRA_SHOW_FRAGMENT;
import static com.android.settings.SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID;
+
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
@@ -47,11 +49,17 @@
@RunWith(RobolectricTestRunner.class)
public class RestrictAppPreferenceControllerTest {
+ private static final int ALLOWED_UID = 111;
+ private static final String ALLOWED_PACKAGE_NAME = "com.android.allowed.package";
+ private static final int RESTRICTED_UID = 222;
+ private static final String RESTRICTED_PACKAGE_NAME = "com.android.restricted.package";
@Mock
private AppOpsManager mAppOpsManager;
@Mock
- private AppOpsManager.PackageOps mPackageOps;
+ private AppOpsManager.PackageOps mRestrictedPackageOps;
+ @Mock
+ private AppOpsManager.PackageOps mAllowedPackageOps;
@Mock
private SettingsActivity mSettingsActivity;
@Mock
@@ -65,11 +73,26 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
+ final AppOpsManager.OpEntry allowOpEntry = new AppOpsManager.OpEntry(
+ AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, AppOpsManager.MODE_ALLOWED, 0, 0, 0, 0, "");
+ final List<AppOpsManager.OpEntry> allowOps = new ArrayList<>();
+ allowOps.add(allowOpEntry);
+ final AppOpsManager.OpEntry restrictedOpEntry = new AppOpsManager.OpEntry(
+ AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, AppOpsManager.MODE_IGNORED, 0, 0, 0, 0, "");
+ final List<AppOpsManager.OpEntry> restrictedOps = new ArrayList<>();
+ restrictedOps.add(restrictedOpEntry);
+ doReturn(ALLOWED_UID).when(mAllowedPackageOps).getUid();
+ doReturn(ALLOWED_PACKAGE_NAME).when(mAllowedPackageOps).getPackageName();
+ doReturn(allowOps).when(mAllowedPackageOps).getOps();
+ doReturn(RESTRICTED_UID).when(mRestrictedPackageOps).getUid();
+ doReturn(RESTRICTED_PACKAGE_NAME).when(mRestrictedPackageOps).getPackageName();
+ doReturn(restrictedOps).when(mRestrictedPackageOps).getOps();
+
mContext = spy(RuntimeEnvironment.application);
doReturn(mAppOpsManager).when(mContext).getSystemService(Context.APP_OPS_SERVICE);
doReturn(mContext).when(mSettingsActivity).getApplicationContext();
mRestrictAppPreferenceController =
- new RestrictAppPreferenceController(mSettingsActivity, mFragment);
+ new RestrictAppPreferenceController(mSettingsActivity, mFragment);
mPackageOpsList = new ArrayList<>();
mPreference = new Preference(mContext);
mPreference.setKey(mRestrictAppPreferenceController.getPreferenceKey());
@@ -77,7 +100,7 @@
@Test
public void testUpdateState_oneApp_showCorrectSummary() {
- mPackageOpsList.add(mPackageOps);
+ mPackageOpsList.add(mRestrictedPackageOps);
doReturn(mPackageOpsList).when(mAppOpsManager).getPackagesForOps(any());
mRestrictAppPreferenceController.updateState(mPreference);
@@ -86,9 +109,10 @@
}
@Test
- public void testUpdateState_twoApps_showCorrectSummary() {
- mPackageOpsList.add(mPackageOps);
- mPackageOpsList.add(mPackageOps);
+ public void testUpdateState_twoRestrictApps_showCorrectSummary() {
+ mPackageOpsList.add(mRestrictedPackageOps);
+ mPackageOpsList.add(mRestrictedPackageOps);
+ mPackageOpsList.add(mAllowedPackageOps);
doReturn(mPackageOpsList).when(mAppOpsManager).getPackagesForOps(any());
mRestrictAppPreferenceController.updateState(mPreference);
@@ -97,7 +121,8 @@
}
@Test
- public void testUpdateState_zeroApp_disabled() {
+ public void testUpdateState_zeroRestrictApp_disabled() {
+ mPackageOpsList.add(mAllowedPackageOps);
doReturn(mPackageOpsList).when(mAppOpsManager).getPackagesForOps(any());
mRestrictAppPreferenceController.updateState(mPreference);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobServiceTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobServiceTest.java
index aa3d5a8..499ab9d 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobServiceTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobServiceTest.java
@@ -18,11 +18,13 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.robolectric.RuntimeEnvironment.application;
@@ -32,6 +34,7 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.os.Process;
import android.os.StatsDimensionsValue;
import android.os.UserManager;
@@ -84,7 +87,7 @@
mBundle = new Bundle();
mBundle.putParcelable(StatsManager.EXTRA_STATS_DIMENSIONS_VALUE, mStatsDimensionsValue);
- mAnomalyDetectionJobService = new AnomalyDetectionJobService();
+ mAnomalyDetectionJobService = spy(new AnomalyDetectionJobService());
}
@Test
@@ -92,13 +95,14 @@
AnomalyDetectionJobService.scheduleAnomalyDetection(application, new Intent());
ShadowJobScheduler shadowJobScheduler =
- Shadows.shadowOf(application.getSystemService(JobScheduler.class));
+ Shadows.shadowOf(application.getSystemService(JobScheduler.class));
List<JobInfo> pendingJobs = shadowJobScheduler.getAllPendingJobs();
assertThat(pendingJobs).hasSize(1);
+
JobInfo pendingJob = pendingJobs.get(0);
assertThat(pendingJob.getId()).isEqualTo(R.id.job_anomaly_detection);
assertThat(pendingJob.getMaxExecutionDelayMillis())
- .isEqualTo(TimeUnit.MINUTES.toMillis(30));
+ .isEqualTo(TimeUnit.MINUTES.toMillis(30));
}
@Test
@@ -115,9 +119,24 @@
}
@Test
+ public void testSaveAnomalyToDatabase_systemUid_doNotSave() {
+ doReturn(Process.SYSTEM_UID).when(
+ mAnomalyDetectionJobService).extractUidFromStatsDimensionsValue(any());
+
+ mAnomalyDetectionJobService.saveAnomalyToDatabase(mBatteryStatsHelper, mUserManager,
+ mBatteryDatabaseManager, mBatteryUtils, mPolicy, mPowerWhitelistBackend,
+ mContext.getContentResolver(), mBundle);
+
+ verify(mBatteryDatabaseManager, never()).insertAnomaly(anyInt(), anyString(), anyInt(),
+ anyInt(), anyLong());
+ }
+
+ @Test
public void testSaveAnomalyToDatabase_normalApp_save() {
doReturn(SYSTEM_PACKAGE).when(mBatteryUtils).getPackageName(anyInt());
doReturn(false).when(mPowerWhitelistBackend).isSysWhitelisted(SYSTEM_PACKAGE);
+ doReturn(Process.FIRST_APPLICATION_UID).when(
+ mAnomalyDetectionJobService).extractUidFromStatsDimensionsValue(any());
mAnomalyDetectionJobService.saveAnomalyToDatabase(mBatteryStatsHelper, mUserManager,
mBatteryDatabaseManager, mBatteryUtils, mPolicy, mPowerWhitelistBackend,
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 9f1bb31..85e5b1e 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
@@ -18,6 +18,7 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.robolectric.Shadows.shadowOf;
@@ -26,10 +27,13 @@
import android.text.format.DateUtils;
import com.android.settings.R;
+import com.android.settings.fuelgauge.Estimate;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.HighUsageTip;
import com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip;
+import com.android.settings.fuelgauge.batterytip.tips.SummaryTip;
import com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip;
+import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.ShadowUtils;
@@ -54,37 +58,44 @@
private static final String PACKAGE_NAME = "com.android.app";
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 BatteryTipDialogFragment mDialogFragment;
private Context mContext;
private HighUsageTip mHighUsageTip;
private RestrictAppTip mRestrictedOneAppTip;
- private RestrictAppTip mRestrictAppsTip;
+ private RestrictAppTip mRestrictTwoAppsTip;
private UnrestrictAppTip mUnrestrictAppTip;
+ private SummaryTip mSummaryTip;
+ private AppInfo mAppInfo;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
+ FakeFeatureFactory.setupForTest();
+ ShadowUtils.setApplicationLabel(PACKAGE_NAME, DISPLAY_NAME);
List<AppInfo> highUsageTips = new ArrayList<>();
- final AppInfo appInfo = new AppInfo.Builder()
+ mAppInfo = new AppInfo.Builder()
.setScreenOnTimeMs(SCREEN_TIME_MS)
.setPackageName(PACKAGE_NAME)
.build();
- highUsageTips.add(appInfo);
+ highUsageTips.add(mAppInfo);
mHighUsageTip = new HighUsageTip(SCREEN_TIME_MS, highUsageTips);
final List<AppInfo> restrictApps = new ArrayList<>();
- restrictApps.add(appInfo);
+ restrictApps.add(mAppInfo);
mRestrictedOneAppTip = new RestrictAppTip(BatteryTip.StateType.NEW,
new ArrayList<>(restrictApps));
- restrictApps.add(appInfo);
- mRestrictAppsTip = new RestrictAppTip(BatteryTip.StateType.NEW,
+ restrictApps.add(mAppInfo);
+ mRestrictTwoAppsTip = new RestrictAppTip(BatteryTip.StateType.NEW,
new ArrayList<>(restrictApps));
- mUnrestrictAppTip = new UnrestrictAppTip(BatteryTip.StateType.NEW, appInfo);
+ mUnrestrictAppTip = new UnrestrictAppTip(BatteryTip.StateType.NEW, mAppInfo);
+ mSummaryTip = spy(new SummaryTip(BatteryTip.StateType.NEW,
+ Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN));
}
@Test
@@ -115,14 +126,15 @@
assertThat(shadowDialog.getTitle()).isEqualTo("Restrict app?");
assertThat(shadowDialog.getMessage())
- .isEqualTo(mContext.getString(R.string.battery_tip_restrict_app_dialog_message));
+ .isEqualTo("To save battery, stop app from using "
+ + "battery in the background.");
}
@Test
- public void testOnCreateDialog_restrictAppsTip_fireRestrictAppsDialog() {
+ public void testOnCreateDialog_restrictTwoAppsTip_fireRestrictTwoAppsDialog() {
Robolectric.getForegroundThreadScheduler().pause();
- mDialogFragment = BatteryTipDialogFragment.newInstance(mRestrictAppsTip);
+ mDialogFragment = BatteryTipDialogFragment.newInstance(mRestrictTwoAppsTip);
FragmentTestUtil.startFragment(mDialogFragment);
@@ -133,14 +145,40 @@
assertThat(shadowDialog.getTitle()).isEqualTo("Restrict 2 apps?");
assertThat(shadowDialog.getMessage())
- .isEqualTo(mContext.getString(R.string.battery_tip_restrict_app_dialog_message));
+ .isEqualTo("To save battery, stop these apps from using battery in the background"
+ + ".\n\nApps:\n");
assertThat(shadowDialog.getView()).isNotNull();
}
@Test
+ public void testOnCreateDialog_restrictSixAppsTip_fireRestrictSixAppsDialog() {
+ Robolectric.getForegroundThreadScheduler().pause();
+
+ final List<AppInfo> appInfos = new ArrayList<>();
+ for (int i = 0; i < 6; i++) {
+ appInfos.add(mAppInfo);
+ }
+ final RestrictAppTip restrictSixAppsTip = new RestrictAppTip(BatteryTip.StateType.NEW,
+ appInfos);
+
+ mDialogFragment = BatteryTipDialogFragment.newInstance(restrictSixAppsTip);
+
+ FragmentTestUtil.startFragment(mDialogFragment);
+
+ Robolectric.getForegroundThreadScheduler().advanceToLastPostedRunnable();
+
+ final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
+ ShadowAlertDialog shadowDialog = shadowOf(dialog);
+
+ assertThat(shadowDialog.getTitle()).isEqualTo("Restrict 6 apps?");
+ assertThat(shadowDialog.getMessage())
+ .isEqualTo("To save battery, stop these apps from using battery in the background"
+ + ".\n\nApps:\napp, app, app, app, app, and app.");
+ }
+
+ @Test
public void testOnCreateDialog_unRestrictAppTip_fireUnRestrictDialog() {
mDialogFragment = BatteryTipDialogFragment.newInstance(mUnrestrictAppTip);
- ShadowUtils.setApplicationLabel(PACKAGE_NAME, DISPLAY_NAME);
FragmentTestUtil.startFragment(mDialogFragment);
@@ -151,4 +189,32 @@
assertThat(shadowDialog.getMessage())
.isEqualTo(mContext.getString(R.string.battery_tip_unrestrict_app_dialog_message));
}
+
+ @Test
+ public void testOnCreateDialog_summaryTipWithEstimation_fireDialogWithEstimation() {
+ doReturn(AVERAGE_TIME_MS).when(mSummaryTip).getAverageTimeMs();
+ mDialogFragment = BatteryTipDialogFragment.newInstance(mSummaryTip);
+
+ FragmentTestUtil.startFragment(mDialogFragment);
+
+ final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
+ ShadowAlertDialog shadowDialog = shadowOf(dialog);
+
+ assertThat(shadowDialog.getMessage()).isEqualTo(
+ "Based on your usage, your battery usually lasts about 1h when fully charged"
+ + ".\n\nIf you need to extend your battery life, turn on Battery Saver.");
+ }
+
+ @Test
+ public void testOnCreateDialog_summaryTipWithoutEstimation_fireDialogWithoutEstimation() {
+ mDialogFragment = BatteryTipDialogFragment.newInstance(mSummaryTip);
+
+ FragmentTestUtil.startFragment(mDialogFragment);
+
+ final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
+ ShadowAlertDialog shadowDialog = shadowOf(dialog);
+
+ assertThat(shadowDialog.getMessage()).isEqualTo(
+ "If you need to extend your battery life, turn on Battery Saver");
+ }
}
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 6f898b2..0ac94c0 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceControllerTest.java
@@ -15,8 +15,11 @@
*/
package com.android.settings.fuelgauge.batterytip;
-import static com.android.settings.fuelgauge.batterytip.tips.BatteryTip.TipType.SMART_BATTERY_MANAGER;
+import static com.android.settings.fuelgauge.batterytip.tips.BatteryTip.TipType
+ .SMART_BATTERY_MANAGER;
+
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
@@ -30,6 +33,7 @@
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceManager;
import android.support.v7.preference.PreferenceScreen;
+import android.text.format.DateUtils;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.SettingsActivity;
@@ -54,6 +58,8 @@
private static final String KEY_PREF = "battery_tip";
private static final String KEY_TIP = "key_battery_tip";
+ private static final long AVERAGE_TIME_MS = DateUtils.HOUR_IN_MILLIS;
+
@Mock
private BatteryTipPreferenceController.BatteryTipListener mBatteryTipListener;
@Mock
@@ -87,9 +93,9 @@
mFeatureFactory = FakeFeatureFactory.setupForTest();
mOldBatteryTips = new ArrayList<>();
- mOldBatteryTips.add(new SummaryTip(BatteryTip.StateType.NEW));
+ mOldBatteryTips.add(new SummaryTip(BatteryTip.StateType.NEW, AVERAGE_TIME_MS));
mNewBatteryTips = new ArrayList<>();
- mNewBatteryTips.add(new SummaryTip(BatteryTip.StateType.INVISIBLE));
+ mNewBatteryTips.add(new SummaryTip(BatteryTip.StateType.INVISIBLE, AVERAGE_TIME_MS));
mBatteryTipPreferenceController = new BatteryTipPreferenceController(mContext, KEY_PREF,
mSettingsActivity, null, mBatteryTipListener);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/SummaryDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/SummaryDetectorTest.java
index 5ca1ad2..df38d34 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/SummaryDetectorTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/SummaryDetectorTest.java
@@ -19,6 +19,8 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.spy;
+import android.text.format.DateUtils;
+
import com.android.settings.fuelgauge.batterytip.BatteryTipPolicy;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -33,6 +35,7 @@
public class SummaryDetectorTest {
private BatteryTipPolicy mPolicy;
+ private static final long AVERAGE_TIME_MS = DateUtils.HOUR_IN_MILLIS;
@Before
public void setUp() {
@@ -44,14 +47,14 @@
@Test
public void testDetect_disabledByPolicy_tipInvisible() {
ReflectionHelpers.setField(mPolicy, "summaryEnabled", false);
- SummaryDetector detector = new SummaryDetector(mPolicy);
+ SummaryDetector detector = new SummaryDetector(mPolicy, AVERAGE_TIME_MS);
assertThat(detector.detect().isVisible()).isFalse();
}
@Test
public void testDetect_notDisabled_tipVisible() {
- SummaryDetector detector = new SummaryDetector(mPolicy);
+ SummaryDetector detector = new SummaryDetector(mPolicy, AVERAGE_TIME_MS);
assertThat(detector.detect().isVisible()).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/SummaryTipTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/SummaryTipTest.java
new file mode 100644
index 0000000..221c37f
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/SummaryTipTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.tips;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.os.Parcel;
+import android.text.format.DateUtils;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+
+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 SummaryTipTest {
+
+ private static final long AVERAGE_TIME_MS = DateUtils.HOUR_IN_MILLIS;
+
+ @Mock
+ private MetricsFeatureProvider mMetricsFeatureProvider;
+ private Context mContext;
+ private SummaryTip mSummaryTip;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mContext = RuntimeEnvironment.application;
+ mSummaryTip =
+ new SummaryTip(BatteryTip.StateType.NEW, AVERAGE_TIME_MS);
+ }
+
+ @Test
+ public void testParcelable() {
+ Parcel parcel = Parcel.obtain();
+ mSummaryTip.writeToParcel(parcel, mSummaryTip.describeContents());
+ parcel.setDataPosition(0);
+
+ final SummaryTip parcelTip = new SummaryTip(parcel);
+
+ assertThat(parcelTip.getAverageTimeMs()).isEqualTo(AVERAGE_TIME_MS);
+ }
+
+ @Test
+ public void testLog() {
+ mSummaryTip.log(mContext, mMetricsFeatureProvider);
+
+ verify(mMetricsFeatureProvider).action(mContext,
+ MetricsProto.MetricsEvent.ACTION_SUMMARY_TIP, BatteryTip.StateType.NEW);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
index 5c81efc..bd94bf5 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
@@ -47,27 +47,12 @@
}
@Test
- public void testGetBehaviorSettingSummary_customBehavior() {
- NotificationManager.Policy policy = new NotificationManager.Policy(
- NotificationManager.Policy.PRIORITY_CATEGORY_EVENTS
- | NotificationManager.Policy.PRIORITY_CATEGORY_REMINDERS
- | NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS
- | NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA,
- 0, 0);
- final String result = mBuilder.getBehaviorSettingSummary(policy,
- Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
-
- String custom = mContext.getString(R.string.zen_mode_behavior_summary_custom);
- assertEquals(custom, result);
- }
-
- @Test
- public void testGetBehaviorSettingSummary_totalSilence() {
+ public void testGetBehaviorSettingSummary_noSoundsCanBypass() {
NotificationManager.Policy policy = new NotificationManager.Policy(0, 0, 0);
final String result = mBuilder.getBehaviorSettingSummary(policy,
Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
- String totalSilence = mContext.getString(R.string.zen_mode_behavior_total_silence);
+ String totalSilence = mContext.getString(R.string.zen_mode_no_exceptions);
assertEquals(totalSilence, result);
}
@@ -80,7 +65,9 @@
final String result = mBuilder.getBehaviorSettingSummary(policy,
Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
- String alarmsAndMedia = mContext.getString(R.string.zen_mode_behavior_alarms_only);
+ String alarmsAndMedia = mContext.getString(R.string.join_two_items,
+ mContext.getString(R.string.zen_mode_alarms),
+ mContext.getString(R.string.zen_mode_media).toLowerCase());
assertEquals(alarmsAndMedia, result);
}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
index bbe104c..559a9ea 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
@@ -20,11 +20,14 @@
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyInt;
+import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.os.ServiceSpecificException;
+import android.security.KeyStore;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -56,6 +59,8 @@
private View mView;
@Mock
private AccessPoint mAccessPoint;
+ @Mock
+ private KeyStore mKeyStore;
public WifiConfigController mController;
private static final String HEX_PSK = "01234567012345670123456701234567012345670123456701234567"
@@ -210,6 +215,37 @@
assertThat(mView.findViewById(R.id.eap).getVisibility()).isEqualTo(View.GONE);
}
+ @Test
+ public void loadCertificates_keyStoreListFail_shouldNotCrash() {
+ // Set up
+ when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_EAP);
+ when(mKeyStore.list(anyString()))
+ .thenThrow(new ServiceSpecificException(-1, "permission error"));
+
+ mController = new TestWifiConfigController(mConfigUiBase, mView, mAccessPoint,
+ WifiConfigUiBase.MODE_CONNECT);
+
+ // Verify that the EAP method menu is visible.
+ assertThat(mView.findViewById(R.id.eap).getVisibility()).isEqualTo(View.VISIBLE);
+ // No Crash
+ }
+
+ @Test
+ public void ssidGetFocus_addNewNetwork_shouldReturnTrue() {
+ mController = new TestWifiConfigController(mConfigUiBase, mView, null /* accessPoint */,
+ WifiConfigUiBase.MODE_CONNECT);
+ final TextView ssid = mView.findViewById(R.id.ssid);
+ // Verify ssid text get focus when add new network (accesspoint is null)
+ assertThat(ssid.isFocused()).isTrue();
+ }
+
+ @Test
+ public void passwordGetFocus_connectSecureWifi_shouldReturnTrue() {
+ final TextView password = mView.findViewById(R.id.password);
+ // Verify password get focus when connect to secure wifi without eap type
+ assertThat(password.isFocused()).isTrue();
+ }
+
public class TestWifiConfigController extends WifiConfigController {
private TestWifiConfigController(
@@ -221,5 +257,8 @@
boolean isSplitSystemUser() {
return false;
}
+
+ @Override
+ KeyStore getKeyStore() { return mKeyStore; }
}
}
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherAutoOffPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherAutoOffPreferenceControllerTest.java
index 2b14e88..c553764 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherAutoOffPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherAutoOffPreferenceControllerTest.java
@@ -81,6 +81,13 @@
assertThat(mSwitchPreference.isChecked()).isFalse();
}
+ @Test
+ public void testUpdateState_toggleDefaultOn() {
+ mController.updateState(mSwitchPreference);
+
+ assertThat(mSwitchPreference.isChecked()).isTrue();
+ }
+
private int getAutoOffSetting() {
return Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.SOFT_AP_TIMEOUT_ENABLED, OFF);