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.aidl;
18 
19 import android.annotation.NonNull;
20 import android.health.connect.HealthConnectException;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23 
24 /** @hide */
25 public final class HealthConnectExceptionParcel implements Parcelable {
26 
27     @NonNull
28     public static final Creator<HealthConnectExceptionParcel> CREATOR =
29             new Creator<HealthConnectExceptionParcel>() {
30                 @Override
31                 public HealthConnectExceptionParcel createFromParcel(Parcel in) {
32                     return new HealthConnectExceptionParcel(
33                             new HealthConnectException(in.readInt(), in.readString()));
34                 }
35 
36                 @Override
37                 public HealthConnectExceptionParcel[] newArray(int size) {
38                     return new HealthConnectExceptionParcel[size];
39                 }
40             };
41 
42     private final HealthConnectException mHealthConnectException;
43 
HealthConnectExceptionParcel(HealthConnectException healthConnectException)44     public HealthConnectExceptionParcel(HealthConnectException healthConnectException) {
45         mHealthConnectException = healthConnectException;
46     }
47 
getHealthConnectException()48     public HealthConnectException getHealthConnectException() {
49         return mHealthConnectException;
50     }
51 
52     @Override
describeContents()53     public int describeContents() {
54         return 0;
55     }
56 
57     @Override
writeToParcel(@onNull Parcel dest, int flags)58     public void writeToParcel(@NonNull Parcel dest, int flags) {
59         dest.writeInt(mHealthConnectException.getErrorCode());
60         dest.writeString(mHealthConnectException.getMessage());
61     }
62 }
63