| 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) { |
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame^] | 45 | this(label, Icon.createWithResource(packageName.getPackageName(), iconResId), extras); |
| 46 | } |
| 47 | |
| 48 | public StatusHints(CharSequence label, Icon icon, Bundle extras) { |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 49 | mLabel = label; |
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame^] | 50 | mIcon = icon; |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 51 | mExtras = extras; |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | /** |
| Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 55 | * @return A package used to load the icon. |
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame^] | 56 | * |
| 57 | * @hide |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 58 | */ |
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame^] | 59 | @SystemApi @Deprecated |
| Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 60 | public ComponentName getPackageName() { |
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame^] | 61 | // Minimal compatibility shim for legacy apps' tests |
| 62 | return new ComponentName("", ""); |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | /** |
| 66 | * @return The label displayed in the in-call UI. |
| 67 | */ |
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 68 | public CharSequence getLabel() { |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 69 | return mLabel; |
| 70 | } |
| 71 | |
| 72 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 73 | * The icon resource ID for the icon to show. |
| 74 | * |
| 75 | * @return A resource ID. |
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame^] | 76 | * |
| 77 | * @hide |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 78 | */ |
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame^] | 79 | @SystemApi @Deprecated |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 80 | public int getIconResId() { |
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame^] | 81 | // Minimal compatibility shim for legacy apps' tests |
| 82 | return 0; |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | /** |
| 86 | * @return An icon displayed in the in-call UI. |
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame^] | 87 | * |
| 88 | * @hide |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 89 | */ |
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame^] | 90 | @SystemApi @Deprecated |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 91 | public Drawable getIcon(Context context) { |
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame^] | 92 | return mIcon.loadDrawable(context); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * @return An icon depicting the status. |
| 97 | */ |
| 98 | public Icon getIcon() { |
| 99 | return mIcon; |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 100 | } |
| 101 | |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 102 | /** |
| 103 | * @return Extra data used to display status. |
| 104 | */ |
| 105 | public Bundle getExtras() { |
| 106 | return mExtras; |
| 107 | } |
| 108 | |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 109 | @Override |
| 110 | public int describeContents() { |
| 111 | return 0; |
| 112 | } |
| 113 | |
| 114 | @Override |
| 115 | public void writeToParcel(Parcel out, int flags) { |
| Santos Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 116 | out.writeCharSequence(mLabel); |
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame^] | 117 | out.writeParcelable(mIcon, 0); |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 118 | out.writeParcelable(mExtras, 0); |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 119 | } |
| 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 Cordon | 146a3e3 | 2014-07-21 00:00:44 -0700 | [diff] [blame] | 133 | mLabel = in.readCharSequence(); |
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame^] | 134 | mIcon = in.readParcelable(getClass().getClassLoader()); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 135 | mExtras = in.readParcelable(getClass().getClassLoader()); |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 136 | } |
| 137 | |
| Sailesh Nepal | f20b916 | 2014-08-12 11:53:32 -0700 | [diff] [blame] | 138 | @Override |
| 139 | public boolean equals(Object other) { |
| 140 | if (other != null && other instanceof StatusHints) { |
| 141 | StatusHints otherHints = (StatusHints) other; |
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame^] | 142 | return Objects.equals(otherHints.getLabel(), getLabel()) && |
| 143 | Objects.equals(otherHints.getIcon(), getIcon()) && |
| Sailesh Nepal | f20b916 | 2014-08-12 11:53:32 -0700 | [diff] [blame] | 144 | Objects.equals(otherHints.getExtras(), getExtras()); |
| 145 | } |
| 146 | return false; |
| 147 | } |
| 148 | |
| 149 | @Override |
| 150 | public int hashCode() { |
| Ihab Awad | a7684ed | 2015-05-13 11:34:53 -0700 | [diff] [blame^] | 151 | return Objects.hashCode(mLabel) + Objects.hashCode(mIcon) + Objects.hashCode(mExtras); |
| Sailesh Nepal | f20b916 | 2014-08-12 11:53:32 -0700 | [diff] [blame] | 152 | } |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 153 | } |