Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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.content.pm; |
| 18 | |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 19 | import android.annotation.IntDef; |
| 20 | import android.annotation.NonNull; |
| 21 | import android.annotation.Nullable; |
Makoto Onuki | 2d5b465 | 2016-03-11 16:09:54 -0800 | [diff] [blame] | 22 | import android.content.ComponentName; |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 23 | import android.content.Intent; |
Todd Kennedy | 18211fd | 2017-06-06 09:15:46 -0700 | [diff] [blame] | 24 | import android.content.pm.PackageManager.ApplicationInfoFlags; |
| 25 | import android.content.pm.PackageManager.ComponentInfoFlags; |
Todd Kennedy | 18211fd | 2017-06-06 09:15:46 -0700 | [diff] [blame] | 26 | import android.content.pm.PackageManager.PackageInfoFlags; |
| 27 | import android.content.pm.PackageManager.ResolveInfoFlags; |
Chad Brubaker | 0606861 | 2017-04-06 09:43:47 -0700 | [diff] [blame] | 28 | import android.os.Bundle; |
Suprabh Shukla | 19b41f3 | 2018-03-26 22:35:13 -0700 | [diff] [blame] | 29 | import android.os.PersistableBundle; |
Makoto Onuki | c29f62c | 2016-06-07 12:19:46 -0700 | [diff] [blame] | 30 | import android.util.SparseArray; |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 31 | |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 32 | import java.lang.annotation.Retention; |
| 33 | import java.lang.annotation.RetentionPolicy; |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 34 | import java.util.List; |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Package manager local system service interface. |
| 38 | * |
| 39 | * @hide Only for use within the system server. |
| 40 | */ |
| 41 | public abstract class PackageManagerInternal { |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 42 | public static final int PACKAGE_SYSTEM = 0; |
| 43 | public static final int PACKAGE_SETUP_WIZARD = 1; |
| 44 | public static final int PACKAGE_INSTALLER = 2; |
| 45 | public static final int PACKAGE_VERIFIER = 3; |
| 46 | public static final int PACKAGE_BROWSER = 4; |
Makoto Onuki | 700feef | 2018-02-15 10:59:41 -0800 | [diff] [blame] | 47 | public static final int PACKAGE_SYSTEM_TEXT_CLASSIFIER = 5; |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 48 | @IntDef(value = { |
| 49 | PACKAGE_SYSTEM, |
| 50 | PACKAGE_SETUP_WIZARD, |
| 51 | PACKAGE_INSTALLER, |
| 52 | PACKAGE_VERIFIER, |
| 53 | PACKAGE_BROWSER, |
Makoto Onuki | 700feef | 2018-02-15 10:59:41 -0800 | [diff] [blame] | 54 | PACKAGE_SYSTEM_TEXT_CLASSIFIER, |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 55 | }) |
| 56 | @Retention(RetentionPolicy.SOURCE) |
| 57 | public @interface KnownPackage {} |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 58 | |
Todd Kennedy | 42d6160 | 2017-12-12 14:44:19 -0800 | [diff] [blame] | 59 | /** Observer called whenever the list of packages changes */ |
| 60 | public interface PackageListObserver { |
| 61 | /** A package was added to the system. */ |
| 62 | void onPackageAdded(@NonNull String packageName); |
| 63 | /** A package was removed from the system. */ |
| 64 | void onPackageRemoved(@NonNull String packageName); |
| 65 | } |
| 66 | |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 67 | /** |
| 68 | * Provider for package names. |
| 69 | */ |
| 70 | public interface PackagesProvider { |
| 71 | |
| 72 | /** |
| 73 | * Gets the packages for a given user. |
| 74 | * @param userId The user id. |
| 75 | * @return The package names. |
| 76 | */ |
| 77 | public String[] getPackages(int userId); |
| 78 | } |
| 79 | |
| 80 | /** |
Svetoslav | 0010b70 | 2015-06-30 18:05:26 -0700 | [diff] [blame] | 81 | * Provider for package names. |
| 82 | */ |
| 83 | public interface SyncAdapterPackagesProvider { |
| 84 | |
| 85 | /** |
| 86 | * Gets the sync adapter packages for given authority and user. |
| 87 | * @param authority The authority. |
| 88 | * @param userId The user id. |
| 89 | * @return The package names. |
| 90 | */ |
| 91 | public String[] getPackages(String authority, int userId); |
| 92 | } |
| 93 | |
| 94 | /** |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 95 | * Sets the location provider packages provider. |
| 96 | * @param provider The packages provider. |
| 97 | */ |
| 98 | public abstract void setLocationPackagesProvider(PackagesProvider provider); |
| 99 | |
| 100 | /** |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 101 | * Sets the voice interaction packages provider. |
| 102 | * @param provider The packages provider. |
| 103 | */ |
| 104 | public abstract void setVoiceInteractionPackagesProvider(PackagesProvider provider); |
Svetoslav | cdfd230 | 2015-06-25 19:07:31 -0700 | [diff] [blame] | 105 | |
| 106 | /** |
| 107 | * Sets the SMS packages provider. |
| 108 | * @param provider The packages provider. |
| 109 | */ |
| 110 | public abstract void setSmsAppPackagesProvider(PackagesProvider provider); |
| 111 | |
| 112 | /** |
| 113 | * Sets the dialer packages provider. |
| 114 | * @param provider The packages provider. |
| 115 | */ |
| 116 | public abstract void setDialerAppPackagesProvider(PackagesProvider provider); |
| 117 | |
| 118 | /** |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 119 | * Sets the sim call manager packages provider. |
| 120 | * @param provider The packages provider. |
| 121 | */ |
| 122 | public abstract void setSimCallManagerPackagesProvider(PackagesProvider provider); |
| 123 | |
| 124 | /** |
Eric Enslen | 1e423b9 | 2017-12-18 11:30:21 -0800 | [diff] [blame] | 125 | * Sets the Use Open Wifi packages provider. |
| 126 | * @param provider The packages provider. |
| 127 | */ |
| 128 | public abstract void setUseOpenWifiAppPackagesProvider(PackagesProvider provider); |
| 129 | |
| 130 | /** |
Svetoslav | 0010b70 | 2015-06-30 18:05:26 -0700 | [diff] [blame] | 131 | * Sets the sync adapter packages provider. |
| 132 | * @param provider The provider. |
| 133 | */ |
| 134 | public abstract void setSyncAdapterPackagesprovider(SyncAdapterPackagesProvider provider); |
| 135 | |
| 136 | /** |
Svetoslav | cdfd230 | 2015-06-25 19:07:31 -0700 | [diff] [blame] | 137 | * Requests granting of the default permissions to the current default SMS app. |
| 138 | * @param packageName The default SMS package name. |
| 139 | * @param userId The user for which to grant the permissions. |
| 140 | */ |
| 141 | public abstract void grantDefaultPermissionsToDefaultSmsApp(String packageName, int userId); |
| 142 | |
| 143 | /** |
| 144 | * Requests granting of the default permissions to the current default dialer app. |
| 145 | * @param packageName The default dialer package name. |
| 146 | * @param userId The user for which to grant the permissions. |
| 147 | */ |
| 148 | public abstract void grantDefaultPermissionsToDefaultDialerApp(String packageName, int userId); |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 149 | |
| 150 | /** |
| 151 | * Requests granting of the default permissions to the current default sim call manager. |
| 152 | * @param packageName The default sim call manager package name. |
| 153 | * @param userId The user for which to grant the permissions. |
| 154 | */ |
| 155 | public abstract void grantDefaultPermissionsToDefaultSimCallManager(String packageName, |
| 156 | int userId); |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 157 | |
| 158 | /** |
Eric Enslen | 1e423b9 | 2017-12-18 11:30:21 -0800 | [diff] [blame] | 159 | * Requests granting of the default permissions to the current default Use Open Wifi app. |
| 160 | * @param packageName The default use open wifi package name. |
| 161 | * @param userId The user for which to grant the permissions. |
| 162 | */ |
| 163 | public abstract void grantDefaultPermissionsToDefaultUseOpenWifiApp(String packageName, |
| 164 | int userId); |
| 165 | |
| 166 | /** |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 167 | * Sets a list of apps to keep in PM's internal data structures and as APKs even if no user has |
| 168 | * currently installed it. The apps are not preloaded. |
| 169 | * @param packageList List of package names to keep cached. |
| 170 | */ |
| 171 | public abstract void setKeepUninstalledPackages(List<String> packageList); |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 172 | |
| 173 | /** |
| 174 | * Gets whether some of the permissions used by this package require a user |
| 175 | * review before any of the app components can run. |
| 176 | * @param packageName The package name for which to check. |
| 177 | * @param userId The user under which to check. |
| 178 | * @return True a permissions review is required. |
| 179 | */ |
| 180 | public abstract boolean isPermissionsReviewRequired(String packageName, int userId); |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 181 | |
| 182 | /** |
Todd Kennedy | 18211fd | 2017-06-06 09:15:46 -0700 | [diff] [blame] | 183 | * Retrieve all of the information we know about a particular package/application. |
| 184 | * @param filterCallingUid The results will be filtered in the context of this UID instead |
| 185 | * of the calling UID. |
| 186 | * @see PackageManager#getPackageInfo(String, int) |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 187 | */ |
Todd Kennedy | 18211fd | 2017-06-06 09:15:46 -0700 | [diff] [blame] | 188 | public abstract PackageInfo getPackageInfo(String packageName, |
| 189 | @PackageInfoFlags int flags, int filterCallingUid, int userId); |
| 190 | |
| 191 | /** |
Suprabh Shukla | 19b41f3 | 2018-03-26 22:35:13 -0700 | [diff] [blame] | 192 | * Retrieve launcher extras for a suspended package provided to the system in |
| 193 | * {@link PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, |
| 194 | * PersistableBundle, String)} |
| 195 | * |
| 196 | * @param packageName The package for which to return launcher extras. |
| 197 | * @param userId The user for which to check, |
| 198 | * @return The launcher extras. |
| 199 | * |
| 200 | * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, |
| 201 | * PersistableBundle, String) |
| 202 | * @see PackageManager#isPackageSuspended() |
| 203 | */ |
| 204 | public abstract Bundle getSuspendedPackageLauncherExtras(String packageName, |
| 205 | int userId); |
| 206 | |
| 207 | /** |
Christopher Tate | a732f01 | 2017-10-26 17:26:53 -0700 | [diff] [blame] | 208 | * Do a straight uid lookup for the given package/application in the given user. |
| 209 | * @see PackageManager#getPackageUidAsUser(String, int, int) |
| 210 | * @return The app's uid, or < 0 if the package was not found in that user |
| 211 | */ |
| 212 | public abstract int getPackageUid(String packageName, |
| 213 | @PackageInfoFlags int flags, int userId); |
| 214 | |
| 215 | /** |
Todd Kennedy | 18211fd | 2017-06-06 09:15:46 -0700 | [diff] [blame] | 216 | * Retrieve all of the information we know about a particular package/application. |
| 217 | * @param filterCallingUid The results will be filtered in the context of this UID instead |
| 218 | * of the calling UID. |
| 219 | * @see PackageManager#getApplicationInfo(String, int) |
| 220 | */ |
| 221 | public abstract ApplicationInfo getApplicationInfo(String packageName, |
| 222 | @ApplicationInfoFlags int flags, int filterCallingUid, int userId); |
| 223 | |
| 224 | /** |
| 225 | * Retrieve all of the information we know about a particular activity class. |
| 226 | * @param filterCallingUid The results will be filtered in the context of this UID instead |
| 227 | * of the calling UID. |
| 228 | * @see PackageManager#getActivityInfo(ComponentName, int) |
| 229 | */ |
| 230 | public abstract ActivityInfo getActivityInfo(ComponentName component, |
| 231 | @ComponentInfoFlags int flags, int filterCallingUid, int userId); |
| 232 | |
| 233 | /** |
| 234 | * Retrieve all activities that can be performed for the given intent. |
| 235 | * @param filterCallingUid The results will be filtered in the context of this UID instead |
| 236 | * of the calling UID. |
| 237 | * @see PackageManager#queryIntentActivities(Intent, int) |
| 238 | */ |
| 239 | public abstract List<ResolveInfo> queryIntentActivities(Intent intent, |
| 240 | @ResolveInfoFlags int flags, int filterCallingUid, int userId); |
Makoto Onuki | 2d5b465 | 2016-03-11 16:09:54 -0800 | [diff] [blame] | 241 | |
| 242 | /** |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 243 | * Retrieve all services that can be performed for the given intent. |
| 244 | * @see PackageManager#queryIntentServices(Intent, int) |
| 245 | */ |
| 246 | public abstract List<ResolveInfo> queryIntentServices( |
| 247 | Intent intent, int flags, int callingUid, int userId); |
| 248 | |
| 249 | /** |
Makoto Onuki | 2d5b465 | 2016-03-11 16:09:54 -0800 | [diff] [blame] | 250 | * Interface to {@link com.android.server.pm.PackageManagerService#getHomeActivitiesAsUser}. |
| 251 | */ |
| 252 | public abstract ComponentName getHomeActivitiesAsUser(List<ResolveInfo> allHomeCandidates, |
| 253 | int userId); |
Makoto Onuki | c29f62c | 2016-06-07 12:19:46 -0700 | [diff] [blame] | 254 | |
| 255 | /** |
Winson Chung | c167427 | 2018-02-21 10:15:17 -0800 | [diff] [blame] | 256 | * @return The default home activity component name. |
| 257 | */ |
| 258 | public abstract ComponentName getDefaultHomeActivity(int userId); |
| 259 | |
| 260 | /** |
Makoto Onuki | c29f62c | 2016-06-07 12:19:46 -0700 | [diff] [blame] | 261 | * Called by DeviceOwnerManagerService to set the package names of device owner and profile |
| 262 | * owners. |
| 263 | */ |
| 264 | public abstract void setDeviceAndProfileOwnerPackages( |
| 265 | int deviceOwnerUserId, String deviceOwner, SparseArray<String> profileOwners); |
| 266 | |
| 267 | /** |
Steven Ng | 9d48a73 | 2016-06-24 19:04:14 +0100 | [diff] [blame] | 268 | * Returns {@code true} if a given package can't be wiped. Otherwise, returns {@code false}. |
Makoto Onuki | c29f62c | 2016-06-07 12:19:46 -0700 | [diff] [blame] | 269 | */ |
Steven Ng | 9d48a73 | 2016-06-24 19:04:14 +0100 | [diff] [blame] | 270 | public abstract boolean isPackageDataProtected(int userId, String packageName); |
Svet Ganov | 973edd19 | 2016-09-08 20:15:55 -0700 | [diff] [blame] | 271 | |
| 272 | /** |
Dianne Hackborn | e07641d | 2016-11-09 15:07:23 -0800 | [diff] [blame] | 273 | * Returns {@code true} if a given package is installed as ephemeral. Otherwise, returns |
| 274 | * {@code false}. |
| 275 | */ |
| 276 | public abstract boolean isPackageEphemeral(int userId, String packageName); |
| 277 | |
| 278 | /** |
Svet Ganov | 973edd19 | 2016-09-08 20:15:55 -0700 | [diff] [blame] | 279 | * Gets whether the package was ever launched. |
| 280 | * @param packageName The package name. |
| 281 | * @param userId The user for which to check. |
| 282 | * @return Whether was launched. |
Amith Yamasani | 2cbfa1e | 2017-03-28 10:34:01 -0700 | [diff] [blame] | 283 | * @throws IllegalArgumentException if the package is not found |
Svet Ganov | 973edd19 | 2016-09-08 20:15:55 -0700 | [diff] [blame] | 284 | */ |
| 285 | public abstract boolean wasPackageEverLaunched(String packageName, int userId); |
Nicolas Prevot | 700e1e7 | 2016-09-28 15:17:18 +0100 | [diff] [blame] | 286 | |
| 287 | /** |
| 288 | * Grants a runtime permission |
| 289 | * @param packageName The package name. |
| 290 | * @param name The name of the permission. |
| 291 | * @param userId The userId for which to grant the permission. |
| 292 | * @param overridePolicy If true, grant this permission even if it is fixed by policy. |
| 293 | */ |
| 294 | public abstract void grantRuntimePermission(String packageName, String name, int userId, |
| 295 | boolean overridePolicy); |
| 296 | |
| 297 | /** |
| 298 | * Revokes a runtime permission |
| 299 | * @param packageName The package name. |
| 300 | * @param name The name of the permission. |
| 301 | * @param userId The userId for which to revoke the permission. |
| 302 | * @param overridePolicy If true, revoke this permission even if it is fixed by policy. |
| 303 | */ |
| 304 | public abstract void revokeRuntimePermission(String packageName, String name, int userId, |
| 305 | boolean overridePolicy); |
| 306 | |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 307 | /** |
Michal Karpinski | cb67dc9 | 2016-12-13 18:20:23 +0000 | [diff] [blame] | 308 | * Retrieve the official name associated with a uid. This name is |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 309 | * guaranteed to never change, though it is possible for the underlying |
Michal Karpinski | cb67dc9 | 2016-12-13 18:20:23 +0000 | [diff] [blame] | 310 | * uid to be changed. That is, if you are storing information about |
| 311 | * uids in persistent storage, you should use the string returned |
| 312 | * by this function instead of the raw uid. |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 313 | * |
Michal Karpinski | cb67dc9 | 2016-12-13 18:20:23 +0000 | [diff] [blame] | 314 | * @param uid The uid for which you would like to retrieve a name. |
| 315 | * @return Returns a unique name for the given uid, or null if the |
| 316 | * uid is not currently assigned. |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 317 | */ |
| 318 | public abstract String getNameForUid(int uid); |
| 319 | |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 320 | /** |
| 321 | * Request to perform the second phase of ephemeral resolution. |
| 322 | * @param responseObj The response of the first phase of ephemeral resolution |
| 323 | * @param origIntent The original intent that triggered ephemeral resolution |
| 324 | * @param resolvedType The resolved type of the intent |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 325 | * @param callingPackage The name of the package requesting the ephemeral application |
Chad Brubaker | 0606861 | 2017-04-06 09:43:47 -0700 | [diff] [blame] | 326 | * @param verificationBundle Optional bundle to pass to the installer for additional |
| 327 | * verification |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 328 | * @param userId The ID of the user that triggered ephemeral resolution |
| 329 | */ |
Todd Kennedy | e991022 | 2017-02-21 16:00:11 -0800 | [diff] [blame] | 330 | public abstract void requestInstantAppResolutionPhaseTwo(AuxiliaryResolveInfo responseObj, |
| 331 | Intent origIntent, String resolvedType, String callingPackage, |
Chad Brubaker | 0606861 | 2017-04-06 09:43:47 -0700 | [diff] [blame] | 332 | Bundle verificationBundle, int userId); |
Svetoslav Ganov | e080da9 | 2016-12-21 17:10:35 -0800 | [diff] [blame] | 333 | |
| 334 | /** |
Todd Kennedy | 0e989d0 | 2017-01-13 14:15:36 -0800 | [diff] [blame] | 335 | * Grants access to the package metadata for an ephemeral application. |
| 336 | * <p> |
| 337 | * When an ephemeral application explicitly tries to interact with a full |
| 338 | * install application [via an activity, service or provider that has been |
| 339 | * exposed using the {@code visibleToInstantApp} attribute], the normal |
| 340 | * application must be able to see metadata about the connecting ephemeral |
| 341 | * app. If the ephemeral application uses an implicit intent [ie action VIEW, |
| 342 | * category BROWSABLE], it remains hidden from the launched activity. |
| 343 | * <p> |
| 344 | * If the {@code sourceUid} is not for an ephemeral app or {@code targetUid} |
| 345 | * is not for a fully installed app, this method will be a no-op. |
| 346 | * |
| 347 | * @param userId the user |
| 348 | * @param intent the intent that triggered the grant |
| 349 | * @param targetAppId The app ID of the fully installed application |
| 350 | * @param ephemeralAppId The app ID of the ephemeral application |
| 351 | */ |
| 352 | public abstract void grantEphemeralAccess(int userId, Intent intent, |
| 353 | int targetAppId, int ephemeralAppId); |
| 354 | |
Todd Kennedy | b21be12 | 2017-03-24 14:10:01 -0700 | [diff] [blame] | 355 | public abstract boolean isInstantAppInstallerComponent(ComponentName component); |
Todd Kennedy | 0e989d0 | 2017-01-13 14:15:36 -0800 | [diff] [blame] | 356 | /** |
Svetoslav Ganov | 096d304 | 2017-01-30 16:34:13 -0800 | [diff] [blame] | 357 | * Prunes instant apps and state associated with uninstalled |
| 358 | * instant apps according to the current platform policy. |
| 359 | */ |
| 360 | public abstract void pruneInstantApps(); |
| 361 | |
| 362 | /** |
Svetoslav Ganov | e080da9 | 2016-12-21 17:10:35 -0800 | [diff] [blame] | 363 | * @return The SetupWizard package name. |
| 364 | */ |
| 365 | public abstract String getSetupWizardPackageName(); |
Suprabh Shukla | aef2513 | 2017-01-23 18:09:03 -0800 | [diff] [blame] | 366 | |
| 367 | public interface ExternalSourcesPolicy { |
| 368 | |
| 369 | int USER_TRUSTED = 0; // User has trusted the package to install apps |
| 370 | int USER_BLOCKED = 1; // User has blocked the package to install apps |
| 371 | int USER_DEFAULT = 2; // Default code to use when user response is unavailable |
| 372 | |
| 373 | /** |
| 374 | * Checks the user preference for whether a package is trusted to request installs through |
| 375 | * package installer |
| 376 | * |
| 377 | * @param packageName The package to check for |
| 378 | * @param uid the uid in which the package is running |
| 379 | * @return {@link USER_TRUSTED} if the user has trusted the package, {@link USER_BLOCKED} |
| 380 | * if user has blocked requests from the package, {@link USER_DEFAULT} if the user response |
| 381 | * is not yet available |
| 382 | */ |
| 383 | int getPackageTrustedToInstallApps(String packageName, int uid); |
| 384 | } |
| 385 | |
| 386 | public abstract void setExternalSourcesPolicy(ExternalSourcesPolicy policy); |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 387 | |
| 388 | /** |
Dianne Hackborn | b1e7776 | 2017-02-13 11:42:18 -0800 | [diff] [blame] | 389 | * Return true if the given package is a persistent app process. |
| 390 | */ |
| 391 | public abstract boolean isPackagePersistent(String packageName); |
| 392 | |
| 393 | /** |
Todd Kennedy | c29b11a | 2017-10-23 15:55:59 -0700 | [diff] [blame] | 394 | * Returns whether or not the given package represents a legacy system application released |
| 395 | * prior to runtime permissions. |
| 396 | */ |
| 397 | public abstract boolean isLegacySystemApp(PackageParser.Package pkg); |
| 398 | |
| 399 | /** |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 400 | * Get all overlay packages for a user. |
| 401 | * @param userId The user for which to get the overlays. |
| 402 | * @return A list of overlay packages. An empty list is returned if the |
| 403 | * user has no installed overlay packages. |
| 404 | */ |
| 405 | public abstract List<PackageInfo> getOverlayPackages(int userId); |
| 406 | |
| 407 | /** |
| 408 | * Get the names of all target packages for a user. |
| 409 | * @param userId The user for which to get the package names. |
| 410 | * @return A list of target package names. This list includes the "android" package. |
| 411 | */ |
| 412 | public abstract List<String> getTargetPackageNames(int userId); |
| 413 | |
| 414 | /** |
| 415 | * Set which overlay to use for a package. |
| 416 | * @param userId The user for which to update the overlays. |
| 417 | * @param targetPackageName The package name of the package for which to update the overlays. |
| 418 | * @param overlayPackageNames The complete list of overlay packages that should be enabled for |
| 419 | * the target. Previously enabled overlays not specified in the list |
| 420 | * will be disabled. Pass in null or an empty list to disable |
| 421 | * all overlays. The order of the items is significant if several |
| 422 | * overlays modify the same resource. |
| 423 | * @return true if all packages names were known by the package manager, false otherwise |
| 424 | */ |
| 425 | public abstract boolean setEnabledOverlayPackages(int userId, String targetPackageName, |
| 426 | List<String> overlayPackageNames); |
Todd Kennedy | 4d1de7d | 2017-02-23 10:32:18 -0800 | [diff] [blame] | 427 | |
| 428 | /** |
Todd Kennedy | 51b3aac | 2017-03-30 17:50:42 -0700 | [diff] [blame] | 429 | * Resolves an activity intent, allowing instant apps to be resolved. |
Todd Kennedy | 4d1de7d | 2017-02-23 10:32:18 -0800 | [diff] [blame] | 430 | */ |
| 431 | public abstract ResolveInfo resolveIntent(Intent intent, String resolvedType, |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 432 | int flags, int userId, boolean resolveForStart); |
Chad Brubaker | 0f28a80 | 2017-03-29 14:05:52 -0700 | [diff] [blame] | 433 | |
| 434 | /** |
Todd Kennedy | 51b3aac | 2017-03-30 17:50:42 -0700 | [diff] [blame] | 435 | * Resolves a service intent, allowing instant apps to be resolved. |
| 436 | */ |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 437 | public abstract ResolveInfo resolveService(Intent intent, String resolvedType, |
Todd Kennedy | 51b3aac | 2017-03-30 17:50:42 -0700 | [diff] [blame] | 438 | int flags, int userId, int callingUid); |
| 439 | |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 440 | /** |
| 441 | * Resolves a content provider intent. |
| 442 | */ |
| 443 | public abstract ProviderInfo resolveContentProvider(String name, int flags, int userId); |
| 444 | |
Todd Kennedy | 51b3aac | 2017-03-30 17:50:42 -0700 | [diff] [blame] | 445 | /** |
Chad Brubaker | 0f28a80 | 2017-03-29 14:05:52 -0700 | [diff] [blame] | 446 | * Track the creator of a new isolated uid. |
| 447 | * @param isolatedUid The newly created isolated uid. |
| 448 | * @param ownerUid The uid of the app that created the isolated process. |
| 449 | */ |
| 450 | public abstract void addIsolatedUid(int isolatedUid, int ownerUid); |
| 451 | |
| 452 | /** |
| 453 | * Track removal of an isolated uid. |
| 454 | * @param isolatedUid isolated uid that is no longer being used. |
| 455 | */ |
| 456 | public abstract void removeIsolatedUid(int isolatedUid); |
Makoto Onuki | e92f794 | 2017-04-26 14:38:18 -0700 | [diff] [blame] | 457 | |
| 458 | /** |
| 459 | * Return the taget SDK version for the app with the given UID. |
| 460 | */ |
| 461 | public abstract int getUidTargetSdkVersion(int uid); |
Makoto Onuki | ad62301 | 2017-05-15 09:29:34 -0700 | [diff] [blame] | 462 | |
Jeff Sharkey | 9252b34 | 2018-01-19 07:58:35 +0900 | [diff] [blame] | 463 | /** |
| 464 | * Return the taget SDK version for the app with the given package name. |
| 465 | */ |
| 466 | public abstract int getPackageTargetSdkVersion(String packageName); |
| 467 | |
Makoto Onuki | ad62301 | 2017-05-15 09:29:34 -0700 | [diff] [blame] | 468 | /** Whether the binder caller can access instant apps. */ |
Todd Kennedy | 3051caa | 2017-05-23 15:54:18 -0700 | [diff] [blame] | 469 | public abstract boolean canAccessInstantApps(int callingUid, int userId); |
Svet Ganov | f935a70 | 2017-08-22 12:15:58 -0700 | [diff] [blame] | 470 | |
Todd Kennedy | 662504f | 2018-03-14 08:09:00 -0700 | [diff] [blame] | 471 | /** Whether the binder caller can access the given component. */ |
| 472 | public abstract boolean canAccessComponent(int callingUid, ComponentName component, int userId); |
| 473 | |
Svet Ganov | f935a70 | 2017-08-22 12:15:58 -0700 | [diff] [blame] | 474 | /** |
| 475 | * Returns {@code true} if a given package has instant application meta-data. |
| 476 | * Otherwise, returns {@code false}. Meta-data is state (eg. cookie, app icon, etc) |
| 477 | * associated with an instant app. It may be kept after the instant app has been uninstalled. |
| 478 | */ |
| 479 | public abstract boolean hasInstantApplicationMetadata(String packageName, int userId); |
Todd Kennedy | df113c3 | 2017-08-31 16:10:29 -0700 | [diff] [blame] | 480 | |
| 481 | /** |
| 482 | * Updates a package last used time. |
| 483 | */ |
| 484 | public abstract void notifyPackageUse(String packageName, int reason); |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 485 | |
| 486 | /** |
| 487 | * Returns a package object for the given package name. |
| 488 | */ |
| 489 | public abstract @Nullable PackageParser.Package getPackage(@NonNull String packageName); |
| 490 | |
| 491 | /** |
Patrick Baumann | b00eb64 | 2018-04-05 14:50:38 -0700 | [diff] [blame^] | 492 | * Returns a {@link com.android.server.pm.PackageSetting} for a given package name. |
| 493 | */ |
| 494 | public abstract @Nullable Object getPackageSetting(String packageName); |
| 495 | |
| 496 | /** |
Todd Kennedy | 42d6160 | 2017-12-12 14:44:19 -0800 | [diff] [blame] | 497 | * Returns a list without a change observer. |
| 498 | * |
| 499 | * {@see #getPackageList(PackageListObserver)} |
| 500 | */ |
| 501 | public @NonNull PackageList getPackageList() { |
| 502 | return getPackageList(null); |
| 503 | } |
| 504 | |
| 505 | /** |
| 506 | * Returns the list of packages installed at the time of the method call. |
| 507 | * <p>The given observer is notified when the list of installed packages |
| 508 | * changes [eg. a package was installed or uninstalled]. It will not be |
| 509 | * notified if a package is updated. |
| 510 | * <p>The package list will not be updated automatically as packages are |
| 511 | * installed / uninstalled. Any changes must be handled within the observer. |
| 512 | */ |
| 513 | public abstract @NonNull PackageList getPackageList(@Nullable PackageListObserver observer); |
| 514 | |
| 515 | /** |
| 516 | * Removes the observer. |
| 517 | * <p>Generally not needed. {@link #getPackageList(PackageListObserver)} will automatically |
| 518 | * remove the observer. |
| 519 | * <p>Does nothing if the observer isn't currently registered. |
| 520 | * <p>Observers are notified asynchronously and it's possible for an observer to be |
| 521 | * invoked after its been removed. |
| 522 | */ |
| 523 | public abstract void removePackageListObserver(@NonNull PackageListObserver observer); |
| 524 | |
| 525 | /** |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 526 | * Returns a package object for the disabled system package name. |
| 527 | */ |
| 528 | public abstract @Nullable PackageParser.Package getDisabledPackage(@NonNull String packageName); |
| 529 | |
| 530 | /** |
| 531 | * Returns whether or not the component is the resolver activity. |
| 532 | */ |
| 533 | public abstract boolean isResolveActivityComponent(@NonNull ComponentInfo component); |
| 534 | |
| 535 | /** |
| 536 | * Returns the package name for a known package. |
| 537 | */ |
| 538 | public abstract @Nullable String getKnownPackageName( |
| 539 | @KnownPackage int knownPackage, int userId); |
| 540 | |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 541 | /** |
| 542 | * Returns whether the package is an instant app. |
| 543 | */ |
| 544 | public abstract boolean isInstantApp(String packageName, int userId); |
| 545 | |
| 546 | /** |
| 547 | * Returns whether the package is an instant app. |
| 548 | */ |
| 549 | public abstract @Nullable String getInstantAppPackageName(int uid); |
| 550 | |
| 551 | /** |
| 552 | * Returns whether or not access to the application should be filtered. |
| 553 | * <p> |
| 554 | * Access may be limited based upon whether the calling or target applications |
| 555 | * are instant applications. |
| 556 | * |
| 557 | * @see #canAccessInstantApps(int) |
| 558 | */ |
| 559 | public abstract boolean filterAppAccess( |
| 560 | @Nullable PackageParser.Package pkg, int callingUid, int userId); |
| 561 | |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 562 | /* |
| 563 | * NOTE: The following methods are temporary until permissions are extracted from |
| 564 | * the package manager into a component specifically for handling permissions. |
| 565 | */ |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 566 | /** Returns the flags for the given permission. */ |
| 567 | public abstract @Nullable int getPermissionFlagsTEMP(@NonNull String permName, |
| 568 | @NonNull String packageName, int userId); |
| 569 | /** Updates the flags for the given permission. */ |
| 570 | public abstract void updatePermissionFlagsTEMP(@NonNull String permName, |
| 571 | @NonNull String packageName, int flagMask, int flagValues, int userId); |
Michal Karpinski | 528c3e5 | 2018-02-07 17:47:10 +0000 | [diff] [blame] | 572 | |
| 573 | /** |
| 574 | * Returns true if it's still safe to restore data backed up from this app's version |
| 575 | * that was signed with restoringFromSigHash. |
| 576 | */ |
| 577 | public abstract boolean isDataRestoreSafe(@NonNull byte[] restoringFromSigHash, |
| 578 | @NonNull String packageName); |
| 579 | |
| 580 | /** |
| 581 | * Returns true if it's still safe to restore data backed up from this app's version |
| 582 | * that was signed with restoringFromSig. |
| 583 | */ |
| 584 | public abstract boolean isDataRestoreSafe(@NonNull Signature restoringFromSig, |
| 585 | @NonNull String packageName); |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 586 | } |