Home | History | Annotate | Download | only in cat
      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.os.Parcel;
     20 import android.os.Parcelable;
     21 
     22 
     23 /**
     24  * Class for representing "Duration" object for CAT.
     25  *
     26  * {@hide}
     27  */
     28 public class Duration implements Parcelable {
     29     public int timeInterval;
     30     public TimeUnit timeUnit;
     31 
     32     public enum TimeUnit {
     33         MINUTE(0x00),
     34         SECOND(0x01),
     35         TENTH_SECOND(0x02);
     36 
     37         private int mValue;
     38 
     39         TimeUnit(int value) {
     40             mValue = value;
     41         }
     42 
     43         public int value() {
     44             return mValue;
     45         }
     46     }
     47 
     48     /**
     49      * @param timeInterval Between 1 and 255 inclusive.
     50      */
     51     public Duration(int timeInterval, TimeUnit timeUnit) {
     52         this.timeInterval = timeInterval;
     53         this.timeUnit = timeUnit;
     54     }
     55 
     56     private Duration(Parcel in) {
     57         timeInterval = in.readInt();
     58         timeUnit = TimeUnit.values()[in.readInt()];
     59     }
     60 
     61     public void writeToParcel(Parcel dest, int flags) {
     62         dest.writeInt(timeInterval);
     63         dest.writeInt(timeUnit.ordinal());
     64     }
     65 
     66     public int describeContents() {
     67         return 0;
     68     }
     69 
     70     public static final Parcelable.Creator<Duration> CREATOR = new Parcelable.Creator<Duration>() {
     71         public Duration createFromParcel(Parcel in) {
     72             return new Duration(in);
     73         }
     74 
     75         public Duration[] newArray(int size) {
     76             return new Duration[size];
     77         }
     78     };
     79 }
     80