Home | History | Annotate | Download | only in applications
      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 
     17 package com.android.settings.applications;
     18 
     19 import android.content.pm.ApplicationInfo;
     20 import android.content.pm.UserInfo;
     21 import android.text.TextUtils;
     22 
     23 import java.util.Objects;
     24 
     25 /**
     26  * Simple class for bringing together information about application and user for which it was
     27  * installed.
     28  */
     29 public 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         final UserAppInfo that = (UserAppInfo) other;
     47 
     48         // As UserInfo and AppInfo do not support hashcode/equals contract, assume
     49         // equality based on corresponding identity fields.
     50         return that.userInfo.id == userInfo.id && TextUtils.equals(that.appInfo.packageName,
     51                 appInfo.packageName);
     52     }
     53 
     54     @Override
     55     public int hashCode() {
     56         return Objects.hash(userInfo.id, appInfo.packageName);
     57     }
     58 }
     59