• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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.uicc;
18 
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 
22 /**
23  * Used to present ADN capacity
24  *
25  * {@hide}
26  */
27 public class AdnCapacity implements Parcelable {
28 
29     private int mMaxAdnCount;
30     private int mUsedAdnCount;
31     private int mMaxEmailCount;
32     private int mUsedEmailCount;
33     private int mMaxAnrCount;
34     private int mUsedAnrCount;
35     private int mMaxNameLength;
36     private int mMaxNumberLength;
37     private int mMaxEmailLength;
38     private int mMaxAnrLength;
39 
40     private int mHashCode = 0;
41 
AdnCapacity(int maxAdnCount, int usedAdnCount, int maxEmailCount, int usedEmailCount, int maxAnrCount, int usedAnrCount, int maxNameLength, int maxNumberLength, int maxEmailLength, int maxAnrLength)42     public AdnCapacity(int maxAdnCount, int usedAdnCount, int maxEmailCount,
43             int usedEmailCount, int maxAnrCount, int usedAnrCount, int maxNameLength,
44             int maxNumberLength, int maxEmailLength, int maxAnrLength) {
45         mMaxAdnCount = maxAdnCount;
46         mUsedAdnCount = usedAdnCount;
47         mMaxEmailCount = maxEmailCount;
48         mUsedEmailCount = usedEmailCount;
49         mMaxAnrCount = maxAnrCount;
50         mUsedAnrCount = usedAnrCount;
51         mMaxNameLength = maxNameLength;
52         mMaxNumberLength = maxNumberLength;
53         mMaxEmailLength = maxEmailLength;
54         mMaxAnrLength = maxAnrLength;
55     }
56 
AdnCapacity()57     public AdnCapacity() {
58         this(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
59     }
60 
getMaxAdnCount()61     public int getMaxAdnCount() {
62         return mMaxAdnCount;
63     }
64 
getUsedAdnCount()65     public int getUsedAdnCount() {
66         return mUsedAdnCount;
67     }
68 
getMaxEmailCount()69     public int getMaxEmailCount() {
70         return mMaxEmailCount;
71     }
72 
getUsedEmailCount()73     public int getUsedEmailCount() {
74         return mUsedEmailCount;
75     }
76 
getMaxAnrCount()77     public int getMaxAnrCount() {
78         return mMaxAnrCount;
79     }
80 
getUsedAnrCount()81     public int getUsedAnrCount() {
82         return mUsedAnrCount;
83     }
84 
getMaxNameLength()85     public int getMaxNameLength() {
86         return mMaxNameLength;
87     }
88 
getMaxNumberLength()89     public int getMaxNumberLength() {
90         return mMaxNumberLength;
91     }
92 
getMaxEmailLength()93     public int getMaxEmailLength() {
94         return mMaxEmailLength;
95     }
96 
getMaxAnrLength()97     public int getMaxAnrLength() {
98         return mMaxAnrLength;
99     }
100 
isSimFull()101     public boolean isSimFull() {
102         return mMaxAdnCount == mUsedAdnCount;
103     }
104 
isSimEmpty()105     public boolean isSimEmpty() {
106         return mUsedAdnCount == 0;
107     }
108 
isSimValid()109     public boolean isSimValid() {
110         return mMaxAdnCount > 0;
111     }
112 
113     public static final Parcelable.Creator<AdnCapacity> CREATOR
114             = new Parcelable.Creator<AdnCapacity>() {
115         @Override
116         public AdnCapacity createFromParcel(Parcel source) {
117             final int maxAdnCount = source.readInt();
118             final int usedAdnCount = source.readInt();
119             final int maxEmailCount = source.readInt();
120             final int usedEmailCount = source.readInt();
121             final int maxAnrCount = source.readInt();
122             final int usedAnrCount = source.readInt();
123             final int maxNameLength = source.readInt();
124             final int maxNumberLength = source.readInt();
125             final int maxEmailLength = source.readInt();
126             final int maxAnrLength = source.readInt();
127             return new AdnCapacity(maxAdnCount, usedAdnCount, maxEmailCount,
128                     usedEmailCount, maxAnrCount, usedAnrCount, maxNameLength,
129                     maxNumberLength, maxEmailLength, maxAnrLength);
130         }
131 
132         @Override
133         public AdnCapacity[] newArray(int size) {
134             return new AdnCapacity[size];
135         }
136     };
137 
138     @Override
describeContents()139     public int describeContents() {
140         return 0;
141     }
142 
143     @Override
writeToParcel(Parcel dest, int flags)144     public void writeToParcel(Parcel dest, int flags) {
145         dest.writeInt(mMaxAdnCount);
146         dest.writeInt(mUsedAdnCount);
147         dest.writeInt(mMaxEmailCount);
148         dest.writeInt(mUsedEmailCount);
149         dest.writeInt(mMaxAnrCount);
150         dest.writeInt(mUsedAnrCount);
151         dest.writeInt(mMaxNameLength);
152         dest.writeInt(mMaxNumberLength);
153         dest.writeInt(mMaxEmailLength);
154         dest.writeInt(mMaxAnrLength);
155     }
156 
157     @Override
equals(Object obj)158     public boolean equals(Object obj) {
159         if (obj instanceof AdnCapacity) {
160             AdnCapacity capacity = (AdnCapacity)obj;
161             return capacity.getMaxAdnCount() == mMaxAdnCount
162                     && capacity.getUsedAdnCount() == mUsedAdnCount
163                     && capacity.getMaxEmailCount() == mMaxEmailCount
164                     && capacity.getUsedEmailCount() == mUsedEmailCount
165                     && capacity.getMaxAnrCount() == mMaxAnrCount
166                     && capacity.getUsedAnrCount() == mUsedAnrCount
167                     && capacity.getMaxNameLength() == mMaxNameLength
168                     && capacity.getMaxNumberLength() == mMaxNumberLength
169                     && capacity.getMaxEmailLength() == mMaxEmailLength
170                     && capacity.getMaxAnrLength() == mMaxAnrLength;
171         } else {
172             return false;
173         }
174     }
175 
176     @Override
hashCode()177     public int hashCode() {
178         if (mHashCode == 0) {
179             mHashCode = mMaxAdnCount;
180             mHashCode = 31 * mHashCode + mUsedAdnCount;
181             mHashCode = 31 * mHashCode + mMaxEmailCount;
182             mHashCode = 31 * mHashCode + mUsedEmailCount;
183             mHashCode = 31 * mHashCode + mMaxAnrCount;
184             mHashCode = 31 * mHashCode + mUsedAnrCount;
185             mHashCode = 31 * mHashCode + mMaxNameLength;
186             mHashCode = 31 * mHashCode + mMaxNumberLength;
187             mHashCode = 31 * mHashCode + mMaxEmailLength;
188             mHashCode = 31 * mHashCode + mMaxAnrLength;
189         }
190         return mHashCode;
191     }
192 }
193