Fix NullPointerException in BatteryUsageStats
Bug: 185287730 Test: Build and launch Settings on a crosshatch Change-Id: Iccdd8a0f3839b98dbb5c09599f35ac15985daa4c
This commit is contained in:
@@ -24,7 +24,6 @@ import com.android.internal.os.BatteryStatsHistory;
|
||||
import com.android.internal.os.BatteryStatsHistoryIterator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -233,8 +232,6 @@ public final class BatteryUsageStats implements Parcelable {
|
||||
mHistoryBuffer = null;
|
||||
mHistoryTagPool = null;
|
||||
}
|
||||
System.out.println("From Parcel = " + Arrays.toString(
|
||||
mCustomPowerComponentNames));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -293,6 +290,7 @@ public final class BatteryUsageStats implements Parcelable {
|
||||
* Builder for BatteryUsageStats.
|
||||
*/
|
||||
public static final class Builder {
|
||||
@NonNull
|
||||
private final String[] mCustomPowerComponentNames;
|
||||
private final int mCustomTimeComponentCount;
|
||||
private final boolean mIncludePowerModels;
|
||||
@@ -311,11 +309,11 @@ public final class BatteryUsageStats implements Parcelable {
|
||||
private Parcel mHistoryBuffer;
|
||||
private List<BatteryStats.HistoryTag> mHistoryTagPool;
|
||||
|
||||
public Builder(String[] customPowerComponentNames, int customTimeComponentCount) {
|
||||
public Builder(@NonNull String[] customPowerComponentNames, int customTimeComponentCount) {
|
||||
this(customPowerComponentNames, customTimeComponentCount, false);
|
||||
}
|
||||
|
||||
public Builder(String[] customPowerComponentNames, int customTimeComponentCount,
|
||||
public Builder(@NonNull String[] customPowerComponentNames, int customTimeComponentCount,
|
||||
boolean includePowerModels) {
|
||||
mCustomPowerComponentNames = customPowerComponentNames;
|
||||
mCustomTimeComponentCount = customTimeComponentCount;
|
||||
|
||||
@@ -6951,9 +6951,9 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
/**
|
||||
* Returns the names of custom power components.
|
||||
*/
|
||||
public @Nullable String[] getCustomPowerComponentNames() {
|
||||
public @NonNull String[] getCustomPowerComponentNames() {
|
||||
if (mGlobalMeasuredEnergyStats == null) {
|
||||
return null;
|
||||
return new String[0];
|
||||
}
|
||||
final String[] names = mGlobalMeasuredEnergyStats.getCustomBucketNames();
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user