Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b59b7c30 authored by Narayan Kamath's avatar Narayan Kamath
Browse files

BatteryStatsImpl: Keep less history around for low mem devices.

Test: Manual; w/ debug.force_low_ram
Bug: 62144301
Change-Id: Iaa163a49403e25f598136aaf980901553525b759
parent 89678d66
Loading
Loading
Loading
Loading
+22 −5
Original line number Diff line number Diff line
@@ -121,15 +121,34 @@ public class BatteryStatsImpl extends BatteryStats {
    private static final int VERSION = 159 + (USE_OLD_HISTORY ? 1000 : 0);

    // Maximum number of items we will record in the history.
    private static final int MAX_HISTORY_ITEMS = 2000;
    private static final int MAX_HISTORY_ITEMS;

    // No, really, THIS is the maximum number of items we will record in the history.
    private static final int MAX_MAX_HISTORY_ITEMS = 3000;
    private static final int MAX_MAX_HISTORY_ITEMS;

    // The maximum number of names wakelocks we will keep track of
    // per uid; once the limit is reached, we batch the remaining wakelocks
    // in to one common name.
    private static final int MAX_WAKELOCKS_PER_UID = 100;
    private static final int MAX_WAKELOCKS_PER_UID;

    static final int MAX_HISTORY_BUFFER; // 256KB
    static final int MAX_MAX_HISTORY_BUFFER; // 320KB

    static {
        if (ActivityManager.isLowRamDeviceStatic()) {
            MAX_HISTORY_ITEMS = 800;
            MAX_MAX_HISTORY_ITEMS = 1200;
            MAX_WAKELOCKS_PER_UID = 40;
            MAX_HISTORY_BUFFER = 96*1024;  // 96KB
            MAX_MAX_HISTORY_BUFFER = 128*1024; // 128KB
        } else {
            MAX_HISTORY_ITEMS = 2000;
            MAX_MAX_HISTORY_ITEMS = 3000;
            MAX_WAKELOCKS_PER_UID = 100;
            MAX_HISTORY_BUFFER = 256*1024;  // 256KB
            MAX_MAX_HISTORY_BUFFER = 320*1024;  // 256KB
        }
    }

    // Number of transmit power states the Wifi controller can be in.
    private static final int NUM_WIFI_TX_LEVELS = 1;
@@ -299,8 +318,6 @@ public class BatteryStatsImpl extends BatteryStats {
    boolean mRecordingHistory = false;
    int mNumHistoryItems;

    static final int MAX_HISTORY_BUFFER = 256*1024; // 256KB
    static final int MAX_MAX_HISTORY_BUFFER = 320*1024; // 320KB
    final Parcel mHistoryBuffer = Parcel.obtain();
    final HistoryItem mHistoryLastWritten = new HistoryItem();
    final HistoryItem mHistoryLastLastWritten = new HistoryItem();