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.util.SparseIntArray; 22 23 import com.android.internal.os.BatterySipper; 24 import com.android.settingslib.fuelgauge.Estimate; 25 26 import java.util.Map; 27 28 /** 29 * Feature Provider used in power usage 30 */ 31 public interface PowerUsageFeatureProvider { 32 33 /** 34 * Check whether location setting is enabled 35 */ isLocationSettingEnabled(String[] packages)36 boolean isLocationSettingEnabled(String[] packages); 37 38 /** 39 * Check whether additional battery info feature is enabled. 40 */ isAdditionalBatteryInfoEnabled()41 boolean isAdditionalBatteryInfoEnabled(); 42 43 /** 44 * Gets an {@link Intent} to show additional battery info. 45 */ getAdditionalBatteryInfoIntent()46 Intent getAdditionalBatteryInfoIntent(); 47 48 /** 49 * Check whether advanced ui is enabled 50 */ isAdvancedUiEnabled()51 boolean isAdvancedUiEnabled(); 52 53 /** 54 * Check whether it is type service 55 */ isTypeService(BatterySipper sipper)56 boolean isTypeService(BatterySipper sipper); 57 58 /** 59 * Check whether it is type system 60 */ isTypeSystem(BatterySipper sipper)61 boolean isTypeSystem(BatterySipper sipper); 62 63 /** 64 * Check whether it is type system 65 */ isTypeSystem(int uid, String[] packages)66 boolean isTypeSystem(int uid, String[] packages); 67 68 /** 69 * Check whether the toggle for power accounting is enabled 70 */ isPowerAccountingToggleEnabled()71 boolean isPowerAccountingToggleEnabled(); 72 73 /** 74 * Returns an improved prediction for battery time remaining. 75 */ getEnhancedBatteryPrediction(Context context)76 Estimate getEnhancedBatteryPrediction(Context context); 77 78 /** 79 * Returns an improved projection curve for future battery level. 80 * @param zeroTime timestamps (array keys) are shifted by this amount 81 */ getEnhancedBatteryPredictionCurve(Context context, long zeroTime)82 SparseIntArray getEnhancedBatteryPredictionCurve(Context context, long zeroTime); 83 84 /** 85 * Checks whether the toggle for enhanced battery predictions is enabled. 86 */ isEnhancedBatteryPredictionEnabled(Context context)87 boolean isEnhancedBatteryPredictionEnabled(Context context); 88 89 /** 90 * Checks whether debugging should be enabled for battery estimates. 91 * @return 92 */ isEstimateDebugEnabled()93 boolean isEstimateDebugEnabled(); 94 95 /** 96 * Converts the provided string containing the remaining time into a debug string for enhanced 97 * estimates. 98 * @param timeRemaining 99 * @return A string containing the estimate and a label indicating it is an enhanced estimate 100 */ getEnhancedEstimateDebugString(String timeRemaining)101 String getEnhancedEstimateDebugString(String timeRemaining); 102 103 /** 104 * Converts the provided string containing the remaining time into a debug string. 105 * @param timeRemaining 106 * @return A string containing the estimate and a label indicating it is a normal estimate 107 */ getOldEstimateDebugString(String timeRemaining)108 String getOldEstimateDebugString(String timeRemaining); 109 110 /** 111 * Returns the string to show in the advanced usage battery page when enhanced estimates are 112 * enabled. This string notifies users that the estimate is using enhanced prediction. 113 */ getAdvancedUsageScreenInfoString()114 String getAdvancedUsageScreenInfoString(); 115 116 /** 117 * Returns a signal to indicate if the device will need to warn the user they may not make it 118 * to their next charging time. 119 * 120 * @param id Optional string used to identify the caller for metrics. Usually the class name of 121 * the caller 122 */ getEarlyWarningSignal(Context context, String id)123 boolean getEarlyWarningSignal(Context context, String id); 124 125 /** 126 * Checks whether smart battery feature is supported in this device 127 */ isSmartBatterySupported()128 boolean isSmartBatterySupported(); 129 130 /** 131 * Checks whether we should enable chart graph design or not. 132 */ isChartGraphEnabled(Context context)133 boolean isChartGraphEnabled(Context context); 134 135 /** 136 * Checks whether we should show usage information by slots or not. 137 */ isChartGraphSlotsEnabled(Context context)138 boolean isChartGraphSlotsEnabled(Context context); 139 140 /** 141 * Returns battery history data with corresponding timestamp key. 142 */ getBatteryHistory(Context context)143 Map<Long, Map<String, BatteryHistEntry>> getBatteryHistory(Context context); 144 } 145