1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings.fuelgauge.batterytip.tips; 18 19 import android.app.settings.SettingsEnums; 20 import android.content.Context; 21 import android.os.Parcel; 22 23 import com.android.settings.R; 24 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; 25 26 /** 27 * Tip to show current battery is overheated 28 */ 29 public class BatteryDefenderTip extends BatteryTip { 30 BatteryDefenderTip(@tateType int state)31 public BatteryDefenderTip(@StateType int state) { 32 super(TipType.BATTERY_DEFENDER, state, true /* showDialog */); 33 } 34 BatteryDefenderTip(Parcel in)35 private BatteryDefenderTip(Parcel in) { 36 super(in); 37 } 38 39 @Override getTitle(Context context)40 public CharSequence getTitle(Context context) { 41 return context.getString(R.string.battery_tip_limited_temporarily_title); 42 } 43 44 @Override getSummary(Context context)45 public CharSequence getSummary(Context context) { 46 return context.getString(R.string.battery_tip_limited_temporarily_summary); 47 } 48 49 @Override getIconId()50 public int getIconId() { 51 return R.drawable.ic_battery_status_good_24dp; 52 } 53 54 @Override updateState(BatteryTip tip)55 public void updateState(BatteryTip tip) { 56 mState = tip.mState; 57 } 58 59 @Override log(Context context, MetricsFeatureProvider metricsFeatureProvider)60 public void log(Context context, MetricsFeatureProvider metricsFeatureProvider) { 61 metricsFeatureProvider.action(context, SettingsEnums.ACTION_BATTERY_DEFENDER_TIP, 62 mState); 63 } 64 65 public static final Creator CREATOR = new Creator() { 66 public BatteryTip createFromParcel(Parcel in) { 67 return new BatteryDefenderTip(in); 68 } 69 70 public BatteryTip[] newArray(int size) { 71 return new BatteryDefenderTip[size]; 72 } 73 }; 74 75 } 76