• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 android.hardware.health;
18 
19 public class Translate {
h2aTranslate( android.hardware.health.V2_0.StorageInfo in)20     static public android.hardware.health.StorageInfo h2aTranslate(
21             android.hardware.health.V2_0.StorageInfo in) {
22         android.hardware.health.StorageInfo out = new android.hardware.health.StorageInfo();
23         out.eol = in.eol;
24         out.lifetimeA = in.lifetimeA;
25         out.lifetimeB = in.lifetimeB;
26         out.version = in.version;
27         return out;
28     }
29 
h2aTranslate( android.hardware.health.V2_0.DiskStats in)30     static public android.hardware.health.DiskStats h2aTranslate(
31             android.hardware.health.V2_0.DiskStats in) {
32         android.hardware.health.DiskStats out = new android.hardware.health.DiskStats();
33         out.reads = in.reads;
34         out.readMerges = in.readMerges;
35         out.readSectors = in.readSectors;
36         out.readTicks = in.readTicks;
37         out.writes = in.writes;
38         out.writeMerges = in.writeMerges;
39         out.writeSectors = in.writeSectors;
40         out.writeTicks = in.writeTicks;
41         out.ioInFlight = in.ioInFlight;
42         out.ioTicks = in.ioTicks;
43         out.ioInQueue = in.ioInQueue;
44         return out;
45     }
46 
h2aTranslateInternal( android.hardware.health.HealthInfo out, android.hardware.health.V1_0.HealthInfo in)47     private static void h2aTranslateInternal(
48             android.hardware.health.HealthInfo out, android.hardware.health.V1_0.HealthInfo in) {
49         out.chargerAcOnline = in.chargerAcOnline;
50         out.chargerUsbOnline = in.chargerUsbOnline;
51         out.chargerWirelessOnline = in.chargerWirelessOnline;
52         out.maxChargingCurrentMicroamps = in.maxChargingCurrent;
53         out.maxChargingVoltageMicrovolts = in.maxChargingVoltage;
54         out.batteryStatus = in.batteryStatus;
55         out.batteryHealth = in.batteryHealth;
56         out.batteryPresent = in.batteryPresent;
57         out.batteryLevel = in.batteryLevel;
58         out.batteryVoltageMillivolts = in.batteryVoltage;
59         out.batteryTemperatureTenthsCelsius = in.batteryTemperature;
60         out.batteryCurrentMicroamps = in.batteryCurrent;
61         out.batteryCycleCount = in.batteryCycleCount;
62         out.batteryFullChargeUah = in.batteryFullCharge;
63         out.batteryChargeCounterUah = in.batteryChargeCounter;
64         out.batteryTechnology = in.batteryTechnology;
65     }
66 
h2aTranslate( android.hardware.health.V1_0.HealthInfo in)67     public static android.hardware.health.HealthInfo h2aTranslate(
68             android.hardware.health.V1_0.HealthInfo in) {
69         android.hardware.health.HealthInfo out = new android.hardware.health.HealthInfo();
70         h2aTranslateInternal(out, in);
71         return out;
72     }
73 
h2aTranslate( android.hardware.health.V2_1.HealthInfo in)74     static public android.hardware.health.HealthInfo h2aTranslate(
75             android.hardware.health.V2_1.HealthInfo in) {
76         android.hardware.health.HealthInfo out = new android.hardware.health.HealthInfo();
77         h2aTranslateInternal(out, in.legacy.legacy);
78         out.batteryCurrentAverageMicroamps = in.legacy.batteryCurrentAverage;
79         out.diskStats = new android.hardware.health.DiskStats[in.legacy.diskStats.size()];
80         for (int i = 0; i < in.legacy.diskStats.size(); i++) {
81             out.diskStats[i] = h2aTranslate(in.legacy.diskStats.get(i));
82         }
83         out.storageInfos = new android.hardware.health.StorageInfo[in.legacy.storageInfos.size()];
84         for (int i = 0; i < in.legacy.storageInfos.size(); i++) {
85             out.storageInfos[i] = h2aTranslate(in.legacy.storageInfos.get(i));
86         }
87         out.batteryCapacityLevel = in.batteryCapacityLevel;
88         out.batteryChargeTimeToFullNowSeconds = in.batteryChargeTimeToFullNowSeconds;
89         out.batteryFullChargeDesignCapacityUah = in.batteryFullChargeDesignCapacityUah;
90         return out;
91     }
92 }
93