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

Commit 4d4f265e authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android Git Automerger
Browse files

am 9f8cc518: Merge "Adjust activity manager process OOM adj." into kraken

Merge commit '9f8cc518' into gingerbread-plus-aosp

* commit '9f8cc518':
  Adjust activity manager process OOM adj.
parents 0905ba7b 9f8cc518
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -21763,7 +21763,18 @@
 type="int"
 transient="false"
 volatile="false"
 value="150"
 value="170"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="IMPORTANCE_PERCEPTIBLE"
 type="int"
 transient="false"
 volatile="false"
 value="130"
 static="true"
 final="true"
 deprecated="not deprecated"
+13 −5
Original line number Diff line number Diff line
@@ -726,16 +726,24 @@ public class ActivityManager {
        public static final int IMPORTANCE_FOREGROUND = 100;
        
        /**
         * Constant for {@link #importance}: this process is running a
         * heavy-weight application and thus should not be killed.
         * Constant for {@link #importance}: this process is running something
         * that is actively visible to the user, though not in the immediate
         * foreground.
         */
        public static final int IMPORTANCE_HEAVY_WEIGHT = 150;
        public static final int IMPORTANCE_VISIBLE = 200;
        
        /**
         * Constant for {@link #importance}: this process is running something
         * that is considered to be actively visible to the user.
         * that is considered to be actively perceptible to the user.  An
         * example would be an application performing background music playback.
         */
        public static final int IMPORTANCE_VISIBLE = 200;
        public static final int IMPORTANCE_PERCEPTIBLE = 130;
        
        /**
         * Constant for {@link #importance}: this process is running a
         * heavy-weight application and thus should not be killed.
         */
        public static final int IMPORTANCE_HEAVY_WEIGHT = 170;
        
        /**
         * Constant for {@link #importance}: this process is contains services
+69 −14
Original line number Diff line number Diff line
@@ -51,50 +51,36 @@ public abstract class BatteryStats implements Parcelable {
    
    /**
     * A constant indicating a sensor timer.
     * 
     * {@hide}
     */
    public static final int SENSOR = 3;
    
    /**
     * A constant indicating a a wifi turn on timer
     *
     * {@hide}
     */
    public static final int WIFI_TURNED_ON = 4;
    
    /**
     * A constant indicating a full wifi lock timer
     *
     * {@hide}
     */
    public static final int FULL_WIFI_LOCK = 5;
    
    /**
     * A constant indicating a scan wifi lock timer
     *
     * {@hide}
     */
    public static final int SCAN_WIFI_LOCK = 6;

     /**
      * A constant indicating a wifi multicast timer
      *
      * {@hide}
      */
     public static final int WIFI_MULTICAST_ENABLED = 7;

    /**
     * A constant indicating an audio turn on timer
     *
     * {@hide}
     */
    public static final int AUDIO_TURNED_ON = 7;

    /**
     * A constant indicating a video turn on timer
     *
     * {@hide}
     */
    public static final int VIDEO_TURNED_ON = 8;

@@ -391,6 +377,61 @@ public abstract class BatteryStats implements Parcelable {
        }
    }

    public final class BatteryHistoryRecord implements Parcelable {
        public BatteryHistoryRecord next;
        
        public long time;
        public byte batteryLevel;
        
        public static final int STATE_SCREEN_MASK = 0x000000f;
        public static final int STATE_SCREEN_SHIFT = 0;
        public static final int STATE_SIGNAL_STRENGTH_MASK = 0x00000f0;
        public static final int STATE_SIGNAL_STRENGTH_SHIFT = 4;
        public static final int STATE_PHONE_STATE_MASK = 0x0000f00;
        public static final int STATE_PHONE_STATE_SHIFT = 8;
        public static final int STATE_DATA_CONNECTION_MASK = 0x000f000;
        public static final int STATE_DATA_CONNECTION_SHIFT = 12;
        
        public static final int STATE_BATTERY_PLUGGED_FLAG = 1<<30;
        public static final int STATE_SCREEN_ON_FLAG = 1<<29;
        public static final int STATE_GPS_ON_FLAG = 1<<28;
        public static final int STATE_PHONE_ON_FLAG = 1<<27;
        public static final int STATE_WIFI_ON_FLAG = 1<<26;
        public static final int STATE_WIFI_RUNNING_FLAG = 1<<25;
        public static final int STATE_WIFI_FULL_LOCK_FLAG = 1<<24;
        public static final int STATE_WIFI_SCAN_LOCK_FLAG = 1<<23;
        public static final int STATE_WIFI_MULTICAST_ON_FLAG = 1<<22;
        public static final int STATE_BLUETOOTH_ON_FLAG = 1<<21;
        public static final int STATE_AUDIO_ON_FLAG = 1<<20;
        public static final int STATE_VIDEO_ON_FLAG = 1<<19;
        
        public int states;

        public BatteryHistoryRecord() {
        }
        
        public BatteryHistoryRecord(long time, Parcel src) {
            this.time = time;
            batteryLevel = (byte)src.readInt();
            states = src.readInt();
        }
        
        public int describeContents() {
            return 0;
        }

        public void writeToParcel(Parcel dest, int flags) {
            dest.writeLong(time);
            dest.writeInt(batteryLevel);
            dest.writeInt(states);
        }
    }
    
    /**
     * Return the current history of battery state changes.
     */
    public abstract BatteryHistoryRecord getHistory();
    
    /**
     * Returns the number of times the device has been started.
     */
@@ -1443,6 +1484,20 @@ public abstract class BatteryStats implements Parcelable {
     */
    @SuppressWarnings("unused")
    public void dumpLocked(PrintWriter pw) {
        BatteryHistoryRecord rec = getHistory();
        if (rec != null) {
            pw.println("Battery History:");
            while (rec != null) {
                pw.print("  ");
                pw.print(rec.time);
                pw.print(" ");
                pw.print(rec.batteryLevel);
                pw.print(" ");
                pw.println(Integer.toHexString(rec.states));
                rec = rec.next;
            }
        }
        
        pw.println("Total Statistics (Current and Historic):");
        pw.println("  System starts: " + getStartCount()
                + ", currently on battery: " + getIsOnBattery());
+232 −4
Original line number Diff line number Diff line
@@ -56,12 +56,13 @@ import java.util.concurrent.atomic.AtomicInteger;
public final class BatteryStatsImpl extends BatteryStats {
    private static final String TAG = "BatteryStatsImpl";
    private static final boolean DEBUG = false;
    private static final boolean DEBUG_HISTORY = false;
    
    // In-memory Parcel magic number, used to detect attempts to unmarshall bad data
    private static final int MAGIC = 0xBA757475; // 'BATSTATS' 

    // Current on-disk Parcel version
    private static final int VERSION = 43;
    private static final int VERSION = 44;

    // The maximum number of names wakelocks we will keep track of
    // per uid; once the limit is reached, we batch the remaining wakelocks
@@ -94,6 +95,11 @@ public final class BatteryStatsImpl extends BatteryStats {
    // is unplugged from power.
    final ArrayList<Unpluggable> mUnpluggables = new ArrayList<Unpluggable>();
    
    BatteryHistoryRecord mHistory;
    BatteryHistoryRecord mHistoryEnd;
    BatteryHistoryRecord mHistoryCache;
    final BatteryHistoryRecord mHistoryCur = new BatteryHistoryRecord();
    
    int mStartCount;

    long mBatteryUptime;
@@ -1042,6 +1048,37 @@ public final class BatteryStatsImpl extends BatteryStats {
        mBtHeadset = headset;
    }

    void addHistoryRecord(long curTime) {
        BatteryHistoryRecord rec = mHistoryCache;
        if (rec != null) {
            mHistoryCache = rec.next;
        } else {
            rec = new BatteryHistoryRecord();
        }
        rec.time = curTime;
        rec.batteryLevel = mHistoryCur.batteryLevel;
        rec.states = mHistoryCur.states;
        addHistoryRecord(rec);
    }
    
    void addHistoryRecord(BatteryHistoryRecord rec) {
        rec.next = null;
        if (mHistoryEnd != null) {
            mHistoryEnd.next = rec;
            mHistoryEnd = rec;
        } else {
            mHistory = mHistoryEnd = rec;
        }
    }
    
    void clearHistory() {
        if (mHistory != null) {
            mHistoryEnd.next = mHistoryCache;
            mHistoryCache = mHistory;
            mHistory = mHistoryEnd = null;
        }
    }
    
    public void doUnplug(long batteryUptime, long batteryRealtime) {
        for (int iu = mUidStats.size() - 1; iu >= 0; iu--) {
            Uid u = mUidStats.valueAt(iu);
@@ -1094,16 +1131,37 @@ public final class BatteryStatsImpl extends BatteryStats {
        mBluetoothPingStart = -1;
    }

    int mGpsNesting;
    
    public void noteStartGps(int uid) {
        if (mGpsNesting == 0) {
            mHistoryCur.states |= BatteryHistoryRecord.STATE_GPS_ON_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "Start GPS to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
        }
        mGpsNesting++;
        getUidStatsLocked(uid).noteStartGps();
    }
    
    public void noteStopGps(int uid) {
        mGpsNesting--;
        if (mGpsNesting == 0) {
            mHistoryCur.states &= ~BatteryHistoryRecord.STATE_GPS_ON_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "Stop GPS to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
        }
        getUidStatsLocked(uid).noteStopGps();
    }

    public void noteScreenOnLocked() {
        if (!mScreenOn) {
            mHistoryCur.states |= BatteryHistoryRecord.STATE_SCREEN_ON_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "Screen on to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            mGpsNesting++;
            mScreenOn = true;
            mScreenOnTimer.startRunningLocked(this);
            if (mScreenBrightnessBin >= 0) {
@@ -1114,6 +1172,10 @@ public final class BatteryStatsImpl extends BatteryStats {
    
    public void noteScreenOffLocked() {
        if (mScreenOn) {
            mHistoryCur.states &= ~BatteryHistoryRecord.STATE_SCREEN_ON_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "Screen off to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            mScreenOn = false;
            mScreenOnTimer.stopRunningLocked(this);
            if (mScreenBrightnessBin >= 0) {
@@ -1128,6 +1190,11 @@ public final class BatteryStatsImpl extends BatteryStats {
        if (bin < 0) bin = 0;
        else if (bin >= NUM_SCREEN_BRIGHTNESS_BINS) bin = NUM_SCREEN_BRIGHTNESS_BINS-1;
        if (mScreenBrightnessBin != bin) {
            mHistoryCur.states = (mHistoryCur.states&~BatteryHistoryRecord.STATE_SCREEN_MASK)
                    | (bin << BatteryHistoryRecord.STATE_SCREEN_SHIFT);
            if (DEBUG_HISTORY) Slog.v(TAG, "Screen brightness " + bin + " to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            if (mScreenOn) {
                if (mScreenBrightnessBin >= 0) {
                    mScreenBrightnessTimer[mScreenBrightnessBin].stopRunningLocked(this);
@@ -1148,6 +1215,10 @@ public final class BatteryStatsImpl extends BatteryStats {
    
    public void notePhoneOnLocked() {
        if (!mPhoneOn) {
            mHistoryCur.states |= BatteryHistoryRecord.STATE_PHONE_ON_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "Phone on to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            mPhoneOn = true;
            mPhoneOnTimer.startRunningLocked(this);
        }
@@ -1155,6 +1226,10 @@ public final class BatteryStatsImpl extends BatteryStats {
    
    public void notePhoneOffLocked() {
        if (mPhoneOn) {
            mHistoryCur.states &= ~BatteryHistoryRecord.STATE_PHONE_ON_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "Phone off to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            mPhoneOn = false;
            mPhoneOnTimer.stopRunningLocked(this);
        }
@@ -1195,8 +1270,16 @@ public final class BatteryStatsImpl extends BatteryStats {
                mPhoneSignalScanningTimer.startRunningLocked(this);
            }
        }
        
        if (mPhoneServiceState != state) {
            mHistoryCur.states = (mHistoryCur.states&~BatteryHistoryRecord.STATE_PHONE_STATE_MASK)
                    | (state << BatteryHistoryRecord.STATE_PHONE_STATE_SHIFT);
            if (DEBUG_HISTORY) Slog.v(TAG, "Phone state " + bin + " to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            mPhoneServiceState = state;
        }
    }

    public void notePhoneSignalStrengthLocked(SignalStrength signalStrength) {
        // Bin the strength.
@@ -1222,6 +1305,11 @@ public final class BatteryStatsImpl extends BatteryStats {
            else bin = SIGNAL_STRENGTH_POOR;
        }
        if (mPhoneSignalStrengthBin != bin) {
            mHistoryCur.states = (mHistoryCur.states&~BatteryHistoryRecord.STATE_SIGNAL_STRENGTH_MASK)
                    | (bin << BatteryHistoryRecord.STATE_SIGNAL_STRENGTH_SHIFT);
            if (DEBUG_HISTORY) Slog.v(TAG, "Signal strength " + bin + " to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            if (mPhoneSignalStrengthBin >= 0) {
                mPhoneSignalStrengthsTimer[mPhoneSignalStrengthBin].stopRunningLocked(this);
            }
@@ -1250,6 +1338,11 @@ public final class BatteryStatsImpl extends BatteryStats {
        }
        if (DEBUG) Log.i(TAG, "Phone Data Connection -> " + dataType + " = " + hasData);
        if (mPhoneDataConnectionType != bin) {
            mHistoryCur.states = (mHistoryCur.states&~BatteryHistoryRecord.STATE_DATA_CONNECTION_MASK)
                    | (bin << BatteryHistoryRecord.STATE_DATA_CONNECTION_SHIFT);
            if (DEBUG_HISTORY) Slog.v(TAG, "Data connection " + bin + " to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            if (mPhoneDataConnectionType >= 0) {
                mPhoneDataConnectionsTimer[mPhoneDataConnectionType].stopRunningLocked(this);
            }
@@ -1260,6 +1353,10 @@ public final class BatteryStatsImpl extends BatteryStats {
    
    public void noteWifiOnLocked(int uid) {
        if (!mWifiOn) {
            mHistoryCur.states |= BatteryHistoryRecord.STATE_WIFI_ON_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "WIFI on to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            mWifiOn = true;
            mWifiOnTimer.startRunningLocked(this);
        }
@@ -1274,6 +1371,10 @@ public final class BatteryStatsImpl extends BatteryStats {
    
    public void noteWifiOffLocked(int uid) {
        if (mWifiOn) {
            mHistoryCur.states &= ~BatteryHistoryRecord.STATE_WIFI_ON_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "WIFI off to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            mWifiOn = false;
            mWifiOnTimer.stopRunningLocked(this);
        }
@@ -1285,6 +1386,10 @@ public final class BatteryStatsImpl extends BatteryStats {

    public void noteAudioOnLocked(int uid) {
        if (!mAudioOn) {
            mHistoryCur.states |= BatteryHistoryRecord.STATE_AUDIO_ON_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "Audio on to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            mAudioOn = true;
            mAudioOnTimer.startRunningLocked(this);
        }
@@ -1293,6 +1398,10 @@ public final class BatteryStatsImpl extends BatteryStats {
    
    public void noteAudioOffLocked(int uid) {
        if (mAudioOn) {
            mHistoryCur.states &= ~BatteryHistoryRecord.STATE_AUDIO_ON_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "Audio off to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            mAudioOn = false;
            mAudioOnTimer.stopRunningLocked(this);
        }
@@ -1301,6 +1410,10 @@ public final class BatteryStatsImpl extends BatteryStats {

    public void noteVideoOnLocked(int uid) {
        if (!mVideoOn) {
            mHistoryCur.states |= BatteryHistoryRecord.STATE_VIDEO_ON_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "Video on to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            mVideoOn = true;
            mVideoOnTimer.startRunningLocked(this);
        }
@@ -1309,6 +1422,10 @@ public final class BatteryStatsImpl extends BatteryStats {
    
    public void noteVideoOffLocked(int uid) {
        if (mVideoOn) {
            mHistoryCur.states &= ~BatteryHistoryRecord.STATE_VIDEO_ON_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "Video off to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            mVideoOn = false;
            mVideoOnTimer.stopRunningLocked(this);
        }
@@ -1317,6 +1434,10 @@ public final class BatteryStatsImpl extends BatteryStats {

    public void noteWifiRunningLocked() {
        if (!mWifiRunning) {
            mHistoryCur.states |= BatteryHistoryRecord.STATE_WIFI_RUNNING_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "WIFI running to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            mWifiRunning = true;
            mWifiRunningTimer.startRunningLocked(this);
        }
@@ -1324,6 +1445,10 @@ public final class BatteryStatsImpl extends BatteryStats {

    public void noteWifiStoppedLocked() {
        if (mWifiRunning) {
            mHistoryCur.states &= ~BatteryHistoryRecord.STATE_WIFI_RUNNING_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "WIFI stopped to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            mWifiRunning = false;
            mWifiRunningTimer.stopRunningLocked(this);
        }
@@ -1331,6 +1456,10 @@ public final class BatteryStatsImpl extends BatteryStats {

    public void noteBluetoothOnLocked() {
        if (!mBluetoothOn) {
            mHistoryCur.states |= BatteryHistoryRecord.STATE_BLUETOOTH_ON_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "Bluetooth on to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            mBluetoothOn = true;
            mBluetoothOnTimer.startRunningLocked(this);
        }
@@ -1338,32 +1467,84 @@ public final class BatteryStatsImpl extends BatteryStats {
    
    public void noteBluetoothOffLocked() {
        if (mBluetoothOn) {
            mHistoryCur.states &= ~BatteryHistoryRecord.STATE_BLUETOOTH_ON_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "Bluetooth off to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
            mBluetoothOn = false;
            mBluetoothOnTimer.stopRunningLocked(this);
        }
    }
    
    int mWifiFullLockNesting = 0;
    
    public void noteFullWifiLockAcquiredLocked(int uid) {
        if (mWifiFullLockNesting == 0) {
            mHistoryCur.states |= BatteryHistoryRecord.STATE_WIFI_FULL_LOCK_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "WIFI full lock on to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
        }
        mWifiFullLockNesting++;
        getUidStatsLocked(uid).noteFullWifiLockAcquiredLocked();
    }

    public void noteFullWifiLockReleasedLocked(int uid) {
        mWifiFullLockNesting--;
        if (mWifiFullLockNesting == 0) {
            mHistoryCur.states &= ~BatteryHistoryRecord.STATE_WIFI_FULL_LOCK_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "WIFI full lock off to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
        }
        getUidStatsLocked(uid).noteFullWifiLockReleasedLocked();
    }

    int mWifiScanLockNesting = 0;
    
    public void noteScanWifiLockAcquiredLocked(int uid) {
        if (mWifiScanLockNesting == 0) {
            mHistoryCur.states |= BatteryHistoryRecord.STATE_WIFI_SCAN_LOCK_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "WIFI scan lock on to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
        }
        mWifiScanLockNesting++;
        getUidStatsLocked(uid).noteScanWifiLockAcquiredLocked();
    }

    public void noteScanWifiLockReleasedLocked(int uid) {
        mWifiScanLockNesting--;
        if (mWifiScanLockNesting == 0) {
            mHistoryCur.states &= ~BatteryHistoryRecord.STATE_WIFI_SCAN_LOCK_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "WIFI scan lock off to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
        }
        getUidStatsLocked(uid).noteScanWifiLockReleasedLocked();
    }

    int mWifiMulticastNesting = 0;
    
    public void noteWifiMulticastEnabledLocked(int uid) {
        if (mWifiMulticastNesting == 0) {
            mHistoryCur.states |= BatteryHistoryRecord.STATE_WIFI_MULTICAST_ON_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "WIFI multicast on to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
        }
        mWifiMulticastNesting++;
        getUidStatsLocked(uid).noteWifiMulticastEnabledLocked();
    }

    public void noteWifiMulticastDisabledLocked(int uid) {
        mWifiMulticastNesting--;
        if (mWifiMulticastNesting == 0) {
            mHistoryCur.states &= ~BatteryHistoryRecord.STATE_WIFI_MULTICAST_ON_FLAG;
            if (DEBUG_HISTORY) Slog.v(TAG, "WIFI multicast off to: "
                    + Integer.toHexString(mHistoryCur.states));
            addHistoryRecord(SystemClock.elapsedRealtime());
        }
        getUidStatsLocked(uid).noteWifiMulticastDisabledLocked();
    }

@@ -2765,6 +2946,11 @@ public final class BatteryStatsImpl extends BatteryStats {
        }
    }

    @Override
    public BatteryHistoryRecord getHistory() {
        return mHistory;
    }
    
    @Override
    public int getStartCount() {
        return mStartCount;
@@ -2784,6 +2970,12 @@ public final class BatteryStatsImpl extends BatteryStats {
                long mSecRealtime = SystemClock.elapsedRealtime();
                long realtime = mSecRealtime * 1000;
                if (onBattery) {
                    clearHistory();
                    mHistoryCur.batteryLevel = (byte)level;
                    mHistoryCur.states &= ~BatteryHistoryRecord.STATE_BATTERY_PLUGGED_FLAG;
                    if (DEBUG_HISTORY) Slog.v(TAG, "Battery unplugged to: "
                            + Integer.toHexString(mHistoryCur.states));
                    addHistoryRecord(mSecRealtime);
                    mTrackBatteryUptimeStart = uptime;
                    mTrackBatteryRealtimeStart = realtime;
                    mUnpluggedBatteryUptime = getBatteryUptimeLocked(uptime);
@@ -2791,6 +2983,11 @@ public final class BatteryStatsImpl extends BatteryStats {
                    mDischargeCurrentLevel = mDischargeStartLevel = level;
                    doUnplug(mUnpluggedBatteryUptime, mUnpluggedBatteryRealtime);
                } else {
                    mHistoryCur.batteryLevel = (byte)level;
                    mHistoryCur.states |= BatteryHistoryRecord.STATE_BATTERY_PLUGGED_FLAG;
                    if (DEBUG_HISTORY) Slog.v(TAG, "Battery plugged to: "
                            + Integer.toHexString(mHistoryCur.states));
                    addHistoryRecord(mSecRealtime);
                    mTrackBatteryPastUptime += uptime - mTrackBatteryUptimeStart;
                    mTrackBatteryPastRealtime += realtime - mTrackBatteryRealtimeStart;
                    mDischargeCurrentLevel = level;
@@ -2806,7 +3003,11 @@ public final class BatteryStatsImpl extends BatteryStats {
    }
    
    public void recordCurrentLevel(int level) {
        if (mDischargeCurrentLevel != level) {
            mDischargeCurrentLevel = level;
            mHistoryCur.batteryLevel = (byte)level;
            addHistoryRecord(SystemClock.elapsedRealtime());
        }
    }
    
    public void updateKernelWakelocksLocked() {
@@ -3146,6 +3347,24 @@ public final class BatteryStatsImpl extends BatteryStats {
        return 0;
    }

    void readHistory(Parcel in) {
        mHistory = mHistoryEnd = mHistoryCache = null;
        long time;
        while ((time=in.readLong()) >= 0) {
            BatteryHistoryRecord rec = new BatteryHistoryRecord(time, in);
            addHistoryRecord(rec);
        }
    }
    
    void writeHistory(Parcel out) {
        BatteryHistoryRecord rec = mHistory;
        while (rec != null) {
            if (rec.time >= 0) rec.writeToParcel(out, 0);
            rec = rec.next;
        }
        out.writeLong(-1);
    }
    
    private void readSummaryFromParcel(Parcel in) {
        final int version = in.readInt();
        if (version != VERSION) {
@@ -3154,6 +3373,8 @@ public final class BatteryStatsImpl extends BatteryStats {
            return;
        }

        readHistory(in);
        
        mStartCount = in.readInt();
        mBatteryUptime = in.readLong();
        mBatteryLastUptime = in.readLong();
@@ -3325,6 +3546,8 @@ public final class BatteryStatsImpl extends BatteryStats {

        out.writeInt(VERSION);

        writeHistory(out);
        
        out.writeInt(mStartCount);
        out.writeLong(computeBatteryUptime(NOW_SYS, STATS_TOTAL));
        out.writeLong(computeBatteryUptime(NOW_SYS, STATS_CURRENT));
@@ -3493,6 +3716,8 @@ public final class BatteryStatsImpl extends BatteryStats {
            throw new ParcelFormatException("Bad magic number");
        }

        readHistory(in);
        
        mStartCount = in.readInt();
        mBatteryUptime = in.readLong();
        mBatteryLastUptime = in.readLong();
@@ -3591,6 +3816,9 @@ public final class BatteryStatsImpl extends BatteryStats {
        final long batteryRealtime = getBatteryRealtimeLocked(uSecRealtime);
        
        out.writeInt(MAGIC);
        
        writeHistory(out);
        
        out.writeInt(mStartCount);
        out.writeLong(mBatteryUptime);
        out.writeLong(mBatteryLastUptime);
Loading