Merge "More updates to battery optimization whitelist" into mnc-dev

This commit is contained in:
Jason Monk
2015-05-12 20:05:26 +00:00
committed by Android (Google) Code Review
5 changed files with 45 additions and 42 deletions

View File

@@ -5860,6 +5860,7 @@
<string name="keywords_all_apps">apps download applications system</string> <string name="keywords_all_apps">apps download applications system</string>
<string name="keywords_app_permissions">apps permissions security</string> <string name="keywords_app_permissions">apps permissions security</string>
<string name="keywords_default_apps">apps default</string> <string name="keywords_default_apps">apps default</string>
<string name="keywords_ignore_optimizations">ignore optimizations doze app standby</string>
<!-- Search keywords for different screen unlock modes : slide to unlock, password, pattern and PIN [CHAR LIMIT=none] --> <!-- Search keywords for different screen unlock modes : slide to unlock, password, pattern and PIN [CHAR LIMIT=none] -->
<string name="keywords_lockscreen">slide password pattern pin</string> <string name="keywords_lockscreen">slide password pattern pin</string>
@@ -6564,22 +6565,19 @@
<!-- Filter for apps allowed to use a lot of power [CHAR LIMIT=25] --> <!-- Filter for apps allowed to use a lot of power [CHAR LIMIT=25] -->
<string name="high_power_filter_on">Allowed</string> <string name="high_power_filter_on">Allowed</string>
<!-- Filter for apps not allowed to use a lot of power [CHAR LIMIT=25] -->
<string name="high_power_filter_off">Not allowed</string>
<!-- Summary of app allowed to use a lot of power [CHAR LIMIT=60] --> <!-- Summary of app allowed to use a lot of power [CHAR LIMIT=60] -->
<string name="high_power_on">Allowed to ignore optimizations</string> <string name="high_power_on">Ignoring battery optimizations</string>
<!-- Summary of app not allowed to use a lot of power [CHAR LIMIT=60] --> <!-- Summary of app not allowed to use a lot of power [CHAR LIMIT=60] -->
<string name="high_power_off">Not allowed to ignore optimizations</string> <string name="high_power_off">Off</string>
<!-- Description of high power switch [CHAR LIMIT=NONE] --> <!-- Description of high power switch [CHAR LIMIT=NONE] -->
<string name="high_power_desc">Ignore optimizations including Battery saver, allow instant content refresh etc.</string> <string name="high_power_desc">Don\'t apply battery optimizations. May drain your battery more quickly.</string>
<!-- Description of number of apps with high power turned on [CHAR LIMIT=NONE] --> <!-- Description of number of apps with high power turned on [CHAR LIMIT=NONE] -->
<plurals name="high_power_count"> <plurals name="high_power_count">
<item quantity="one">1 app is allowed to ignore battery optimizations</item> <item quantity="one">1 app allowed to ignore battery optimizations</item>
<item quantity="other"><xliff:g id="count" example="10">%d</xliff:g> apps are allowed to battery optimizations</item> <item quantity="other"><xliff:g id="count" example="10">%d</xliff:g> apps allowed to ignore battery optimizations</item>
</plurals> </plurals>
<!-- Summary of power usage for an app [CHAR LIMIT=NONE] --> <!-- Summary of power usage for an app [CHAR LIMIT=NONE] -->

View File

@@ -43,7 +43,8 @@
<PreferenceScreen <PreferenceScreen
android:key="high_power_apps" android:key="high_power_apps"
android:title="@string/high_power_apps" android:title="@string/high_power_apps"
android:fragment="com.android.settings.applications.ManageApplications"> android:fragment="com.android.settings.applications.ManageApplications"
settings:keywords="@string/keywords_ignore_optimizations">
<extra <extra
android:name="classname" android:name="classname"
android:value="com.android.settings.Settings$HighPowerApplicationsActivity" /> android:value="com.android.settings.Settings$HighPowerApplicationsActivity" />

View File

@@ -25,23 +25,28 @@
android:layout="@layout/two_buttons_panel" android:layout="@layout/two_buttons_panel"
android:selectable="false" /> android:selectable="false" />
<PreferenceCategory
android:key="controls_parent"
android:title="@string/controls_subtitle">
<Preference <Preference
android:key="high_power" android:key="high_power"
android:title="@string/high_power_apps" /> android:title="@string/high_power_apps" />
</PreferenceCategory>
<PreferenceCategory <PreferenceCategory
android:key="details_parent" android:key="details_parent"
android:layout="@layout/tall_preference_category"
android:title="@string/details_subtitle" /> android:title="@string/details_subtitle" />
<PreferenceCategory <PreferenceCategory
android:key="controls_parent" android:key="messages_parent"
android:title="@string/controls_subtitle" /> android:layout="@layout/tall_preference_category" />
<PreferenceCategory
android:key="messages_parent" />
<PreferenceCategory <PreferenceCategory
android:key="packages_parent" android:key="packages_parent"
android:layout="@layout/tall_preference_category"
android:title="@string/packages_subtitle" /> android:title="@string/packages_subtitle" />
</PreferenceScreen> </PreferenceScreen>

View File

@@ -109,22 +109,22 @@ public class ManageApplications extends InstrumentedFragment
// Filter options used for displayed list of applications // Filter options used for displayed list of applications
// The order which they appear is the order they will show when spinner is present. // The order which they appear is the order they will show when spinner is present.
public static final int FILTER_APPS_ALL = 0; public static final int FILTER_APPS_POWER_WHITELIST = 0;
public static final int FILTER_APPS_ENABLED = 1; public static final int FILTER_APPS_ALL = 1;
public static final int FILTER_APPS_DISABLED = 2; public static final int FILTER_APPS_ENABLED = 2;
public static final int FILTER_APPS_BLOCKED = 3; public static final int FILTER_APPS_DISABLED = 3;
public static final int FILTER_APPS_PRIORITY = 4; public static final int FILTER_APPS_BLOCKED = 4;
public static final int FILTER_APPS_NO_PEEKING = 5; public static final int FILTER_APPS_PRIORITY = 5;
public static final int FILTER_APPS_SENSITIVE = 6; public static final int FILTER_APPS_NO_PEEKING = 6;
public static final int FILTER_APPS_PERSONAL = 7; public static final int FILTER_APPS_SENSITIVE = 7;
public static final int FILTER_APPS_WORK = 8; public static final int FILTER_APPS_PERSONAL = 8;
public static final int FILTER_APPS_WITH_DOMAIN_URLS = 9; public static final int FILTER_APPS_WORK = 9;
public static final int FILTER_APPS_USAGE_ACCESS = 10; public static final int FILTER_APPS_WITH_DOMAIN_URLS = 10;
public static final int FILTER_APPS_POWER_WHITELIST = 11; public static final int FILTER_APPS_USAGE_ACCESS = 11;
public static final int FILTER_APPS_POWER_NO_WHITELIST = 12;
// This is the string labels for the filter modes above, the order must be kept in sync. // This is the string labels for the filter modes above, the order must be kept in sync.
public static final int[] FILTER_LABELS = new int[] { public static final int[] FILTER_LABELS = new int[] {
R.string.high_power_filter_on, // High power whitelist, on
R.string.filter_all_apps, // All apps R.string.filter_all_apps, // All apps
R.string.filter_enabled_apps, // Enabled R.string.filter_enabled_apps, // Enabled
R.string.filter_apps_disabled, // Disabled R.string.filter_apps_disabled, // Disabled
@@ -136,12 +136,11 @@ public class ManageApplications extends InstrumentedFragment
R.string.filter_work_apps, // Work R.string.filter_work_apps, // Work
R.string.filter_with_domain_urls_apps, // Domain URLs R.string.filter_with_domain_urls_apps, // Domain URLs
R.string.filter_all_apps, // Usage access screen, never displayed R.string.filter_all_apps, // Usage access screen, never displayed
R.string.high_power_filter_on, // High power whitelist, on
R.string.high_power_filter_off, // High power whitelist, off
}; };
// This is the actual mapping to filters from FILTER_ constants above, the order must // This is the actual mapping to filters from FILTER_ constants above, the order must
// be kept in sync. // be kept in sync.
public static final AppFilter[] FILTERS = new AppFilter[] { public static final AppFilter[] FILTERS = new AppFilter[] {
AppStatePowerBridge.FILTER_POWER_WHITELISTED, // High power whitelist, on
ApplicationsState.FILTER_EVERYTHING, // All apps ApplicationsState.FILTER_EVERYTHING, // All apps
ApplicationsState.FILTER_ALL_ENABLED, // Enabled ApplicationsState.FILTER_ALL_ENABLED, // Enabled
ApplicationsState.FILTER_DISABLED, // Disabled ApplicationsState.FILTER_DISABLED, // Disabled
@@ -153,8 +152,6 @@ public class ManageApplications extends InstrumentedFragment
ApplicationsState.FILTER_WORK, // Work ApplicationsState.FILTER_WORK, // Work
ApplicationsState.FILTER_WITH_DOMAIN_URLS, // Apps with Domain URLs ApplicationsState.FILTER_WITH_DOMAIN_URLS, // Apps with Domain URLs
AppStateUsageBridge.FILTER_APP_USAGE, // Apps with Domain URLs AppStateUsageBridge.FILTER_APP_USAGE, // Apps with Domain URLs
AppStatePowerBridge.FILTER_POWER_WHITELISTED, // High power whitelist, on
AppStatePowerBridge.FILTER_POWER_NOT_WHITELISTED, // High power whitelist, off
}; };
// sort order // sort order
@@ -321,7 +318,7 @@ public class ManageApplications extends InstrumentedFragment
mFilterAdapter.enableFilter(FILTER_APPS_NO_PEEKING); mFilterAdapter.enableFilter(FILTER_APPS_NO_PEEKING);
} }
if (mListType == LIST_TYPE_HIGH_POWER) { if (mListType == LIST_TYPE_HIGH_POWER) {
mFilterAdapter.enableFilter(FILTER_APPS_POWER_NO_WHITELIST); mFilterAdapter.enableFilter(FILTER_APPS_ALL);
} }
if (mListType == LIST_TYPE_STORAGE) { if (mListType == LIST_TYPE_STORAGE) {
mApplications.setOverrideFilter(new VolumeFilter(mVolumeUuid)); mApplications.setOverrideFilter(new VolumeFilter(mVolumeUuid));

View File

@@ -358,6 +358,8 @@ public class PowerUsageDetail extends PowerUsageBase implements Button.OnClickLi
if (mHighPower != null) { if (mHighPower != null) {
mHighPower.setSummary(HighPowerDetail.getSummary(getActivity(), mApp.packageName)); mHighPower.setSummary(HighPowerDetail.getSummary(getActivity(), mApp.packageName));
} }
setupHeader();
} }
private void createDetails() { private void createDetails() {
@@ -370,8 +372,6 @@ public class PowerUsageDetail extends PowerUsageBase implements Button.OnClickLi
mNoCoverage = args.getDouble(EXTRA_NO_COVERAGE, 0); mNoCoverage = args.getDouble(EXTRA_NO_COVERAGE, 0);
mShowLocationButton = args.getBoolean(EXTRA_SHOW_LOCATION_BUTTON); mShowLocationButton = args.getBoolean(EXTRA_SHOW_LOCATION_BUTTON);
setupHeader();
mTypes = args.getIntArray(EXTRA_DETAIL_TYPES); mTypes = args.getIntArray(EXTRA_DETAIL_TYPES);
mValues = args.getDoubleArray(EXTRA_DETAIL_VALUES); mValues = args.getDoubleArray(EXTRA_DETAIL_VALUES);
@@ -445,14 +445,14 @@ public class PowerUsageDetail extends PowerUsageBase implements Button.OnClickLi
private void setupHeader() { private void setupHeader() {
final Bundle args = getArguments(); final Bundle args = getArguments();
String title = args.getString(EXTRA_TITLE); String title = args.getString(EXTRA_TITLE);
String iconPackage = args.getString(EXTRA_ICON_PACKAGE); String pkg = args.getString(EXTRA_ICON_PACKAGE);
int iconId = args.getInt(EXTRA_ICON_ID, 0); int iconId = args.getInt(EXTRA_ICON_ID, 0);
Drawable appIcon = null; Drawable appIcon = null;
if (!TextUtils.isEmpty(iconPackage)) { if (!TextUtils.isEmpty(pkg)) {
try { try {
final PackageManager pm = getActivity().getPackageManager(); final PackageManager pm = getActivity().getPackageManager();
ApplicationInfo ai = pm.getPackageInfo(iconPackage, 0).applicationInfo; ApplicationInfo ai = pm.getPackageInfo(pkg, 0).applicationInfo;
if (ai != null) { if (ai != null) {
appIcon = ai.loadIcon(pm); appIcon = ai.loadIcon(pm);
} }
@@ -466,8 +466,11 @@ public class PowerUsageDetail extends PowerUsageBase implements Button.OnClickLi
appIcon = getActivity().getPackageManager().getDefaultActivityIcon(); appIcon = getActivity().getPackageManager().getDefaultActivityIcon();
} }
if (pkg == null && mPackages != null) {
pkg = mPackages[0];
}
AppHeader.createAppHeader(this, appIcon, title, AppHeader.createAppHeader(this, appIcon, title,
AppInfoWithHeader.getInfoIntent(this, iconPackage), pkg != null ? AppInfoWithHeader.getInfoIntent(this, pkg) : null,
mDrainType != DrainType.APP ? android.R.color.white : 0); mDrainType != DrainType.APP ? android.R.color.white : 0);
} }
@@ -629,7 +632,6 @@ public class PowerUsageDetail extends PowerUsageBase implements Button.OnClickLi
private void addControl(int pageSummary, int actionTitle, final int action) { private void addControl(int pageSummary, int actionTitle, final int action) {
Preference pref = new Preference(getActivity()); Preference pref = new Preference(getActivity());
pref.setTitle(actionTitle); pref.setTitle(actionTitle);
pref.setSummary(pageSummary);
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() { pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {