1 /* 2 * Copyright (C) 2023 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 com.android.settings.connecteddevice.audiosharing; 18 19 import android.os.Parcel; 20 import android.os.Parcelable; 21 22 import androidx.annotation.NonNull; 23 import androidx.annotation.Nullable; 24 25 import java.util.Objects; 26 27 public final class AudioSharingDeviceItem implements Parcelable { 28 private final String mName; 29 private final int mGroupId; 30 private final boolean mIsActive; 31 AudioSharingDeviceItem(String name, int groupId, boolean isActive)32 public AudioSharingDeviceItem(String name, int groupId, boolean isActive) { 33 mName = name; 34 mGroupId = groupId; 35 mIsActive = isActive; 36 } 37 getName()38 public String getName() { 39 return mName; 40 } 41 getGroupId()42 public int getGroupId() { 43 return mGroupId; 44 } 45 isActive()46 public boolean isActive() { 47 return mIsActive; 48 } 49 AudioSharingDeviceItem(Parcel in)50 public AudioSharingDeviceItem(Parcel in) { 51 mName = in.readString(); 52 mGroupId = in.readInt(); 53 mIsActive = in.readBoolean(); 54 } 55 56 @Override writeToParcel(Parcel dest, int flags)57 public void writeToParcel(Parcel dest, int flags) { 58 dest.writeString(mName); 59 dest.writeInt(mGroupId); 60 dest.writeBoolean(mIsActive); 61 } 62 63 @Override describeContents()64 public int describeContents() { 65 return 0; 66 } 67 68 public static final Creator<AudioSharingDeviceItem> CREATOR = 69 new Creator<AudioSharingDeviceItem>() { 70 @Override 71 public AudioSharingDeviceItem createFromParcel(Parcel in) { 72 return new AudioSharingDeviceItem(in); 73 } 74 75 @Override 76 public AudioSharingDeviceItem[] newArray(int size) { 77 return new AudioSharingDeviceItem[size]; 78 } 79 }; 80 81 @Override 82 @NonNull toString()83 public String toString() { 84 return "AudioSharingDeviceItem groupId = " + mGroupId + ", isActive = " + mIsActive; 85 } 86 87 @Override equals(@ullable Object obj)88 public boolean equals(@Nullable Object obj) { 89 if (!(obj instanceof AudioSharingDeviceItem other)) return false; 90 return mName.equals(other.getName()) && mGroupId == other.getGroupId() 91 && mIsActive == other.isActive(); 92 } 93 94 @Override hashCode()95 public int hashCode() { 96 return Objects.hash(mName, mGroupId, mIsActive); 97 } 98 } 99