diff options
Diffstat (limited to 'Settings/src/com/android/tv/settings/enterprise/apps/UserAppInfo.java')
-rw-r--r-- | Settings/src/com/android/tv/settings/enterprise/apps/UserAppInfo.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Settings/src/com/android/tv/settings/enterprise/apps/UserAppInfo.java b/Settings/src/com/android/tv/settings/enterprise/apps/UserAppInfo.java new file mode 100644 index 000000000..b2a357e7d --- /dev/null +++ b/Settings/src/com/android/tv/settings/enterprise/apps/UserAppInfo.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.tv.settings.enterprise.apps; + +import android.content.pm.ApplicationInfo; +import android.content.pm.UserInfo; +import android.text.TextUtils; + +import java.util.Objects; + +/** + * Simple class for bringing together information about application and user for which it was + * installed. + * + * Forked from: + * Settings/src/com/android/settings/applications/UserAppInfo.java + */ +public class UserAppInfo { + public final UserInfo userInfo; + public final ApplicationInfo appInfo; + + public UserAppInfo(UserInfo mUserInfo, ApplicationInfo mAppInfo) { + this.userInfo = mUserInfo; + this.appInfo = mAppInfo; + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if (other == null || getClass() != other.getClass()) { + return false; + } + final UserAppInfo that = (UserAppInfo) other; + + // As UserInfo and AppInfo do not support hashcode/equals contract, assume + // equality based on corresponding identity fields. + return that.userInfo.id == userInfo.id && TextUtils.equals(that.appInfo.packageName, + appInfo.packageName); + } + + @Override + public int hashCode() { + return Objects.hash(userInfo.id, appInfo.packageName); + } +} |