1/* 2 * Copyright (C) 2018 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 hardware.google.pixelstats@1.0; 18 19 20/** 21 * IPixelStats is an interface that allows clients to report specific hardware 22 * reliabilty events, which are translated into calls to libmetricslogger. 23 */ 24interface IPixelStats { 25 26 /** 27 * Report plugging of a device into the USB-C connector. 28 */ 29 reportUsbConnectorConnected(); 30 31 /** 32 * Report unplugging of a device from the USB-C connector. 33 * @param durationMillis Time, in milliseconds, that connector was connected. 34 */ 35 reportUsbConnectorDisconnected(int32_t durationMillis); 36 37 /** 38 * Reports the connection, along with VID, PID, of any USB device attached 39 * to this system with a USB audio interface. 40 * @param vid USB Vendor ID 41 * @param pid USB Product ID 42 */ 43 reportUsbAudioConnected(int32_t vid, int32_t pid); 44 45 /** 46 * Reports the disconnection, along with VID, PID, and connection duration, 47 * of any USB device attached to this system with a USB audio interface. 48 * @param vid USB Vendor ID 49 * @param pid USB Product ID 50 * @param duration_millis Time, in milliseconds, that the device was connected. 51 */ 52 reportUsbAudioDisconnected(int32_t vid, int32_t pid, int32_t durationMillis); 53 54 /** 55 * Report the detected speaker impedance value. 56 * @param speakerLocation a vendor-specific value identifying a 57 * particular speaker on the device. 58 * This value is opaque to the server, it must 59 * not try to interpret any meaning to this location. 60 * @param milliOhms the detected impedance in milliOhms. 61 */ 62 reportSpeakerImpedance(int32_t speakerLocation, int32_t milliOhms); 63 64 /** HardwareType for reportHardwareFailed */ 65 enum HardwareType : uint32_t { 66 UNKNOWN = 0, 67 MICROPHONE = 1, 68 CODEC = 2, 69 SPEAKER = 3, 70 FINGERPRINT = 4, 71 }; 72 /** 73 * ErrorCodes for reportHardwareFailed. 74 * ErrorCode interpretation depends on the hardwareType parameter. 75 * Values prefixed by different hardwareTypes overlap. 76 * COMPLETE refers to a complete failure e.g. non-responsive microphone. 77 * For most components, unless a more specific failure exists, COMPLETE should be used. 78 * UNKNOWN refers to an unexpected or unknown error. 79 */ 80 enum HardwareErrorCode : int32_t { 81 UNKNOWN = 0, 82 COMPLETE = 1, 83 SPEAKER_HIGH_Z = 2, 84 SPEAKER_SHORT = 3, 85 FINGERPRINT_SENSOR_BROKEN = 4, 86 FINGERPRINT_TOO_MANY_DEAD_PIXELS = 5, 87 }; 88 /** 89 * Report the detected failure of a hardware component. 90 * @param hardwareType the type of hardware component that failed. 91 * @param hardwareLocation a vendor-specific value indentifying a particular 92 * instance of the given hardwareType. Opaque id, 93 * not to be interpreted by server code. 94 * @param failureCode a code identifying the failure mode of the hardware 95 * component. Depends on hardwareType. 96 */ 97 reportHardwareFailed(HardwareType hardwareType, int32_t hardwareLocation, HardwareErrorCode errorCode); 98 99 100 /** 101 * Report the detection of a physical drop event, as detected by 102 * accelerometers. 103 * @param confidencePctg percentage confidence that a drop occured. 104 * Heuristic. 105 * @param accelPeak peak detected acceleration, in units of 1/1000ths 106 * of a g. 107 * @param freefallDuration Duration of estimated freefall, in ms. 108 */ 109 reportPhysicalDropDetected(int32_t confidencePctg, int32_t accelPeak, int32_t freefallDuration); 110 111 /** 112 * Report bucketed battery charge cycles. 113 * 114 * A comma-seperated list of buckets representing the number of times 115 * the battery has charged past equal-sized fractions of full capacity. 116 * For example, given "12, 11, 10, 9, 8, 7, 6, 5", the battery has charged 117 * past 1/8th full 12 times, 2/8ths full 11 times, etc. 118 * @param buckets the comma-separated string of bucket values. 119 * format: \s*(\d+,\s*)*\d+\s* 120 */ 121 reportChargeCycles(string buckets); 122 123 /** 124 * reportBatteryHealthSnapshot records a variety of battery parameters at multiple 125 * points throughout the day. Every 24hrs, the client is expected to report the snapshot 126 * at the following points throughout the day: 127 */ 128 enum BatterySnapshotType : int32_t { 129 MIN_TEMP, // Snapshot at min batt temp over 24hrs. 130 MAX_TEMP, // Snapshot at max batt temp over 24hrs. 131 MIN_RESISTANCE, // Snapshot at min batt resistance over 24hrs. 132 MAX_RESISTANCE, // Snapshot at max batt resistance over 24hrs. 133 MIN_VOLTAGE, // Snapshot at min batt voltage over 24hrs. 134 MAX_VOLTAGE, // Snapshot at max batt voltage over 24hrs. 135 MEDIAN_RESISTANCE, // Snapshot at median battery resistance over 24hrs. 136 }; 137 /** Parameters for reportBatteryHealthSnapshot. */ 138 struct BatteryHealthSnapshotArgs { 139 BatterySnapshotType type; 140 int32_t temperatureDeciC; 141 int32_t voltageMicroV; 142 int32_t currentMicroA; 143 int32_t openCircuitVoltageMicroV; 144 int32_t resistanceMicroOhm; 145 int32_t levelPercent; 146 }; 147 /** 148 * Report battery health snapshot, aggregated. 149 * Resistance, Voltage, Open Circuit Voltage, Temperature, and Charge Level 150 * are snapshotted periodically over 24hrs. 151 * Once per day, snapshots of the following type are reported: 152 * Min & Max Temp, Min & Max Resistance, Min & Max Voltage, Median Resistance. 153 * @param SnapshotType The instance of this snapshot. 154 * @param Temperature Temperature, in 1/10ths of degree C. 155 * @param Voltage Battery Voltage, in microVolts. 156 * @param OpenCircuitVoltage Battery Open Circuit Voltage, in microVolts. 157 * @param Current Battery current, in microAmps. 158 * @param Resistance Battery Resistance, in microOhms. 159 * @param Level Battery Level, as % of full. 160 */ 161 reportBatteryHealthSnapshot(BatteryHealthSnapshotArgs args); 162 163 /** 164 * Classifications of IO Operations for reportSlowIo. 165 */ 166 enum IoOperation : int32_t { 167 UNKNOWN, 168 READ, 169 WRITE, 170 UNMAP, 171 SYNC, 172 }; 173 /** 174 * Report slow I/O operations, aggregated. 175 * @param ioOperation The type of slow IO operation. 176 * @param count The number of slow IO operations of this type over 24hrs. 177 */ 178 reportSlowIo(IoOperation operation, int32_t count); 179 180 /** 181 * Report a shutdown event caused by low battery. 182 * @param voltageMicroV last recorded battery voltage prior to shutdown. 183 */ 184 reportBatteryCausedShutdown(int32_t voltageMicroV); 185}; 186