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 package android.health.connect.internal.datatypes; 17 18 import android.annotation.NonNull; 19 import android.annotation.Nullable; 20 import android.graphics.Bitmap; 21 import android.health.connect.datatypes.AppInfo; 22 23 import java.util.Set; 24 25 /** 26 * @hide 27 * @see AppInfo 28 */ 29 public final class AppInfoInternal { 30 private long mId; 31 private final String mPackageName; 32 private final String mName; 33 private final Bitmap mIcon; 34 35 private Set<Integer> mRecordTypesUsed; 36 37 @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression AppInfoInternal( @onNull long id, @NonNull String packageName, @Nullable String name, @Nullable Bitmap icon, @Nullable Set<Integer> recordTypesUsed)38 public AppInfoInternal( 39 @NonNull long id, 40 @NonNull String packageName, 41 @Nullable String name, 42 @Nullable Bitmap icon, 43 @Nullable Set<Integer> recordTypesUsed) { 44 mId = id; 45 mPackageName = packageName; 46 mName = name; 47 mIcon = icon; 48 mRecordTypesUsed = recordTypesUsed; 49 } 50 51 @NonNull getId()52 public long getId() { 53 return mId; 54 } 55 56 /** returns this object with the specified id */ 57 @NonNull setId(long id)58 public AppInfoInternal setId(long id) { 59 mId = id; 60 return this; 61 } 62 63 /** sets or updates the value of recordTypesUsed for app info. */ 64 @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression setRecordTypesUsed(@ullable Set<Integer> recordTypesUsed)65 public void setRecordTypesUsed(@Nullable Set<Integer> recordTypesUsed) { 66 mRecordTypesUsed = recordTypesUsed; 67 } 68 69 @NonNull getPackageName()70 public String getPackageName() { 71 return mPackageName; 72 } 73 74 @Nullable getName()75 public String getName() { 76 return mName; 77 } 78 79 @Nullable getIcon()80 public Bitmap getIcon() { 81 return mIcon; 82 } 83 84 @Nullable getRecordTypesUsed()85 public Set<Integer> getRecordTypesUsed() { 86 return mRecordTypesUsed; 87 } 88 89 /** returns a new {@link AppInfo} object from this object */ 90 @NonNull toExternal()91 public AppInfo toExternal() { 92 return new AppInfo.Builder(getPackageName(), getName(), getIcon()).build(); 93 } 94 } 95