Make battery settings use new battery graph.
Change-Id: I633a8750f9668c6315cd42866297ac3460375c22
This commit is contained in:
50
res/layout/battery_usage_graph.xml
Normal file
50
res/layout/battery_usage_graph.xml
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/charge"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
|
android:textSize="36sp"
|
||||||
|
android:textColor="?android:attr/colorAccent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/estimation"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingBottom="8dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:textColor="?android:attr/textColorSecondary" />
|
||||||
|
|
||||||
|
<com.android.settingslib.graph.UsageView
|
||||||
|
android:id="@+id/battery_usage"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
settings:sideLabels="@array/battery_labels"
|
||||||
|
android:colorAccent="?android:attr/colorAccent"
|
||||||
|
android:gravity="end"
|
||||||
|
settings:textColor="?android:attr/textColorSecondary" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
22
res/layout/preference_widget_summary.xml
Normal file
22
res/layout/preference_widget_summary.xml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/widget_summary"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:textColor="?android:attr/textColorSecondary" />
|
@@ -7166,4 +7166,19 @@
|
|||||||
<!-- Title for suggestion adding more fingerprints [CHAR LIMIT=30] -->
|
<!-- Title for suggestion adding more fingerprints [CHAR LIMIT=30] -->
|
||||||
<string name="suggestion_additional_fingerprints">Additional Fingerprints</string>
|
<string name="suggestion_additional_fingerprints">Additional Fingerprints</string>
|
||||||
|
|
||||||
|
<!-- Summary of battery saver when on [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="battery_saver_on_summary">On / <xliff:g name="automatic_state" example="Never turn on automatically">%1$s</xliff:g></string>
|
||||||
|
|
||||||
|
<!-- Summary of battery saver when off [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="battery_saver_off_summary">Off / <xliff:g name="automatic_state" example="Never turn on automatically">%1$s</xliff:g></string>
|
||||||
|
|
||||||
|
<!-- [CHAR_LIMIT=NONE] Battery saver: Description for automatic entry option: Never -->
|
||||||
|
<string name="battery_saver_desc_turn_on_auto_never">Never turn on automatically</string>
|
||||||
|
|
||||||
|
<!-- [CHAR_LIMIT=NONE] Battery saver: Description for automatic entry option: pct% battery -->
|
||||||
|
<string name="battery_saver_desc_turn_on_auto_pct">Turn on automatically at %1$s battery</string>
|
||||||
|
|
||||||
|
<!-- [CHAR_LIMIT=NONE] Label for when app is ignoring battery optimizations -->
|
||||||
|
<string name="not_battery_optimizing">Not using battery optimization</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -19,6 +19,10 @@
|
|||||||
android:title="@string/power_usage_summary_title"
|
android:title="@string/power_usage_summary_title"
|
||||||
settings:keywords="@string/keywords_battery">
|
settings:keywords="@string/keywords_battery">
|
||||||
|
|
||||||
|
<com.android.settings.fuelgauge.BatterySaverPreference
|
||||||
|
android:title="@string/battery_saver"
|
||||||
|
android:fragment="com.android.settings.fuelgauge.BatterySaverSettings" />
|
||||||
|
|
||||||
<com.android.settings.fuelgauge.BatteryHistoryPreference
|
<com.android.settings.fuelgauge.BatteryHistoryPreference
|
||||||
android:key="battery_history" />
|
android:key="battery_history" />
|
||||||
|
|
||||||
|
@@ -42,6 +42,8 @@ public class TintablePreference extends Preference {
|
|||||||
if (mTintColor != 0) {
|
if (mTintColor != 0) {
|
||||||
((ImageView) view.findViewById(android.R.id.icon)).setImageTintList(
|
((ImageView) view.findViewById(android.R.id.icon)).setImageTintList(
|
||||||
ColorStateList.valueOf(mTintColor));
|
ColorStateList.valueOf(mTintColor));
|
||||||
|
} else {
|
||||||
|
((ImageView) view.findViewById(android.R.id.icon)).setImageTintList(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,17 +17,17 @@
|
|||||||
package com.android.settings.fuelgauge;
|
package com.android.settings.fuelgauge;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.BatteryStats;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceViewHolder;
|
import android.support.v7.preference.PreferenceViewHolder;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.ViewGroup;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.internal.os.BatteryStatsHelper;
|
import com.android.internal.os.BatteryStatsHelper;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.Utils;
|
||||||
|
import com.android.settingslib.BatteryInfo;
|
||||||
|
import com.android.settingslib.graph.UsageView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom preference for displaying power consumption as a bar and an icon on the left for the
|
* Custom preference for displaying power consumption as a bar and an icon on the left for the
|
||||||
@@ -38,73 +38,41 @@ public class BatteryHistoryPreference extends Preference {
|
|||||||
|
|
||||||
protected static final String BATTERY_HISTORY_FILE = "tmp_bat_history.bin";
|
protected static final String BATTERY_HISTORY_FILE = "tmp_bat_history.bin";
|
||||||
|
|
||||||
private BatteryStats mStats;
|
|
||||||
private Intent mBatteryBroadcast;
|
|
||||||
|
|
||||||
private BatteryHistoryChart mChart;
|
|
||||||
private BatteryStatsHelper mHelper;
|
private BatteryStatsHelper mHelper;
|
||||||
|
private BatteryInfo mBatteryInfo;
|
||||||
|
|
||||||
public BatteryHistoryPreference(Context context, AttributeSet attrs) {
|
public BatteryHistoryPreference(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
setLayoutResource(R.layout.battery_usage_graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onClick() {
|
protected void onClick() {
|
||||||
if (!isEnabled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mHelper.storeStatsHistoryInFile(BATTERY_HISTORY_FILE);
|
mHelper.storeStatsHistoryInFile(BATTERY_HISTORY_FILE);
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString(BatteryHistoryDetail.EXTRA_STATS, BATTERY_HISTORY_FILE);
|
args.putString(BatteryHistoryDetail.EXTRA_STATS, BATTERY_HISTORY_FILE);
|
||||||
args.putParcelable(BatteryHistoryDetail.EXTRA_BROADCAST,
|
args.putParcelable(BatteryHistoryDetail.EXTRA_BROADCAST, mHelper.getBatteryBroadcast());
|
||||||
mHelper.getBatteryBroadcast());
|
Utils.startWithFragment(getContext(), BatteryHistoryDetail.class.getName(), args,
|
||||||
if (getContext() instanceof SettingsActivity) {
|
null, 0, R.string.history_details_title, null);
|
||||||
SettingsActivity sa = (SettingsActivity) getContext();
|
|
||||||
sa.startPreferencePanel(BatteryHistoryDetail.class.getName(), args,
|
|
||||||
R.string.history_details_title, null, null, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStats(BatteryStatsHelper batteryStats) {
|
public void setStats(BatteryStatsHelper batteryStats) {
|
||||||
// Clear out the chart to receive new data.
|
|
||||||
mChart = null;
|
|
||||||
mHelper = batteryStats;
|
mHelper = batteryStats;
|
||||||
mStats = batteryStats.getStats();
|
final long elapsedRealtimeUs = SystemClock.elapsedRealtime() * 1000;
|
||||||
mBatteryBroadcast = batteryStats.getBatteryBroadcast();
|
mBatteryInfo = BatteryInfo.getBatteryInfo(getContext(), batteryStats.getBatteryBroadcast(),
|
||||||
if (getLayoutResource() != R.layout.battery_history_chart) {
|
batteryStats.getStats(), elapsedRealtimeUs);
|
||||||
// Now we should have some data, set the layout we want.
|
|
||||||
setLayoutResource(R.layout.battery_history_chart);
|
|
||||||
}
|
|
||||||
notifyChanged();
|
notifyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
BatteryStats getStats() {
|
|
||||||
return mStats;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||||
super.onBindViewHolder(view);
|
if (mBatteryInfo == null) {
|
||||||
|
|
||||||
if (mStats == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BatteryHistoryChart chart = (BatteryHistoryChart) view.findViewById(
|
view.setDividerAllowedAbove(true);
|
||||||
R.id.battery_history_chart);
|
((TextView) view.findViewById(R.id.charge)).setText(mBatteryInfo.batteryPercentString);
|
||||||
if (mChart == null) {
|
((TextView) view.findViewById(R.id.estimation)).setText(mBatteryInfo.remainingLabel);
|
||||||
// First time: use and initialize this chart.
|
UsageView usageView = (UsageView) view.findViewById(R.id.battery_usage);
|
||||||
chart.setStats(mStats, mBatteryBroadcast);
|
mBatteryInfo.bindHistory(usageView);
|
||||||
mChart = chart;
|
|
||||||
} else {
|
|
||||||
// All future times: forget the newly inflated chart, re-use the
|
|
||||||
// already initialized chart from last time.
|
|
||||||
ViewGroup parent = (ViewGroup) chart.getParent();
|
|
||||||
int index = parent.indexOfChild(chart);
|
|
||||||
parent.removeViewAt(index);
|
|
||||||
if (mChart.getParent() != null) {
|
|
||||||
((ViewGroup) mChart.getParent()).removeView(mChart);
|
|
||||||
}
|
|
||||||
parent.addView(mChart, index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.fuelgauge;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.ContentObserver;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.PowerManager;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.provider.Settings.Global;
|
||||||
|
import android.support.v7.preference.Preference;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.Utils;
|
||||||
|
|
||||||
|
public class BatterySaverPreference extends Preference {
|
||||||
|
|
||||||
|
private PowerManager mPowerManager;
|
||||||
|
|
||||||
|
public BatterySaverPreference(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void performClick(View view) {
|
||||||
|
Utils.startWithFragment(getContext(), getFragment(), null, null, 0, 0, getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttached() {
|
||||||
|
super.onAttached();
|
||||||
|
mPowerManager = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE);
|
||||||
|
mObserver.onChange(true);
|
||||||
|
getContext().getContentResolver().registerContentObserver(
|
||||||
|
Settings.Global.getUriFor(Global.LOW_POWER_MODE_TRIGGER_LEVEL), true, mObserver);
|
||||||
|
getContext().getContentResolver().registerContentObserver(
|
||||||
|
Settings.Global.getUriFor(Global.LOW_POWER_MODE), true, mObserver);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDetached() {
|
||||||
|
super.onDetached();
|
||||||
|
getContext().getContentResolver().unregisterContentObserver(mObserver);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSwitch() {
|
||||||
|
final Context context = getContext();
|
||||||
|
final boolean mode = mPowerManager.isPowerSaveMode();
|
||||||
|
int format = mode ? R.string.battery_saver_on_summary
|
||||||
|
: R.string.battery_saver_off_summary;
|
||||||
|
int percent = Settings.Global.getInt(context.getContentResolver(),
|
||||||
|
Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
|
||||||
|
int percentFormat = percent > 0 ? R.string.battery_saver_desc_turn_on_auto_pct
|
||||||
|
: R.string.battery_saver_desc_turn_on_auto_never;
|
||||||
|
setSummary(context.getString(format, context.getString(percentFormat,
|
||||||
|
Utils.formatPercentage(percent))));
|
||||||
|
}
|
||||||
|
|
||||||
|
private final ContentObserver mObserver = new ContentObserver(new Handler()) {
|
||||||
|
@Override
|
||||||
|
public void onChange(boolean selfChange) {
|
||||||
|
updateSwitch();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
@@ -20,30 +20,37 @@ import android.content.Context;
|
|||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.support.v7.preference.PreferenceViewHolder;
|
import android.support.v7.preference.PreferenceViewHolder;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settings.AppProgressPreference;
|
import com.android.settings.TintablePreference;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom preference for displaying power consumption as a bar and an icon on
|
* Custom preference for displaying power consumption as a bar and an icon on
|
||||||
* the left for the subsystem/app type.
|
* the left for the subsystem/app type.
|
||||||
*/
|
*/
|
||||||
public class PowerGaugePreference extends AppProgressPreference {
|
public class PowerGaugePreference extends TintablePreference {
|
||||||
|
private final int mIconSize;
|
||||||
|
|
||||||
private BatteryEntry mInfo;
|
private BatteryEntry mInfo;
|
||||||
private final CharSequence mContentDescription;
|
private final CharSequence mContentDescription;
|
||||||
|
private CharSequence mProgress;
|
||||||
|
|
||||||
public PowerGaugePreference(Context context, Drawable icon, CharSequence contentDescription,
|
public PowerGaugePreference(Context context, Drawable icon, CharSequence contentDescription,
|
||||||
BatteryEntry info) {
|
BatteryEntry info) {
|
||||||
super(context, null);
|
super(context, null);
|
||||||
setIcon(icon != null ? icon : new ColorDrawable(0));
|
setIcon(icon != null ? icon : new ColorDrawable(0));
|
||||||
|
setWidgetLayoutResource(R.layout.preference_widget_summary);
|
||||||
mInfo = info;
|
mInfo = info;
|
||||||
mContentDescription = contentDescription;
|
mContentDescription = contentDescription;
|
||||||
|
mIconSize = context.getResources().getDimensionPixelSize(R.dimen.app_icon_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPercent(double percentOfMax, double percentOfTotal) {
|
public void setPercent(double percentOfMax, double percentOfTotal) {
|
||||||
setProgress((int) Math.ceil(percentOfMax));
|
mProgress = Utils.formatPercentage((int) (percentOfTotal + 0.5));
|
||||||
setSummary(Utils.formatPercentage((int) (percentOfTotal + 0.5)));
|
notifyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
BatteryEntry getInfo() {
|
BatteryEntry getInfo() {
|
||||||
@@ -53,7 +60,10 @@ public class PowerGaugePreference extends AppProgressPreference {
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||||
super.onBindViewHolder(view);
|
super.onBindViewHolder(view);
|
||||||
|
ImageView icon = (ImageView) view.findViewById(android.R.id.icon);
|
||||||
|
icon.setLayoutParams(new LinearLayout.LayoutParams(mIconSize, mIconSize));
|
||||||
|
|
||||||
|
((TextView) view.findViewById(R.id.widget_summary)).setText(mProgress);
|
||||||
if (mContentDescription != null) {
|
if (mContentDescription != null) {
|
||||||
final TextView titleView = (TextView) view.findViewById(android.R.id.title);
|
final TextView titleView = (TextView) view.findViewById(android.R.id.title);
|
||||||
titleView.setContentDescription(mContentDescription);
|
titleView.setContentDescription(mContentDescription);
|
||||||
|
@@ -65,7 +65,6 @@ public class PowerUsageSummary extends PowerUsageBase {
|
|||||||
private static final String KEY_BATTERY_HISTORY = "battery_history";
|
private static final String KEY_BATTERY_HISTORY = "battery_history";
|
||||||
|
|
||||||
private static final int MENU_STATS_TYPE = Menu.FIRST;
|
private static final int MENU_STATS_TYPE = Menu.FIRST;
|
||||||
private static final int MENU_BATTERY_SAVER = Menu.FIRST + 2;
|
|
||||||
private static final int MENU_HIGH_POWER_APPS = Menu.FIRST + 3;
|
private static final int MENU_HIGH_POWER_APPS = Menu.FIRST + 3;
|
||||||
private static final int MENU_HELP = Menu.FIRST + 4;
|
private static final int MENU_HELP = Menu.FIRST + 4;
|
||||||
|
|
||||||
@@ -134,9 +133,6 @@ public class PowerUsageSummary extends PowerUsageBase {
|
|||||||
.setAlphabeticShortcut('t');
|
.setAlphabeticShortcut('t');
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem batterySaver = menu.add(0, MENU_BATTERY_SAVER, 0, R.string.battery_saver);
|
|
||||||
batterySaver.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
|
||||||
|
|
||||||
menu.add(0, MENU_HIGH_POWER_APPS, 0, R.string.high_power_apps);
|
menu.add(0, MENU_HIGH_POWER_APPS, 0, R.string.high_power_apps);
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
}
|
}
|
||||||
@@ -158,10 +154,6 @@ public class PowerUsageSummary extends PowerUsageBase {
|
|||||||
}
|
}
|
||||||
refreshStats();
|
refreshStats();
|
||||||
return true;
|
return true;
|
||||||
case MENU_BATTERY_SAVER:
|
|
||||||
sa.startPreferencePanel(BatterySaverSettings.class.getName(), null,
|
|
||||||
R.string.battery_saver, null, null, 0);
|
|
||||||
return true;
|
|
||||||
case MENU_HIGH_POWER_APPS:
|
case MENU_HIGH_POWER_APPS:
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString(ManageApplications.EXTRA_CLASSNAME,
|
args.putString(ManageApplications.EXTRA_CLASSNAME,
|
||||||
@@ -280,6 +272,7 @@ public class PowerUsageSummary extends PowerUsageBase {
|
|||||||
|
|
||||||
protected void refreshStats() {
|
protected void refreshStats() {
|
||||||
super.refreshStats();
|
super.refreshStats();
|
||||||
|
PowerWhitelistBackend powerWhiteist = PowerWhitelistBackend.getInstance();
|
||||||
updatePreference(mHistPref);
|
updatePreference(mHistPref);
|
||||||
mAppListGroup.removeAll();
|
mAppListGroup.removeAll();
|
||||||
mAppListGroup.setOrderingAsAdded(false);
|
mAppListGroup.setOrderingAsAdded(false);
|
||||||
@@ -352,6 +345,12 @@ public class PowerUsageSummary extends PowerUsageBase {
|
|||||||
pref.setTitle(entry.getLabel());
|
pref.setTitle(entry.getLabel());
|
||||||
pref.setOrder(i + 1);
|
pref.setOrder(i + 1);
|
||||||
pref.setPercent(percentOfMax, percentOfTotal);
|
pref.setPercent(percentOfMax, percentOfTotal);
|
||||||
|
if (sipper.drainType == DrainType.APP) {
|
||||||
|
pref.setSummary(powerWhiteist.isWhitelisted(entry.defaultPackageName)
|
||||||
|
|| powerWhiteist.isSysWhitelisted(entry.defaultPackageName)
|
||||||
|
? getString(R.string.not_battery_optimizing)
|
||||||
|
: null);
|
||||||
|
}
|
||||||
if (sipper.uidObj != null) {
|
if (sipper.uidObj != null) {
|
||||||
pref.setKey(Integer.toString(sipper.uidObj.getUid()));
|
pref.setKey(Integer.toString(sipper.uidObj.getUid()));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user