1 /* 2 * Copyright (C) 2016 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.internal.os.BatterySipper; 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(BatterySipper sipper)58 boolean isTypeService(BatterySipper sipper); 59 60 /** 61 * Check whether it is type system 62 */ isTypeSystem(BatterySipper sipper)63 boolean isTypeSystem(BatterySipper sipper); 64 65 /** 66 * Check whether it is type system 67 */ isTypeSystem(int uid, String[] packages)68 boolean isTypeSystem(int uid, String[] packages); 69 70 /** 71 * Check whether the toggle for power accounting is enabled 72 */ isPowerAccountingToggleEnabled()73 boolean isPowerAccountingToggleEnabled(); 74 75 /** 76 * Returns an improved prediction for battery time remaining. 77 */ getEnhancedBatteryPrediction(Context context)78 Estimate getEnhancedBatteryPrediction(Context context); 79 80 /** 81 * Returns an improved projection curve for future battery level. 82 * @param zeroTime timestamps (array keys) are shifted by this amount 83 */ getEnhancedBatteryPredictionCurve(Context context, long zeroTime)84 SparseIntArray getEnhancedBatteryPredictionCurve(Context context, long zeroTime); 85 86 /** 87 * Checks whether the toggle for enhanced battery predictions is enabled. 88 */ isEnhancedBatteryPredictionEnabled(Context context)89 boolean isEnhancedBatteryPredictionEnabled(Context context); 90 91 /** 92 * Checks whether debugging should be enabled for battery estimates. 93 * @return 94 */ isEstimateDebugEnabled()95 boolean isEstimateDebugEnabled(); 96 97 /** 98 * Converts the provided string containing the remaining time into a debug string for enhanced 99 * estimates. 100 * @param timeRemaining 101 * @return A string containing the estimate and a label indicating it is an enhanced estimate 102 */ getEnhancedEstimateDebugString(String timeRemaining)103 String getEnhancedEstimateDebugString(String timeRemaining); 104 105 /** 106 * Converts the provided string containing the remaining time into a debug string. 107 * @param timeRemaining 108 * @return A string containing the estimate and a label indicating it is a normal estimate 109 */ getOldEstimateDebugString(String timeRemaining)110 String getOldEstimateDebugString(String timeRemaining); 111 112 /** 113 * Returns the string to show in the advanced usage battery page when enhanced estimates are 114 * enabled. This string notifies users that the estimate is using enhanced prediction. 115 */ getAdvancedUsageScreenInfoString()116 String getAdvancedUsageScreenInfoString(); 117 118 /** 119 * Returns a signal to indicate if the device will need to warn the user they may not make it 120 * to their next charging time. 121 * 122 * @param id Optional string used to identify the caller for metrics. Usually the class name of 123 * the caller 124 */ getEarlyWarningSignal(Context context, String id)125 boolean getEarlyWarningSignal(Context context, String id); 126 127 /** 128 * Checks whether smart battery feature is supported in this device 129 */ isSmartBatterySupported()130 boolean isSmartBatterySupported(); 131 132 /** 133 * Checks whether we should enable chart graph design or not. 134 */ isChartGraphEnabled(Context context)135 boolean isChartGraphEnabled(Context context); 136 137 /** 138 * Checks whether we should show usage information by slots or not. 139 */ isChartGraphSlotsEnabled(Context context)140 boolean isChartGraphSlotsEnabled(Context context); 141 142 /** 143 * Checks whether adaptive charging feature is supported in this device 144 */ isAdaptiveChargingSupported()145 boolean isAdaptiveChargingSupported(); 146 147 /** 148 * Gets a intent for one time bypass charge limited to resume charging. 149 */ getResumeChargeIntent()150 Intent getResumeChargeIntent(); 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 {@link Uri} to monitor battery history data is update. 159 */ getBatteryHistoryUri()160 Uri getBatteryHistoryUri(); 161 162 /** 163 * Returns {@link Set} for hidding applications background usage time. 164 */ getHideBackgroundUsageTimeSet(Context context)165 Set<CharSequence> getHideBackgroundUsageTimeSet(Context context); 166 167 /** 168 * Returns package names for hidding application in the usage screen. 169 */ getHideApplicationEntries(Context context)170 CharSequence[] getHideApplicationEntries(Context context); 171 172 /** 173 * Returns package names for hidding summary in the usage screen. 174 */ getHideApplicationSummary(Context context)175 CharSequence[] getHideApplicationSummary(Context context); 176 } 177