blob: 99c8d7fdc92fafe477df76e8f5d566abeae30f65 [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) {
Ihab Awada7684ed2015-05-13 11:34:53 -070045 this(label, Icon.createWithResource(packageName.getPackageName(), iconResId), extras);
46 }
47
48 public StatusHints(CharSequence label, Icon icon, Bundle extras) {
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070049 mLabel = label;
Ihab Awada7684ed2015-05-13 11:34:53 -070050 mIcon = icon;
Sailesh Nepal61203862014-07-11 14:50:13 -070051 mExtras = extras;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070052 }
53
54 /**
Nancy Chenea38cca2014-09-05 16:38:49 -070055 * @return A package used to load the icon.
Ihab Awada7684ed2015-05-13 11:34:53 -070056 *
57 * @hide
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070058 */
Ihab Awada7684ed2015-05-13 11:34:53 -070059 @SystemApi @Deprecated
Nancy Chenea38cca2014-09-05 16:38:49 -070060 public ComponentName getPackageName() {
Ihab Awada7684ed2015-05-13 11:34:53 -070061 // Minimal compatibility shim for legacy apps' tests
62 return new ComponentName("", "");
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070063 }
64
65 /**
66 * @return The label displayed in the in-call UI.
67 */
Santos Cordon146a3e32014-07-21 00:00:44 -070068 public CharSequence getLabel() {
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070069 return mLabel;
70 }
71
72 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -070073 * The icon resource ID for the icon to show.
74 *
75 * @return A resource ID.
Ihab Awada7684ed2015-05-13 11:34:53 -070076 *
77 * @hide
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070078 */
Ihab Awada7684ed2015-05-13 11:34:53 -070079 @SystemApi @Deprecated
Ihab Awadb19a0bc2014-08-07 19:46:01 -070080 public int getIconResId() {
Ihab Awada7684ed2015-05-13 11:34:53 -070081 // Minimal compatibility shim for legacy apps' tests
82 return 0;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070083 }
84
85 /**
86 * @return An icon displayed in the in-call UI.
Ihab Awada7684ed2015-05-13 11:34:53 -070087 *
88 * @hide
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070089 */
Ihab Awada7684ed2015-05-13 11:34:53 -070090 @SystemApi @Deprecated
Sailesh Nepale7ef59a2014-07-08 21:48:22 -070091 public Drawable getIcon(Context context) {
Ihab Awada7684ed2015-05-13 11:34:53 -070092 return mIcon.loadDrawable(context);
93 }
94
95 /**
96 * @return An icon depicting the status.
97 */
98 public Icon getIcon() {
99 return mIcon;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700100 }
101
Sailesh Nepal61203862014-07-11 14:50:13 -0700102 /**
103 * @return Extra data used to display status.
104 */
105 public Bundle getExtras() {
106 return mExtras;
107 }
108
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700109 @Override
110 public int describeContents() {
111 return 0;
112 }
113
114 @Override
115 public void writeToParcel(Parcel out, int flags) {
Santos Cordon146a3e32014-07-21 00:00:44 -0700116 out.writeCharSequence(mLabel);
Ihab Awada7684ed2015-05-13 11:34:53 -0700117 out.writeParcelable(mIcon, 0);
Sailesh Nepal61203862014-07-11 14:50:13 -0700118 out.writeParcelable(mExtras, 0);
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700119 }
120
121 public static final Creator<StatusHints> CREATOR
122 = new Creator<StatusHints>() {
123 public StatusHints createFromParcel(Parcel in) {
124 return new StatusHints(in);
125 }
126
127 public StatusHints[] newArray(int size) {
128 return new StatusHints[size];
129 }
130 };
131
132 private StatusHints(Parcel in) {
Santos Cordon146a3e32014-07-21 00:00:44 -0700133 mLabel = in.readCharSequence();
Ihab Awada7684ed2015-05-13 11:34:53 -0700134 mIcon = in.readParcelable(getClass().getClassLoader());
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700135 mExtras = in.readParcelable(getClass().getClassLoader());
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700136 }
137
Sailesh Nepalf20b9162014-08-12 11:53:32 -0700138 @Override
139 public boolean equals(Object other) {
140 if (other != null && other instanceof StatusHints) {
141 StatusHints otherHints = (StatusHints) other;
Ihab Awada7684ed2015-05-13 11:34:53 -0700142 return Objects.equals(otherHints.getLabel(), getLabel()) &&
143 Objects.equals(otherHints.getIcon(), getIcon()) &&
Sailesh Nepalf20b9162014-08-12 11:53:32 -0700144 Objects.equals(otherHints.getExtras(), getExtras());
145 }
146 return false;
147 }
148
149 @Override
150 public int hashCode() {
Ihab Awada7684ed2015-05-13 11:34:53 -0700151 return Objects.hashCode(mLabel) + Objects.hashCode(mIcon) + Objects.hashCode(mExtras);
Sailesh Nepalf20b9162014-08-12 11:53:32 -0700152 }
Sailesh Nepale7ef59a2014-07-08 21:48:22 -0700153}