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