1 /* 2 * Copyright (C) 2023 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.health.connect.datatypes; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.graphics.Bitmap; 22 23 import java.util.Objects; 24 25 /** Application Info class containing details about a given application */ 26 public final class AppInfo { 27 /** Application name/label */ 28 private final String mName; 29 30 /** Application icon as bitmap */ 31 private final Bitmap mIcon; 32 33 /** Application package name */ 34 private final String mPackageName; 35 36 /** 37 * Builder for {@link AppInfo} 38 * 39 * @hide 40 */ 41 public static final class Builder { 42 private final String mPackageName; 43 private final String mName; 44 private final Bitmap mIcon; 45 46 /** 47 * @param packageName package name of the application 48 * @param name name/label of the application. Optional 49 * @param icon icon of the application. Optional. 50 */ 51 @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression Builder(@onNull String packageName, @Nullable String name, @Nullable Bitmap icon)52 public Builder(@NonNull String packageName, @Nullable String name, @Nullable Bitmap icon) { 53 Objects.requireNonNull(packageName); 54 mPackageName = packageName; 55 mName = name; 56 mIcon = icon; 57 } 58 59 /** 60 * @return Object of {@link AppInfo} 61 */ 62 @NonNull build()63 public AppInfo build() { 64 return new AppInfo(mPackageName, mName, mIcon); 65 } 66 } 67 68 @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression AppInfo(@onNull String packageName, @Nullable String name, @Nullable Bitmap icon)69 private AppInfo(@NonNull String packageName, @Nullable String name, @Nullable Bitmap icon) { 70 Objects.requireNonNull(packageName); 71 mPackageName = packageName; 72 mName = name; 73 mIcon = icon; 74 } 75 76 /** Returns the application package name */ 77 @NonNull getPackageName()78 public String getPackageName() { 79 return mPackageName; 80 } 81 82 /** Returns the application icon as bitmap */ 83 @Nullable getIcon()84 public Bitmap getIcon() { 85 return mIcon; 86 } 87 88 /** Returns the application name/label */ 89 @Nullable getName()90 public String getName() { 91 return mName; 92 } 93 } 94