Add battery warning TipType
Bug: 309054332 Test: rebuild Change-Id: Ib7f95eb14aac7ac6d6a0941ea40a9eb723fa9300
This commit is contained in:
@@ -39,9 +39,11 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
* pre-defined action(e.g. turn on battery saver)
|
* pre-defined action(e.g. turn on battery saver)
|
||||||
*/
|
*/
|
||||||
public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
|
public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
|
||||||
|
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@IntDef({StateType.NEW, StateType.HANDLED, StateType.INVISIBLE})
|
@IntDef({StateType.NEW, StateType.HANDLED, StateType.INVISIBLE})
|
||||||
public @interface StateType {
|
public @interface StateType {
|
||||||
|
|
||||||
int NEW = 0;
|
int NEW = 0;
|
||||||
int HANDLED = 1;
|
int HANDLED = 1;
|
||||||
int INVISIBLE = 2;
|
int INVISIBLE = 2;
|
||||||
@@ -59,7 +61,8 @@ public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
|
|||||||
TipType.REMOVE_APP_RESTRICTION,
|
TipType.REMOVE_APP_RESTRICTION,
|
||||||
TipType.BATTERY_DEFENDER,
|
TipType.BATTERY_DEFENDER,
|
||||||
TipType.DOCK_DEFENDER,
|
TipType.DOCK_DEFENDER,
|
||||||
TipType.INCOMPATIBLE_CHARGER
|
TipType.INCOMPATIBLE_CHARGER,
|
||||||
|
TipType.BATTERY_WARNING
|
||||||
})
|
})
|
||||||
public @interface TipType {
|
public @interface TipType {
|
||||||
int SMART_BATTERY_MANAGER = 0;
|
int SMART_BATTERY_MANAGER = 0;
|
||||||
@@ -73,6 +76,7 @@ public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
|
|||||||
int BATTERY_DEFENDER = 8;
|
int BATTERY_DEFENDER = 8;
|
||||||
int DOCK_DEFENDER = 9;
|
int DOCK_DEFENDER = 9;
|
||||||
int INCOMPATIBLE_CHARGER = 10;
|
int INCOMPATIBLE_CHARGER = 10;
|
||||||
|
int BATTERY_WARNING = 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting static final SparseIntArray TIP_ORDER;
|
@VisibleForTesting static final SparseIntArray TIP_ORDER;
|
||||||
@@ -90,25 +94,26 @@ public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
|
|||||||
TIP_ORDER.append(TipType.SMART_BATTERY_MANAGER, 8);
|
TIP_ORDER.append(TipType.SMART_BATTERY_MANAGER, 8);
|
||||||
TIP_ORDER.append(TipType.REDUCED_BATTERY, 9);
|
TIP_ORDER.append(TipType.REDUCED_BATTERY, 9);
|
||||||
TIP_ORDER.append(TipType.REMOVE_APP_RESTRICTION, 10);
|
TIP_ORDER.append(TipType.REMOVE_APP_RESTRICTION, 10);
|
||||||
|
TIP_ORDER.append(TipType.BATTERY_WARNING, 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String KEY_PREFIX = "key_battery_tip";
|
private static final String KEY_PREFIX = "key_battery_tip";
|
||||||
|
|
||||||
protected int mType;
|
|
||||||
protected int mState;
|
protected int mState;
|
||||||
|
protected int mType;
|
||||||
protected boolean mShowDialog;
|
protected boolean mShowDialog;
|
||||||
|
|
||||||
/** Whether we need to update battery tip when configuration change */
|
/** Whether we need to update battery tip when configuration change */
|
||||||
protected boolean mNeedUpdate;
|
protected boolean mNeedUpdate;
|
||||||
|
|
||||||
BatteryTip(Parcel in) {
|
public BatteryTip(Parcel in) {
|
||||||
mType = in.readInt();
|
mType = in.readInt();
|
||||||
mState = in.readInt();
|
mState = in.readInt();
|
||||||
mShowDialog = in.readBoolean();
|
mShowDialog = in.readBoolean();
|
||||||
mNeedUpdate = in.readBoolean();
|
mNeedUpdate = in.readBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
BatteryTip(int type, int state, boolean showDialog) {
|
public BatteryTip(int type, int state, boolean showDialog) {
|
||||||
mType = type;
|
mType = type;
|
||||||
mState = state;
|
mState = state;
|
||||||
mShowDialog = showDialog;
|
mShowDialog = showDialog;
|
||||||
@@ -201,7 +206,7 @@ public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
|
|||||||
return "type=" + mType + " state=" + mState;
|
return "type=" + mType + " state=" + mState;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardPreference castToCardPreferenceSafely(Preference preference) {
|
public CardPreference castToCardPreferenceSafely(Preference preference) {
|
||||||
return preference instanceof CardPreference ? (CardPreference) preference : null;
|
return preference instanceof CardPreference ? (CardPreference) preference : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user