1/* 2 * Copyright (C) 2017 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 17package android.hardware.health@2.0; 18 19import @1.0::BatteryStatus; 20 21import IHealthInfoCallback; 22 23/** 24 * IHealth manages health info and posts events on registered callbacks. 25 */ 26interface IHealth { 27 28 /** 29 * Register a callback for any health info events. 30 * 31 * Registering a new callback must not unregister the old one; the old 32 * callback remains registered until one of the following happens: 33 * - A client explicitly calls {@link unregisterCallback} to unregister it. 34 * - The client process that hosts the callback dies. 35 * 36 * @param callback the callback to register. 37 * @return result SUCCESS if successful, 38 * UNKNOWN for other errors. 39 */ 40 registerCallback(IHealthInfoCallback callback) generates (Result result); 41 42 /** 43 * Explicitly unregister a callback that is previously registered through 44 * {@link registerCallback}. 45 * 46 * @param callback the callback to unregister 47 * @return result SUCCESS if successful, 48 * NOT_FOUND if callback is not registered previously, 49 * UNKNOWN for other errors. 50 */ 51 unregisterCallback(IHealthInfoCallback callback) generates (Result result); 52 53 /** 54 * Schedule update. 55 * 56 * When update() is called, the service must notify all registered callbacks 57 * with the most recent health info. 58 * 59 * @return result SUCCESS if successful, 60 * CALLBACK_DIED if any registered callback is dead, 61 * UNKNOWN for other errors. 62 */ 63 update() generates (Result result); 64 65 /** 66 * Get battery capacity in microampere-hours(µAh). 67 * 68 * @return result SUCCESS if successful, 69 * NOT_SUPPORTED if this property is not supported 70 * (e.g. the file that stores this property does not exist), 71 * UNKNOWN for other errors. 72 * @return value battery capacity, or 0 if not successful. 73 */ 74 getChargeCounter() generates (Result result, int32_t value); 75 76 /** 77 * Get instantaneous battery current in microamperes(µA). 78 * 79 * Positive values indicate net current entering the battery from a charge 80 * source, negative values indicate net current discharging from the 81 * battery. 82 * 83 * @return result SUCCESS if successful, 84 * NOT_SUPPORTED if this property is not supported 85 * (e.g. the file that stores this property does not exist), 86 * UNKNOWN for other errors. 87 * @return value instantaneous battery current, or 0 if not 88 * successful. 89 */ 90 getCurrentNow() generates (Result result, int32_t value); 91 92 /** 93 * Get average battery current in microamperes(µA). 94 * 95 * Positive values indicate net current entering the battery from a charge 96 * source, negative values indicate net current discharging from the 97 * battery. The time period over which the average is computed may depend on 98 * the fuel gauge hardware and its configuration. 99 * 100 * @return result SUCCESS if successful, 101 * NOT_SUPPORTED if this property is not supported 102 * (e.g. the file that stores this property does not exist), 103 * UNKNOWN for other errors. 104 * @return value average battery current, or 0 if not successful. 105 */ 106 getCurrentAverage() generates (Result result, int32_t value); 107 108 /** 109 * Get remaining battery capacity percentage of total capacity 110 * (with no fractional part). 111 * 112 * @return result SUCCESS if successful, 113 * NOT_SUPPORTED if this property is not supported 114 * (e.g. the file that stores this property does not exist), 115 * UNKNOWN for other errors. 116 * @return value remaining battery capacity, or 0 if not successful. 117 */ 118 getCapacity() generates (Result result, int32_t value); 119 120 /** 121 * Get battery remaining energy in nanowatt-hours. 122 * 123 * @return result SUCCESS if successful, 124 * NOT_SUPPORTED if this property is not supported, 125 * UNKNOWN for other errors. 126 * @return value remaining energy, or 0 if not successful. 127 */ 128 getEnergyCounter() generates (Result result, int64_t value); 129 130 /** 131 * Get battery charge status. 132 * 133 * @return result SUCCESS if successful, 134 * NOT_SUPPORTED if this property is not supported 135 * (e.g. the file that stores this property does not exist), 136 * UNKNOWN other errors. 137 * @return value charge status, or UNKNOWN if not successful. 138 */ 139 getChargeStatus() generates (Result result, BatteryStatus value); 140 141 /** 142 * Get storage info. 143 * 144 * @return result SUCCESS if successful, 145 * NOT_SUPPORTED if this property is not supported, 146 * UNKNOWN other errors. 147 * @return value vector of StorageInfo structs, to be ignored if result is not 148 * SUCCESS. 149 */ 150 getStorageInfo() generates (Result result, vec<StorageInfo> value); 151 152 /** 153 * Gets disk statistics (number of reads/writes processed, number of I/O 154 * operations in flight etc). 155 * 156 * @return result SUCCESS if successful, 157 * NOT_SUPPORTED if this property is not supported, 158 * UNKNOWN other errors. 159 * @return value vector of disk statistics, to be ignored if result is not SUCCESS. 160 * The mapping is index 0->sda, 1->sdb and so on. 161 */ 162 getDiskStats() generates (Result result, vec<DiskStats> value); 163 164 /** 165 * Get Health Information. 166 * 167 * @return result SUCCESS if successful, 168 * NOT_SUPPORTED if this API is not supported, 169 * UNKNOWN for other errors. 170 * @return value Health information, to be ignored if result is not 171 * SUCCESS. 172 */ 173 getHealthInfo() generates (Result result, @2.0::HealthInfo value); 174}; 175