UserAppInfo.java revision 60b2960cbb4df5310d054da57e2ec134b3fca0e6
1/*
2 * Copyright (C) 2017 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
17package com.android.settings.applications;
18
19import android.content.pm.ApplicationInfo;
20import android.content.pm.UserInfo;
21import android.text.TextUtils;
22
23import java.util.Objects;
24
25/**
26 * Simple class for bringing together information about application and user for which it was
27 * installed.
28 */
29public class UserAppInfo {
30    public final UserInfo userInfo;
31    public final ApplicationInfo appInfo;
32
33    public UserAppInfo(UserInfo mUserInfo, ApplicationInfo mAppInfo) {
34        this.userInfo = mUserInfo;
35        this.appInfo = mAppInfo;
36    }
37
38    @Override
39    public boolean equals(Object other) {
40        if (other == this) {
41            return true;
42        }
43        if (other == null || getClass() != other.getClass()) {
44            return false;
45        }
46
47        final UserAppInfo that = (UserAppInfo) other;
48
49        return that.userInfo.id == userInfo.id && TextUtils.equals(that.appInfo.packageName,
50                appInfo.packageName);
51    }
52
53    @Override
54    public int hashCode() {
55        return Objects.hash(userInfo.id, appInfo.packageName);
56    }
57}
58