1 /* 2 * Copyright (C) 2022 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; 18 19 import android.content.Context; 20 import android.content.Intent; 21 import android.net.Uri; 22 import android.util.SparseIntArray; 23 24 import com.android.settings.fuelgauge.batteryusage.BatteryHistEntry; 25 import com.android.settingslib.fuelgauge.Estimate; 26 27 import java.util.Map; 28 import java.util.Set; 29 30 /** 31 * Feature Provider used in power usage 32 */ 33 public interface PowerUsageFeatureProvider { 34 35 /** 36 * Check whether location setting is enabled 37 */ isLocationSettingEnabled(String[] packages)38 boolean isLocationSettingEnabled(String[] packages); 39 40 /** 41 * Check whether additional battery info feature is enabled. 42 */ isAdditionalBatteryInfoEnabled()43 boolean isAdditionalBatteryInfoEnabled(); 44 45 /** 46 * Gets an {@link Intent} to show additional battery info. 47 */ getAdditionalBatteryInfoIntent()48 Intent getAdditionalBatteryInfoIntent(); 49 50 /** 51 * Check whether advanced ui is enabled 52 */ isAdvancedUiEnabled()53 boolean isAdvancedUiEnabled(); 54 55 /** 56 * Check whether it is type service 57 */ isTypeService(int uid)58 boolean isTypeService(int uid); 59 60 /** 61 * Check whether it is type system 62 */ isTypeSystem(int uid, String[] packages)63 boolean isTypeSystem(int uid, String[] packages); 64 65 /** 66 * Check whether the toggle for power accounting is enabled 67 */ isPowerAccountingToggleEnabled()68 boolean isPowerAccountingToggleEnabled(); 69 70 /** 71 * Returns an improved prediction for battery time remaining. 72 */ getEnhancedBatteryPrediction(Context context)73 Estimate getEnhancedBatteryPrediction(Context context); 74 75 /** 76 * Returns an improved projection curve for future battery level. 77 * 78 * @param zeroTime timestamps (array keys) are shifted by this amount 79 */ getEnhancedBatteryPredictionCurve(Context context, long zeroTime)80 SparseIntArray getEnhancedBatteryPredictionCurve(Context context, long zeroTime); 81 82 /** 83 * Checks whether the toggle for enhanced battery predictions is enabled. 84 */ isEnhancedBatteryPredictionEnabled(Context context)85 boolean isEnhancedBatteryPredictionEnabled(Context context); 86 87 /** 88 * Checks whether debugging should be enabled for battery estimates. 89 */ isEstimateDebugEnabled()90 boolean isEstimateDebugEnabled(); 91 92 /** 93 * Converts the provided string containing the remaining time into a debug string for enhanced 94 * estimates. 95 * 96 * @return A string containing the estimate and a label indicating it is an enhanced estimate 97 */ getEnhancedEstimateDebugString(String timeRemaining)98 String getEnhancedEstimateDebugString(String timeRemaining); 99 100 /** 101 * Converts the provided string containing the remaining time into a debug string. 102 * 103 * @return A string containing the estimate and a label indicating it is a normal estimate 104 */ getOldEstimateDebugString(String timeRemaining)105 String getOldEstimateDebugString(String timeRemaining); 106 107 /** 108 * Returns the string to show in the advanced usage battery page when enhanced estimates are 109 * enabled. This string notifies users that the estimate is using enhanced prediction. 110 */ getAdvancedUsageScreenInfoString()111 String getAdvancedUsageScreenInfoString(); 112 113 /** 114 * Returns a signal to indicate if the device will need to warn the user they may not make it 115 * to their next charging time. 116 * 117 * @param id Optional string used to identify the caller for metrics. Usually the class name of 118 * the caller 119 */ getEarlyWarningSignal(Context context, String id)120 boolean getEarlyWarningSignal(Context context, String id); 121 122 /** 123 * Checks whether smart battery feature is supported in this device 124 */ isSmartBatterySupported()125 boolean isSmartBatterySupported(); 126 127 /** 128 * Checks whether we should enable chart graph design or not. 129 */ isChartGraphEnabled(Context context)130 boolean isChartGraphEnabled(Context context); 131 132 /** 133 * Checks whether we should show usage information by slots or not. 134 */ isChartGraphSlotsEnabled(Context context)135 boolean isChartGraphSlotsEnabled(Context context); 136 137 /** 138 * Checks whether adaptive charging feature is supported in this device 139 */ isAdaptiveChargingSupported()140 boolean isAdaptiveChargingSupported(); 141 142 /** 143 * Returns {@code true} if current defender mode is extra defend 144 */ isExtraDefend()145 boolean isExtraDefend(); 146 147 /** 148 * Gets a intent for one time bypass charge limited to resume charging. 149 */ getResumeChargeIntent(boolean isDockDefender)150 Intent getResumeChargeIntent(boolean isDockDefender); 151 152 /** 153 * Returns battery history data with corresponding timestamp key. 154 */ getBatteryHistory(Context context)155 Map<Long, Map<String, BatteryHistEntry>> getBatteryHistory(Context context); 156 157 /** 158 * Returns battery history data since last full charge with corresponding timestamp key. 159 */ getBatteryHistorySinceLastFullCharge(Context context)160 Map<Long, Map<String, BatteryHistEntry>> getBatteryHistorySinceLastFullCharge(Context context); 161 162 /** 163 * Returns {@link Uri} to monitor battery history data is update. 164 */ getBatteryHistoryUri()165 Uri getBatteryHistoryUri(); 166 167 /** 168 * Returns {@link Set} for hidding applications background usage time. 169 */ getHideBackgroundUsageTimeSet(Context context)170 Set<CharSequence> getHideBackgroundUsageTimeSet(Context context); 171 172 /** 173 * Returns package names for hidding application in the usage screen. 174 */ getHideApplicationEntries(Context context)175 CharSequence[] getHideApplicationEntries(Context context); 176 177 /** 178 * Returns package names for hidding summary in the usage screen. 179 */ getHideApplicationSummary(Context context)180 CharSequence[] getHideApplicationSummary(Context context); 181 } 182