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