1 /**
2  * Copyright (C) 2020 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.telephony;
18 
19 import android.annotation.IntDef;
20 import android.annotation.NonNull;
21 import android.annotation.SystemApi;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 
25 import java.lang.annotation.Retention;
26 import java.lang.annotation.RetentionPolicy;
27 
28 /**
29  * CDMA ERI (Enhanced Roaming Indicator) information.
30  *
31  * This contains the following ERI information
32  *
33  * 1. ERI (Enhanced Roaming Indicator) icon index. The number is assigned by
34  *    3GPP2 C.R1001-H v1.0 Table 8.1-1. Additionally carriers define their own
35  *    ERI icon index.
36  * 2. CDMA ERI icon mode. This represents how the icon should be displayed.
37  *    Its one of the following CDMA ERI icon mode
38  *    {@link android.telephony.CdmaEriInformation#ERI_ICON_MODE_NORMAL}
39  *    {@link android.telephony.CdmaEriInformation#ERI_ICON_MODE_FLASH}
40  *
41  * @hide
42  */
43 public final class CdmaEriInformation implements Parcelable {
44     /** @hide */
45     @Retention(RetentionPolicy.SOURCE)
46     @IntDef(prefix = {"ERI_"}, value = {
47                 ERI_ON,
48                 ERI_OFF,
49                 ERI_FLASH
50             })
51     public @interface EriIconIndex {}
52 
53     /**
54      * ERI (Enhanced Roaming Indicator) is ON i.e value 0 defined by
55      * 3GPP2 C.R1001-H v1.0 Table 8.1-1.
56      */
57     public static final int ERI_ON = 0;
58 
59     /**
60      * ERI (Enhanced Roaming Indicator) is OFF i.e value 1 defined by
61      * 3GPP2 C.R1001-H v1.0 Table 8.1-1.
62      */
63     public static final int ERI_OFF = 1;
64 
65     /**
66      * ERI (Enhanced Roaming Indicator) is FLASH i.e value 2 defined by
67      * 3GPP2 C.R1001-H v1.0 Table 8.1-1.
68      */
69     public static final int ERI_FLASH = 2;
70 
71     /** @hide */
72     @Retention(RetentionPolicy.SOURCE)
73     @IntDef(prefix = {"ERI_ICON_MODE_"}, value = {
74                 ERI_ICON_MODE_NORMAL,
75                 ERI_ICON_MODE_FLASH
76             })
77     public @interface EriIconMode {}
78 
79     /**
80      * ERI (Enhanced Roaming Indicator) icon mode is normal. This constant represents that
81      * the ERI icon should be displayed normally.
82      *
83      * Note: ERI is defined 3GPP2 C.R1001-H Table 8.1-1
84      */
85     public static final int ERI_ICON_MODE_NORMAL = 0;
86 
87     /**
88      * ERI (Enhanced Roaming Indicator) icon mode flash. This constant represents that
89      * the ERI icon should be flashing.
90      *
91      * Note: ERI is defined 3GPP2 C.R1001-H Table 8.1-1
92      */
93     public static final int ERI_ICON_MODE_FLASH = 1;
94 
95     private @EriIconIndex int mIconIndex;
96     private @EriIconMode int mIconMode;
97 
98     /**
99      * Creates CdmaEriInformation from iconIndex and iconMode
100      *
101      * @hide
102      */
CdmaEriInformation(@riIconIndex int iconIndex, @EriIconMode int iconMode)103     public CdmaEriInformation(@EriIconIndex int iconIndex, @EriIconMode int iconMode) {
104         mIconIndex = iconIndex;
105         mIconMode = iconMode;
106     }
107 
108     /** Gets the ERI icon index */
getEriIconIndex()109     public @EriIconIndex int getEriIconIndex() {
110         return mIconIndex;
111     }
112 
113     /**
114      * Sets the ERI icon index
115      *
116      * @hide
117      */
setEriIconIndex(@riIconIndex int iconIndex)118     public void setEriIconIndex(@EriIconIndex int iconIndex) {
119         mIconIndex = iconIndex;
120     }
121 
122     /** Gets the ERI icon mode */
getEriIconMode()123     public @EriIconMode int getEriIconMode() {
124         return mIconMode;
125     }
126 
127     /**
128      * Sets the ERI icon mode
129      *
130      * @hide
131      */
setEriIconMode(@riIconMode int iconMode)132     public void setEriIconMode(@EriIconMode int iconMode) {
133         mIconMode = iconMode;
134     }
135     /** Implement the Parcelable interface */
136     @Override
writeToParcel(@onNull Parcel dest, int flags)137     public void writeToParcel(@NonNull Parcel dest, int flags) {
138         dest.writeInt(mIconIndex);
139         dest.writeInt(mIconMode);
140     }
141 
142     /** Implement the Parcelable interface */
143     @Override
describeContents()144     public int describeContents() {
145         return 0;
146     }
147 
148     /**
149      * Construct a CdmaEriInformation object from the given parcel
150      */
CdmaEriInformation(Parcel in)151     private CdmaEriInformation(Parcel in) {
152         mIconIndex = in.readInt();
153         mIconMode = in.readInt();
154     }
155 
156     /** Implement the Parcelable interface */
157     public static final @android.annotation.NonNull Parcelable.Creator<CdmaEriInformation> CREATOR =
158             new Parcelable.Creator<CdmaEriInformation>() {
159         @Override
160         public CdmaEriInformation createFromParcel(Parcel in) {
161             return new CdmaEriInformation(in);
162         }
163 
164         @Override
165         public CdmaEriInformation[] newArray(int size) {
166             return new CdmaEriInformation[size];
167         }
168     };
169 }
170