1 /* 2 * Copyright (C) 2024 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.nfc; 18 19 import android.annotation.UserIdInt; 20 21 import java.util.Objects; 22 23 /** 24 * @hide 25 */ 26 public class PackageAndUser { 27 @UserIdInt private final int mUserId; 28 private String mPackage; 29 PackageAndUser(@serIdInt int userId, String pkg)30 public PackageAndUser(@UserIdInt int userId, String pkg) { 31 mUserId = userId; 32 mPackage = pkg; 33 } 34 35 /** 36 * @hide 37 */ describeContents()38 public int describeContents() { 39 return 0; 40 } 41 42 @UserIdInt getUserId()43 public int getUserId() { 44 return mUserId; 45 } 46 getPackage()47 public String getPackage() { 48 return mPackage; 49 } 50 51 @Override toString()52 public String toString() { 53 return mPackage + " for user id: " + mUserId; 54 } 55 56 @Override equals(Object obj)57 public boolean equals(Object obj) { 58 if (obj != null && obj instanceof PackageAndUser) { 59 PackageAndUser other = (PackageAndUser) obj; 60 return other.getUserId() == mUserId 61 && Objects.equals(other.getPackage(), mPackage); 62 } 63 return false; 64 } 65 66 @Override hashCode()67 public int hashCode() { 68 if (mPackage == null) { 69 return mUserId; 70 } 71 return mPackage.hashCode() + mUserId; 72 } 73 } 74