• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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.car.carlauncher;
18 
19 import android.annotation.Nullable;
20 import android.graphics.drawable.Drawable;
21 
22 /**
23  * Meta data of an app including the display name, the full package name, and the icon drawable.
24  */
25 
26 final class AppMetaData {
27     // The display name of the app
28     @Nullable
29     private String mDisplayName;
30     // The package name of the app
31     private String mPackageName;
32     private Drawable mIcon;
33     private boolean mIsDistractionOptimized;
34 
AppMetaData( CharSequence displayName, String packageName, Drawable icon, boolean isDistractionOptimized)35     public AppMetaData(
36             CharSequence displayName,
37             String packageName,
38             Drawable icon,
39             boolean isDistractionOptimized) {
40         mDisplayName = displayName == null ? "" : displayName.toString();
41         mPackageName = packageName == null ? "" : packageName;
42         mIcon = icon;
43         mIsDistractionOptimized = isDistractionOptimized;
44     }
45 
getDisplayName()46     public String getDisplayName() {
47         return mDisplayName;
48     }
49 
getPackageName()50     public String getPackageName() {
51         return mPackageName;
52     }
53 
getIcon()54     public Drawable getIcon() {
55         return mIcon;
56     }
57 
getIsDistractionOptimized()58     public boolean getIsDistractionOptimized() {
59         return mIsDistractionOptimized;
60     }
61 
62     /**
63      * The equality of two AppMetaData is determined by whether the package names are the same.
64      *
65      * @param o Object that this AppMetaData object is compared against
66      * @return {@code true} when two AppMetaData have the same package name
67      */
68     @Override
equals(Object o)69     public boolean equals(Object o) {
70         if (!(o instanceof AppMetaData)) {
71             return false;
72         } else {
73             return ((AppMetaData) o).getPackageName().equals(mPackageName);
74         }
75     }
76 
77     @Override
hashCode()78     public int hashCode() {
79         return mPackageName.hashCode();
80     }
81 }
82