1 /** 2 * Copyright (c) 2020, 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 android.service.notification; 18 19 import android.annotation.Nullable; 20 import android.app.NotificationChannel; 21 import android.content.pm.ShortcutInfo; 22 import android.graphics.drawable.Drawable; 23 import android.os.Parcel; 24 import android.os.Parcelable; 25 26 import java.util.Objects; 27 28 /** 29 * @hide 30 */ 31 public final class ConversationChannelWrapper implements Parcelable { 32 33 private NotificationChannel mNotificationChannel; 34 private CharSequence mGroupLabel; 35 private CharSequence mParentChannelLabel; 36 private ShortcutInfo mShortcutInfo; 37 private String mPkg; 38 private int mUid; 39 ConversationChannelWrapper()40 public ConversationChannelWrapper() {} 41 ConversationChannelWrapper(Parcel in)42 protected ConversationChannelWrapper(Parcel in) { 43 mNotificationChannel = in.readParcelable(NotificationChannel.class.getClassLoader()); 44 mGroupLabel = in.readCharSequence(); 45 mParentChannelLabel = in.readCharSequence(); 46 mShortcutInfo = in.readParcelable(ShortcutInfo.class.getClassLoader()); 47 mPkg = in.readStringNoHelper(); 48 mUid = in.readInt(); 49 } 50 51 @Override writeToParcel(Parcel dest, int flags)52 public void writeToParcel(Parcel dest, int flags) { 53 dest.writeParcelable(mNotificationChannel, flags); 54 dest.writeCharSequence(mGroupLabel); 55 dest.writeCharSequence(mParentChannelLabel); 56 dest.writeParcelable(mShortcutInfo, flags); 57 dest.writeStringNoHelper(mPkg); 58 dest.writeInt(mUid); 59 } 60 61 @Override describeContents()62 public int describeContents() { 63 return 0; 64 } 65 66 public static final Creator<ConversationChannelWrapper> CREATOR = 67 new Creator<ConversationChannelWrapper>() { 68 @Override 69 public ConversationChannelWrapper createFromParcel(Parcel in) { 70 return new ConversationChannelWrapper(in); 71 } 72 73 @Override 74 public ConversationChannelWrapper[] newArray(int size) { 75 return new ConversationChannelWrapper[size]; 76 } 77 }; 78 79 getNotificationChannel()80 public NotificationChannel getNotificationChannel() { 81 return mNotificationChannel; 82 } 83 setNotificationChannel( NotificationChannel notificationChannel)84 public void setNotificationChannel( 85 NotificationChannel notificationChannel) { 86 mNotificationChannel = notificationChannel; 87 } 88 getGroupLabel()89 public CharSequence getGroupLabel() { 90 return mGroupLabel; 91 } 92 setGroupLabel(CharSequence groupLabel)93 public void setGroupLabel(CharSequence groupLabel) { 94 mGroupLabel = groupLabel; 95 } 96 getParentChannelLabel()97 public CharSequence getParentChannelLabel() { 98 return mParentChannelLabel; 99 } 100 setParentChannelLabel(CharSequence parentChannelLabel)101 public void setParentChannelLabel(CharSequence parentChannelLabel) { 102 mParentChannelLabel = parentChannelLabel; 103 } 104 getShortcutInfo()105 public ShortcutInfo getShortcutInfo() { 106 return mShortcutInfo; 107 } 108 setShortcutInfo(ShortcutInfo shortcutInfo)109 public void setShortcutInfo(ShortcutInfo shortcutInfo) { 110 mShortcutInfo = shortcutInfo; 111 } 112 getPkg()113 public String getPkg() { 114 return mPkg; 115 } 116 setPkg(String pkg)117 public void setPkg(String pkg) { 118 mPkg = pkg; 119 } 120 getUid()121 public int getUid() { 122 return mUid; 123 } 124 setUid(int uid)125 public void setUid(int uid) { 126 mUid = uid; 127 } 128 129 @Override equals(@ullable Object o)130 public boolean equals(@Nullable Object o) { 131 if (this == o) return true; 132 if (o == null || getClass() != o.getClass()) return false; 133 ConversationChannelWrapper that = (ConversationChannelWrapper) o; 134 return Objects.equals(getNotificationChannel(), that.getNotificationChannel()) && 135 Objects.equals(getGroupLabel(), that.getGroupLabel()) && 136 Objects.equals(getParentChannelLabel(), that.getParentChannelLabel()) && 137 Objects.equals(getShortcutInfo(), that.getShortcutInfo()) && 138 Objects.equals(getPkg(), that.getPkg()) && 139 getUid() == that.getUid(); 140 } 141 142 @Override hashCode()143 public int hashCode() { 144 return Objects.hash(getNotificationChannel(), getGroupLabel(), getParentChannelLabel(), 145 getShortcutInfo(), getPkg(), getUid()); 146 } 147 } 148