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.graphics.Bitmap;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23 
24 public class TextMessage implements Parcelable {
25     public String title = "";
26     @UnsupportedAppUsage
27     public String text = null;
28     public Bitmap icon = null;
29     @UnsupportedAppUsage
30     public boolean iconSelfExplanatory = false;
31     public boolean isHighPriority = false;
32     public boolean responseNeeded = true;
33     public boolean userClear = false;
34     public Duration duration = null;
35 
36     @UnsupportedAppUsage
TextMessage()37     TextMessage() {
38     }
39 
TextMessage(Parcel in)40     private TextMessage(Parcel in) {
41         title = in.readString();
42         text = in.readString();
43         icon = in.readParcelable(Bitmap.class.getClassLoader());
44         iconSelfExplanatory = in.readInt() == 1 ? true : false;
45         isHighPriority = in.readInt() == 1 ? true : false;
46         responseNeeded = in.readInt() == 1 ? true : false;
47         userClear = in.readInt() == 1 ? true : false;
48         duration = in.readParcelable(null);
49     }
50 
51     @Override
describeContents()52     public int describeContents() {
53         return 0;
54     }
55 
56     @Override
writeToParcel(Parcel dest, int flags)57     public void writeToParcel(Parcel dest, int flags) {
58         dest.writeString(title);
59         dest.writeString(text);
60         dest.writeParcelable(icon, 0);
61         dest.writeInt(iconSelfExplanatory ? 1 : 0);
62         dest.writeInt(isHighPriority ? 1 : 0);
63         dest.writeInt(responseNeeded ? 1 : 0);
64         dest.writeInt(userClear ? 1 : 0);
65         dest.writeParcelable(duration, 0);
66     }
67 
68     public static final Parcelable.Creator<TextMessage> CREATOR = new Parcelable.Creator<TextMessage>() {
69         @Override
70         public TextMessage createFromParcel(Parcel in) {
71             return new TextMessage(in);
72         }
73 
74         @Override
75         public TextMessage[] newArray(int size) {
76             return new TextMessage[size];
77         }
78     };
79 
80     @Override
toString()81     public String toString() {
82         return "title=" + title + " text=" + text + " icon=" + icon +
83             " iconSelfExplanatory=" + iconSelfExplanatory + " isHighPriority=" +
84             isHighPriority + " responseNeeded=" + responseNeeded + " userClear=" +
85             userClear + " duration=" + duration;
86     }
87 }
88