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 com.android.server.health;
18 
19 /**
20  * Utils for {@link om.android.server.BatteryService} to deal with health info structs.
21  *
22  * @hide
23  */
24 public class Utils {
Utils()25     private Utils() {}
26 
27     /**
28      * Copy health info struct.
29      *
30      * @param dst destination
31      * @param src source
32      */
copy( android.hardware.health.V1_0.HealthInfo dst, android.hardware.health.V1_0.HealthInfo src)33     public static void copy(
34             android.hardware.health.V1_0.HealthInfo dst,
35             android.hardware.health.V1_0.HealthInfo src) {
36         dst.chargerAcOnline = src.chargerAcOnline;
37         dst.chargerUsbOnline = src.chargerUsbOnline;
38         dst.chargerWirelessOnline = src.chargerWirelessOnline;
39         dst.maxChargingCurrent = src.maxChargingCurrent;
40         dst.maxChargingVoltage = src.maxChargingVoltage;
41         dst.batteryStatus = src.batteryStatus;
42         dst.batteryHealth = src.batteryHealth;
43         dst.batteryPresent = src.batteryPresent;
44         dst.batteryLevel = src.batteryLevel;
45         dst.batteryVoltage = src.batteryVoltage;
46         dst.batteryTemperature = src.batteryTemperature;
47         dst.batteryCurrent = src.batteryCurrent;
48         dst.batteryCycleCount = src.batteryCycleCount;
49         dst.batteryFullCharge = src.batteryFullCharge;
50         dst.batteryChargeCounter = src.batteryChargeCounter;
51         dst.batteryTechnology = src.batteryTechnology;
52     }
53 
54     /**
55      * Copy battery fields of {@link android.hardware.health.HealthInfo} V1. This excludes
56      * non-battery fields like {@link android.hardware.health.HealthInfo#diskStats diskStats} and
57      * {@link android.hardware.health.HealthInfo#storageInfos storageInfos}
58      *
59      * @param dst destination
60      * @param src source
61      */
copyV1Battery( android.hardware.health.HealthInfo dst, android.hardware.health.HealthInfo src)62     public static void copyV1Battery(
63             android.hardware.health.HealthInfo dst, android.hardware.health.HealthInfo src) {
64         dst.chargerAcOnline = src.chargerAcOnline;
65         dst.chargerUsbOnline = src.chargerUsbOnline;
66         dst.chargerWirelessOnline = src.chargerWirelessOnline;
67         dst.maxChargingCurrentMicroamps = src.maxChargingCurrentMicroamps;
68         dst.maxChargingVoltageMicrovolts = src.maxChargingVoltageMicrovolts;
69         dst.batteryStatus = src.batteryStatus;
70         dst.batteryHealth = src.batteryHealth;
71         dst.batteryPresent = src.batteryPresent;
72         dst.batteryLevel = src.batteryLevel;
73         dst.batteryVoltageMillivolts = src.batteryVoltageMillivolts;
74         dst.batteryTemperatureTenthsCelsius = src.batteryTemperatureTenthsCelsius;
75         dst.batteryCurrentMicroamps = src.batteryCurrentMicroamps;
76         dst.batteryCycleCount = src.batteryCycleCount;
77         dst.batteryFullChargeUah = src.batteryFullChargeUah;
78         dst.batteryChargeCounterUah = src.batteryChargeCounterUah;
79         dst.batteryTechnology = src.batteryTechnology;
80         dst.batteryCurrentAverageMicroamps = src.batteryCurrentAverageMicroamps;
81         dst.batteryCapacityLevel = src.batteryCapacityLevel;
82         dst.batteryChargeTimeToFullNowSeconds = src.batteryChargeTimeToFullNowSeconds;
83         dst.batteryFullChargeDesignCapacityUah = src.batteryFullChargeDesignCapacityUah;
84     }
85 }
86