Merge "Add protection for the BadParcelableException" into udc-dev am: 54f39ec271
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/23279576 Change-Id: Idd3c88bc1eb26817f3ee19046c75dd2459744fc1 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -18,7 +18,9 @@ package com.android.settings.fuelgauge.batterytip;
|
|||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.BadParcelableException;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
@@ -142,14 +144,26 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void restoreInstanceState(Bundle bundle) {
|
public void restoreInstanceState(Bundle bundle) {
|
||||||
if (bundle != null) {
|
if (bundle == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
List<BatteryTip> batteryTips = bundle.getParcelableArrayList(KEY_BATTERY_TIPS);
|
List<BatteryTip> batteryTips = bundle.getParcelableArrayList(KEY_BATTERY_TIPS);
|
||||||
updateBatteryTips(batteryTips);
|
updateBatteryTips(batteryTips);
|
||||||
|
} catch (BadParcelableException e) {
|
||||||
|
Log.e(TAG, "failed to invoke restoreInstanceState()", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveInstanceState(Bundle outState) {
|
public void saveInstanceState(Bundle bundle) {
|
||||||
outState.putParcelableList(KEY_BATTERY_TIPS, mBatteryTips);
|
if (bundle == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
bundle.putParcelableList(KEY_BATTERY_TIPS, mBatteryTips);
|
||||||
|
} catch (BadParcelableException e) {
|
||||||
|
Log.e(TAG, "failed to invoke saveInstanceState()", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean needUpdate() {
|
public boolean needUpdate() {
|
||||||
|
Reference in New Issue
Block a user