summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/fuelgauge/PowerUsageSummary.java
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2010-11-12 14:13:03 -0800
committerAmith Yamasani <yamasani@google.com>2010-11-12 14:13:03 -0800
commit137588d60b0d8bb9612fa42f6d650751f540177b (patch)
tree1011a419f9491bf6597c1e2ccdaebb616397b31a /src/com/android/settings/fuelgauge/PowerUsageSummary.java
parentc05dedf9bee2445b6a35e7ca2f2d67f9b570bfaa (diff)
downloadpackages_apps_settings-137588d60b0d8bb9612fa42f6d650751f540177b.zip
packages_apps_settings-137588d60b0d8bb9612fa42f6d650751f540177b.tar.gz
packages_apps_settings-137588d60b0d8bb9612fa42f6d650751f540177b.tar.bz2
Don't show battery usage information if data is bogus.
Diffstat (limited to 'src/com/android/settings/fuelgauge/PowerUsageSummary.java')
-rw-r--r--src/com/android/settings/fuelgauge/PowerUsageSummary.java30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 9fdc7f2..aae60eb 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -16,6 +16,13 @@
package com.android.settings.fuelgauge;
+import com.android.internal.app.IBatteryStats;
+import com.android.internal.os.BatteryStatsImpl;
+import com.android.internal.os.PowerProfile;
+import com.android.settings.R;
+import com.android.settings.applications.InstalledAppDetails;
+import com.android.settings.fuelgauge.PowerUsageDetail.DrainType;
+
import android.content.Context;
import android.content.Intent;
import android.hardware.SensorManager;
@@ -40,13 +47,6 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
-import com.android.internal.app.IBatteryStats;
-import com.android.internal.os.BatteryStatsImpl;
-import com.android.internal.os.PowerProfile;
-import com.android.settings.R;
-import com.android.settings.applications.InstalledAppDetails;
-import com.android.settings.fuelgauge.PowerUsageDetail.DrainType;
-
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
@@ -309,6 +309,12 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
}
}
+ private void addNotAvailableMessage() {
+ Preference notAvailable = new Preference(getActivity());
+ notAvailable.setTitle(R.string.power_usage_not_available);
+ mAppListGroup.addPreference(notAvailable);
+ }
+
private void refreshStats() {
if (mStats == null) {
load();
@@ -323,15 +329,19 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
mUsageList.clear();
mWifiSippers.clear();
mBluetoothSippers.clear();
- processAppUsage();
- processMiscUsage();
-
mAppListGroup.setOrderingAsAdded(false);
BatteryHistoryPreference hist = new BatteryHistoryPreference(getActivity(), mStats);
hist.setOrder(-1);
mAppListGroup.addPreference(hist);
+ if (mPowerProfile.getAveragePower(PowerProfile.POWER_SCREEN_FULL) < 10) {
+ addNotAvailableMessage();
+ return;
+ }
+ processAppUsage();
+ processMiscUsage();
+
Collections.sort(mUsageList);
for (BatterySipper sipper : mUsageList) {
if (sipper.getSortValue() < MIN_POWER_THRESHOLD) continue;