1e889fec6ce208965ed895907a629110ea081526cYifan Hong/*
2e889fec6ce208965ed895907a629110ea081526cYifan Hong * Copyright (C) 2017 The Android Open Source Project
3e889fec6ce208965ed895907a629110ea081526cYifan Hong *
4e889fec6ce208965ed895907a629110ea081526cYifan Hong * Licensed under the Apache License, Version 2.0 (the "License");
5e889fec6ce208965ed895907a629110ea081526cYifan Hong * you may not use this file except in compliance with the License.
6e889fec6ce208965ed895907a629110ea081526cYifan Hong * You may obtain a copy of the License at
7e889fec6ce208965ed895907a629110ea081526cYifan Hong *
8e889fec6ce208965ed895907a629110ea081526cYifan Hong *      http://www.apache.org/licenses/LICENSE-2.0
9e889fec6ce208965ed895907a629110ea081526cYifan Hong *
10e889fec6ce208965ed895907a629110ea081526cYifan Hong * Unless required by applicable law or agreed to in writing, software
11e889fec6ce208965ed895907a629110ea081526cYifan Hong * distributed under the License is distributed on an "AS IS" BASIS,
12e889fec6ce208965ed895907a629110ea081526cYifan Hong * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13e889fec6ce208965ed895907a629110ea081526cYifan Hong * See the License for the specific language governing permissions and
14e889fec6ce208965ed895907a629110ea081526cYifan Hong * limitations under the License.
15e889fec6ce208965ed895907a629110ea081526cYifan Hong */
16e889fec6ce208965ed895907a629110ea081526cYifan Hong
17e889fec6ce208965ed895907a629110ea081526cYifan Hongpackage android.hardware.health@2.0;
18e889fec6ce208965ed895907a629110ea081526cYifan Hong
19e889fec6ce208965ed895907a629110ea081526cYifan Hongimport @1.0::BatteryStatus;
20e889fec6ce208965ed895907a629110ea081526cYifan Hong
21e889fec6ce208965ed895907a629110ea081526cYifan Hongimport IHealthInfoCallback;
22e889fec6ce208965ed895907a629110ea081526cYifan Hong
23e889fec6ce208965ed895907a629110ea081526cYifan Hong/**
24e889fec6ce208965ed895907a629110ea081526cYifan Hong * IHealth manages health info and posts events on registered callbacks.
25e889fec6ce208965ed895907a629110ea081526cYifan Hong */
26e889fec6ce208965ed895907a629110ea081526cYifan Honginterface IHealth {
27e889fec6ce208965ed895907a629110ea081526cYifan Hong
28e889fec6ce208965ed895907a629110ea081526cYifan Hong    /**
29e889fec6ce208965ed895907a629110ea081526cYifan Hong     * Register a callback for any health info events.
30e889fec6ce208965ed895907a629110ea081526cYifan Hong     *
31e889fec6ce208965ed895907a629110ea081526cYifan Hong     * Registering a new callback must not unregister the old one; the old
32e889fec6ce208965ed895907a629110ea081526cYifan Hong     * callback remains registered until one of the following happens:
33e889fec6ce208965ed895907a629110ea081526cYifan Hong     * - A client explicitly calls {@link unregisterCallback} to unregister it.
34e889fec6ce208965ed895907a629110ea081526cYifan Hong     * - The client process that hosts the callback dies.
35e889fec6ce208965ed895907a629110ea081526cYifan Hong     *
36e889fec6ce208965ed895907a629110ea081526cYifan Hong     * @param callback the callback to register.
37e889fec6ce208965ed895907a629110ea081526cYifan Hong     * @return result SUCCESS if successful,
38e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                UNKNOWN for other errors.
39e889fec6ce208965ed895907a629110ea081526cYifan Hong     */
40e889fec6ce208965ed895907a629110ea081526cYifan Hong    registerCallback(IHealthInfoCallback callback) generates (Result result);
41e889fec6ce208965ed895907a629110ea081526cYifan Hong
42e889fec6ce208965ed895907a629110ea081526cYifan Hong    /**
43e889fec6ce208965ed895907a629110ea081526cYifan Hong     * Explicitly unregister a callback that is previously registered through
44e889fec6ce208965ed895907a629110ea081526cYifan Hong     * {@link registerCallback}.
45e889fec6ce208965ed895907a629110ea081526cYifan Hong     *
46e889fec6ce208965ed895907a629110ea081526cYifan Hong     * @param callback the callback to unregister
47e889fec6ce208965ed895907a629110ea081526cYifan Hong     * @return result SUCCESS if successful,
48e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                NOT_FOUND if callback is not registered previously,
49e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                UNKNOWN for other errors.
50e889fec6ce208965ed895907a629110ea081526cYifan Hong     */
51e889fec6ce208965ed895907a629110ea081526cYifan Hong    unregisterCallback(IHealthInfoCallback callback) generates (Result result);
52e889fec6ce208965ed895907a629110ea081526cYifan Hong
53e889fec6ce208965ed895907a629110ea081526cYifan Hong    /**
54e889fec6ce208965ed895907a629110ea081526cYifan Hong     * Schedule update.
55e889fec6ce208965ed895907a629110ea081526cYifan Hong     *
56e889fec6ce208965ed895907a629110ea081526cYifan Hong     * When update() is called, the service must notify all registered callbacks
57e889fec6ce208965ed895907a629110ea081526cYifan Hong     * with the most recent health info.
58e889fec6ce208965ed895907a629110ea081526cYifan Hong     *
59e889fec6ce208965ed895907a629110ea081526cYifan Hong     * @return result SUCCESS if successful,
60e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                CALLBACK_DIED if any registered callback is dead,
61e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                UNKNOWN for other errors.
62e889fec6ce208965ed895907a629110ea081526cYifan Hong     */
63e889fec6ce208965ed895907a629110ea081526cYifan Hong    update() generates (Result result);
64e889fec6ce208965ed895907a629110ea081526cYifan Hong
65e889fec6ce208965ed895907a629110ea081526cYifan Hong    /**
66e889fec6ce208965ed895907a629110ea081526cYifan Hong     * Get battery capacity in microampere-hours(µAh).
67e889fec6ce208965ed895907a629110ea081526cYifan Hong     *
68e889fec6ce208965ed895907a629110ea081526cYifan Hong     * @return result SUCCESS if successful,
69e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                NOT_SUPPORTED if this property is not supported
70e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                 (e.g. the file that stores this property does not exist),
71e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                UNKNOWN for other errors.
7281874af4a117cd25559f438f1c580d27253058baYifan Hong     * @return value battery capacity, or 0 if not successful.
73e889fec6ce208965ed895907a629110ea081526cYifan Hong     */
74e889fec6ce208965ed895907a629110ea081526cYifan Hong    getChargeCounter() generates (Result result, int32_t value);
75e889fec6ce208965ed895907a629110ea081526cYifan Hong
76e889fec6ce208965ed895907a629110ea081526cYifan Hong    /**
77e889fec6ce208965ed895907a629110ea081526cYifan Hong     * Get instantaneous battery current in microamperes(µA).
78e889fec6ce208965ed895907a629110ea081526cYifan Hong     *
79e889fec6ce208965ed895907a629110ea081526cYifan Hong     * Positive values indicate net current entering the battery from a charge
80e889fec6ce208965ed895907a629110ea081526cYifan Hong     * source, negative values indicate net current discharging from the
81e889fec6ce208965ed895907a629110ea081526cYifan Hong     * battery.
82e889fec6ce208965ed895907a629110ea081526cYifan Hong     *
83e889fec6ce208965ed895907a629110ea081526cYifan Hong     * @return result SUCCESS if successful,
84e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                NOT_SUPPORTED if this property is not supported
85e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                 (e.g. the file that stores this property does not exist),
86e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                UNKNOWN for other errors.
8781874af4a117cd25559f438f1c580d27253058baYifan Hong     * @return value instantaneous battery current, or 0 if not
88e889fec6ce208965ed895907a629110ea081526cYifan Hong     *               successful.
89e889fec6ce208965ed895907a629110ea081526cYifan Hong     */
90e889fec6ce208965ed895907a629110ea081526cYifan Hong    getCurrentNow() generates (Result result, int32_t value);
91e889fec6ce208965ed895907a629110ea081526cYifan Hong
92e889fec6ce208965ed895907a629110ea081526cYifan Hong    /**
93e889fec6ce208965ed895907a629110ea081526cYifan Hong     * Get average battery current in microamperes(µA).
94e889fec6ce208965ed895907a629110ea081526cYifan Hong     *
95e889fec6ce208965ed895907a629110ea081526cYifan Hong     * Positive values indicate net current entering the battery from a charge
96e889fec6ce208965ed895907a629110ea081526cYifan Hong     * source, negative values indicate net current discharging from the
97e889fec6ce208965ed895907a629110ea081526cYifan Hong     * battery. The time period over which the average is computed may depend on
98e889fec6ce208965ed895907a629110ea081526cYifan Hong     * the fuel gauge hardware and its configuration.
99e889fec6ce208965ed895907a629110ea081526cYifan Hong     *
100e889fec6ce208965ed895907a629110ea081526cYifan Hong     * @return result SUCCESS if successful,
101e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                NOT_SUPPORTED if this property is not supported
102e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                 (e.g. the file that stores this property does not exist),
103e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                UNKNOWN for other errors.
10481874af4a117cd25559f438f1c580d27253058baYifan Hong     * @return value average battery current, or 0 if not successful.
105e889fec6ce208965ed895907a629110ea081526cYifan Hong     */
106e889fec6ce208965ed895907a629110ea081526cYifan Hong    getCurrentAverage() generates (Result result, int32_t value);
107e889fec6ce208965ed895907a629110ea081526cYifan Hong
108e889fec6ce208965ed895907a629110ea081526cYifan Hong    /**
109e889fec6ce208965ed895907a629110ea081526cYifan Hong     * Get remaining battery capacity percentage of total capacity
110e889fec6ce208965ed895907a629110ea081526cYifan Hong     * (with no fractional part).
111e889fec6ce208965ed895907a629110ea081526cYifan Hong     *
112e889fec6ce208965ed895907a629110ea081526cYifan Hong     * @return result SUCCESS if successful,
113e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                NOT_SUPPORTED if this property is not supported
114e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                 (e.g. the file that stores this property does not exist),
115e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                UNKNOWN for other errors.
11681874af4a117cd25559f438f1c580d27253058baYifan Hong     * @return value remaining battery capacity, or 0 if not successful.
117e889fec6ce208965ed895907a629110ea081526cYifan Hong     */
118e889fec6ce208965ed895907a629110ea081526cYifan Hong    getCapacity() generates (Result result, int32_t value);
119e889fec6ce208965ed895907a629110ea081526cYifan Hong
120e889fec6ce208965ed895907a629110ea081526cYifan Hong    /**
121e889fec6ce208965ed895907a629110ea081526cYifan Hong     * Get battery remaining energy in nanowatt-hours.
122e889fec6ce208965ed895907a629110ea081526cYifan Hong     *
123e889fec6ce208965ed895907a629110ea081526cYifan Hong     * @return result SUCCESS if successful,
124e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                NOT_SUPPORTED if this property is not supported,
125e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                UNKNOWN for other errors.
12681874af4a117cd25559f438f1c580d27253058baYifan Hong     * @return value remaining energy, or 0 if not successful.
127e889fec6ce208965ed895907a629110ea081526cYifan Hong     */
128e889fec6ce208965ed895907a629110ea081526cYifan Hong    getEnergyCounter() generates (Result result, int64_t value);
129e889fec6ce208965ed895907a629110ea081526cYifan Hong
130e889fec6ce208965ed895907a629110ea081526cYifan Hong    /**
131e889fec6ce208965ed895907a629110ea081526cYifan Hong     * Get battery charge status.
132e889fec6ce208965ed895907a629110ea081526cYifan Hong     *
133e889fec6ce208965ed895907a629110ea081526cYifan Hong     * @return result SUCCESS if successful,
134e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                NOT_SUPPORTED if this property is not supported
135e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                 (e.g. the file that stores this property does not exist),
136e889fec6ce208965ed895907a629110ea081526cYifan Hong     *                UNKNOWN other errors.
137e889fec6ce208965ed895907a629110ea081526cYifan Hong     * @return value charge status, or UNKNOWN if not successful.
138e889fec6ce208965ed895907a629110ea081526cYifan Hong     */
139e889fec6ce208965ed895907a629110ea081526cYifan Hong    getChargeStatus() generates (Result result, BatteryStatus value);
1402b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju
1412b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju    /**
1422b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju     * Get storage info.
1432b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju     *
1442b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju     * @return result SUCCESS if successful,
1452b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju     *                NOT_SUPPORTED if this property is not supported,
1462b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju     *                UNKNOWN other errors.
1472b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju     * @return value vector of StorageInfo structs, to be ignored if result is not
1482b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju     *               SUCCESS.
1492b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju     */
1502b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju    getStorageInfo() generates (Result result, vec<StorageInfo> value);
1512b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju
1522b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju    /**
1532b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju     * Gets disk statistics (number of reads/writes processed, number of I/O
1542b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju     * operations in flight etc).
1552b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju     *
1562b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju     * @return result SUCCESS if successful,
1572b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju     *                NOT_SUPPORTED if this property is not supported,
1582b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju     *                UNKNOWN other errors.
1592b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju     * @return value vector of disk statistics, to be ignored if result is not SUCCESS.
1602b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju     *               The mapping is index 0->sda, 1->sdb and so on.
1612b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju     */
1622b520838b13f91538fbc4d0c4672e92213b48243Hridya Valsaraju    getDiskStats() generates (Result result, vec<DiskStats> value);
1631bd377283379503203a6e29591ea67226ce9d0a6Hridya Valsaraju
1641bd377283379503203a6e29591ea67226ce9d0a6Hridya Valsaraju    /**
1651bd377283379503203a6e29591ea67226ce9d0a6Hridya Valsaraju     * Get Health Information.
1661bd377283379503203a6e29591ea67226ce9d0a6Hridya Valsaraju     *
1671bd377283379503203a6e29591ea67226ce9d0a6Hridya Valsaraju     * @return result SUCCESS if successful,
1681bd377283379503203a6e29591ea67226ce9d0a6Hridya Valsaraju     *                NOT_SUPPORTED if this API is not supported,
1691bd377283379503203a6e29591ea67226ce9d0a6Hridya Valsaraju     *                UNKNOWN for other errors.
1701bd377283379503203a6e29591ea67226ce9d0a6Hridya Valsaraju     * @return value  Health information, to be ignored if result is not
1711bd377283379503203a6e29591ea67226ce9d0a6Hridya Valsaraju     *                SUCCESS.
1721bd377283379503203a6e29591ea67226ce9d0a6Hridya Valsaraju     */
1731bd377283379503203a6e29591ea67226ce9d0a6Hridya Valsaraju    getHealthInfo() generates (Result result, @2.0::HealthInfo value);
174e889fec6ce208965ed895907a629110ea081526cYifan Hong};
175