Merge "Add try-catch to avoid IllegalStateException in the data parsing" into sc-v2-dev am: f438abe0d9
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/16038010 Change-Id: Ifbb0ea168a7f099ebaed0c20aa9b8ab1cf1c3dbd
This commit is contained in:
@@ -21,6 +21,7 @@ import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.BatteryUsageStats;
|
import android.os.BatteryUsageStats;
|
||||||
import android.os.UidBatteryConsumer;
|
import android.os.UidBatteryConsumer;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
@@ -41,6 +42,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* {@link BatteryTipDetector} since it need the most up-to-date {@code visibleTips}
|
* {@link BatteryTipDetector} since it need the most up-to-date {@code visibleTips}
|
||||||
*/
|
*/
|
||||||
public class HighUsageDetector implements BatteryTipDetector {
|
public class HighUsageDetector implements BatteryTipDetector {
|
||||||
|
private static final String TAG = "HighUsageDetector";
|
||||||
|
|
||||||
private BatteryTipPolicy mPolicy;
|
private BatteryTipPolicy mPolicy;
|
||||||
private BatteryUsageStats mBatteryUsageStats;
|
private BatteryUsageStats mBatteryUsageStats;
|
||||||
private final BatteryInfo mBatteryInfo;
|
private final BatteryInfo mBatteryInfo;
|
||||||
@@ -113,6 +116,10 @@ public class HighUsageDetector implements BatteryTipDetector {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void parseBatteryData() {
|
void parseBatteryData() {
|
||||||
mBatteryInfo.parseBatteryHistory(mDataParser);
|
try {
|
||||||
|
mBatteryInfo.parseBatteryHistory(mDataParser);
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
Log.e(TAG, "parseBatteryData() failed", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user