• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 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 com.android.internal.telephony.cat;
18 
19 import android.compat.annotation.UnsupportedAppUsage;
20 import android.os.Build;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23 
24 
25 /**
26  * Class for representing "Duration" object for CAT.
27  *
28  * {@hide}
29  */
30 public class Duration implements Parcelable {
31     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
32     public int timeInterval;
33     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
34     public TimeUnit timeUnit;
35 
36     public enum TimeUnit {
37         MINUTE(0x00),
38         SECOND(0x01),
39         TENTH_SECOND(0x02);
40 
41         private int mValue;
42 
TimeUnit(int value)43         TimeUnit(int value) {
44             mValue = value;
45         }
46 
47         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
value()48         public int value() {
49             return mValue;
50         }
51     }
52 
53     /**
54      * @param timeInterval Between 1 and 255 inclusive.
55      */
Duration(int timeInterval, TimeUnit timeUnit)56     public Duration(int timeInterval, TimeUnit timeUnit) {
57         this.timeInterval = timeInterval;
58         this.timeUnit = timeUnit;
59     }
60 
Duration(Parcel in)61     private Duration(Parcel in) {
62         timeInterval = in.readInt();
63         timeUnit = TimeUnit.values()[in.readInt()];
64     }
65 
66     @Override
writeToParcel(Parcel dest, int flags)67     public void writeToParcel(Parcel dest, int flags) {
68         dest.writeInt(timeInterval);
69         dest.writeInt(timeUnit.ordinal());
70     }
71 
72     @Override
describeContents()73     public int describeContents() {
74         return 0;
75     }
76 
77     public static final Parcelable.Creator<Duration> CREATOR = new Parcelable.Creator<Duration>() {
78         @Override
79         public Duration createFromParcel(Parcel in) {
80             return new Duration(in);
81         }
82 
83         @Override
84         public Duration[] newArray(int size) {
85             return new Duration[size];
86         }
87     };
88 }
89