OSDN Git Service

Fix issue #13095629: Device is in restart mode for long time...
authorDianne Hackborn <hackbod@google.com>
Wed, 19 Feb 2014 18:49:24 +0000 (10:49 -0800)
committerDianne Hackborn <hackbod@google.com>
Wed, 19 Feb 2014 18:49:24 +0000 (10:49 -0800)
...during taking OTA

Add some sanity checks.

Change-Id: I6bec1b8d8443c4b3c2a706635acf89c8e5051428

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

index 155f062..274e267 100644 (file)
@@ -23,6 +23,7 @@ import android.bluetooth.BluetoothHeadset;
 import android.content.Context;
 import android.net.ConnectivityManager;
 import android.net.NetworkStats;
+import android.os.BadParcelableException;
 import android.os.BatteryManager;
 import android.os.BatteryStats;
 import android.os.FileUtils;
@@ -86,7 +87,7 @@ public final class BatteryStatsImpl extends BatteryStats {
     private static final int MAGIC = 0xBA757475; // 'BATSTATS'
 
     // Current on-disk Parcel version
-    private static final int VERSION = 84 + (USE_OLD_HISTORY ? 1000 : 0);
+    private static final int VERSION = 85 + (USE_OLD_HISTORY ? 1000 : 0);
 
     // Maximum number of items we will record in the history.
     private static final int MAX_HISTORY_ITEMS = 2000;
@@ -6026,7 +6027,7 @@ public final class BatteryStatsImpl extends BatteryStats {
             stream.close();
 
             readSummaryFromParcel(in);
-        } catch(java.io.IOException e) {
+        } catch(Exception e) {
             Slog.e("BatteryStats", "Error reading battery statistics", e);
         }
 
@@ -6234,6 +6235,9 @@ public final class BatteryStatsImpl extends BatteryStats {
         }
 
         sNumSpeedSteps = in.readInt();
+        if (sNumSpeedSteps < 0 || sNumSpeedSteps > 100) {
+            throw new BadParcelableException("Bad speed steps in data: " + sNumSpeedSteps);
+        }
 
         final int NU = in.readInt();
         if (NU > 10000) {