diff options
author | Dianne Hackborn <hackbod@google.com> | 2014-08-06 19:22:46 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2014-08-07 12:19:48 -0700 |
commit | 537a0a82351d9671d14dccde8c9fc2a45c3c4f3a (patch) | |
tree | ad6491bae0d3cee490baac0a5f41ab232a842206 /src/com | |
parent | 689d2ce29b3093c32d1d2b70caa6fb36a4ecefcb (diff) | |
download | packages_apps_Settings-537a0a82351d9671d14dccde8c9fc2a45c3c4f3a.tar.gz packages_apps_Settings-537a0a82351d9671d14dccde8c9fc2a45c3c4f3a.tar.bz2 packages_apps_Settings-537a0a82351d9671d14dccde8c9fc2a45c3c4f3a.zip |
Fix issue #16555033: Battery history overflowing too much
Use new mechanism to retrieve battery stats, now that they
can be much larger.
Make sure these will ever end up going through an IPC.
Change-Id: Ic582a61d736e24bddc905082c1565ece00fcbb29
Diffstat (limited to 'src/com')
3 files changed, 10 insertions, 18 deletions
diff --git a/src/com/android/settings/fuelgauge/BatteryHistoryDetail.java b/src/com/android/settings/fuelgauge/BatteryHistoryDetail.java index 248d47127..63e4e13e2 100644 --- a/src/com/android/settings/fuelgauge/BatteryHistoryDetail.java +++ b/src/com/android/settings/fuelgauge/BatteryHistoryDetail.java @@ -18,31 +18,27 @@ package com.android.settings.fuelgauge; import android.app.Fragment; import android.content.Intent; +import android.os.BatteryStats; import android.os.Bundle; -import android.os.Parcel; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import com.android.internal.os.BatteryStatsImpl; +import com.android.internal.os.BatteryStatsHelper; import com.android.settings.R; public class BatteryHistoryDetail extends Fragment { public static final String EXTRA_STATS = "stats"; public static final String EXTRA_BROADCAST = "broadcast"; - private BatteryStatsImpl mStats; + private BatteryStats mStats; private Intent mBatteryBroadcast; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); - byte[] data = getArguments().getByteArray(EXTRA_STATS); - Parcel parcel = Parcel.obtain(); - parcel.unmarshall(data, 0, data.length); - parcel.setDataPosition(0); - mStats = com.android.internal.os.BatteryStatsImpl.CREATOR - .createFromParcel(parcel); + String histFile = getArguments().getString(EXTRA_STATS); + mStats = BatteryStatsHelper.statsFromFile(getActivity(), histFile); mBatteryBroadcast = getArguments().getParcelable(EXTRA_BROADCAST); } diff --git a/src/com/android/settings/fuelgauge/BatteryHistoryPreference.java b/src/com/android/settings/fuelgauge/BatteryHistoryPreference.java index 300b98f42..e7326b16f 100644 --- a/src/com/android/settings/fuelgauge/BatteryHistoryPreference.java +++ b/src/com/android/settings/fuelgauge/BatteryHistoryPreference.java @@ -47,8 +47,6 @@ public class BatteryHistoryPreference extends Preference { setLayoutResource(R.layout.preference_batteryhistory); mStats = stats; mBatteryBroadcast = batteryBroadcast; - // Make it non selectable - setSelectable(false); } BatteryStats getStats() { diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java index e6534eb69..c438aec86 100644 --- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java +++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java @@ -26,7 +26,6 @@ import android.os.BatteryStats; import android.os.Bundle; import android.os.Handler; import android.os.Message; -import android.os.Parcel; import android.os.UserHandle; import android.os.UserManager; import android.preference.Preference; @@ -46,8 +45,6 @@ import com.android.settings.R; import com.android.settings.SettingsActivity; import java.util.List; -import java.util.ArrayList; -import java.util.Collections; /** * Displays a list of apps and subsystems that consume power, ordered by how much power was @@ -61,6 +58,8 @@ public class PowerUsageSummary extends PreferenceFragment { private static final String KEY_APP_LIST = "app_list"; + private static final String BATTERY_HISTORY_FILE = "tmp_bat_history.bin"; + private static final int MENU_STATS_TYPE = Menu.FIRST; private static final int MENU_STATS_REFRESH = Menu.FIRST + 1; private static final int MENU_BATTERY_SAVER = Menu.FIRST + 2; @@ -116,6 +115,7 @@ public class PowerUsageSummary extends PreferenceFragment { @Override public void onResume() { super.onResume(); + BatteryStatsHelper.dropFile(getActivity(), BATTERY_HISTORY_FILE); updateBatteryStatus(getActivity().registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED))); if (mHandler.hasMessages(MSG_REFRESH_STATS)) { @@ -151,11 +151,9 @@ public class PowerUsageSummary extends PreferenceFragment { @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (preference instanceof BatteryHistoryPreference) { - Parcel hist = Parcel.obtain(); - mStatsHelper.getStats().writeToParcelWithoutUids(hist, 0); - byte[] histData = hist.marshall(); + mStatsHelper.storeStatsHistoryInFile(BATTERY_HISTORY_FILE); Bundle args = new Bundle(); - args.putByteArray(BatteryHistoryDetail.EXTRA_STATS, histData); + args.putString(BatteryHistoryDetail.EXTRA_STATS, BATTERY_HISTORY_FILE); args.putParcelable(BatteryHistoryDetail.EXTRA_BROADCAST, mStatsHelper.getBatteryBroadcast()); SettingsActivity sa = (SettingsActivity) getActivity(); |