Skip to content

Commit 722565a

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "Fix inconsistency in user activity types." into jb-mr1-dev
2 parents 6089a88 + df693de commit 722565a

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

core/java/android/os/BatteryStats.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,15 @@ public abstract long getWifiMulticastTime(long batteryRealtime,
277277
public abstract long getVideoTurnedOnTime(long batteryRealtime, int which);
278278

279279
/**
280-
* Note that these must match the constants in android.os.LocalPowerManager.
280+
* Note that these must match the constants in android.os.PowerManager.
281+
* Also, if the user activity types change, the BatteryStatsImpl.VERSION must
282+
* also be bumped.
281283
*/
282284
static final String[] USER_ACTIVITY_TYPES = {
283-
"other", "cheek", "touch", "long_touch", "touch_up", "button", "unknown"
285+
"other", "button", "touch"
284286
};
285287

286-
public static final int NUM_USER_ACTIVITY_TYPES = 7;
288+
public static final int NUM_USER_ACTIVITY_TYPES = 3;
287289

288290
public abstract void noteUserActivityLocked(int type);
289291
public abstract boolean hasUserActivity();

core/java/com/android/internal/os/BatteryStatsImpl.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public final class BatteryStatsImpl extends BatteryStats {
8787
private static final int MAGIC = 0xBA757475; // 'BATSTATS'
8888

8989
// Current on-disk Parcel version
90-
private static final int VERSION = 61 + (USE_OLD_HISTORY ? 1000 : 0);
90+
private static final int VERSION = 62 + (USE_OLD_HISTORY ? 1000 : 0);
9191

9292
// Maximum number of items we will record in the history.
9393
private static final int MAX_HISTORY_ITEMS = 2000;
@@ -2681,9 +2681,12 @@ public void noteUserActivityLocked(int type) {
26812681
if (mUserActivityCounters == null) {
26822682
initUserActivityLocked();
26832683
}
2684-
if (type < 0) type = 0;
2685-
else if (type >= NUM_USER_ACTIVITY_TYPES) type = NUM_USER_ACTIVITY_TYPES-1;
2686-
mUserActivityCounters[type].stepAtomic();
2684+
if (type >= 0 && type < NUM_USER_ACTIVITY_TYPES) {
2685+
mUserActivityCounters[type].stepAtomic();
2686+
} else {
2687+
Slog.w(TAG, "Unknown user activity type " + type + " was specified.",
2688+
new Throwable());
2689+
}
26872690
}
26882691

26892692
@Override

0 commit comments

Comments
 (0)