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::HealthInfo;
20import @1.0::Result;
21
22/**
23 * Status values for HAL methods.
24 */
25enum Result : @1.0::Result {
26    NOT_FOUND,
27    CALLBACK_DIED,
28};
29
30/*
31 * Identification attributes for a storage device.
32 */
33struct StorageAttribute {
34    /**
35     * Set to true if internal storage
36     */
37    bool isInternal;
38    /**
39     * Set to true if this is the boot device.
40     */
41    bool isBootDevice;
42    /**
43     * Name of the storage device.
44     */
45    string name;
46};
47
48/*
49 * Information on storage device including life time estimates, end of life
50 * information and other attributes.
51 */
52struct StorageInfo {
53    /**
54     * Attributes of the storage device whose info is contained by the struct.
55     */
56    StorageAttribute attr;
57    /**
58     * pre-eol (end of life) information. Follows JEDEC standard No.84-B50.
59     */
60    uint16_t eol;
61    /**
62     * device life time estimation (type A). Follows JEDEC standard No.84-B50.
63     */
64    uint16_t lifetimeA;
65    /**
66     * device life time estimation (type B). Follows JEDEC standard No.84-B50.
67     */
68    uint16_t lifetimeB;
69    /**
70     * version string
71     */
72    string version;
73};
74/*
75 * Disk statistics since boot.
76 */
77struct DiskStats {
78    /**
79     * Number of reads processed.
80     */
81    uint64_t reads;
82    /**
83     * number of read I/Os merged with in-queue I/Os.
84     */
85    uint64_t readMerges;
86    /**
87     * number of sectors read.
88     */
89    uint64_t readSectors;
90    /**
91     * total wait time for read requests.
92     */
93    uint64_t readTicks;
94    /**
95     * number of writes processed.
96     */
97    uint64_t writes;
98    /**
99     * number of writes merged with in-queue I/Os.
100     */
101    uint64_t writeMerges;
102    /**
103     * number of sectors written.
104     */
105    uint64_t writeSectors;
106    /**
107     * total wait time for write requests.
108     */
109    uint64_t writeTicks;
110    /**
111     * number of I/Os currently in flight.
112     */
113    uint64_t ioInFlight;
114    /**
115     * total time this block device has been active.
116     */
117    uint64_t ioTicks;
118    /**
119     * total wait time for all requests.
120     */
121    uint64_t ioInQueue;
122    /**
123     * Attributes of the memory device.
124     */
125    StorageAttribute attr;
126};
127
128/**
129 * Combined Health Information.
130 */
131struct HealthInfo {
132    /**
133     * V1.0 HealthInfo.
134     * If a member is unsupported, it is filled with:
135     * - 0 (for integers);
136     * - false (for booleans);
137     * - empty string (for strings);
138     * - UNKNOWN (for BatteryStatus and BatteryHealth).
139     */
140    @1.0::HealthInfo legacy;
141    /**
142     * Average battery current in uA. Will be 0 if unsupported.
143     */
144    int32_t batteryCurrentAverage;
145    /**
146     * Disk Statistics. Will be an empty vector if unsupported.
147     */
148    vec<DiskStats> diskStats;
149    /**
150     * Information on storage devices. Will be an empty vector if
151     * unsupported.
152     */
153    vec<StorageInfo> storageInfos;
154};
155