blob: 453f408bedba96801081c3ada2807b4b4f9419d8 [file] [log] [blame]
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07001/*
2 * Copyright (C) 2014 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
Tyler Gunnef9f6f92014-09-12 22:16:17 -070017package android.telecom;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070018
Ihab Awada7684ed2015-05-13 11:34:53 -070019import android.annotation.SystemApi;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070020import android.content.ComponentName;
21import android.content.Context;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070022import android.graphics.drawable.Drawable;
Ihab Awada7684ed2015-05-13 11:34:53 -070023import android.graphics.drawable.Icon;
Sailesh Nepal61203862014-07-11 14:50:13 -070024import android.os.Bundle;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070025import android.os.Parcel;
26import android.os.Parcelable;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070027
Sailesh Nepalf20b9162014-08-12 11:53:32 -070028import java.util.Objects;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070029
30/**
31 * Contains status label and icon displayed in the in-call UI.
32 */
33public final class StatusHints implements Parcelable {
34
Santos Cordon146a3e32014-07-21 00:00:44 -070035 private final CharSequence mLabel;
Ihab Awada7684ed2015-05-13 11:34:53 -070036 private final Icon mIcon;
Sailesh Nepal61203862014-07-11 14:50:13 -070037 private final Bundle mExtras;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070038
Ihab Awada7684ed2015-05-13 11:34:53 -070039 /**
40 * @hide
41 */
42 @SystemApi @Deprecated
Nancy Chenea38cca2014-09-05 16:38:49 -070043 public StatusHints(ComponentName packageName, CharSequence label, int iconResId,
44 Bundle extras) {
Sailesh Nepald9be9cf2015-05-14 18:28:10 -070045 this(label, iconResId == 0 ? null : Icon.createWithResource(packageName.getPackageName(),
46 iconResId), extras);
Ihab Awada7684ed2015-05-13 11:34:53 -070047 }
48
49 public StatusHints(CharSequence label, Icon icon, Bundle extras) {
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070050 mLabel = label;
Ihab Awada7684ed2015-05-13 11:34:53 -070051 mIcon = icon;
Sailesh Nepal61203862014-07-11 14:50:13 -070052 mExtras = extras;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070053 }
54
55 /**
Nancy Chenea38cca2014-09-05 16:38:49 -070056 * @return A package used to load the icon.
Ihab Awada7684ed2015-05-13 11:34:53 -070057 *
58 * @hide
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070059 */
Ihab Awada7684ed2015-05-13 11:34:53 -070060 @SystemApi @Deprecated
Nancy Chenea38cca2014-09-05 16:38:49 -070061 public ComponentName getPackageName() {
Ihab Awada7684ed2015-05-13 11:34:53 -070062 // Minimal compatibility shim for legacy apps' tests
63 return new ComponentName("", "");
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070064 }
65
66 /**
67 * @return The label displayed in the in-call UI.
68 */
Santos Cordon146a3e32014-07-21 00:00:44 -070069 public CharSequence getLabel() {
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070070 return mLabel;
71 }
72
73 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -070074 * The icon resource ID for the icon to show.
75 *
76 * @return A resource ID.
Ihab Awada7684ed2015-05-13 11:34:53 -070077 *
78 * @hide
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070079 */
Ihab Awada7684ed2015-05-13 11:34:53 -070080 @SystemApi @Deprecated
Ihab Awadb19a0bc2014-08-07 19:46:01 -070081 public int getIconResId() {
Ihab Awada7684ed2015-05-13 11:34:53 -070082 // Minimal compatibility shim for legacy apps' tests
83 return 0;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070084 }
85
86 /**
87 * @return An icon displayed in the in-call UI.
Ihab Awada7684ed2015-05-13 11:34:53 -070088 *
89 * @hide
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070090 */
Ihab Awada7684ed2015-05-13 11:34:53 -070091 @SystemApi @Deprecated
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070092 public Drawable getIcon(Context context) {
Ihab Awada7684ed2015-05-13 11:34:53 -070093 return mIcon.loadDrawable(context);
94 }
95
96 /**
97 * @return An icon depicting the status.
98 */
99 public Icon getIcon() {
100 return mIcon;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700101 }
102
Sailesh Nepal61203862014-07-11 14:50:13 -0700103 /**
104 * @return Extra data used to display status.
105 */
106 public Bundle getExtras() {
107 return mExtras;
108 }
109
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700110 @Override
111 public int describeContents() {
112 return 0;
113 }
114
115 @Override
116 public void writeToParcel(Parcel out, int flags) {
Santos Cordon146a3e32014-07-21 00:00:44 -0700117 out.writeCharSequence(mLabel);
Ihab Awada7684ed2015-05-13 11:34:53 -0700118 out.writeParcelable(mIcon, 0);
Sailesh Nepal61203862014-07-11 14:50:13 -0700119 out.writeParcelable(mExtras, 0);
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700120 }
121
122 public static final Creator<StatusHints> CREATOR
123 = new Creator<StatusHints>() {
124 public StatusHints createFromParcel(Parcel in) {
125 return new StatusHints(in);
126 }
127
128 public StatusHints[] newArray(int size) {
129 return new StatusHints[size];
130 }
131 };
132
133 private StatusHints(Parcel in) {
Santos Cordon146a3e32014-07-21 00:00:44 -0700134 mLabel = in.readCharSequence();
Ihab Awada7684ed2015-05-13 11:34:53 -0700135 mIcon = in.readParcelable(getClass().getClassLoader());
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700136 mExtras = in.readParcelable(getClass().getClassLoader());
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700137 }
138
Sailesh Nepalf20b9162014-08-12 11:53:32 -0700139 @Override
140 public boolean equals(Object other) {
141 if (other != null && other instanceof StatusHints) {
142 StatusHints otherHints = (StatusHints) other;
Ihab Awada7684ed2015-05-13 11:34:53 -0700143 return Objects.equals(otherHints.getLabel(), getLabel()) &&
144 Objects.equals(otherHints.getIcon(), getIcon()) &&
Sailesh Nepalf20b9162014-08-12 11:53:32 -0700145 Objects.equals(otherHints.getExtras(), getExtras());
146 }
147 return false;
148 }
149
150 @Override
151 public int hashCode() {
Ihab Awada7684ed2015-05-13 11:34:53 -0700152 return Objects.hashCode(mLabel) + Objects.hashCode(mIcon) + Objects.hashCode(mExtras);
Sailesh Nepalf20b9162014-08-12 11:53:32 -0700153 }
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700154}