1 /*
2  * Copyright (C) 2023 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.health.connect.internal.datatypes;
18 
19 import android.annotation.NonNull;
20 import android.health.connect.datatypes.HeartRateVariabilityRmssdRecord;
21 import android.health.connect.datatypes.Identifier;
22 import android.health.connect.datatypes.RecordTypeIdentifier;
23 import android.os.Parcel;
24 
25 /** @hide */
26 @Identifier(recordIdentifier = RecordTypeIdentifier.RECORD_TYPE_HEART_RATE_VARIABILITY_RMSSD)
27 public final class HeartRateVariabilityRmssdRecordInternal
28         extends InstantRecordInternal<HeartRateVariabilityRmssdRecord> {
29     private double mHeartRateVariabilityMillis = 0.0;
30 
31     @Override
populateInstantRecordFrom(@onNull Parcel parcel)32     void populateInstantRecordFrom(@NonNull Parcel parcel) {
33         mHeartRateVariabilityMillis = parcel.readDouble();
34     }
35 
36     @Override
populateInstantRecordTo(@onNull Parcel parcel)37     void populateInstantRecordTo(@NonNull Parcel parcel) {
38         parcel.writeDouble(mHeartRateVariabilityMillis);
39     }
40 
getHeartRateVariabilityMillis()41     public double getHeartRateVariabilityMillis() {
42         return mHeartRateVariabilityMillis;
43     }
44 
setHeartRateVariabilityMillis(double heartRateVariabilityMillis)45     public void setHeartRateVariabilityMillis(double heartRateVariabilityMillis) {
46         mHeartRateVariabilityMillis = heartRateVariabilityMillis;
47     }
48 
49     @NonNull
50     @Override
toExternalRecord()51     public HeartRateVariabilityRmssdRecord toExternalRecord() {
52         return new HeartRateVariabilityRmssdRecord.Builder(
53                         buildMetaData(), getTime(), getHeartRateVariabilityMillis())
54                 .setZoneOffset(getZoneOffset())
55                 .buildWithoutValidation();
56     }
57 }
58