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 17package com.android.internal.telephony.cat; 18 19import android.os.Parcel; 20import android.os.Parcelable; 21 22 23/** 24 * Class for representing "Duration" object for CAT. 25 * 26 * {@hide} 27 */ 28public 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 @Override 62 public void writeToParcel(Parcel dest, int flags) { 63 dest.writeInt(timeInterval); 64 dest.writeInt(timeUnit.ordinal()); 65 } 66 67 @Override 68 public int describeContents() { 69 return 0; 70 } 71 72 public static final Parcelable.Creator<Duration> CREATOR = new Parcelable.Creator<Duration>() { 73 @Override 74 public Duration createFromParcel(Parcel in) { 75 return new Duration(in); 76 } 77 78 @Override 79 public Duration[] newArray(int size) { 80 return new Duration[size]; 81 } 82 }; 83} 84