| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 1 | /* | 
|  | 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 Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 17 | package android.telecom; | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 18 |  | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 19 | import android.annotation.SystemApi; | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 20 | import android.content.ComponentName; | 
|  | 21 | import android.content.Context; | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 22 | import android.graphics.drawable.Drawable; | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 23 | import android.graphics.drawable.Icon; | 
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 24 | import android.os.Bundle; | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 25 | import android.os.Parcel; | 
|  | 26 | import android.os.Parcelable; | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 27 |  | 
| Sailesh Nepal | f20b916 | 2014-08-12 11:53:32 -0700 | [diff] [blame] | 28 | import java.util.Objects; | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 29 |  | 
|  | 30 | /** | 
|  | 31 | * Contains status label and icon displayed in the in-call UI. | 
|  | 32 | */ | 
|  | 33 | public final class StatusHints implements Parcelable { | 
|  | 34 |  | 
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 35 | private final CharSequence mLabel; | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 36 | private final Icon mIcon; | 
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 37 | private final Bundle mExtras; | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 38 |  | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 39 | /** | 
|  | 40 | * @hide | 
|  | 41 | */ | 
|  | 42 | @SystemApi @Deprecated | 
| Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 43 | public StatusHints(ComponentName packageName, CharSequence label, int iconResId, | 
|  | 44 | Bundle extras) { | 
| Sailesh Nepal | d9be9cf | 2015-05-14 18:28:10 -0700 | [diff] [blame] | 45 | this(label, iconResId == 0 ? null : Icon.createWithResource(packageName.getPackageName(), | 
|  | 46 | iconResId), extras); | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 47 | } | 
|  | 48 |  | 
|  | 49 | public StatusHints(CharSequence label, Icon icon, Bundle extras) { | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 50 | mLabel = label; | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 51 | mIcon = icon; | 
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 52 | mExtras = extras; | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 53 | } | 
|  | 54 |  | 
|  | 55 | /** | 
| Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 56 | * @return A package used to load the icon. | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 57 | * | 
|  | 58 | * @hide | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 59 | */ | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 60 | @SystemApi @Deprecated | 
| Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 61 | public ComponentName getPackageName() { | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 62 | // Minimal compatibility shim for legacy apps' tests | 
|  | 63 | return new ComponentName("", ""); | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 64 | } | 
|  | 65 |  | 
|  | 66 | /** | 
|  | 67 | * @return The label displayed in the in-call UI. | 
|  | 68 | */ | 
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 69 | public CharSequence getLabel() { | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 70 | return mLabel; | 
|  | 71 | } | 
|  | 72 |  | 
|  | 73 | /** | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 74 | * The icon resource ID for the icon to show. | 
|  | 75 | * | 
|  | 76 | * @return A resource ID. | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 77 | * | 
|  | 78 | * @hide | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 79 | */ | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 80 | @SystemApi @Deprecated | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 81 | public int getIconResId() { | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 82 | // Minimal compatibility shim for legacy apps' tests | 
|  | 83 | return 0; | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 84 | } | 
|  | 85 |  | 
|  | 86 | /** | 
|  | 87 | * @return An icon displayed in the in-call UI. | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 88 | * | 
|  | 89 | * @hide | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 90 | */ | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 91 | @SystemApi @Deprecated | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 92 | public Drawable getIcon(Context context) { | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 93 | return mIcon.loadDrawable(context); | 
|  | 94 | } | 
|  | 95 |  | 
|  | 96 | /** | 
|  | 97 | * @return An icon depicting the status. | 
|  | 98 | */ | 
|  | 99 | public Icon getIcon() { | 
|  | 100 | return mIcon; | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 101 | } | 
|  | 102 |  | 
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 103 | /** | 
|  | 104 | * @return Extra data used to display status. | 
|  | 105 | */ | 
|  | 106 | public Bundle getExtras() { | 
|  | 107 | return mExtras; | 
|  | 108 | } | 
|  | 109 |  | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 110 | @Override | 
|  | 111 | public int describeContents() { | 
|  | 112 | return 0; | 
|  | 113 | } | 
|  | 114 |  | 
|  | 115 | @Override | 
|  | 116 | public void writeToParcel(Parcel out, int flags) { | 
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 117 | out.writeCharSequence(mLabel); | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 118 | out.writeParcelable(mIcon, 0); | 
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 119 | out.writeParcelable(mExtras, 0); | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 120 | } | 
|  | 121 |  | 
| Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 122 | public static final @android.annotation.NonNull Creator<StatusHints> CREATOR | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 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 Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 134 | mLabel = in.readCharSequence(); | 
| Bernardo Rufino | 1a5cb38 | 2022-01-14 17:35:36 +0000 | [diff] [blame] | 135 | mIcon = in.readParcelable(getClass().getClassLoader(), android.graphics.drawable.Icon.class); | 
|  | 136 | mExtras = in.readParcelable(getClass().getClassLoader(), android.os.Bundle.class); | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 137 | } | 
|  | 138 |  | 
| Sailesh Nepal | f20b916 | 2014-08-12 11:53:32 -0700 | [diff] [blame] | 139 | @Override | 
|  | 140 | public boolean equals(Object other) { | 
|  | 141 | if (other != null && other instanceof StatusHints) { | 
|  | 142 | StatusHints otherHints = (StatusHints) other; | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 143 | return Objects.equals(otherHints.getLabel(), getLabel()) && | 
|  | 144 | Objects.equals(otherHints.getIcon(), getIcon()) && | 
| Sailesh Nepal | f20b916 | 2014-08-12 11:53:32 -0700 | [diff] [blame] | 145 | Objects.equals(otherHints.getExtras(), getExtras()); | 
|  | 146 | } | 
|  | 147 | return false; | 
|  | 148 | } | 
|  | 149 |  | 
|  | 150 | @Override | 
|  | 151 | public int hashCode() { | 
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame] | 152 | return Objects.hashCode(mLabel) + Objects.hashCode(mIcon) + Objects.hashCode(mExtras); | 
| Sailesh Nepal | f20b916 | 2014-08-12 11:53:32 -0700 | [diff] [blame] | 153 | } | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 154 | } |