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
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user