diff options
author | Adam Lesinski <adamlesinski@google.com> | 2015-11-13 15:54:59 -0800 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2015-12-15 22:12:10 +0000 |
commit | 5f8c8186ec608182386ce09b6b4ffc449606f22b (patch) | |
tree | 6ebd9f4ba034ca402eef1681cdb0f103b8e825e8 /core/java/com | |
parent | 36393a5674bf50b351b5961a194ce2814ca00140 (diff) | |
download | frameworks_base-5f8c8186ec608182386ce09b6b4ffc449606f22b.zip frameworks_base-5f8c8186ec608182386ce09b6b4ffc449606f22b.tar.gz frameworks_base-5f8c8186ec608182386ce09b6b4ffc449606f22b.tar.bz2 |
DO NOT MERGE: Fix batterystats battery level int packing
We introduced some new flag at the lowest significant bit of the
battery level int but failed to account for it when unpacking.
Bug:25596467
Change-Id: I4320e6fcc208ec6de249b14fe3e399ab2f32d839
(cherry picked from commit 6902052c77bbcb9078b4ced243874f67542f64f9)
Diffstat (limited to 'core/java/com')
-rw-r--r-- | core/java/com/android/internal/os/BatteryStatsImpl.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index a47724c..1d9fa9d 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -105,7 +105,7 @@ public final class BatteryStatsImpl extends BatteryStats { private static final int MAGIC = 0xBA757475; // 'BATSTATS' // Current on-disk Parcel version - private static final int VERSION = 132 + (USE_OLD_HISTORY ? 1000 : 0); + private static final int VERSION = 133 + (USE_OLD_HISTORY ? 1000 : 0); // Maximum number of items we will record in the history. private static final int MAX_HISTORY_ITEMS = 2000; @@ -1968,8 +1968,14 @@ public final class BatteryStatsImpl extends BatteryStats { private int buildBatteryLevelInt(HistoryItem h) { return ((((int)h.batteryLevel)<<25)&0xfe000000) - | ((((int)h.batteryTemperature)<<14)&0x01ff8000) - | ((((int)h.batteryVoltage)<<1)&0x00007fff); + | ((((int)h.batteryTemperature)<<15)&0x01ff8000) + | ((((int)h.batteryVoltage)<<1)&0x00007ffe); + } + + private void readBatteryLevelInt(int batteryLevelInt, HistoryItem out) { + out.batteryLevel = (byte)((batteryLevelInt & 0xfe000000) >>> 25); + out.batteryTemperature = (short)((batteryLevelInt & 0x01ff8000) >>> 15); + out.batteryVoltage = (char)((batteryLevelInt & 0x00007ffe) >>> 1); } private int buildStateInt(HistoryItem h) { @@ -2110,9 +2116,7 @@ public final class BatteryStatsImpl extends BatteryStats { final int batteryLevelInt; if ((firstToken&DELTA_BATTERY_LEVEL_FLAG) != 0) { batteryLevelInt = src.readInt(); - cur.batteryLevel = (byte)((batteryLevelInt>>25)&0x7f); - cur.batteryTemperature = (short)((batteryLevelInt<<7)>>21); - cur.batteryVoltage = (char)(batteryLevelInt&0x3fff); + readBatteryLevelInt(batteryLevelInt, cur); cur.numReadInts += 1; if (DEBUG) Slog.i(TAG, "READ DELTA: batteryToken=0x" + Integer.toHexString(batteryLevelInt) |