• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.os.Bundle;
22 import android.util.ArrayMap;
23 import android.util.SparseIntArray;
24 
25 import com.android.settings.fuelgauge.batteryusage.PowerAnomalyEventList;
26 import com.android.settingslib.fuelgauge.Estimate;
27 
28 import java.util.List;
29 import java.util.Set;
30 
31 /**
32  * Feature Provider used in power usage
33  */
34 public interface PowerUsageFeatureProvider {
35 
36     /**
37      * Check whether the battery usage button is enabled in the battery page
38      */
isBatteryUsageEnabled()39     boolean isBatteryUsageEnabled();
40 
41     /**
42      * Check whether the battery tips card is enabled in the battery usage page
43      */
isBatteryTipsEnabled()44     boolean isBatteryTipsEnabled();
45 
46     /**
47      * Returns a threshold (in milliseconds) for the minimal screen on time in battery usage list
48      */
getBatteryUsageListScreenOnTimeThresholdInMs()49     double getBatteryUsageListScreenOnTimeThresholdInMs();
50 
51     /**
52      * Returns a threshold (mA) for the minimal comsume power in battery usage list
53      */
getBatteryUsageListConsumePowerThreshold()54     double getBatteryUsageListConsumePowerThreshold();
55 
56     /**
57      * Returns an allowlist of app names combined into the system-apps item
58      */
getSystemAppsAllowlist()59     List<String> getSystemAppsAllowlist();
60 
61     /**
62      * Check whether location setting is enabled
63      */
isLocationSettingEnabled(String[] packages)64     boolean isLocationSettingEnabled(String[] packages);
65 
66     /**
67      * Gets an {@link Intent} to show additional battery info
68      */
getAdditionalBatteryInfoIntent()69     Intent getAdditionalBatteryInfoIntent();
70 
71     /**
72      * Check whether it is type service
73      */
isTypeService(int uid)74     boolean isTypeService(int uid);
75 
76     /**
77      * Check whether it is type system
78      */
isTypeSystem(int uid, String[] packages)79     boolean isTypeSystem(int uid, String[] packages);
80 
81     /**
82      * Returns an improved prediction for battery time remaining
83      */
getEnhancedBatteryPrediction(Context context)84     Estimate getEnhancedBatteryPrediction(Context context);
85 
86     /**
87      * Returns an improved projection curve for future battery level
88      *
89      * @param zeroTime timestamps (array keys) are shifted by this amount
90      */
getEnhancedBatteryPredictionCurve(Context context, long zeroTime)91     SparseIntArray getEnhancedBatteryPredictionCurve(Context context, long zeroTime);
92 
93     /**
94      * Checks whether the toggle for enhanced battery predictions is enabled
95      */
isEnhancedBatteryPredictionEnabled(Context context)96     boolean isEnhancedBatteryPredictionEnabled(Context context);
97 
98     /**
99      * Checks whether debugging should be enabled for battery estimates
100      */
isEstimateDebugEnabled()101     boolean isEstimateDebugEnabled();
102 
103     /**
104      * Converts the provided string containing the remaining time into a debug string for enhanced
105      * estimates
106      *
107      * @return A string containing the estimate and a label indicating it is an enhanced estimate
108      */
getEnhancedEstimateDebugString(String timeRemaining)109     String getEnhancedEstimateDebugString(String timeRemaining);
110 
111     /**
112      * Converts the provided string containing the remaining time into a debug string
113      *
114      * @return A string containing the estimate and a label indicating it is a normal estimate
115      */
getOldEstimateDebugString(String timeRemaining)116     String getOldEstimateDebugString(String timeRemaining);
117 
118     /**
119      * Checks whether smart battery feature is supported in this device
120      */
isSmartBatterySupported()121     boolean isSmartBatterySupported();
122 
123     /**
124      * Checks whether we should show usage information by slots or not
125      */
isChartGraphSlotsEnabled(Context context)126     boolean isChartGraphSlotsEnabled(Context context);
127 
128     /**
129      * Returns {@code true} if current defender mode is extra defend
130      */
isExtraDefend()131     boolean isExtraDefend();
132 
133     /**
134      * Returns {@code true} if delay the hourly job when device is booting
135      */
delayHourlyJobWhenBooting()136     boolean delayHourlyJobWhenBooting();
137 
138     /**
139      * Insert settings configuration data for anomaly detection
140      */
insertSettingsData(Context context, double displayDrain)141     void insertSettingsData(Context context, double displayDrain);
142 
143     /**
144      * Returns {@link Bundle} for settings anomaly detection result
145      */
detectSettingsAnomaly(Context context, double displayDrain)146     PowerAnomalyEventList detectSettingsAnomaly(Context context, double displayDrain);
147 
148     /**
149      * Gets an intent for one time bypass charge limited to resume charging.
150      */
getResumeChargeIntent(boolean isDockDefender)151     Intent getResumeChargeIntent(boolean isDockDefender);
152 
153     /**
154      * Returns the intent action used to mark as the full charge start event.
155      */
getFullChargeIntentAction()156     String getFullChargeIntentAction();
157 
158     /**
159      * Returns {@link Set} for the system component ids which are combined into others
160      */
getOthersSystemComponentSet()161     Set<Integer> getOthersSystemComponentSet();
162 
163     /**
164      * Returns {@link Set} for the custom system component names which are combined into others
165      */
getOthersCustomComponentNameSet()166     Set<String> getOthersCustomComponentNameSet();
167 
168     /**
169      * Returns {@link Set} for hiding system component ids in the usage screen
170      */
getHideSystemComponentSet()171     Set<Integer> getHideSystemComponentSet();
172 
173     /**
174      * Returns {@link Set} for hiding application package names in the usage screen
175      */
getHideApplicationSet()176     Set<String> getHideApplicationSet();
177 
178     /**
179      * Returns {@link Set} for hiding applications background usage time
180      */
getHideBackgroundUsageTimeSet()181     Set<String> getHideBackgroundUsageTimeSet();
182 
183     /**
184      * Returns {@link Set} for ignoring task root class names for screen on time
185      */
getIgnoreScreenOnTimeTaskRootSet()186     Set<String> getIgnoreScreenOnTimeTaskRootSet();
187 
188     /**
189      * Returns the customized device build information for data backup
190      */
getBuildMetadata1(Context context)191     String getBuildMetadata1(Context context);
192 
193     /**
194      * Returns the customized device build information for data backup
195      */
getBuildMetadata2(Context context)196     String getBuildMetadata2(Context context);
197 
198     /**
199      * Whether the app optimization mode is valid to restore
200      */
isValidToRestoreOptimizationMode(ArrayMap<String, String> deviceInfoMap)201     boolean isValidToRestoreOptimizationMode(ArrayMap<String, String> deviceInfoMap);
202 }
203