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 static android.health.connect.Constants.DEFAULT_INT;
19 
20 import android.annotation.NonNull;
21 import android.health.connect.datatypes.Identifier;
22 import android.health.connect.datatypes.RecordTypeIdentifier;
23 import android.health.connect.datatypes.StepsRecord;
24 import android.os.Parcel;
25 
26 /**
27  * @see StepsRecord
28  * @hide
29  */
30 @Identifier(recordIdentifier = RecordTypeIdentifier.RECORD_TYPE_STEPS)
31 public final class StepsRecordInternal extends IntervalRecordInternal<StepsRecord> {
32     private int mCount = DEFAULT_INT;
33 
getCount()34     public int getCount() {
35         return mCount;
36     }
37 
38     /** returns this object with the specified count */
39     @NonNull
setCount(int count)40     public StepsRecordInternal setCount(int count) {
41         this.mCount = count;
42         return this;
43     }
44 
45     @NonNull
46     @Override
toExternalRecord()47     public StepsRecord toExternalRecord() {
48         return new StepsRecord.Builder(buildMetaData(), getStartTime(), getEndTime(), getCount())
49                 .setStartZoneOffset(getStartZoneOffset())
50                 .setEndZoneOffset(getEndZoneOffset())
51                 .buildWithoutValidation();
52     }
53 
54     @Override
populateIntervalRecordFrom(@onNull Parcel parcel)55     void populateIntervalRecordFrom(@NonNull Parcel parcel) {
56         mCount = parcel.readInt();
57     }
58 
59     @Override
populateIntervalRecordTo(@onNull Parcel parcel)60     void populateIntervalRecordTo(@NonNull Parcel parcel) {
61         parcel.writeInt(mCount);
62     }
63 }
64