1 /*
2  * Copyright (C) 2007 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.Parcel;
21 import android.os.Parcelable;
22 
23 abstract class ValueObject {
getTag()24     abstract ComprehensionTlvTag getTag();
25 }
26 
27 /**
28  * Class for Command Details object of proactive commands from SIM.
29  * {@hide}
30  */
31 public class CommandDetails extends ValueObject implements Parcelable {
32     @UnsupportedAppUsage
33     public boolean compRequired;
34     @UnsupportedAppUsage
35     public int commandNumber;
36     @UnsupportedAppUsage
37     public int typeOfCommand;
38     @UnsupportedAppUsage
39     public int commandQualifier;
40 
41     @Override
getTag()42     public ComprehensionTlvTag getTag() {
43         return ComprehensionTlvTag.COMMAND_DETAILS;
44     }
45 
CommandDetails()46     CommandDetails() {
47     }
48 
compareTo(CommandDetails other)49     public boolean compareTo(CommandDetails other) {
50         return (this.compRequired == other.compRequired &&
51                 this.commandNumber == other.commandNumber &&
52                 this.commandQualifier == other.commandQualifier &&
53                 this.typeOfCommand == other.typeOfCommand);
54     }
55 
CommandDetails(Parcel in)56     public CommandDetails(Parcel in) {
57         compRequired = in.readInt() != 0;
58         commandNumber = in.readInt();
59         typeOfCommand = in.readInt();
60         commandQualifier = in.readInt();
61     }
62 
63     @Override
writeToParcel(Parcel dest, int flags)64     public void writeToParcel(Parcel dest, int flags) {
65         dest.writeInt(compRequired ? 1 : 0);
66         dest.writeInt(commandNumber);
67         dest.writeInt(typeOfCommand);
68         dest.writeInt(commandQualifier);
69     }
70 
71     public static final Parcelable.Creator<CommandDetails> CREATOR =
72                                 new Parcelable.Creator<CommandDetails>() {
73         @Override
74         public CommandDetails createFromParcel(Parcel in) {
75             return new CommandDetails(in);
76         }
77 
78         @Override
79         public CommandDetails[] newArray(int size) {
80             return new CommandDetails[size];
81         }
82     };
83 
84     @Override
describeContents()85     public int describeContents() {
86         return 0;
87     }
88 
89     @Override
toString()90     public String toString() {
91         return "CmdDetails: compRequired=" + compRequired +
92                 " commandNumber=" + commandNumber +
93                 " typeOfCommand=" + typeOfCommand +
94                 " commandQualifier=" + commandQualifier;
95     }
96 }
97 
98 class DeviceIdentities extends ValueObject {
99     public int sourceId;
100     @UnsupportedAppUsage
101     public int destinationId;
102 
103     @Override
getTag()104     ComprehensionTlvTag getTag() {
105         return ComprehensionTlvTag.DEVICE_IDENTITIES;
106     }
107 }
108 
109 // Container class to hold icon identifier value.
110 class IconId extends ValueObject {
111     @UnsupportedAppUsage
112     int recordNumber;
113     boolean selfExplanatory;
114 
115     @Override
getTag()116     ComprehensionTlvTag getTag() {
117         return ComprehensionTlvTag.ICON_ID;
118     }
119 }
120 
121 // Container class to hold item icon identifier list value.
122 class ItemsIconId extends ValueObject {
123     int [] recordNumbers;
124     boolean selfExplanatory;
125 
126     @Override
getTag()127     ComprehensionTlvTag getTag() {
128         return ComprehensionTlvTag.ITEM_ICON_ID_LIST;
129     }
130 }
131