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