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 @Nullable private final String mName; 33 @Nullable private final Bitmap mIcon; 34 @Nullable private Set<Integer> mRecordTypesUsed; 35 AppInfoInternal( long id, String packageName, @Nullable String name, @Nullable Bitmap icon, @Nullable Set<Integer> recordTypesUsed)36 public AppInfoInternal( 37 long id, 38 String packageName, 39 @Nullable String name, 40 @Nullable Bitmap icon, 41 @Nullable Set<Integer> recordTypesUsed) { 42 mId = id; 43 mPackageName = packageName; 44 mName = name; 45 mIcon = icon; 46 mRecordTypesUsed = recordTypesUsed; 47 } 48 49 @NonNull getId()50 public long getId() { 51 return mId; 52 } 53 54 /** returns this object with the specified id */ 55 @NonNull setId(long id)56 public AppInfoInternal setId(long id) { 57 mId = id; 58 return this; 59 } 60 61 /** sets or updates the value of recordTypesUsed for app info. */ setRecordTypesUsed(@ullable Set<Integer> recordTypesUsed)62 public void setRecordTypesUsed(@Nullable Set<Integer> recordTypesUsed) { 63 mRecordTypesUsed = recordTypesUsed; 64 } 65 66 @NonNull getPackageName()67 public String getPackageName() { 68 return mPackageName; 69 } 70 71 @Nullable getName()72 public String getName() { 73 return mName; 74 } 75 76 @Nullable getIcon()77 public Bitmap getIcon() { 78 return mIcon; 79 } 80 81 @Nullable getRecordTypesUsed()82 public Set<Integer> getRecordTypesUsed() { 83 return mRecordTypesUsed; 84 } 85 86 /** returns a new {@link AppInfo} object from this object */ 87 @NonNull toExternal()88 public AppInfo toExternal() { 89 return new AppInfo.Builder(getPackageName(), getName(), getIcon()).build(); 90 } 91 } 92