Merge "Add Default backup page to list of allowed fragments." into pi-dev
diff --git a/res/color/white_disabled.xml b/res/color/white_disabled.xml
deleted file mode 100644
index 17008a8..0000000
--- a/res/color/white_disabled.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:color="@android:color/white"
- android:alpha="?android:attr/disabledAlpha" />
-</selector>
diff --git a/res/drawable/data_usage_progress.xml b/res/drawable/color_bar_progress.xml
similarity index 72%
rename from res/drawable/data_usage_progress.xml
rename to res/drawable/color_bar_progress.xml
index 46b9a12..d277467 100644
--- a/res/drawable/data_usage_progress.xml
+++ b/res/drawable/color_bar_progress.xml
@@ -16,19 +16,19 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape android:shape="rectangle"
- android:tint="?android:attr/colorControlActivated">
- <corners android:radius="5dp" />
+ android:tint="@*android:color/config_progress_background_tint">
+ <corners android:radius="@*android:dimen/config_progressBarCornerRadius" />
<size android:height="10dp" />
- <solid android:color="@color/white_disabled" />
+ <solid android:color="@*android:color/white_disabled_material" />
</shape>
- </item>
+ </item>r
<item android:id="@android:id/secondaryProgress">
<scale android:scaleWidth="100%">
<shape android:shape="rectangle"
android:tint="?android:attr/colorControlActivated">
- <corners android:radius="5dp" />
+ <corners android:radius="@*android:dimen/config_progressBarCornerRadius" />
<size android:height="10dp" />
- <solid android:color="@color/white_disabled" />
+ <solid android:color="@*android:color/white_disabled_material" />
</shape>
</scale>
</item>
@@ -36,9 +36,9 @@
<scale android:scaleWidth="100%">
<shape android:shape="rectangle"
android:tint="?android:attr/colorControlActivated">
- <corners android:radius="5dp" />
+ <corners android:radius="@*android:dimen/config_progressBarCornerRadius" />
<size android:height="10dp" />
- <solid android:color="@android:color/black" />
+ <solid android:color="@android:color/white" />
</shape>
</scale>
</item>
diff --git a/res/drawable/ring_progress.xml b/res/drawable/ring_progress.xml
index 02fcd5b..346ff5f 100644
--- a/res/drawable/ring_progress.xml
+++ b/res/drawable/ring_progress.xml
@@ -22,7 +22,7 @@
android:thickness="@dimen/ring_progress_bar_thickness"
android:useLevel="false"
android:tint="?android:colorControlNormal">
- <solid android:color="@color/white_disabled" />
+ <solid android:color="@*android:color/white_disabled_material" />
</shape>
</item>
<item android:id="@android:id/progress">
diff --git a/res/layout/data_usage_summary_preference.xml b/res/layout/data_usage_summary_preference.xml
index 384ed8c..719db91 100644
--- a/res/layout/data_usage_summary_preference.xml
+++ b/res/layout/data_usage_summary_preference.xml
@@ -70,8 +70,8 @@
android:id="@+id/determinateBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
- android:layout_height="10dp"
- android:progressDrawable="@drawable/data_usage_progress"/>
+ android:layout_height="wrap_content"
+ android:progressDrawable="@drawable/color_bar_progress"/>
<LinearLayout
android:id="@+id/label_bar"
diff --git a/res/layout/master_clear.xml b/res/layout/master_clear.xml
index d328478..c1e224f 100644
--- a/res/layout/master_clear.xml
+++ b/res/layout/master_clear.xml
@@ -116,6 +116,7 @@
</LinearLayout>
</LinearLayout>
<include layout="@layout/reset_esim_checkbox"
+ android:layout_marginTop="40dp"
android:id="@+id/erase_esim_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
diff --git a/res/layout/preference_widget_radiobutton.xml b/res/layout/preference_widget_radiobutton.xml
index b3ec43d..b35e644 100644
--- a/res/layout/preference_widget_radiobutton.xml
+++ b/res/layout/preference_widget_radiobutton.xml
@@ -21,5 +21,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
+ android:background="@null"
android:focusable="false"
android:clickable="false" />
diff --git a/res/layout/reset_esim_checkbox.xml b/res/layout/reset_esim_checkbox.xml
index d830bf4..fb15fe6 100644
--- a/res/layout/reset_esim_checkbox.xml
+++ b/res/layout/reset_esim_checkbox.xml
@@ -30,6 +30,7 @@
android:paddingEnd="@dimen/reset_checkbox_padding_end"
android:focusable="false"
android:clickable="false"
+ android:checked="true"
android:duplicateParentState="true" />
<LinearLayout
diff --git a/res/layout/running_processes_header.xml b/res/layout/running_processes_header.xml
index ac31543..a696b38 100644
--- a/res/layout/running_processes_header.xml
+++ b/res/layout/running_processes_header.xml
@@ -36,11 +36,12 @@
android:gravity="left|center_vertical"
android:text="@string/running_processes_header_title" />
- <view class="com.android.settings.widget.LinearColorBar"
+ <ProgressBar
android:id="@+id/color_bar"
+ style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
- android:layout_height="16sp"
- android:orientation="horizontal" />
+ android:layout_height="wrap_content"
+ android:progressDrawable="@drawable/color_bar_progress"/>
<LinearLayout
android:layout_width="match_parent"
diff --git a/res/layout/settings_summary_preference.xml b/res/layout/settings_summary_preference.xml
index 1340571..ae3b70d 100644
--- a/res/layout/settings_summary_preference.xml
+++ b/res/layout/settings_summary_preference.xml
@@ -42,11 +42,12 @@
android:paddingBottom="5dp"
android:maxLines="10" />
- <com.android.settings.widget.LinearColorBar
+ <ProgressBar
android:id="@+id/color_bar"
+ style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
- android:layout_height="28dp"
- />
+ android:layout_height="wrap_content"
+ android:progressDrawable="@drawable/color_bar_progress"/>
<LinearLayout
android:id="@+id/label_bar"
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index e326dbe..5c3dc8f 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1070,7 +1070,7 @@
</string-array>
<string-array name="wifi_metered_entries">
- <item>Use network preference</item>
+ <item>Detect automatically</item>
<item>Treat as metered</item>
<item>Treat as unmetered</item>
</string-array>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8eaf3d6..41b8b6c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -811,7 +811,7 @@
<!-- Text shown for the title of the lockdown option -->
<string name="lockdown_settings_title">Show lockdown option</string>
<!-- Text shown for the description of the lockdown option -->
- <string name="lockdown_settings_summary">Display power button option that turns off extended access and fingerprint unlocking.</string>
+ <string name="lockdown_settings_summary">Display power button option that turns off Smart Lock, fingerprint unlocking, and notifications on the lock screen</string>
<!-- Text shown for summary of owner info setting (if none set) [CHAR LIMIT=40]-->
<string name="owner_info_settings_summary">None</string>
<!-- Description of how many characters are used in owner info [CHAR LIMIT=40]-->
@@ -3224,7 +3224,7 @@
<!-- SD card & phone storage settings screen, message on screen after user selects Reset network settings [CHAR LIMIT=NONE] -->
<string name="reset_network_desc">This will reset all network settings, including:\n\n<li>Wi\u2011Fi</li>\n<li>Mobile data</li>\n<li>Bluetooth</li>"</string>
<!-- SD card & phone storage settings screen, title for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=NONE] -->
- <string name="reset_esim_title">Also reset eSIMs</string>
+ <string name="reset_esim_title">Also reset eSIM</string>
<!-- SD card & phone storage settings screen, message for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=NONE] -->
<string name="reset_esim_desc">Erase all eSIMs on the phone. You\u2019ll have to contact your carrier to redownload your eSIMs. This will not cancel your mobile service plan.</string>
<!-- SD card & phone storage settings screen, button on screen after user selects Reset network settings -->
@@ -3274,7 +3274,7 @@
<!-- SD card & phone storage settings screen, description for check box to erase USB storage [CHAR LIMIT=NONE] -->
<string name="erase_external_storage_description" product="default">Erase all the data on the SD card, such as music or photos</string>
<!-- SD card & phone storage settings screen, label for check box to erase all the carriers information on the embedded SIM card [CHAR LIMIT=30] -->
- <string name="erase_esim_storage">Erase eSIMs</string>
+ <string name="erase_esim_storage">Erase eSIM</string>
<!-- SD card & phone storage settings screen, description for check box to erase eSIMs for default devices [CHAR LIMIT=NONE] -->
<string name="erase_esim_storage_description" product="default">Erase all eSIMs on the phone. This will not cancel your mobile service plan.</string>
<!-- SD card & phone storage settings screen, description for check box to erase eSIMs for tablets [CHAR LIMIT=NONE] -->
@@ -4434,6 +4434,10 @@
<string name="accessibility_summary_state_enabled">On</string>
<!-- Preference's state when disabled. -->
<string name="accessibility_summary_state_disabled">Off</string>
+ <!-- Accessibility service's preference's state when enabled but not running (like maybe it crashed). -->
+ <string name="accessibility_summary_state_stopped">Not working. Tap for info.</string>
+ <!-- Accessibility service's description when enabled but not running (like maybe it crashed). -->
+ <string name="accessibility_description_state_stopped">This service is malfunctioning.</string>
<!-- Title for the preference to show a tile for a particular feature in the Quick Settings pane. [CHAR LIMIT=NONE] -->
<string name="enable_quick_setting">Show in Quick Settings</string>
@@ -7170,6 +7174,9 @@
<!-- Configure Notifications: Title for the option controlling notifications on the lockscreen. [CHAR LIMIT=30] -->
<string name="lock_screen_notifications_title">On lock screen</string>
+ <!-- Configure Notifications: Title for the option controlling notifications for work profile. [CHAR LIMIT=30] -->
+ <string name="locked_work_profile_notification_title">When work profile is locked</string>
+
<!-- Configure Notifications: Value for lockscreen notifications: all information will be
shown in notifications shown on a secure lock screen
[CHAR LIMIT=50] -->
@@ -7200,10 +7207,6 @@
[CHAR LIMIT=50] -->
<string name="lock_screen_notifications_summary_hide_profile">Hide sensitive work content</string>
- <!-- Configure Notifications: Value for lockscreen notifications: work notifications will not appear on a secure lock screen
- [CHAR LIMIT=50] -->
- <string name="lock_screen_notifications_summary_disable_profile">Don\u2019t show work notifications at all</string>
-
<!-- Security > Choose PIN/PW/Pattern > Notification redaction interstitial: Message asking the user how they want their profile notifications to appear when the device is locked [CHAR LIMIT=NONE] -->
<string name="lock_screen_notifications_interstitial_message_profile">When your device is locked, how do you want profile notifications to show?</string>
@@ -8594,7 +8597,7 @@
<string name="condition_airplane_title">Airplane mode is on</string>
<!-- Summary of condition that airplane mode is on [CHAR LIMIT=NONE] -->
- <string name="condition_airplane_summary">Wi-Fi, Bluetooth, and mobile network are turned off. You can\'t make phone calls or connect to the internet.</string>
+ <string name="condition_airplane_summary">When airplane mode is turned on, Wi\u2011Fi, Bluetooth, and mobile network are turned off. Wi\u2011Fi and Bluetooth can be turned back on.</string>
<!-- Title of condition that do not disturb is on [CHAR LIMIT=36] -->
<string name="condition_zen_title">Do Not Disturb is on</string>
@@ -9546,6 +9549,9 @@
<!-- Summary for media output settings when the media stream is being captured by something else. -->
<string name="media_output_summary_unavailable">Unavailable</string>
+ <!-- Title for HFP(hands free profile) output switch button in settings. -->
+ <string name="take_call_on_title">Take call on</string>
+
<!-- Title for battery Suggestion. (tablet) [CHAR LIMIT=46] -->
<string name="battery_suggestion_title" product="tablet" >Improve tablet\'s battery life</string>
<!-- Title for battery Suggestion. (device) [CHAR LIMIT=46] -->
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index 598b110..d7153ef 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -89,10 +89,9 @@
<com.android.settings.RestrictedListPreference
android:key="lock_screen_notifications_profile"
- android:title="@string/lock_screen_notifications_title"
+ android:title="@string/locked_work_profile_notification_title"
android:summary="@string/summary_placeholder"
android:order="24"/>
-
</PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml
index d616bb6..22079bf 100644
--- a/res/xml/location_settings.xml
+++ b/res/xml/location_settings.xml
@@ -31,33 +31,37 @@
android:selectable="true"
android:fragment="com.android.settings.location.RecentLocationRequestSeeAllFragment"/>
- <!-- This preference category gets removed if new_recent_location_ui is disabled -->
- <Preference
- android:key="app_level_permissions"
- android:title="@string/location_app_level_permissions"
- settings:allowDividerAbove="true">
- <intent android:action="android.intent.action.MANAGE_PERMISSION_APPS">
- <extra android:name="android.intent.extra.PERMISSION_NAME"
- android:value="android.permission-group.LOCATION" />
- </intent>
- </Preference>
-
- <Preference
- android:key="location_scanning"
- android:title="@string/location_scanning_screen_title"
- android:fragment="com.android.settings.location.ScanningSettings"/>
-
- <!-- This preference gets removed if there is no managed profile -->
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="managed_profile_location_switch"
- android:title="@string/managed_profile_location_switch_title"
- settings:useAdminDisabledSummary="true"
- android:enabled="false"
- android:selectable="true" />
-
<PreferenceCategory
- android:key="location_services"
- android:title="@string/location_category_location_services"/>
+ android:key="location_advanced_settings"
+ settings:initialExpandedChildrenCount="1">
+
+ <!-- This preference category gets removed if new_recent_location_ui is disabled -->
+ <Preference
+ android:key="app_level_permissions"
+ android:title="@string/location_app_level_permissions">
+ <intent android:action="android.intent.action.MANAGE_PERMISSION_APPS">
+ <extra android:name="android.intent.extra.PERMISSION_NAME"
+ android:value="android.permission-group.LOCATION" />
+ </intent>
+ </Preference>
+
+ <Preference
+ android:key="location_scanning"
+ android:title="@string/location_scanning_screen_title"
+ android:fragment="com.android.settings.location.ScanningSettings"/>
+
+ <!-- This preference gets removed if there is no managed profile -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="managed_profile_location_switch"
+ android:title="@string/managed_profile_location_switch_title"
+ settings:useAdminDisabledSummary="true"
+ android:enabled="false"
+ android:selectable="true" />
+
+ <PreferenceCategory
+ android:key="location_services"
+ android:title="@string/location_category_location_services"/>
+ </PreferenceCategory>
<PreferenceCategory
android:key="location_footer"
diff --git a/res/xml/security_lockscreen_settings.xml b/res/xml/security_lockscreen_settings.xml
index 3d3bfd0..5b313b3 100644
--- a/res/xml/security_lockscreen_settings.xml
+++ b/res/xml/security_lockscreen_settings.xml
@@ -46,7 +46,7 @@
<com.android.settings.RestrictedListPreference
android:key="security_setting_lock_screen_notif_work"
- android:title="@string/lock_screen_notifications_title"
+ android:title="@string/locked_work_profile_notification_title"
android:summary="@string/summary_placeholder" />
</PreferenceCategory>
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index 46e0d41..766c6ae 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -357,7 +357,9 @@
return false;
}
ContentResolver cr = context.getContentResolver();
- return Settings.Global.getInt(cr, Settings.Global.EUICC_PROVISIONED, 0) != 0;
+ return Settings.Global.getInt(cr, Settings.Global.EUICC_PROVISIONED, 0) != 0
+ || Settings.Global.getInt(
+ cr, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
}
@VisibleForTesting
diff --git a/src/com/android/settings/SummaryPreference.java b/src/com/android/settings/SummaryPreference.java
index 23965ee..dbe036a 100644
--- a/src/com/android/settings/SummaryPreference.java
+++ b/src/com/android/settings/SummaryPreference.java
@@ -20,10 +20,9 @@
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
+import android.widget.ProgressBar;
import android.widget.TextView;
-import com.android.settings.widget.LinearColorBar;
-
/**
* Provides a summary of a setting page in a preference. Such as memory or data usage.
*/
@@ -33,8 +32,6 @@
private String mAmount;
private String mUnits;
- private int mLeft, mMiddle, mRight;
- private boolean mColorsSet = false;
private boolean mChartEnabled = true;
private float mLeftRatio, mMiddleRatio, mRightRatio;
private String mStartLabel;
@@ -81,26 +78,17 @@
notifyChanged();
}
- public void setColors(int left, int middle, int right) {
- mLeft = left;
- mMiddle = middle;
- mRight = right;
- mColorsSet = true;
- notifyChanged();
- }
-
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
- final LinearColorBar colorBar = holder.itemView.findViewById(R.id.color_bar);
+ final ProgressBar colorBar = holder.itemView.findViewById(R.id.color_bar);
if (mChartEnabled) {
colorBar.setVisibility(View.VISIBLE);
- colorBar.setRatios(mLeftRatio, mMiddleRatio, mRightRatio);
- if (mColorsSet) {
- colorBar.setColors(mLeft, mMiddle, mRight);
- }
+ int progress = (int) (mLeftRatio * 100);
+ colorBar.setProgress(progress);
+ colorBar.setSecondaryProgress(progress + (int) (mMiddleRatio * 100));
} else {
colorBar.setVisibility(View.GONE);
}
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 1091aea..5460946 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -976,8 +976,8 @@
public static Drawable getBadgedIcon(IconDrawableFactory iconDrawableFactory,
PackageManager packageManager, String packageName, int userId) {
try {
- final ApplicationInfo appInfo = packageManager.getApplicationInfo(packageName,
- PackageManager.GET_META_DATA);
+ final ApplicationInfo appInfo = packageManager.getApplicationInfoAsUser(
+ packageName, PackageManager.GET_META_DATA, userId);
return iconDrawableFactory.getBadgedIcon(appInfo, userId);
} catch (PackageManager.NameNotFoundException e) {
return packageManager.getDefaultActivityIcon();
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 2292ca2..ae36e0a 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -211,7 +211,6 @@
private SwitchPreference mToggleDisableAnimationsPreference;
private SwitchPreference mToggleMasterMonoPreference;
private ListPreference mSelectLongPressTimeoutPreference;
- private Preference mNoServicesMessagePreference;
private Preference mCaptioningPreferenceScreen;
private Preference mDisplayMagnificationPreferenceScreen;
private Preference mFontSizePreferenceScreen;
@@ -495,12 +494,12 @@
List<AccessibilityServiceInfo> installedServices =
accessibilityManager.getInstalledAccessibilityServiceList();
+ List<AccessibilityServiceInfo> enabledServiceInfos = accessibilityManager
+ .getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
Set<ComponentName> enabledServices = AccessibilityUtils.getEnabledServicesFromSettings(
getActivity());
List<String> permittedServices = mDpm.getPermittedAccessibilityServices(
UserHandle.myUserId());
- final boolean accessibilityEnabled = Settings.Secure.getInt(getContentResolver(),
- Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1;
PreferenceCategory downloadedServicesCategory =
mCategoryToPrefCategoryMap.get(CATEGORY_DOWNLOADED_SERVICES);
@@ -513,7 +512,7 @@
final AccessibilityServiceInfo info = installedServices.get(i);
final ResolveInfo resolveInfo = info.getResolveInfo();
- RestrictedPreference preference =
+ final RestrictedPreference preference =
new RestrictedPreference(downloadedServicesCategory.getContext());
final String title = resolveInfo.loadLabel(getPackageManager()).toString();
@@ -524,32 +523,44 @@
icon = resolveInfo.loadIcon(getPackageManager());
}
- ServiceInfo serviceInfo = resolveInfo.serviceInfo;
- String packageName = serviceInfo.packageName;
- ComponentName componentName = new ComponentName(packageName, serviceInfo.name);
+ final ServiceInfo serviceInfo = resolveInfo.serviceInfo;
+ final String packageName = serviceInfo.packageName;
+ final ComponentName componentName = new ComponentName(packageName, serviceInfo.name);
preference.setKey(componentName.flattenToString());
preference.setTitle(title);
Utils.setSafeIcon(preference, icon);
- final boolean serviceEnabled = accessibilityEnabled
- && enabledServices.contains(componentName);
- final String serviceState = serviceEnabled ?
- getString(R.string.accessibility_summary_state_enabled) :
- getString(R.string.accessibility_summary_state_disabled);
- final CharSequence serviceSummary = info.loadSummary(getPackageManager());
- final String stateSummaryCombo = getString(
- R.string.preference_summary_default_combination,
- serviceState, serviceSummary);
- preference.setSummary((TextUtils.isEmpty(serviceSummary)) ? serviceState
- : stateSummaryCombo);
+ final boolean serviceEnabled = enabledServices.contains(componentName);
+ String description = info.loadDescription(getPackageManager());
+ if (TextUtils.isEmpty(description)) {
+ description = getString(R.string.accessibility_service_default_description);
+ }
+
+ if (serviceEnabled && AccessibilityUtils.hasServiceCrashed(
+ packageName, serviceInfo.name, enabledServiceInfos)) {
+ // Update the summaries for services that have crashed.
+ preference.setSummary(R.string.accessibility_summary_state_stopped);
+ description = getString(R.string.accessibility_description_state_stopped);
+ } else {
+ final String serviceState = serviceEnabled ?
+ getString(R.string.accessibility_summary_state_enabled) :
+ getString(R.string.accessibility_summary_state_disabled);
+ final CharSequence serviceSummary = info.loadSummary(getPackageManager());
+ final String stateSummaryCombo = getString(
+ R.string.preference_summary_default_combination,
+ serviceState, serviceSummary);
+ preference.setSummary((TextUtils.isEmpty(serviceSummary)) ? serviceState
+ : stateSummaryCombo);
+ }
// Disable all accessibility services that are not permitted.
- boolean serviceAllowed =
+ final boolean serviceAllowed =
permittedServices == null || permittedServices.contains(packageName);
if (!serviceAllowed && !serviceEnabled) {
- EnforcedAdmin admin = RestrictedLockUtils.checkIfAccessibilityServiceDisallowed(
- getActivity(), packageName, UserHandle.myUserId());
+ final EnforcedAdmin admin =
+ RestrictedLockUtils.checkIfAccessibilityServiceDisallowed(
+ getActivity(), packageName, UserHandle.myUserId());
if (admin != null) {
preference.setDisabledByAdmin(admin);
} else {
@@ -562,19 +573,14 @@
preference.setFragment(ToggleAccessibilityServicePreferenceFragment.class.getName());
preference.setPersistent(true);
- Bundle extras = preference.getExtras();
+ final Bundle extras = preference.getExtras();
extras.putString(EXTRA_PREFERENCE_KEY, preference.getKey());
extras.putBoolean(EXTRA_CHECKED, serviceEnabled);
extras.putString(EXTRA_TITLE, title);
extras.putParcelable(EXTRA_RESOLVE_INFO, resolveInfo);
-
- String description = info.loadDescription(getPackageManager());
- if (TextUtils.isEmpty(description)) {
- description = getString(R.string.accessibility_service_default_description);
- }
extras.putString(EXTRA_SUMMARY, description);
- String settingsClassName = info.getSettingsActivityName();
+ final String settingsClassName = info.getSettingsActivityName();
if (!TextUtils.isEmpty(settingsClassName)) {
extras.putString(EXTRA_SETTINGS_TITLE,
getString(R.string.accessibility_menu_item_settings));
@@ -595,7 +601,7 @@
// If the user has not installed any additional services, hide the category.
if (downloadedServicesCategory.getPreferenceCount() == 0) {
- PreferenceScreen screen = getPreferenceScreen();
+ final PreferenceScreen screen = getPreferenceScreen();
screen.removePreference(downloadedServicesCategory);
}
}
diff --git a/src/com/android/settings/applications/RunningProcessesView.java b/src/com/android/settings/applications/RunningProcessesView.java
index 650f56c..d714c5f 100644
--- a/src/com/android/settings/applications/RunningProcessesView.java
+++ b/src/com/android/settings/applications/RunningProcessesView.java
@@ -20,6 +20,8 @@
import android.app.Dialog;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.content.res.ColorStateList;
+import android.graphics.PorterDuff;
import android.os.Bundle;
import android.os.SystemClock;
import android.os.UserHandle;
@@ -36,6 +38,7 @@
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListView;
+import android.widget.ProgressBar;
import android.widget.TextView;
import com.android.internal.util.MemInfoReader;
@@ -43,7 +46,6 @@
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.widget.LinearColorBar;
import java.util.ArrayList;
import java.util.Collections;
@@ -75,7 +77,7 @@
ListView mListView;
View mHeader;
ServiceListAdapter mAdapter;
- LinearColorBar mColorBar;
+ ProgressBar mColorBar;
TextView mBackgroundProcessPrefix;
TextView mAppsProcessPrefix;
TextView mForegroundProcessPrefix;
@@ -385,9 +387,9 @@
Formatter.formatShortFileSize(getContext(), highRam));
mForegroundProcessText.setText(getResources().getString(
R.string.running_processes_header_ram, sizeStr));
- mColorBar.setRatios(highRam/(float)totalRam,
- medRam/(float)totalRam,
- lowRam/(float)totalRam);
+ int progress = (int) ((highRam/(float) totalRam) * 100);
+ mColorBar.setProgress(progress);
+ mColorBar.setSecondaryProgress(progress + (int) ((medRam/(float) totalRam) * 100));
}
}
}
@@ -446,17 +448,22 @@
mListView.setAdapter(mAdapter);
mHeader = inflater.inflate(R.layout.running_processes_header, null);
mListView.addHeaderView(mHeader, null, false /* set as not selectable */);
- mColorBar = (LinearColorBar)mHeader.findViewById(R.id.color_bar);
+ mColorBar = mHeader.findViewById(R.id.color_bar);
final Context context = getContext();
- mColorBar.setColors(context.getColor(R.color.running_processes_system_ram),
- Utils.getColorAccent(context),
- context.getColor(R.color.running_processes_free_ram));
- mBackgroundProcessPrefix = (TextView)mHeader.findViewById(R.id.freeSizePrefix);
- mAppsProcessPrefix = (TextView)mHeader.findViewById(R.id.appsSizePrefix);
- mForegroundProcessPrefix = (TextView)mHeader.findViewById(R.id.systemSizePrefix);
- mBackgroundProcessText = (TextView)mHeader.findViewById(R.id.freeSize);
- mAppsProcessText = (TextView)mHeader.findViewById(R.id.appsSize);
- mForegroundProcessText = (TextView)mHeader.findViewById(R.id.systemSize);
+ mColorBar.setProgressTintList(
+ ColorStateList.valueOf(context.getColor(R.color.running_processes_system_ram)));
+ mColorBar.setSecondaryProgressTintList(
+ ColorStateList.valueOf(Utils.getColorAccent(context)));
+ mColorBar.setSecondaryProgressTintMode(PorterDuff.Mode.SRC);
+ mColorBar.setProgressBackgroundTintList(
+ ColorStateList.valueOf(context.getColor(R.color.running_processes_free_ram)));
+ mColorBar.setProgressBackgroundTintMode(PorterDuff.Mode.SRC);
+ mBackgroundProcessPrefix = mHeader.findViewById(R.id.freeSizePrefix);
+ mAppsProcessPrefix = mHeader.findViewById(R.id.appsSizePrefix);
+ mForegroundProcessPrefix = mHeader.findViewById(R.id.systemSizePrefix);
+ mBackgroundProcessText = mHeader.findViewById(R.id.freeSize);
+ mAppsProcessText = mHeader.findViewById(R.id.appsSize);
+ mForegroundProcessText = mHeader.findViewById(R.id.systemSize);
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
mAm.getMemoryInfo(memInfo);
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
index 6376347..993ff47 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
@@ -88,29 +88,8 @@
public boolean onPreferenceClick(Preference preference) {
final CachedBluetoothDevice device =
((BluetoothDevicePreference) preference).getBluetoothDevice();
- if (device == null) {
- return false;
- }
-
- // Set the device as active per profile only if the device supports that profile
- // TODO: The active device selector location might change in the future
Log.i(TAG, "OnPreferenceClickListener: device=" + device);
- boolean result = false;
- A2dpProfile a2dpProfile = mLocalManager.getProfileManager().getA2dpProfile();
- if ((a2dpProfile != null) && device.isConnectedProfile(a2dpProfile)) {
- if (a2dpProfile.setActiveDevice(device.getDevice())) {
- Log.i(TAG, "OnPreferenceClickListener: A2DP active device=" + device);
- result = true;
- }
- }
- HeadsetProfile headsetProfile = mLocalManager.getProfileManager().getHeadsetProfile();
- if ((headsetProfile != null) && device.isConnectedProfile(headsetProfile)) {
- if (headsetProfile.setActiveDevice(device.getDevice())) {
- Log.i(TAG, "OnPreferenceClickListener: Headset active device=" + device);
- result = true;
- }
- }
- return result;
+ return device.setActive();
}
}
diff --git a/src/com/android/settings/datausage/DataUsageSummaryPreference.java b/src/com/android/settings/datausage/DataUsageSummaryPreference.java
index 43ebecc..2c61e21 100644
--- a/src/com/android/settings/datausage/DataUsageSummaryPreference.java
+++ b/src/com/android/settings/datausage/DataUsageSummaryPreference.java
@@ -129,14 +129,15 @@
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
-
+ ProgressBar bar = (ProgressBar) holder.findViewById(R.id.determinateBar);
if (mChartEnabled && (!TextUtils.isEmpty(mStartLabel) || !TextUtils.isEmpty(mEndLabel))) {
+ bar.setVisibility(View.VISIBLE);
holder.findViewById(R.id.label_bar).setVisibility(View.VISIBLE);
- ProgressBar bar = (ProgressBar) holder.findViewById(R.id.determinateBar);
bar.setProgress((int) (mProgress * 100));
((TextView) holder.findViewById(android.R.id.text1)).setText(mStartLabel);
((TextView) holder.findViewById(android.R.id.text2)).setText(mEndLabel);
} else {
+ bar.setVisibility(View.GONE);
holder.findViewById(R.id.label_bar).setVisibility(View.GONE);
}
diff --git a/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceController.java b/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceController.java
index 21bd4b7..c117b9a 100644
--- a/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceController.java
@@ -15,7 +15,6 @@
package com.android.settings.fuelgauge;
import android.app.AppOpsManager;
-import android.app.Fragment;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.os.UserManager;
@@ -24,6 +23,7 @@
import com.android.settings.R;
import com.android.settings.Utils;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.fuelgauge.batterytip.AppInfo;
import com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment;
@@ -51,17 +51,17 @@
DevicePolicyManagerWrapper mDpm;
@VisibleForTesting
BatteryUtils mBatteryUtils;
- private Fragment mFragment;
+ private InstrumentedPreferenceFragment mFragment;
private String mTargetPackage;
private PowerWhitelistBackend mPowerWhitelistBackend;
- public BackgroundActivityPreferenceController(Context context, Fragment fragment,
- int uid, String packageName) {
+ public BackgroundActivityPreferenceController(Context context,
+ InstrumentedPreferenceFragment fragment, int uid, String packageName) {
this(context, fragment, uid, packageName, PowerWhitelistBackend.getInstance());
}
@VisibleForTesting
- BackgroundActivityPreferenceController(Context context, Fragment fragment,
+ BackgroundActivityPreferenceController(Context context, InstrumentedPreferenceFragment fragment,
int uid, String packageName, PowerWhitelistBackend backend) {
super(context);
mPowerWhitelistBackend = backend;
@@ -137,7 +137,8 @@
? new UnrestrictAppTip(BatteryTip.StateType.NEW, appInfo)
: new RestrictAppTip(BatteryTip.StateType.NEW, appInfo);
- final BatteryTipDialogFragment dialogFragment = BatteryTipDialogFragment.newInstance(tip);
+ final BatteryTipDialogFragment dialogFragment = BatteryTipDialogFragment.newInstance(tip,
+ mFragment.getMetricsCategory());
dialogFragment.setTargetFragment(mFragment, 0 /* requestCode */);
dialogFragment.show(mFragment.getFragmentManager(), TAG);
}
diff --git a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
index de01533..b5b98c35 100644
--- a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
@@ -482,6 +482,7 @@
notAvailable = new Preference(mPrefContext);
notAvailable.setKey(NOT_AVAILABLE);
notAvailable.setTitle(R.string.power_usage_not_available);
+ notAvailable.setSelectable(false);
mAppListGroup.addPreference(notAvailable);
}
}
diff --git a/src/com/android/settings/fuelgauge/RestrictedAppDetails.java b/src/com/android/settings/fuelgauge/RestrictedAppDetails.java
index 631fd06..e75112c 100644
--- a/src/com/android/settings/fuelgauge/RestrictedAppDetails.java
+++ b/src/com/android/settings/fuelgauge/RestrictedAppDetails.java
@@ -131,8 +131,8 @@
final CheckBoxPreference checkBoxPreference = new AppCheckBoxPreference(context);
final AppInfo appInfo = mAppInfos.get(i);
try {
- final ApplicationInfo applicationInfo = mPackageManager.getApplicationInfo(
- appInfo.packageName, 0 /* flags */);
+ final ApplicationInfo applicationInfo = mPackageManager.getApplicationInfoAsUser(
+ appInfo.packageName, 0 /* flags */, UserHandle.getUserId(appInfo.uid));
checkBoxPreference.setChecked(true);
checkBoxPreference.setTitle(mPackageManager.getApplicationLabel(applicationInfo));
checkBoxPreference.setIcon(
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
index cb508b3..de88279 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
@@ -51,15 +51,19 @@
DialogInterface.OnClickListener {
private static final String ARG_BATTERY_TIP = "battery_tip";
+ private static final String ARG_METRICS_KEY = "metrics_key";
@VisibleForTesting
BatteryTip mBatteryTip;
+ @VisibleForTesting
+ int mMetricsKey;
- public static BatteryTipDialogFragment newInstance(BatteryTip batteryTip) {
+ public static BatteryTipDialogFragment newInstance(BatteryTip batteryTip, int metricsKey) {
BatteryTipDialogFragment dialogFragment = new BatteryTipDialogFragment();
Bundle args = new Bundle(1);
args.putParcelable(ARG_BATTERY_TIP, batteryTip);
+ args.putInt(ARG_METRICS_KEY, metricsKey);
dialogFragment.setArguments(args);
return dialogFragment;
@@ -71,6 +75,7 @@
final Context context = getContext();
mBatteryTip = bundle.getParcelable(ARG_BATTERY_TIP);
+ mMetricsKey = bundle.getInt(ARG_METRICS_KEY);
switch (mBatteryTip.getType()) {
case BatteryTip.TipType.SUMMARY:
@@ -163,7 +168,7 @@
(SettingsActivity) getActivity(),
(InstrumentedPreferenceFragment) getTargetFragment());
if (action != null) {
- action.handlePositiveAction();
+ action.handlePositiveAction(mMetricsKey);
}
lsn.onBatteryTipHandled(mBatteryTip);
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
index 9e47782..76c65e0 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
@@ -118,14 +118,14 @@
if (batteryTip != null) {
if (batteryTip.shouldShowDialog()) {
BatteryTipDialogFragment dialogFragment = BatteryTipDialogFragment.newInstance(
- batteryTip);
+ batteryTip, mFragment.getMetricsCategory());
dialogFragment.setTargetFragment(mFragment, REQUEST_ANOMALY_ACTION);
dialogFragment.show(mFragment.getFragmentManager(), TAG);
} else {
final BatteryTipAction action = BatteryTipUtils.getActionForBatteryTip(batteryTip,
mSettingsActivity, mFragment);
if (action != null) {
- action.handlePositiveAction();
+ action.handlePositiveAction(mFragment.getMetricsCategory());
}
if (mBatteryTipListener != null) {
mBatteryTipListener.onBatteryTipHandled(batteryTip);
diff --git a/src/com/android/settings/fuelgauge/batterytip/actions/BatterySaverAction.java b/src/com/android/settings/fuelgauge/batterytip/actions/BatterySaverAction.java
index 310d3f8..bb52623 100644
--- a/src/com/android/settings/fuelgauge/batterytip/actions/BatterySaverAction.java
+++ b/src/com/android/settings/fuelgauge/batterytip/actions/BatterySaverAction.java
@@ -19,6 +19,8 @@
import android.content.Context;
import android.os.PowerManager;
+import com.android.internal.logging.nano.MetricsProto;
+
public class BatterySaverAction extends BatteryTipAction {
private PowerManager mPowerManager;
@@ -31,7 +33,9 @@
* Handle the action when user clicks positive button
*/
@Override
- public void handlePositiveAction() {
+ public void handlePositiveAction(int metricsKey) {
mPowerManager.setPowerSaveMode(true);
+ mMetricsFeatureProvider.action(mContext,
+ MetricsProto.MetricsEvent.ACTION_TIP_TURN_ON_BATTERY_SAVER, metricsKey);
}
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/actions/BatteryTipAction.java b/src/com/android/settings/fuelgauge/batterytip/actions/BatteryTipAction.java
index 1bf08b7..0ae2c14 100644
--- a/src/com/android/settings/fuelgauge/batterytip/actions/BatteryTipAction.java
+++ b/src/com/android/settings/fuelgauge/batterytip/actions/BatteryTipAction.java
@@ -18,6 +18,7 @@
import android.content.Context;
+import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
/**
@@ -25,13 +26,15 @@
*/
public abstract class BatteryTipAction {
protected Context mContext;
+ protected MetricsFeatureProvider mMetricsFeatureProvider;
public BatteryTipAction(Context context) {
mContext = context;
+ mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
}
/**
* Handle the action when user clicks positive button
*/
- public abstract void handlePositiveAction();
+ public abstract void handlePositiveAction(int metricsKey);
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/actions/OpenRestrictAppFragmentAction.java b/src/com/android/settings/fuelgauge/batterytip/actions/OpenRestrictAppFragmentAction.java
index 77bf861..afb80f2 100644
--- a/src/com/android/settings/fuelgauge/batterytip/actions/OpenRestrictAppFragmentAction.java
+++ b/src/com/android/settings/fuelgauge/batterytip/actions/OpenRestrictAppFragmentAction.java
@@ -18,6 +18,7 @@
import android.app.Fragment;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.SettingsActivity;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.fuelgauge.BatteryUtils;
@@ -49,7 +50,9 @@
* Handle the action when user clicks positive button
*/
@Override
- public void handlePositiveAction() {
+ public void handlePositiveAction(int metricsKey) {
+ mMetricsFeatureProvider.action(mContext,
+ MetricsProto.MetricsEvent.ACTION_TIP_OPEN_APP_RESTRICTION_PAGE, metricsKey);
final List<AppInfo> mAppInfos = mRestrictAppTip.getRestrictAppList();
RestrictedAppDetails.startRestrictedAppDetails(mSettingsActivity, mFragment,
mAppInfos);
diff --git a/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppAction.java b/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppAction.java
index 37f4b2a..0009451 100644
--- a/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppAction.java
+++ b/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppAction.java
@@ -19,7 +19,10 @@
import android.app.AppOpsManager;
import android.content.Context;
import android.support.annotation.VisibleForTesting;
+import android.util.Pair;
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.internal.util.CollectionUtils;
import com.android.settings.fuelgauge.BatteryUtils;
import com.android.settings.fuelgauge.batterytip.AnomalyDatabaseHelper;
import com.android.settings.fuelgauge.batterytip.AppInfo;
@@ -49,14 +52,28 @@
* Handle the action when user clicks positive button
*/
@Override
- public void handlePositiveAction() {
+ public void handlePositiveAction(int metricsKey) {
final List<AppInfo> appInfos = mRestrictAppTip.getRestrictAppList();
for (int i = 0, size = appInfos.size(); i < size; i++) {
- final String packageName = appInfos.get(i).packageName;
+ final AppInfo appInfo = appInfos.get(i);
+ final String packageName = appInfo.packageName;
// Force app standby, then app can't run in the background
mBatteryUtils.setForceAppStandby(mBatteryUtils.getPackageUid(packageName), packageName,
AppOpsManager.MODE_IGNORED);
+ if (CollectionUtils.isEmpty(appInfo.anomalyTypes)) {
+ // Only log context if there is no anomaly type
+ mMetricsFeatureProvider.action(mContext,
+ MetricsProto.MetricsEvent.ACTION_TIP_RESTRICT_APP, packageName,
+ Pair.create(MetricsProto.MetricsEvent.FIELD_CONTEXT, metricsKey));
+ } else {
+ for (int type : appInfo.anomalyTypes) {
+ mMetricsFeatureProvider.action(mContext,
+ MetricsProto.MetricsEvent.ACTION_TIP_RESTRICT_APP, packageName,
+ Pair.create(MetricsProto.MetricsEvent.FIELD_CONTEXT, metricsKey),
+ Pair.create(MetricsProto.MetricsEvent.FIELD_ANOMALY_TYPE, type));
+ }
+ }
}
mBatteryDatabaseManager.updateAnomalies(appInfos, AnomalyDatabaseHelper.State.HANDLED);
diff --git a/src/com/android/settings/fuelgauge/batterytip/actions/SmartBatteryAction.java b/src/com/android/settings/fuelgauge/batterytip/actions/SmartBatteryAction.java
index 750ece9..4892591 100644
--- a/src/com/android/settings/fuelgauge/batterytip/actions/SmartBatteryAction.java
+++ b/src/com/android/settings/fuelgauge/batterytip/actions/SmartBatteryAction.java
@@ -18,6 +18,7 @@
import android.app.Fragment;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.core.SubSettingLauncher;
@@ -38,7 +39,9 @@
* Handle the action when user clicks positive button
*/
@Override
- public void handlePositiveAction() {
+ public void handlePositiveAction(int metricsKey) {
+ mMetricsFeatureProvider.action(mContext,
+ MetricsProto.MetricsEvent.ACTION_TIP_OPEN_SMART_BATTERY, metricsKey);
new SubSettingLauncher(mSettingsActivity)
.setSourceMetricsCategory(mFragment instanceof Instrumentable
? ((Instrumentable) mFragment).getMetricsCategory()
diff --git a/src/com/android/settings/fuelgauge/batterytip/actions/UnrestrictAppAction.java b/src/com/android/settings/fuelgauge/batterytip/actions/UnrestrictAppAction.java
index 16812f6..fab7b01 100644
--- a/src/com/android/settings/fuelgauge/batterytip/actions/UnrestrictAppAction.java
+++ b/src/com/android/settings/fuelgauge/batterytip/actions/UnrestrictAppAction.java
@@ -18,7 +18,10 @@
import android.app.AppOpsManager;
import android.content.Context;
+import android.support.annotation.VisibleForTesting;
+import android.util.Pair;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.fuelgauge.BatteryUtils;
import com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip;
@@ -27,7 +30,8 @@
*/
public class UnrestrictAppAction extends BatteryTipAction {
private UnrestrictAppTip mUnRestrictAppTip;
- private BatteryUtils mBatteryUtils;
+ @VisibleForTesting
+ BatteryUtils mBatteryUtils;
public UnrestrictAppAction(Context context, UnrestrictAppTip tip) {
super(context);
@@ -39,10 +43,13 @@
* Handle the action when user clicks positive button
*/
@Override
- public void handlePositiveAction() {
+ public void handlePositiveAction(int metricsKey) {
final String packageName = mUnRestrictAppTip.getPackageName();
// Clear force app standby, then app can run in the background
mBatteryUtils.setForceAppStandby(mBatteryUtils.getPackageUid(packageName), packageName,
AppOpsManager.MODE_ALLOWED);
+ mMetricsFeatureProvider.action(mContext,
+ MetricsProto.MetricsEvent.ACTION_TIP_UNRESTRICT_APP, packageName, Pair.create(
+ MetricsProto.MetricsEvent.FIELD_CONTEXT, metricsKey));
}
}
diff --git a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
index bf821db..1845fef 100644
--- a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
+++ b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
@@ -19,6 +19,7 @@
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS;
import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS;
+import android.app.admin.DevicePolicyManager;
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
@@ -59,7 +60,7 @@
private RestrictedListPreference mLockscreen;
private RestrictedListPreference mLockscreenProfile;
- private final int mProfileChallengeUserId;
+ private final int mProfileUserId;
private final boolean mSecure;
private final boolean mSecureProfile;
@@ -78,29 +79,24 @@
mWorkSettingCategoryKey = workSettingCategoryKey;
mWorkSettingKey = workSettingKey;
- mProfileChallengeUserId = Utils.getManagedProfileId(
- UserManager.get(context), UserHandle.myUserId());
+ mProfileUserId = Utils.getManagedProfileId(UserManager.get(context), UserHandle.myUserId());
final LockPatternUtils utils = FeatureFactory.getFactory(context)
.getSecurityFeatureProvider()
.getLockPatternUtils(context);
mSecure = utils.isSecure(UserHandle.myUserId());
- mSecureProfile = (mProfileChallengeUserId != UserHandle.USER_NULL)
- && (utils.isSecure(mProfileChallengeUserId)
- || (!utils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId) && mSecure));
+ mSecureProfile = (mProfileUserId != UserHandle.USER_NULL) && utils.isSecure(mProfileUserId);
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mLockscreen =
- (RestrictedListPreference) screen.findPreference(mSettingKey);
+ mLockscreen = (RestrictedListPreference) screen.findPreference(mSettingKey);
if (mLockscreen == null) {
Log.i(TAG, "Preference not found: " + mSettingKey);
return;
}
- if (mProfileChallengeUserId != UserHandle.USER_NULL) {
- mLockscreenProfile = (RestrictedListPreference) screen.findPreference(
- mWorkSettingKey);
+ if (mProfileUserId != UserHandle.USER_NULL) {
+ mLockscreenProfile = (RestrictedListPreference) screen.findPreference(mWorkSettingKey);
} else {
setVisible(screen, mWorkSettingKey, false /* visible */);
setVisible(screen, mWorkSettingCategoryKey, false /* visible */);
@@ -178,9 +174,6 @@
KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
}
- entries.add(mContext.getString(R.string.lock_screen_notifications_summary_disable_profile));
- values.add(Integer.toString(R.string.lock_screen_notifications_summary_disable_profile));
-
mLockscreenProfile.setEntries(entries.toArray(new CharSequence[entries.size()]));
mLockscreenProfile.setEntryValues(values.toArray(new CharSequence[values.size()]));
updateLockscreenNotificationsForProfile();
@@ -221,23 +214,17 @@
final String key = preference.getKey();
if (TextUtils.equals(mWorkSettingKey, key)) {
if (Utils.startQuietModeDialogIfNecessary(mContext, UserManager.get(mContext),
- mProfileChallengeUserId)) {
+ mProfileUserId)) {
return false;
}
final int val = Integer.parseInt((String) newValue);
if (val == mLockscreenSelectedValueProfile) {
return false;
}
- final boolean enabled =
- val != R.string.lock_screen_notifications_summary_disable_profile;
- final boolean show =
- val == R.string.lock_screen_notifications_summary_show_profile;
+ final boolean show = val == R.string.lock_screen_notifications_summary_show_profile;
Settings.Secure.putIntForUser(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
- show ? 1 : 0, mProfileChallengeUserId);
- Settings.Secure.putIntForUser(mContext.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
- enabled ? 1 : 0, mProfileChallengeUserId);
+ show ? 1 : 0, mProfileUserId);
mLockscreenSelectedValueProfile = val;
return true;
} else if (TextUtils.equals(mSettingKey, key)) {
@@ -245,8 +232,7 @@
if (val == mLockscreenSelectedValue) {
return false;
}
- final boolean enabled =
- val != R.string.lock_screen_notifications_summary_disable;
+ final boolean enabled = val != R.string.lock_screen_notifications_summary_disable;
final boolean show = val == R.string.lock_screen_notifications_summary_show;
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, show ? 1 : 0);
@@ -268,10 +254,10 @@
new RestrictedListPreference.RestrictedItem(entry, entryValue, admin);
mLockscreen.addRestrictedItem(item);
}
- if (mProfileChallengeUserId != UserHandle.USER_NULL) {
+ if (mProfileUserId != UserHandle.USER_NULL) {
RestrictedLockUtils.EnforcedAdmin profileAdmin =
RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
- mContext, keyguardNotificationFeatures, mProfileChallengeUserId);
+ mContext, keyguardNotificationFeatures, mProfileUserId);
if (profileAdmin != null && mLockscreenProfile != null) {
RestrictedListPreference.RestrictedItem item =
new RestrictedListPreference.RestrictedItem(
@@ -282,13 +268,13 @@
}
public static int getSummaryResource(Context context) {
- final boolean enabled = getLockscreenNotificationsEnabled(context, UserHandle.myUserId());
+ final boolean enabled = getLockscreenNotificationsEnabled(context);
final boolean secure = FeatureFactory.getFactory(context)
.getSecurityFeatureProvider()
.getLockPatternUtils(context)
.isSecure(UserHandle.myUserId());
final boolean allowPrivate = !secure
- || getLockscreenAllowPrivateNotifications(context, UserHandle.myUserId());
+ || getAllowPrivateNotifications(context, UserHandle.myUserId());
return !enabled ? R.string.lock_screen_notifications_summary_disable :
allowPrivate ? R.string.lock_screen_notifications_summary_show :
R.string.lock_screen_notifications_summary_hide;
@@ -303,30 +289,34 @@
mLockscreen.setValue(Integer.toString(mLockscreenSelectedValue));
}
+ private boolean adminAllowsUnredactedNotifications(int userId) {
+ final int dpmFlags = mContext.getSystemService(DevicePolicyManager.class)
+ .getKeyguardDisabledFeatures(null/* admin */, userId);
+ return (dpmFlags & KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS) == 0;
+ }
+
private void updateLockscreenNotificationsForProfile() {
- if (mProfileChallengeUserId == UserHandle.USER_NULL) {
+ if (mProfileUserId == UserHandle.USER_NULL) {
return;
}
if (mLockscreenProfile == null) {
return;
}
- final boolean enabled = getLockscreenNotificationsEnabled(mContext,mProfileChallengeUserId);
- final boolean allowPrivate = !mSecureProfile
- || getLockscreenAllowPrivateNotifications(mContext, mProfileChallengeUserId);
+ final boolean allowPrivate = adminAllowsUnredactedNotifications(mProfileUserId) &&
+ (!mSecureProfile || getAllowPrivateNotifications(mContext, mProfileUserId));
mLockscreenProfile.setSummary("%s");
- mLockscreenSelectedValueProfile = !enabled
- ? R.string.lock_screen_notifications_summary_disable_profile
- : (allowPrivate ? R.string.lock_screen_notifications_summary_show_profile
- : R.string.lock_screen_notifications_summary_hide_profile);
+ mLockscreenSelectedValueProfile = allowPrivate
+ ? R.string.lock_screen_notifications_summary_show_profile
+ : R.string.lock_screen_notifications_summary_hide_profile;
mLockscreenProfile.setValue(Integer.toString(mLockscreenSelectedValueProfile));
}
- private static boolean getLockscreenNotificationsEnabled(Context context, int userId) {
- return Settings.Secure.getIntForUser(context.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, userId) != 0;
+ private static boolean getLockscreenNotificationsEnabled(Context context) {
+ return Settings.Secure.getInt(context.getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
}
- private static boolean getLockscreenAllowPrivateNotifications(Context context, int userId) {
+ private static boolean getAllowPrivateNotifications(Context context, int userId) {
return Settings.Secure.getIntForUser(context.getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, userId) != 0;
}
@@ -356,7 +346,7 @@
super.onChange(selfChange, uri);
if (LOCK_SCREEN_PRIVATE_URI.equals(uri) || LOCK_SCREEN_SHOW_URI.equals(uri)) {
updateLockscreenNotifications();
- if (mProfileChallengeUserId != UserHandle.USER_NULL) {
+ if (mProfileUserId != UserHandle.USER_NULL) {
updateLockscreenNotificationsForProfile();
}
}
diff --git a/src/com/android/settings/notification/RedactionInterstitial.java b/src/com/android/settings/notification/RedactionInterstitial.java
index 93c14c7..12fc796 100644
--- a/src/com/android/settings/notification/RedactionInterstitial.java
+++ b/src/com/android/settings/notification/RedactionInterstitial.java
@@ -119,12 +119,12 @@
getContext(), getActivity().getIntent().getExtras());
if (UserManager.get(getContext()).isManagedProfile(mUserId)) {
((TextView) view.findViewById(R.id.message))
- .setText(R.string.lock_screen_notifications_interstitial_message_profile);
+ .setText(R.string.lock_screen_notifications_interstitial_message_profile);
mShowAllButton.setText(R.string.lock_screen_notifications_summary_show_profile);
mRedactSensitiveButton
- .setText(R.string.lock_screen_notifications_summary_hide_profile);
- ((RadioButton) view.findViewById(R.id.hide_all))
- .setText(R.string.lock_screen_notifications_summary_disable_profile);
+ .setText(R.string.lock_screen_notifications_summary_hide_profile);
+
+ ((RadioButton) view.findViewById(R.id.hide_all)).setVisibility(View.GONE);
}
final Button button = (Button) view.findViewById(R.id.redaction_done_button);
@@ -164,10 +164,11 @@
}
private void loadFromSettings() {
- final boolean enabled = Settings.Secure.getIntForUser(getContentResolver(),
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, mUserId) != 0;
+ final boolean managed = UserManager.get(getContext()).isManagedProfile(mUserId);
+ final boolean enabled = !managed || Settings.Secure.getIntForUser(getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, mUserId) != 0;
final boolean show = Settings.Secure.getIntForUser(getContentResolver(),
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, mUserId) != 0;
+ Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, mUserId) != 0;
int checkedButtonId = R.id.hide_all;
if (enabled) {
diff --git a/src/com/android/settings/widget/LinearColorBar.java b/src/com/android/settings/widget/LinearColorBar.java
deleted file mode 100644
index df1403e..0000000
--- a/src/com/android/settings/widget/LinearColorBar.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.widget;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Rect;
-import android.util.AttributeSet;
-import android.util.DisplayMetrics;
-import android.widget.LinearLayout;
-
-import com.android.settings.Utils;
-
-/**
- * @Deprecated Use {@link android.widget.ProgressBar} instead.
- */
-public class LinearColorBar extends LinearLayout {
-
- static final int RIGHT_COLOR = 0xffced7db;
- static final int GRAY_COLOR = 0xff555555;
- static final int WHITE_COLOR = 0xffffffff;
-
- private float mRedRatio;
- private float mYellowRatio;
- private float mGreenRatio;
-
- private int mLeftColor;
- private int mMiddleColor;
- private int mRightColor = RIGHT_COLOR;
-
- private int mColoredRegions = REGION_RED | REGION_YELLOW | REGION_GREEN;
-
- final Rect mRect = new Rect();
- final Paint mPaint = new Paint();
-
- int mLineWidth;
-
- int mLastRegion;
-
- final Paint mColorGradientPaint = new Paint();
- final Paint mEdgeGradientPaint = new Paint();
-
- public static final int REGION_RED = 1 << 0;
- public static final int REGION_YELLOW = 1 << 1;
- public static final int REGION_GREEN = 1 << 2;
-
- public LinearColorBar(Context context, AttributeSet attrs) {
- super(context, attrs);
- setWillNotDraw(false);
- mPaint.setStyle(Paint.Style.FILL);
- mColorGradientPaint.setStyle(Paint.Style.FILL);
- mColorGradientPaint.setAntiAlias(true);
- mEdgeGradientPaint.setStyle(Paint.Style.STROKE);
- mLineWidth = getResources().getDisplayMetrics().densityDpi >= DisplayMetrics.DENSITY_HIGH
- ? 2 : 1;
- mEdgeGradientPaint.setStrokeWidth(mLineWidth);
- mEdgeGradientPaint.setAntiAlias(true);
- mLeftColor = mMiddleColor = Utils.getColorAccent(context);
- }
-
- public void setRatios(float red, float yellow, float green) {
- mRedRatio = red;
- mYellowRatio = yellow;
- mGreenRatio = green;
- invalidate();
- }
-
- public void setColors(int red, int yellow, int green) {
- mLeftColor = red;
- mMiddleColor = yellow;
- mRightColor = green;
- updateIndicator();
- invalidate();
- }
-
- private void updateIndicator() {
- int off = getPaddingTop() - getPaddingBottom();
- if (off < 0) off = 0;
- mRect.top = off;
- mRect.bottom = getHeight();
- }
-
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- super.onSizeChanged(w, h, oldw, oldh);
- updateIndicator();
- }
-
- @Override
- protected void dispatchSetPressed(boolean pressed) {
- invalidate();
- }
-
- private int pickColor(int color, int region) {
- if (isPressed() && (mLastRegion & region) != 0) {
- return WHITE_COLOR;
- }
- if ((mColoredRegions & region) == 0) {
- return GRAY_COLOR;
- }
- return color;
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
-
- final int width = getWidth();
-
- if (!isLayoutRtl()) {
- drawLtr(canvas, width);
- } else {
- drawRtl(canvas, width);
- }
- }
-
- private void drawLtr(Canvas canvas, int width) {
- int start = 0;
- int end = start + (int) (width * mRedRatio);
- int end2 = end + (int) (width * mYellowRatio);
-
- if (start < end) {
- mRect.left = start;
- mRect.right = end;
- mPaint.setColor(pickColor(mLeftColor, REGION_RED));
- canvas.drawRect(mRect, mPaint);
- start = end;
- }
-
- end = end2;
-
- if (start < end) {
- mRect.left = start;
- mRect.right = end;
- mPaint.setColor(pickColor(mMiddleColor, REGION_YELLOW));
- canvas.drawRect(mRect, mPaint);
- start = end;
- }
-
- end = width;
- if (start < end) {
- mRect.left = start;
- mRect.right = end;
- mPaint.setColor(pickColor(mRightColor, REGION_GREEN));
- canvas.drawRect(mRect, mPaint);
- }
- }
-
- private void drawRtl(Canvas canvas, int width) {
- int start = width;
- int end = start - (int) (width * mRedRatio);
- int end2 = end - (int) (width * mYellowRatio);
-
- if (start > end) {
- mRect.left = end;
- mRect.right = start;
- mPaint.setColor(pickColor(mLeftColor, REGION_RED));
- canvas.drawRect(mRect, mPaint);
- start = end;
- }
-
- end = end2;
-
- if (start > end) {
- mRect.left = end;
- mRect.right = start;
- mPaint.setColor(pickColor(mMiddleColor, REGION_YELLOW));
- canvas.drawRect(mRect, mPaint);
- start = end;
- }
-
- end = 0;
- if (start > end) {
- mRect.left = end;
- mRect.right = start;
- mPaint.setColor(pickColor(mRightColor, REGION_GREEN));
- canvas.drawRect(mRect, mPaint);
- }
- }
-}
\ No newline at end of file
diff --git a/src/com/android/settings/widget/RadioButtonPreference.java b/src/com/android/settings/widget/RadioButtonPreference.java
index cf5921e..d386698 100644
--- a/src/com/android/settings/widget/RadioButtonPreference.java
+++ b/src/com/android/settings/widget/RadioButtonPreference.java
@@ -20,7 +20,9 @@
import android.support.v4.content.res.TypedArrayUtils;
import android.support.v7.preference.CheckBoxPreference;
import android.support.v7.preference.PreferenceViewHolder;
+import android.text.TextUtils;
import android.util.AttributeSet;
+import android.view.View;
import android.widget.TextView;
import com.android.settings.R;
@@ -72,6 +74,12 @@
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
+ View summaryContainer = view.findViewById(R.id.summary_container);
+ if (summaryContainer != null) {
+ summaryContainer.setVisibility(
+ TextUtils.isEmpty(getSummary()) ? View.GONE : View.VISIBLE);
+ }
+
TextView title = (TextView) view.findViewById(android.R.id.title);
if (title != null) {
title.setSingleLine(false);
diff --git a/tests/robotests/src/com/android/settings/MasterClearTest.java b/tests/robotests/src/com/android/settings/MasterClearTest.java
index dc956aa..64dab16 100644
--- a/tests/robotests/src/com/android/settings/MasterClearTest.java
+++ b/tests/robotests/src/com/android/settings/MasterClearTest.java
@@ -45,6 +45,7 @@
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.Button;
+import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.ScrollView;
@@ -142,27 +143,43 @@
@Test
public void testShowWipeEuicc_euiccDisabled() {
- prepareEuiccState(false /* isEuiccEnabled */, true /* isEuiccProvisioned */);
+ prepareEuiccState(
+ false /* isEuiccEnabled */,
+ true /* isEuiccProvisioned */,
+ false /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isFalse();
}
@Test
public void testShowWipeEuicc_euiccEnabled_unprovisioned() {
- prepareEuiccState(true /* isEuiccEnabled */, false /* isEuiccProvisioned */);
+ prepareEuiccState(
+ true /* isEuiccEnabled */,
+ false /* isEuiccProvisioned */,
+ false /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isFalse();
}
@Test
public void testShowWipeEuicc_euiccEnabled_provisioned() {
- prepareEuiccState(true /* isEuiccEnabled */, true /* isEuiccProvisioned */);
+ prepareEuiccState(
+ true /* isEuiccEnabled */,
+ true /* isEuiccProvisioned */,
+ false /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isTrue();
}
- private void prepareEuiccState(boolean isEuiccEnabled, boolean isEuiccProvisioned) {
- doReturn(mActivity).when(mMasterClear).getContext();
- doReturn(isEuiccEnabled).when(mMasterClear).isEuiccEnabled(any());
- ContentResolver cr = mActivity.getContentResolver();
- Settings.Global.putInt(cr, Settings.Global.EUICC_PROVISIONED, isEuiccProvisioned ? 1 : 0);
+ @Test
+ public void testShowWipeEuicc_developerMode_unprovisioned() {
+ prepareEuiccState(
+ true /* isEuiccEnabled */,
+ false /* isEuiccProvisioned */,
+ true /* isDeveloper */);
+ assertThat(mMasterClear.showWipeEuicc()).isTrue();
+ }
+
+ @Test
+ public void testEsimRecheckBoxDefaultChecked() {
+ assertThat(((CheckBox) mContentView.findViewById(R.id.erase_esim)).isChecked()).isTrue();
}
@Test
@@ -373,6 +390,16 @@
verify(viewTreeObserver, never()).removeOnGlobalLayoutListener(mMasterClear);
}
+ private void prepareEuiccState(
+ boolean isEuiccEnabled, boolean isEuiccProvisioned, boolean isDeveloper) {
+ doReturn(mActivity).when(mMasterClear).getContext();
+ doReturn(isEuiccEnabled).when(mMasterClear).isEuiccEnabled(any());
+ ContentResolver cr = mActivity.getContentResolver();
+ Settings.Global.putInt(cr, Settings.Global.EUICC_PROVISIONED, isEuiccProvisioned ? 1 : 0);
+ Settings.Global.putInt(
+ cr, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, isDeveloper ? 1 : 0);
+ }
+
private void initScrollView(int height, int scrollY, int childBottom) {
when(mScrollView.getHeight()).thenReturn(height);
when(mScrollView.getScrollY()).thenReturn(scrollY);
diff --git a/tests/robotests/src/com/android/settings/SummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/SummaryPreferenceTest.java
index 9ca93f5..9352d4b 100644
--- a/tests/robotests/src/com/android/settings/SummaryPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/SummaryPreferenceTest.java
@@ -25,13 +25,16 @@
import android.widget.TextView;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.robolectric.annotation.Config;
import org.robolectric.RuntimeEnvironment;
@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = SettingsShadowResourcesImpl.class)
public class SummaryPreferenceTest {
private PreferenceViewHolder mHolder;
diff --git a/tests/robotests/src/com/android/settings/UtilsTest.java b/tests/robotests/src/com/android/settings/UtilsTest.java
index a2b1892..fcd40aa 100644
--- a/tests/robotests/src/com/android/settings/UtilsTest.java
+++ b/tests/robotests/src/com/android/settings/UtilsTest.java
@@ -17,6 +17,9 @@
package com.android.settings;
import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.doReturn;
@@ -188,12 +191,13 @@
@Test
public void testGetBadgedIcon_usePackageNameAndUserId()
throws PackageManager.NameNotFoundException {
- doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfo(PACKAGE_NAME,
- PackageManager.GET_META_DATA);
+ doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfoAsUser(
+ PACKAGE_NAME, PackageManager.GET_META_DATA, USER_ID);
Utils.getBadgedIcon(mIconDrawableFactory, mPackageManager, PACKAGE_NAME, USER_ID);
// Verify that it uses the correct user id
+ verify(mPackageManager).getApplicationInfoAsUser(eq(PACKAGE_NAME), anyInt(), eq(USER_ID));
verify(mIconDrawableFactory).getBadgedIcon(mApplicationInfo, USER_ID);
}
}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
index 58e42a0..bfa296b 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
@@ -228,6 +228,7 @@
bindViewHolder();
assertThat(mLabelBar.getVisibility()).isEqualTo(View.GONE);
+ assertThat(mProgressBar.getVisibility()).isEqualTo(View.GONE);
}
@Test
@@ -236,6 +237,7 @@
bindViewHolder();
assertThat(mLabelBar.getVisibility()).isEqualTo(View.GONE);
+ assertThat(mProgressBar.getVisibility()).isEqualTo(View.GONE);
}
@Test
@@ -245,6 +247,7 @@
bindViewHolder();
assertThat(mLabelBar.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(mProgressBar.getVisibility()).isEqualTo(View.VISIBLE);
}
diff --git a/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollEnrollingTest.java b/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollEnrollingTest.java
index c9ed3a5..b9a6b10 100644
--- a/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollEnrollingTest.java
+++ b/tests/robotests/src/com/android/settings/fingerprint/FingerprintEnrollEnrollingTest.java
@@ -36,6 +36,7 @@
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import com.android.settings.testutils.shadow.ShadowUtils;
import com.android.settings.testutils.shadow.ShadowVibrator;
import com.android.settings.wrapper.FingerprintManagerWrapper;
@@ -54,7 +55,10 @@
import java.util.concurrent.TimeUnit;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = {ShadowUtils.class, ShadowVibrator.class})
+@Config(shadows = {
+ SettingsShadowResourcesImpl.class,
+ ShadowUtils.class,
+ ShadowVibrator.class})
public class FingerprintEnrollEnrollingTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/RestrictedAppDetailsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/RestrictedAppDetailsTest.java
index 261acad..94a6903 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/RestrictedAppDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/RestrictedAppDetailsTest.java
@@ -21,13 +21,13 @@
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
+import android.os.UserHandle;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceManager;
@@ -54,7 +54,8 @@
public class RestrictedAppDetailsTest {
private static final String PACKAGE_NAME = "com.android.app";
- private static final int UID = 234;
+ private static final int USER_ID = 10;
+ private static final int UID = UserHandle.getUid(USER_ID, 234);
private static final String APP_NAME = "app";
@Mock
@@ -99,7 +100,8 @@
@Test
public void testRefreshUi_displayPreference() throws Exception {
- doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfo(PACKAGE_NAME, 0);
+ doReturn(mApplicationInfo).when(mPackageManager)
+ .getApplicationInfoAsUser(PACKAGE_NAME, 0, USER_ID);
doReturn(APP_NAME).when(mPackageManager).getApplicationLabel(mApplicationInfo);
mRestrictedAppDetails.refreshUi();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
index f09e569..d32e026 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
@@ -59,6 +59,7 @@
private static final String DISPLAY_NAME = "app";
private static final long SCREEN_TIME_MS = DateUtils.HOUR_IN_MILLIS;
private static final long AVERAGE_TIME_MS = DateUtils.HOUR_IN_MILLIS;
+ private static final int METRICS_KEY = 1;
private BatteryTipDialogFragment mDialogFragment;
private Context mContext;
@@ -102,7 +103,7 @@
public void testOnCreateDialog_highUsageTip_fireHighUsageDialog() {
Robolectric.getForegroundThreadScheduler().pause();
- mDialogFragment = BatteryTipDialogFragment.newInstance(mHighUsageTip);
+ mDialogFragment = BatteryTipDialogFragment.newInstance(mHighUsageTip, METRICS_KEY);
FragmentTestUtil.startFragment(mDialogFragment);
@@ -117,7 +118,7 @@
@Test
public void testOnCreateDialog_restrictOneAppTip_fireRestrictOneAppDialog() {
- mDialogFragment = BatteryTipDialogFragment.newInstance(mRestrictedOneAppTip);
+ mDialogFragment = BatteryTipDialogFragment.newInstance(mRestrictedOneAppTip, METRICS_KEY);
FragmentTestUtil.startFragment(mDialogFragment);
@@ -134,7 +135,8 @@
public void testOnCreateDialog_restrictTwoAppsTip_fireRestrictTwoAppsDialog() {
Robolectric.getForegroundThreadScheduler().pause();
- mDialogFragment = BatteryTipDialogFragment.newInstance(mRestrictTwoAppsTip);
+ mDialogFragment = BatteryTipDialogFragment.newInstance(mRestrictTwoAppsTip, METRICS_KEY);
+
FragmentTestUtil.startFragment(mDialogFragment);
@@ -161,7 +163,7 @@
final RestrictAppTip restrictSixAppsTip = new RestrictAppTip(BatteryTip.StateType.NEW,
appInfos);
- mDialogFragment = BatteryTipDialogFragment.newInstance(restrictSixAppsTip);
+ mDialogFragment = BatteryTipDialogFragment.newInstance(restrictSixAppsTip, METRICS_KEY);
FragmentTestUtil.startFragment(mDialogFragment);
@@ -178,7 +180,8 @@
@Test
public void testOnCreateDialog_unRestrictAppTip_fireUnRestrictDialog() {
- mDialogFragment = BatteryTipDialogFragment.newInstance(mUnrestrictAppTip);
+ mDialogFragment = BatteryTipDialogFragment.newInstance(mUnrestrictAppTip, METRICS_KEY);
+ ShadowUtils.setApplicationLabel(PACKAGE_NAME, DISPLAY_NAME);
FragmentTestUtil.startFragment(mDialogFragment);
@@ -193,7 +196,7 @@
@Test
public void testOnCreateDialog_summaryTipWithEstimation_fireDialogWithEstimation() {
doReturn(AVERAGE_TIME_MS).when(mSummaryTip).getAverageTimeMs();
- mDialogFragment = BatteryTipDialogFragment.newInstance(mSummaryTip);
+ mDialogFragment = BatteryTipDialogFragment.newInstance(mSummaryTip, METRICS_KEY);
FragmentTestUtil.startFragment(mDialogFragment);
@@ -207,7 +210,7 @@
@Test
public void testOnCreateDialog_summaryTipWithoutEstimation_fireDialogWithoutEstimation() {
- mDialogFragment = BatteryTipDialogFragment.newInstance(mSummaryTip);
+ mDialogFragment = BatteryTipDialogFragment.newInstance(mSummaryTip, METRICS_KEY);
FragmentTestUtil.startFragment(mDialogFragment);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceControllerTest.java
index 612f569..1e754c8 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceControllerTest.java
@@ -37,6 +37,7 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.SettingsActivity;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.SummaryTip;
import com.android.settings.testutils.FakeFeatureFactory;
@@ -70,6 +71,8 @@
private SettingsActivity mSettingsActivity;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private PreferenceManager mPreferenceManager;
+ @Mock
+ private InstrumentedPreferenceFragment mFragment;
private Context mContext;
private PreferenceGroup mPreferenceGroup;
@@ -98,7 +101,7 @@
mNewBatteryTips.add(new SummaryTip(BatteryTip.StateType.INVISIBLE, AVERAGE_TIME_MS));
mBatteryTipPreferenceController = new BatteryTipPreferenceController(mContext, KEY_PREF,
- mSettingsActivity, null, mBatteryTipListener);
+ mSettingsActivity, mFragment, mBatteryTipListener);
mBatteryTipPreferenceController.mPreferenceGroup = mPreferenceGroup;
mBatteryTipPreferenceController.mPrefContext = mContext;
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppActionTest.java
index 8934dfa..0e06765 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppActionTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppActionTest.java
@@ -20,12 +20,16 @@
import static org.mockito.Mockito.verify;
import android.app.AppOpsManager;
+import android.content.Context;
+import android.util.Pair;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.fuelgauge.BatteryUtils;
import com.android.settings.fuelgauge.batterytip.AppInfo;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip;
import com.android.settings.testutils.DatabaseTestUtils;
+import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.After;
@@ -44,21 +48,32 @@
private static final String PACKAGE_NAME_1 = "com.android.app1";
private static final String PACKAGE_NAME_2 = "com.android.app2";
+ private static final int ANOMALY_WAKEUP = 0;
+ private static final int ANOMALY_BT = 1;
+ private static final int METRICS_KEY = 1;
@Mock
private BatteryUtils mBatteryUtils;
private RestrictAppAction mRestrictAppAction;
+ private FakeFeatureFactory mFeatureFactory;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
final List<AppInfo> mAppInfos = new ArrayList<>();
- mAppInfos.add(new AppInfo.Builder().setPackageName(PACKAGE_NAME_1).build());
- mAppInfos.add(new AppInfo.Builder().setPackageName(PACKAGE_NAME_2).build());
+ mAppInfos.add(new AppInfo.Builder()
+ .setPackageName(PACKAGE_NAME_1)
+ .build());
+ mAppInfos.add(new AppInfo.Builder()
+ .setPackageName(PACKAGE_NAME_2)
+ .addAnomalyType(ANOMALY_BT)
+ .addAnomalyType(ANOMALY_WAKEUP)
+ .build());
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mRestrictAppAction = new RestrictAppAction(RuntimeEnvironment.application,
- new RestrictAppTip(BatteryTip.StateType.NEW, mAppInfos));
+ new RestrictAppTip(BatteryTip.StateType.NEW, mAppInfos));
mRestrictAppAction.mBatteryUtils = mBatteryUtils;
}
@@ -69,11 +84,22 @@
@Test
public void testHandlePositiveAction() {
- mRestrictAppAction.handlePositiveAction();
+ mRestrictAppAction.handlePositiveAction(METRICS_KEY);
verify(mBatteryUtils)
- .setForceAppStandby(anyInt(), eq(PACKAGE_NAME_1), eq(AppOpsManager.MODE_IGNORED));
+ .setForceAppStandby(anyInt(), eq(PACKAGE_NAME_1), eq(AppOpsManager.MODE_IGNORED));
verify(mBatteryUtils)
- .setForceAppStandby(anyInt(), eq(PACKAGE_NAME_2), eq(AppOpsManager.MODE_IGNORED));
+ .setForceAppStandby(anyInt(), eq(PACKAGE_NAME_2), eq(AppOpsManager.MODE_IGNORED));
+ verify(mFeatureFactory.metricsFeatureProvider).action(RuntimeEnvironment.application,
+ MetricsProto.MetricsEvent.ACTION_TIP_RESTRICT_APP, PACKAGE_NAME_1, Pair.create(
+ MetricsProto.MetricsEvent.FIELD_CONTEXT, METRICS_KEY));
+ verify(mFeatureFactory.metricsFeatureProvider).action(RuntimeEnvironment.application,
+ MetricsProto.MetricsEvent.ACTION_TIP_RESTRICT_APP, PACKAGE_NAME_2,
+ Pair.create(MetricsProto.MetricsEvent.FIELD_CONTEXT, METRICS_KEY),
+ Pair.create(MetricsProto.MetricsEvent.FIELD_ANOMALY_TYPE, ANOMALY_WAKEUP));
+ verify(mFeatureFactory.metricsFeatureProvider).action(RuntimeEnvironment.application,
+ MetricsProto.MetricsEvent.ACTION_TIP_RESTRICT_APP, PACKAGE_NAME_2,
+ Pair.create(MetricsProto.MetricsEvent.FIELD_CONTEXT, METRICS_KEY),
+ Pair.create(MetricsProto.MetricsEvent.FIELD_ANOMALY_TYPE, ANOMALY_BT));
}
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/UnrestrictAppActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/UnrestrictAppActionTest.java
new file mode 100644
index 0000000..f176324
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/UnrestrictAppActionTest.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.fuelgauge.batterytip.actions;
+
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.verify;
+
+import android.app.AppOpsManager;
+import android.util.Pair;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.fuelgauge.BatteryUtils;
+import com.android.settings.fuelgauge.batterytip.AppInfo;
+import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
+import com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip;
+import com.android.settings.testutils.DatabaseTestUtils;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class UnrestrictAppActionTest {
+
+ private static final String PACKAGE_NAME_1 = "com.android.app1";
+ private static final int METRICS_KEY = 1;
+
+ @Mock
+ private BatteryUtils mBatteryUtils;
+ private UnrestrictAppAction mUnrestrictAppAction;
+ private FakeFeatureFactory mFeatureFactory;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ final AppInfo appInfo = new AppInfo.Builder().setPackageName(PACKAGE_NAME_1).build();
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
+
+ mUnrestrictAppAction = new UnrestrictAppAction(RuntimeEnvironment.application,
+ new UnrestrictAppTip(BatteryTip.StateType.NEW, appInfo));
+ mUnrestrictAppAction.mBatteryUtils = mBatteryUtils;
+ }
+
+ @After
+ public void cleanUp() {
+ DatabaseTestUtils.clearDb(RuntimeEnvironment.application);
+ }
+
+ @Test
+ public void testHandlePositiveAction() {
+ mUnrestrictAppAction.handlePositiveAction(METRICS_KEY);
+
+ verify(mBatteryUtils)
+ .setForceAppStandby(anyInt(), eq(PACKAGE_NAME_1), eq(AppOpsManager.MODE_ALLOWED));
+ verify(mFeatureFactory.metricsFeatureProvider).action(RuntimeEnvironment.application,
+ MetricsProto.MetricsEvent.ACTION_TIP_UNRESTRICT_APP, PACKAGE_NAME_1, Pair.create(
+ MetricsProto.MetricsEvent.FIELD_CONTEXT, METRICS_KEY));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java
index 361b7b3..3fb8e2d 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java
@@ -52,6 +52,11 @@
id = R.drawable.ic_expand_more_inverse;
} else if (id == R.drawable.selectable_card_grey) {
id = R.drawable.ic_expand_more_inverse;
+ } else if (id == R.drawable.color_bar_progress
+ || id == R.drawable.ring_progress) {
+ // color_bar_progress and ring_progress use hidden resources, so just use the regular
+ // progress_horizontal drawable
+ id = android.R.drawable.progress_horizontal;
}
return super.loadDrawable(wrapper, value, id, density, theme);
}
diff --git a/tests/robotests/src/com/android/settings/widget/LinearColorBarTest.java b/tests/robotests/src/com/android/settings/widget/LinearColorBarTest.java
deleted file mode 100644
index e2c82c2..0000000
--- a/tests/robotests/src/com/android/settings/widget/LinearColorBarTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.widget;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.graphics.Canvas;
-
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-import org.robolectric.shadows.ShadowCanvas;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class LinearColorBarTest {
-
- private static final int HEIGHT = 100;
- private static final int WIDTH = 100;
-
- private Context mContext;
- private LinearColorBar mLinearColorBar;
- private Canvas mCanvas;
-
- @Before
- public void setUp() {
- mContext = RuntimeEnvironment.application;
- mLinearColorBar = spy(new LinearColorBar(mContext, null /* attrs */));
- when(mLinearColorBar.getHeight()).thenReturn(HEIGHT);
- when(mLinearColorBar.getWidth()).thenReturn(WIDTH);
- mLinearColorBar.setRatios(0.2f, 0.4f, 0.4f);
- mLinearColorBar.setColors(1, 2, 3);
- mCanvas = new Canvas();
- }
-
- @Test
- public void draw_ltr_showStartFromLeft() {
- mLinearColorBar.onDraw(mCanvas);
-
- final ShadowCanvas shadowCanvas = Shadows.shadowOf(mCanvas);
- assertThat(shadowCanvas.getRectPaintHistoryCount()).isEqualTo(3);
-
- // 3 boxes, takes space of 20%, 40%, 40% of the the WIDTH correspondingly.
- assertThat(shadowCanvas.getDrawnRect(0).left).isWithin(0.01f).of(0);
- assertThat(shadowCanvas.getDrawnRect(1).left).isWithin(0.01f).of(20);
- assertThat(shadowCanvas.getDrawnRect(2).left).isWithin(0.01f).of(60);
- }
-
- @Test
- public void draw_rtl_showStartFromRight() {
- when(mLinearColorBar.isLayoutRtl()).thenReturn(true);
-
- mLinearColorBar.onDraw(mCanvas);
-
- final ShadowCanvas shadowCanvas = Shadows.shadowOf(mCanvas);
- assertThat(shadowCanvas.getRectPaintHistoryCount()).isEqualTo(3);
-
- // 3 boxes, takes space of 20%, 40%, 40% of the the WIDTH correspondingly.
- assertThat(shadowCanvas.getDrawnRect(0).right).isWithin(0.01f).of(100);
- assertThat(shadowCanvas.getDrawnRect(1).right).isWithin(0.01f).of(80);
- assertThat(shadowCanvas.getDrawnRect(2).right).isWithin(0.01f).of(40);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/widget/RadioButtonPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/RadioButtonPreferenceTest.java
new file mode 100644
index 0000000..e8a705c
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/widget/RadioButtonPreferenceTest.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.widget;
+
+import static junit.framework.Assert.assertEquals;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import android.app.Application;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.view.View;
+
+import com.android.settings.R;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class RadioButtonPreferenceTest {
+
+ private Application mContext;
+ private RadioButtonPreference mPreference;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mPreference = new RadioButtonPreference(mContext);
+ }
+
+ @Test
+ public void summary_containerShouldBeVisible() {
+ mPreference.setSummary("some summary");
+ View summaryContainer = new View(mContext);
+ View view = mock(View.class);
+ when(view.findViewById(R.id.summary_container)).thenReturn(summaryContainer);
+ PreferenceViewHolder preferenceViewHolder =
+ PreferenceViewHolder.createInstanceForTests(view);
+ mPreference.onBindViewHolder(preferenceViewHolder);
+ assertEquals(View.VISIBLE, summaryContainer.getVisibility());
+ }
+
+ @Test
+ public void emptySummary_containerShouldBeGone() {
+ mPreference.setSummary("");
+ View summaryContainer = new View(mContext);
+ View view = mock(View.class);
+ when(view.findViewById(R.id.summary_container)).thenReturn(summaryContainer);
+ PreferenceViewHolder preferenceViewHolder =
+ PreferenceViewHolder.createInstanceForTests(view);
+ mPreference.onBindViewHolder(preferenceViewHolder);
+ assertEquals(View.GONE, summaryContainer.getVisibility());
+ }
+
+ @Test
+ public void nullSummary_containerShouldBeGone() {
+ mPreference.setSummary(null);
+ View summaryContainer = new View(mContext);
+ View view = mock(View.class);
+ when(view.findViewById(R.id.summary_container)).thenReturn(summaryContainer);
+ PreferenceViewHolder preferenceViewHolder =
+ PreferenceViewHolder.createInstanceForTests(view);
+ mPreference.onBindViewHolder(preferenceViewHolder);
+ assertEquals(View.GONE, summaryContainer.getVisibility());
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/widget/RingProgressBarTest.java b/tests/robotests/src/com/android/settings/widget/RingProgressBarTest.java
index d14203d..8dc78a5 100644
--- a/tests/robotests/src/com/android/settings/widget/RingProgressBarTest.java
+++ b/tests/robotests/src/com/android/settings/widget/RingProgressBarTest.java
@@ -22,6 +22,7 @@
import android.view.View.MeasureSpec;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import org.junit.Before;
import org.junit.Test;
@@ -29,6 +30,7 @@
import org.robolectric.RuntimeEnvironment;
@RunWith(SettingsRobolectricTestRunner.class)
+@org.robolectric.annotation.Config(shadows = SettingsShadowResourcesImpl.class)
public class RingProgressBarTest {
private Context mContext = RuntimeEnvironment.application;
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiMeteredPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiMeteredPreferenceControllerTest.java
index d568004..b3e5cb5 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiMeteredPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiMeteredPreferenceControllerTest.java
@@ -81,6 +81,6 @@
mPreferenceController.updateState(mDropDownPreference);
- assertThat(mDropDownPreference.getEntry()).isEqualTo("Use network preference");
+ assertThat(mDropDownPreference.getEntry()).isEqualTo("Detect automatically");
}
}