Merge "update the whitelist for anomaly detection" 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..c2e1581 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,31 @@
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"
+ android:paddingTop="12dp"
+ android:paddingBottom="4dp"
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" />
- <TextView
- android:id="@android:id/summary"
+ <android.widget.ProgressBar
+ android:id="@+id/determinateBar"
+ style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceListItemSecondary"
- android:textColor="?android:attr/textColorSecondary"
- android:paddingBottom="5dp" />
-
- <com.android.settings.widget.LinearColorBar
- android:id="@+id/color_bar"
- 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 +81,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 +103,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..162674b 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>
@@ -4892,6 +4892,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 +6949,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 +7004,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 +7602,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>
@@ -8575,10 +8585,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 +8657,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,10 +8687,10 @@
<!-- 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>
<!-- Summary describing when the billing cycle for their phone carrier starts [CHAR LIMIT=NONE] -->
@@ -8704,6 +8717,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>
@@ -8786,10 +8802,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 +9486,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/DataUsageSummaryPreference.java b/src/com/android/settings/datausage/DataUsageSummaryPreference.java
index d886154..dbf87fe 100644
--- a/src/com/android/settings/datausage/DataUsageSummaryPreference.java
+++ b/src/com/android/settings/datausage/DataUsageSummaryPreference.java
@@ -18,14 +18,16 @@
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.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.StringUtil;
import java.util.Objects;
@@ -33,7 +35,11 @@
/**
* Provides a summary of data usage.
*/
-public class DataUsageSummaryPreference extends SummaryPreference {
+public class DataUsageSummaryPreference extends Preference {
+
+ private boolean mChartEnabled = true;
+ private String mStartLabel;
+ private String mEndLabel;
private int mNumPlans;
/** The ending time of the billing cycle in milliseconds since epoch. */
@@ -45,6 +51,9 @@
private String mLimitInfoText;
private Intent mLaunchIntent;
+ /** Progress to display on ProgressBar */
+ private float mProgress;
+
public DataUsageSummaryPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setLayoutResource(R.layout.data_usage_summary_preference);
@@ -57,6 +66,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,10 +81,33 @@
notifyChanged();
}
+ public void setChartEnabled(boolean enabled) {
+ if (mChartEnabled != enabled) {
+ mChartEnabled = enabled;
+ notifyChanged();
+ }
+ }
+
+ public void setLabels(String start, String end) {
+ mStartLabel = start;
+ mEndLabel = end;
+ 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);
+ }
+
TextView usageTitle = (TextView) holder.findViewById(R.id.usage_title);
usageTitle.setVisibility(mNumPlans > 1 ? View.VISIBLE : View.GONE);
diff --git a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
index 11da829..0729fff 100644
--- a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
+++ b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
@@ -194,8 +194,7 @@
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);
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
index 9e172de..b39e4ef 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(
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/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/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/DataUsageSummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
index ecd556d..57f1f8c 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
@@ -24,6 +24,8 @@
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;
@@ -54,6 +56,10 @@
private TextView mCarrierInfo;
private TextView mDataLimits;
private Button mLaunchButton;
+ private LinearLayout mLabelBar;
+ private TextView mLabel1;
+ private TextView mLabel2;
+ private ProgressBar mProgressBar;
private long mCycleEnd;
private long mUpdateTime;
@@ -159,6 +165,46 @@
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");
+ }
+
private void bindViewHolder() {
mSummaryPreference.onBindViewHolder(mHolder);
mUsageTitle = (TextView) mHolder.findViewById(R.id.usage_title);
@@ -166,5 +212,9 @@
mCarrierInfo = (TextView) mHolder.findViewById(R.id.carrier_and_update);
mDataLimits = (TextView) mHolder.findViewById(R.id.data_limits);
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/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
index 9f1bb31..6f8bb26 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,9 +27,11 @@
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.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.ShadowUtils;
@@ -54,6 +57,7 @@
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;
@@ -61,6 +65,7 @@
private RestrictAppTip mRestrictedOneAppTip;
private RestrictAppTip mRestrictAppsTip;
private UnrestrictAppTip mUnrestrictAppTip;
+ private SummaryTip mSummaryTip;
@Before
public void setUp() {
@@ -85,6 +90,8 @@
new ArrayList<>(restrictApps));
mUnrestrictAppTip = new UnrestrictAppTip(BatteryTip.StateType.NEW, appInfo);
+ mSummaryTip = spy(new SummaryTip(BatteryTip.StateType.NEW,
+ Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN));
}
@Test
@@ -151,4 +158,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);