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 package android.health.connect.internal.datatypes; 17 18 import android.annotation.NonNull; 19 import android.health.connect.datatypes.Identifier; 20 import android.health.connect.datatypes.RecordTypeIdentifier; 21 import android.health.connect.datatypes.RestingHeartRateRecord; 22 import android.os.Parcel; 23 24 /** 25 * @see RestingHeartRateRecord 26 * @hide 27 */ 28 @Identifier(recordIdentifier = RecordTypeIdentifier.RECORD_TYPE_RESTING_HEART_RATE) 29 public final class RestingHeartRateRecordInternal 30 extends InstantRecordInternal<RestingHeartRateRecord> { 31 private int mBeatsPerMinute; 32 getBeatsPerMinute()33 public int getBeatsPerMinute() { 34 return mBeatsPerMinute; 35 } 36 37 /** returns this object with the specified beatsPerMinute */ 38 @NonNull setBeatsPerMinute(int beatsPerMinute)39 public RestingHeartRateRecordInternal setBeatsPerMinute(int beatsPerMinute) { 40 this.mBeatsPerMinute = beatsPerMinute; 41 return this; 42 } 43 44 @NonNull 45 @Override toExternalRecord()46 public RestingHeartRateRecord toExternalRecord() { 47 return new RestingHeartRateRecord.Builder(buildMetaData(), getTime(), getBeatsPerMinute()) 48 .setZoneOffset(getZoneOffset()) 49 .buildWithoutValidation(); 50 } 51 52 @Override populateInstantRecordFrom(@onNull Parcel parcel)53 void populateInstantRecordFrom(@NonNull Parcel parcel) { 54 mBeatsPerMinute = parcel.readInt(); 55 } 56 57 @Override populateInstantRecordTo(@onNull Parcel parcel)58 void populateInstantRecordTo(@NonNull Parcel parcel) { 59 parcel.writeInt(mBeatsPerMinute); 60 } 61 } 62