1 /*
2  * Copyright (C) 2018 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 
18 package android.telephony.ims;
19 
20 import android.annotation.NonNull;
21 import android.annotation.SystemApi;
22 import android.annotation.TestApi;
23 import android.os.Parcel;
24 import android.os.Parcelable;
25 
26 import java.util.Arrays;
27 
28 
29 /**
30  * Parcelable object to handle IMS supplementary service notifications.
31  *
32  * @hide
33  */
34 @SystemApi
35 @TestApi
36 public final class ImsSuppServiceNotification implements Parcelable {
37     private static final String TAG = "ImsSuppServiceNotification";
38 
39     /** Type of notification: 0 = MO; 1 = MT */
40     public final int notificationType;
41     /** TS 27.007 7.17 "code1" or "code2" */
42     public final int code;
43     /** TS 27.007 7.17 "index" - Not used currently*/
44     public final int index;
45     /** TS 27.007 7.17 "type" (MT only) - Not used currently */
46     public final int type;
47     /** TS 27.007 7.17 "number" (MT only) */
48     public final String number;
49     /** List of forwarded numbers, if any */
50     public final String[] history;
51 
52 
ImsSuppServiceNotification(int notificationType, int code, int index, int type, String number, String[] history)53     public ImsSuppServiceNotification(int notificationType, int code, int index, int type,
54             String number, String[] history) {
55         this.notificationType = notificationType;
56         this.code = code;
57         this.index = index;
58         this.type = type;
59         this.number = number;
60         this.history = history;
61     }
62 
63     /** @hide */
ImsSuppServiceNotification(Parcel in)64     public ImsSuppServiceNotification(Parcel in) {
65         notificationType = in.readInt();
66         code = in.readInt();
67         index = in.readInt();
68         type = in.readInt();
69         number = in.readString();
70         history = in.createStringArray();
71     }
72 
73     @NonNull
74     @Override
toString()75     public String toString() {
76         return "{ notificationType=" + notificationType +
77                 ", code=" + code +
78                 ", index=" + index +
79                 ", type=" + type +
80                 ", number=" + number +
81                 ", history=" + Arrays.toString(history) +
82                 " }";
83     }
84 
85     @Override
describeContents()86     public int describeContents() {
87         return 0;
88     }
89 
90     @Override
writeToParcel(Parcel out, int flags)91     public void writeToParcel(Parcel out, int flags) {
92         out.writeInt(notificationType);
93         out.writeInt(code);
94         out.writeInt(index);
95         out.writeInt(type);
96         out.writeString(number);
97         out.writeStringArray(history);
98     }
99 
100     public static final @android.annotation.NonNull Creator<ImsSuppServiceNotification> CREATOR =
101             new Creator<ImsSuppServiceNotification>() {
102         @Override
103         public ImsSuppServiceNotification createFromParcel(Parcel in) {
104             return new ImsSuppServiceNotification(in);
105         }
106 
107         @Override
108         public ImsSuppServiceNotification[] newArray(int size) {
109             return new ImsSuppServiceNotification[size];
110         }
111     };
112 }
113