• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 static com.android.healthfitness.flags.Flags.FLAG_ACTIVITY_INTENSITY;
20 
21 import android.annotation.FlaggedApi;
22 import android.annotation.NonNull;
23 import android.health.connect.datatypes.ActivityIntensityRecord;
24 import android.health.connect.datatypes.Identifier;
25 import android.health.connect.datatypes.RecordTypeIdentifier;
26 import android.os.Parcel;
27 
28 /**
29  * @see ActivityIntensityRecord
30  * @hide
31  */
32 @FlaggedApi(FLAG_ACTIVITY_INTENSITY)
33 @Identifier(recordIdentifier = RecordTypeIdentifier.RECORD_TYPE_ACTIVITY_INTENSITY)
34 public final class ActivityIntensityRecordInternal
35         extends IntervalRecordInternal<ActivityIntensityRecord> {
36 
37     private int mActivityIntensityType;
38 
39     @Override
populateIntervalRecordFrom(@onNull Parcel parcel)40     void populateIntervalRecordFrom(@NonNull Parcel parcel) {
41         mActivityIntensityType = parcel.readInt();
42     }
43 
44     @Override
populateIntervalRecordTo(@onNull Parcel parcel)45     void populateIntervalRecordTo(@NonNull Parcel parcel) {
46         parcel.writeInt(mActivityIntensityType);
47     }
48 
49     @Override
toExternalRecord()50     public ActivityIntensityRecord toExternalRecord() {
51         ActivityIntensityRecord.Builder builder =
52                 new ActivityIntensityRecord.Builder(
53                         buildMetaData(), getStartTime(), getEndTime(), mActivityIntensityType);
54 
55         if (getStartZoneOffset() != null) {
56             builder.setStartZoneOffset(getStartZoneOffset());
57         }
58 
59         if (getEndZoneOffset() != null) {
60             builder.setEndZoneOffset(getEndZoneOffset());
61         }
62 
63         return builder.buildWithoutValidation();
64     }
65 
66     @ActivityIntensityRecord.ActivityIntensityType
getActivityIntensityType()67     public int getActivityIntensityType() {
68         return mActivityIntensityType;
69     }
70 
71     /**
72      * @return this object with the measurement location.
73      */
74     @NonNull
setActivityIntensityType(int activityIntensityType)75     public ActivityIntensityRecordInternal setActivityIntensityType(int activityIntensityType) {
76         mActivityIntensityType = activityIntensityType;
77         return this;
78     }
79 }
80