1 /* 2 * Copyright (C) 2021 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.server.pm.pkg; 18 19 import android.annotation.CurrentTimeMillisLong; 20 import android.annotation.NonNull; 21 import android.annotation.Nullable; 22 import android.annotation.SystemApi; 23 import android.content.pm.PackageManager; 24 import android.content.pm.overlay.OverlayPaths; 25 import android.os.UserHandle; 26 import android.processor.immutability.Immutable; 27 import android.util.ArraySet; 28 29 import java.util.Map; 30 31 32 /** 33 * State for an app for a specific user, such as installed/enabled. 34 * 35 * Querying for a non-existent user does not throw an exception, so it is the responsibility of 36 * the caller to check for valid users if necessary. A default value assuming the app is installed 37 * for the non-existent user will be returned. 38 * 39 * The parent of this class is {@link PackageState}, which handles non-user state and holds one or 40 * many different {@link PackageUserState PackageUserStates}. This class is 41 * accessed through {@link PackageState#getStateForUser(UserHandle)}. 42 * 43 * @hide 44 */ 45 @SystemApi(client = SystemApi.Client.SYSTEM_SERVER) 46 @Immutable 47 public interface PackageUserState { 48 49 /** 50 * @return whether the package is marked as installed 51 */ isInstalled()52 boolean isInstalled(); 53 54 /** 55 * In epoch milliseconds. The timestamp of the first install of the app of the particular user 56 * on the device, surviving past app updates. Different users might have a different first 57 * install time. 58 * <p/> 59 * This does not survive full removal of the app (i.e., uninstalls for all users). 60 */ 61 @CurrentTimeMillisLong getFirstInstallTimeMillis()62 long getFirstInstallTimeMillis(); 63 64 // Methods below this comment are not yet exposed as API 65 66 /** 67 * @hide 68 */ 69 @NonNull 70 PackageUserState DEFAULT = PackageUserStateInternal.DEFAULT; 71 72 /** 73 * Combination of {@link #getOverlayPaths()} and {@link #getSharedLibraryOverlayPaths()} 74 * 75 * @hide 76 */ 77 @Immutable.Ignore 78 @Nullable getAllOverlayPaths()79 OverlayPaths getAllOverlayPaths(); 80 81 /** 82 * Credential encrypted /data partition inode. 83 * 84 * @hide 85 */ getCeDataInode()86 long getCeDataInode(); 87 88 /** 89 * Device encrypted /data partition inode. 90 * 91 * @hide 92 */ getDeDataInode()93 long getDeDataInode(); 94 95 /** 96 * Fully qualified class names of components explicitly disabled. 97 * 98 * @hide 99 */ 100 @NonNull getDisabledComponents()101 ArraySet<String> getDisabledComponents(); 102 103 /** 104 * @hide 105 */ 106 @PackageManager.DistractionRestriction getDistractionFlags()107 int getDistractionFlags(); 108 109 /** 110 * Fully qualified class names of components explicitly enabled. 111 * 112 * @hide 113 */ 114 @NonNull getEnabledComponents()115 ArraySet<String> getEnabledComponents(); 116 117 /** 118 * Retrieve the effective enabled state of the package itself. 119 * 120 * @hide 121 */ 122 @PackageManager.EnabledState getEnabledState()123 int getEnabledState(); 124 125 /** 126 * @hide 127 * @see PackageManager#setHarmfulAppWarning(String, CharSequence) 128 */ 129 @Nullable getHarmfulAppWarning()130 String getHarmfulAppWarning(); 131 132 /** 133 * @hide 134 */ 135 @PackageManager.InstallReason getInstallReason()136 int getInstallReason(); 137 138 /** 139 * Tracks the last calling package to set a specific enabled state for the package. 140 * 141 * @hide 142 */ 143 @Nullable getLastDisableAppCaller()144 String getLastDisableAppCaller(); 145 146 /** 147 * @hide 148 */ 149 @Immutable.Ignore 150 @Nullable getOverlayPaths()151 OverlayPaths getOverlayPaths(); 152 153 /** 154 * @hide 155 */ 156 @Immutable.Ignore 157 @NonNull getSharedLibraryOverlayPaths()158 Map<String, OverlayPaths> getSharedLibraryOverlayPaths(); 159 160 /** 161 * @hide 162 */ 163 @PackageManager.UninstallReason getUninstallReason()164 int getUninstallReason(); 165 166 /** 167 * @return whether the given fully qualified class name is explicitly enabled 168 * @hide 169 */ isComponentEnabled(@onNull String componentName)170 boolean isComponentEnabled(@NonNull String componentName); 171 172 /** 173 * @return {@link #isComponentEnabled(String)} but for explicitly disabled 174 * @hide 175 */ isComponentDisabled(@onNull String componentName)176 boolean isComponentDisabled(@NonNull String componentName); 177 178 /** 179 * @hide 180 * @see PackageManager#setApplicationHiddenSettingAsUser(String, boolean, UserHandle) 181 */ isHidden()182 boolean isHidden(); 183 184 /** 185 * @return whether the package is marked as an ephemeral app, which restricts permissions, 186 * features, visibility 187 * @hide 188 */ isInstantApp()189 boolean isInstantApp(); 190 191 /** 192 * @return whether the package has not been launched since being explicitly stopped 193 * @hide 194 */ isNotLaunched()195 boolean isNotLaunched(); 196 197 /** 198 * @return whether the package has been stopped, which can occur if it's force-stopped, data 199 * cleared, or just been installed 200 * @hide 201 */ isStopped()202 boolean isStopped(); 203 204 /** 205 * @return whether the package has been suspended, maybe by the device admin, disallowing its 206 * launch 207 * @hide 208 */ isSuspended()209 boolean isSuspended(); 210 211 /** 212 * @return whether the package was installed as a virtual preload, which may be done as part 213 * of device infrastructure auto installation outside of the initial device image 214 * @hide 215 */ isVirtualPreload()216 boolean isVirtualPreload(); 217 218 /** 219 * @return whether the package is quarantined in order to minimize ad-spam and pop ups 220 * when-not-in-use. 221 * @hide 222 */ isQuarantined()223 boolean isQuarantined(); 224 225 /** 226 * The "package:type/entry" form of the theme resource ID previously set as the splash screen. 227 * 228 * @hide 229 * @see android.window.SplashScreen#setSplashScreenTheme(int) 230 * @see android.content.res.Resources#getResourceName(int) 231 */ 232 @Nullable getSplashScreenTheme()233 String getSplashScreenTheme(); 234 235 /** 236 * @return the min aspect ratio setting of the package which by default is unset 237 * unless it has been set by the user 238 * @hide 239 */ 240 @PackageManager.UserMinAspectRatio getMinAspectRatio()241 int getMinAspectRatio(); 242 243 /** 244 * Information about the archived state of an app. Set only if an app is archived. 245 * 246 * @hide 247 */ 248 @Immutable.Ignore 249 @Nullable getArchiveState()250 ArchiveState getArchiveState(); 251 252 /** 253 * @return whether the data dir exists. True when the app is installed for the user, or when the 254 * app is uninstalled for the user with {@link PackageManager#DELETE_KEEP_DATA}. 255 * 256 * @hide 257 */ dataExists()258 boolean dataExists(); 259 } 260