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

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

am 9934fa77: Merge "Fix issue #3074745: Crash in system process" into gingerbread

Merge commit '9934fa77' into gingerbread-plus-aosp

* commit '9934fa77':
  Fix issue #3074745: Crash in system process
parents 965d5337 9934fa77
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -449,6 +449,10 @@ public abstract class BatteryStats implements Parcelable {
        public static final int STATE_WAKE_LOCK_FLAG = 1<<17;
        public static final int STATE_SENSOR_ON_FLAG = 1<<16;
        
        public static final int MOST_INTERESTING_STATES =
            STATE_BATTERY_PLUGGED_FLAG | STATE_SCREEN_ON_FLAG
            | STATE_GPS_ON_FLAG | STATE_PHONE_IN_CALL_FLAG;

        public int states;

        public HistoryItem() {
+25 −5
Original line number Diff line number Diff line
@@ -72,6 +72,9 @@ public final class BatteryStatsImpl extends BatteryStats {
    // Maximum number of items we will record in the history.
    private static final int MAX_HISTORY_ITEMS = 2000;
    
    // No, really, THIS is the maximum number of items we will record in the history.
    private static final int MAX_MAX_HISTORY_ITEMS = 3000;

    // 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.
@@ -1171,15 +1174,20 @@ public final class BatteryStatsImpl extends BatteryStats {
        mBtHeadset = headset;
    }

    int mChangedStates = 0;

    void addHistoryRecordLocked(long curTime) {
        if (!mHaveBatteryLevel || !mRecordingHistory) {
            return;
        }

        // If the current time is basically the same as the last time,
        // just collapse into one record.
        // and no states have since the last recorded entry changed and
        // are now resetting back to their original value, then just collapse
        // into one record.
        if (mHistoryEnd != null && mHistoryEnd.cmd == HistoryItem.CMD_UPDATE
                && (mHistoryBaseTime+curTime) < (mHistoryEnd.time+500)) {
                && (mHistoryBaseTime+curTime) < (mHistoryEnd.time+2000)
                && ((mHistoryEnd.states^mHistoryCur.states)&mChangedStates) == 0) {
            // If the current is the same as the one before, then we no
            // longer need the entry.
            if (mHistoryLastEnd != null && mHistoryLastEnd.cmd == HistoryItem.CMD_UPDATE
@@ -1190,20 +1198,29 @@ public final class BatteryStatsImpl extends BatteryStats {
                mHistoryEnd = mHistoryLastEnd;
                mHistoryLastEnd = null;
            } else {
                mChangedStates |= mHistoryEnd.states^mHistoryCur.states;
                mHistoryEnd.setTo(mHistoryEnd.time, HistoryItem.CMD_UPDATE, mHistoryCur);
            }
            return;
        }

        if (mNumHistoryItems == MAX_HISTORY_ITEMS) {
        mChangedStates = 0;

        if (mNumHistoryItems == MAX_HISTORY_ITEMS
                || mNumHistoryItems == MAX_MAX_HISTORY_ITEMS) {
            addHistoryRecordLocked(curTime, HistoryItem.CMD_OVERFLOW);
        }

        if (mNumHistoryItems >= MAX_HISTORY_ITEMS) {
            // Once we've reached the maximum number of items, we only
            // record changes to the battery level and the most interesting states.
            // Once we've reached the maximum maximum number of items, we only
            // record changes to the battery level.
            if (mHistoryEnd != null && mHistoryEnd.batteryLevel
                    == mHistoryCur.batteryLevel) {
                    == mHistoryCur.batteryLevel &&
                    (mNumHistoryItems >= MAX_MAX_HISTORY_ITEMS
                            || ((mHistoryEnd.states^mHistoryCur.states)
                                    & HistoryItem.MOST_INTERESTING_STATES) == 0)) {
                return;
            }
        }
@@ -4452,10 +4469,13 @@ public final class BatteryStatsImpl extends BatteryStats {
    }

    public void commitPendingDataToDisk() {
        Parcel next;
        final Parcel next;
        synchronized (this) {
            next = mPendingWrite;
            mPendingWrite = null;
            if (next == null) {
                return;
            }

            mWriteLock.lock();
        }