1 /* 2 * Copyright (C) 2018 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 suggest turn on smart battery if it is not on 28 */ 29 public class SmartBatteryTip extends BatteryTip { 30 SmartBatteryTip(@tateType int state)31 public SmartBatteryTip(@StateType int state) { 32 super(TipType.SMART_BATTERY_MANAGER, state, false /* showDialog */); 33 } 34 SmartBatteryTip(Parcel in)35 private SmartBatteryTip(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_smart_battery_title); 42 } 43 44 @Override getSummary(Context context)45 public CharSequence getSummary(Context context) { 46 return context.getString(R.string.battery_tip_smart_battery_summary); 47 } 48 49 @Override getIconId()50 public int getIconId() { 51 return R.drawable.ic_perm_device_information_red_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_SMART_BATTERY_TIP, 62 mState); 63 } 64 65 public static final Creator CREATOR = new Creator() { 66 public BatteryTip createFromParcel(Parcel in) { 67 return new SmartBatteryTip(in); 68 } 69 70 public BatteryTip[] newArray(int size) { 71 return new SmartBatteryTip[size]; 72 } 73 }; 74 75 } 76