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; |
Ricky Wai | cf134eb | 2018-10-10 09:26:32 +0100 | [diff] [blame] | 22 | import android.annotation.UserIdInt; |
Makoto Onuki | 2d5b465 | 2016-03-11 16:09:54 -0800 | [diff] [blame] | 23 | import android.content.ComponentName; |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 24 | import android.content.Intent; |
Todd Kennedy | 18211fd | 2017-06-06 09:15:46 -0700 | [diff] [blame] | 25 | import android.content.pm.PackageManager.ApplicationInfoFlags; |
| 26 | import android.content.pm.PackageManager.ComponentInfoFlags; |
Todd Kennedy | 18211fd | 2017-06-06 09:15:46 -0700 | [diff] [blame] | 27 | import android.content.pm.PackageManager.PackageInfoFlags; |
| 28 | import android.content.pm.PackageManager.ResolveInfoFlags; |
Chad Brubaker | 0606861 | 2017-04-06 09:43:47 -0700 | [diff] [blame] | 29 | import android.os.Bundle; |
Suprabh Shukla | 19b41f3 | 2018-03-26 22:35:13 -0700 | [diff] [blame] | 30 | import android.os.PersistableBundle; |
Eugene Susla | abdefba | 2018-11-09 18:06:43 -0800 | [diff] [blame] | 31 | import android.util.ArraySet; |
Makoto Onuki | c29f62c | 2016-06-07 12:19:46 -0700 | [diff] [blame] | 32 | import android.util.SparseArray; |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 33 | |
Svet Ganov | d873ae6 | 2018-06-25 16:39:23 -0700 | [diff] [blame] | 34 | import com.android.internal.util.function.TriFunction; |
| 35 | |
Jeff Sharkey | 5790af0 | 2018-08-13 17:42:54 -0600 | [diff] [blame] | 36 | import java.io.IOException; |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 37 | import java.lang.annotation.Retention; |
| 38 | import java.lang.annotation.RetentionPolicy; |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 39 | import java.util.List; |
Svet Ganov | d873ae6 | 2018-06-25 16:39:23 -0700 | [diff] [blame] | 40 | import java.util.function.BiFunction; |
Eugene Susla | abdefba | 2018-11-09 18:06:43 -0800 | [diff] [blame] | 41 | import java.util.function.Consumer; |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 42 | |
| 43 | /** |
| 44 | * Package manager local system service interface. |
| 45 | * |
| 46 | * @hide Only for use within the system server. |
| 47 | */ |
| 48 | public abstract class PackageManagerInternal { |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 49 | public static final int PACKAGE_SYSTEM = 0; |
| 50 | public static final int PACKAGE_SETUP_WIZARD = 1; |
| 51 | public static final int PACKAGE_INSTALLER = 2; |
| 52 | public static final int PACKAGE_VERIFIER = 3; |
| 53 | public static final int PACKAGE_BROWSER = 4; |
Makoto Onuki | 700feef | 2018-02-15 10:59:41 -0800 | [diff] [blame] | 54 | public static final int PACKAGE_SYSTEM_TEXT_CLASSIFIER = 5; |
Philip P. Moltmann | 8943ad6 | 2018-07-25 12:12:30 -0700 | [diff] [blame] | 55 | public static final int PACKAGE_PERMISSION_CONTROLLER = 6; |
Varun Shah | 5f30365 | 2018-11-16 18:11:19 -0800 | [diff] [blame] | 56 | public static final int PACKAGE_WELLBEING = 7; |
Jeff Sharkey | 15707b3 | 2018-12-10 12:08:41 -0700 | [diff] [blame] | 57 | public static final int PACKAGE_DOCUMENTER = 8; |
Stanislav Zholnin | 596437f | 2018-12-28 15:34:23 +0000 | [diff] [blame] | 58 | public static final int PACKAGE_CONFIGURATOR = 9; |
Joe Onorato | 5a15b55 | 2018-12-18 10:40:04 -0800 | [diff] [blame] | 59 | public static final int PACKAGE_INCIDENT_REPORT_APPROVER = 10; |
George Hodulik | cd7695d | 2019-01-29 18:17:05 -0800 | [diff] [blame] | 60 | public static final int PACKAGE_APP_PREDICTOR = 11; |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 61 | @IntDef(value = { |
| 62 | PACKAGE_SYSTEM, |
| 63 | PACKAGE_SETUP_WIZARD, |
| 64 | PACKAGE_INSTALLER, |
| 65 | PACKAGE_VERIFIER, |
| 66 | PACKAGE_BROWSER, |
Makoto Onuki | 700feef | 2018-02-15 10:59:41 -0800 | [diff] [blame] | 67 | PACKAGE_SYSTEM_TEXT_CLASSIFIER, |
Philip P. Moltmann | 8943ad6 | 2018-07-25 12:12:30 -0700 | [diff] [blame] | 68 | PACKAGE_PERMISSION_CONTROLLER, |
Varun Shah | 5f30365 | 2018-11-16 18:11:19 -0800 | [diff] [blame] | 69 | PACKAGE_WELLBEING, |
Jeff Sharkey | 15707b3 | 2018-12-10 12:08:41 -0700 | [diff] [blame] | 70 | PACKAGE_DOCUMENTER, |
Stanislav Zholnin | 596437f | 2018-12-28 15:34:23 +0000 | [diff] [blame] | 71 | PACKAGE_CONFIGURATOR, |
Joe Onorato | 5a15b55 | 2018-12-18 10:40:04 -0800 | [diff] [blame] | 72 | PACKAGE_INCIDENT_REPORT_APPROVER, |
George Hodulik | cd7695d | 2019-01-29 18:17:05 -0800 | [diff] [blame] | 73 | PACKAGE_APP_PREDICTOR, |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 74 | }) |
| 75 | @Retention(RetentionPolicy.SOURCE) |
| 76 | public @interface KnownPackage {} |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 77 | |
Todd Kennedy | 42d6160 | 2017-12-12 14:44:19 -0800 | [diff] [blame] | 78 | /** Observer called whenever the list of packages changes */ |
| 79 | public interface PackageListObserver { |
| 80 | /** A package was added to the system. */ |
| 81 | void onPackageAdded(@NonNull String packageName); |
| 82 | /** A package was removed from the system. */ |
| 83 | void onPackageRemoved(@NonNull String packageName); |
| 84 | } |
| 85 | |
Svet Ganov | d873ae6 | 2018-06-25 16:39:23 -0700 | [diff] [blame] | 86 | /** Interface to override permission checks via composition */ |
| 87 | public interface CheckPermissionDelegate { |
| 88 | /** |
| 89 | * Allows overriding check permission behavior. |
| 90 | * |
| 91 | * @param permName The permission to check. |
| 92 | * @param pkgName The package for which to check. |
| 93 | * @param userId The user for which to check. |
| 94 | * @param superImpl The super implementation. |
| 95 | * @return The check permission result. |
| 96 | */ |
| 97 | int checkPermission(String permName, String pkgName, int userId, |
| 98 | TriFunction<String, String, Integer, Integer> superImpl); |
| 99 | |
| 100 | /** |
| 101 | * Allows overriding check UID permission behavior. |
| 102 | * |
| 103 | * @param permName The permission to check. |
| 104 | * @param uid The UID for which to check. |
| 105 | * @param superImpl The super implementation. |
| 106 | * @return The check permission result. |
| 107 | */ |
| 108 | int checkUidPermission(String permName, int uid, |
| 109 | BiFunction<String, Integer, Integer> superImpl); |
| 110 | } |
| 111 | |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 112 | /** |
| 113 | * Provider for package names. |
| 114 | */ |
| 115 | public interface PackagesProvider { |
| 116 | |
| 117 | /** |
| 118 | * Gets the packages for a given user. |
| 119 | * @param userId The user id. |
| 120 | * @return The package names. |
| 121 | */ |
| 122 | public String[] getPackages(int userId); |
| 123 | } |
| 124 | |
| 125 | /** |
Svetoslav | 0010b70 | 2015-06-30 18:05:26 -0700 | [diff] [blame] | 126 | * Provider for package names. |
| 127 | */ |
| 128 | public interface SyncAdapterPackagesProvider { |
| 129 | |
| 130 | /** |
| 131 | * Gets the sync adapter packages for given authority and user. |
| 132 | * @param authority The authority. |
| 133 | * @param userId The user id. |
| 134 | * @return The package names. |
| 135 | */ |
| 136 | public String[] getPackages(String authority, int userId); |
| 137 | } |
| 138 | |
| 139 | /** |
Hai Zhang | 85fd062 | 2019-02-01 14:06:04 -0800 | [diff] [blame] | 140 | * Provider for default browser |
| 141 | */ |
| 142 | public interface DefaultBrowserProvider { |
| 143 | |
| 144 | /** |
| 145 | * Get the package name of the default browser. |
| 146 | * |
| 147 | * @param userId the user id |
| 148 | * |
| 149 | * @return the package name of the default browser, or {@code null} if none |
| 150 | */ |
| 151 | @Nullable |
| 152 | String getDefaultBrowser(@UserIdInt int userId); |
| 153 | |
| 154 | /** |
| 155 | * Set the package name of the default browser. |
| 156 | * |
| 157 | * @param packageName package name of the default browser, or {@code null} to remove |
| 158 | * @param userId the user id |
| 159 | * |
| 160 | * @return whether the default browser was successfully set. |
| 161 | */ |
| 162 | boolean setDefaultBrowser(@Nullable String packageName, @UserIdInt int userId); |
Hai Zhang | fafe525 | 2019-02-27 15:29:48 -0800 | [diff] [blame] | 163 | |
| 164 | /** |
| 165 | * Set the package name of the default browser asynchronously. |
| 166 | * |
| 167 | * @param packageName package name of the default browser, or {@code null} to remove |
| 168 | * @param userId the user id |
| 169 | */ |
| 170 | void setDefaultBrowserAsync(@Nullable String packageName, @UserIdInt int userId); |
Hai Zhang | 85fd062 | 2019-02-01 14:06:04 -0800 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | /** |
Hai Zhang | 8be463f | 2019-02-11 16:44:45 -0800 | [diff] [blame] | 174 | * Provider for default home |
| 175 | */ |
| 176 | public interface DefaultHomeProvider { |
| 177 | |
| 178 | /** |
| 179 | * Get the package name of the default home. |
| 180 | * |
| 181 | * @param userId the user id |
| 182 | * |
| 183 | * @return the package name of the default home, or {@code null} if none |
| 184 | */ |
| 185 | @Nullable |
| 186 | String getDefaultHome(@UserIdInt int userId); |
| 187 | |
| 188 | /** |
| 189 | * Set the package name of the default home. |
| 190 | * |
| 191 | * @param packageName package name of the default home, or {@code null} to remove |
| 192 | * @param userId the user id |
| 193 | */ |
| 194 | void setDefaultHomeAsync(@Nullable String packageName, @UserIdInt int userId); |
| 195 | } |
| 196 | |
| 197 | /** |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 198 | * Sets the location provider packages provider. |
| 199 | * @param provider The packages provider. |
| 200 | */ |
| 201 | public abstract void setLocationPackagesProvider(PackagesProvider provider); |
| 202 | |
| 203 | /** |
Wei Wang | ffb94e6 | 2019-01-14 00:05:45 -0800 | [diff] [blame] | 204 | * Set the location extra packages provider. |
| 205 | * @param provider The packages provider. |
| 206 | */ |
| 207 | public abstract void setLocationExtraPackagesProvider(PackagesProvider provider); |
| 208 | |
| 209 | /** |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 210 | * Sets the voice interaction packages provider. |
| 211 | * @param provider The packages provider. |
| 212 | */ |
| 213 | public abstract void setVoiceInteractionPackagesProvider(PackagesProvider provider); |
Svetoslav | cdfd230 | 2015-06-25 19:07:31 -0700 | [diff] [blame] | 214 | |
| 215 | /** |
Eric Enslen | 1e423b9 | 2017-12-18 11:30:21 -0800 | [diff] [blame] | 216 | * Sets the Use Open Wifi packages provider. |
| 217 | * @param provider The packages provider. |
| 218 | */ |
| 219 | public abstract void setUseOpenWifiAppPackagesProvider(PackagesProvider provider); |
| 220 | |
| 221 | /** |
Svetoslav | 0010b70 | 2015-06-30 18:05:26 -0700 | [diff] [blame] | 222 | * Sets the sync adapter packages provider. |
| 223 | * @param provider The provider. |
| 224 | */ |
| 225 | public abstract void setSyncAdapterPackagesprovider(SyncAdapterPackagesProvider provider); |
| 226 | |
| 227 | /** |
Philip P. Moltmann | b0be05c | 2018-09-19 02:46:56 +0000 | [diff] [blame] | 228 | * Called when the package for the default dialer changed |
| 229 | * |
| 230 | * @param packageName the new dialer package |
| 231 | * @param userId user for which the change was made |
Svetoslav | cdfd230 | 2015-06-25 19:07:31 -0700 | [diff] [blame] | 232 | */ |
Philip P. Moltmann | b0be05c | 2018-09-19 02:46:56 +0000 | [diff] [blame] | 233 | public void onDefaultDialerAppChanged(String packageName, int userId) {} |
Svetoslav | cdfd230 | 2015-06-25 19:07:31 -0700 | [diff] [blame] | 234 | |
| 235 | /** |
Philip P. Moltmann | b0be05c | 2018-09-19 02:46:56 +0000 | [diff] [blame] | 236 | * Called when the package for the default SMS handler changed |
| 237 | * |
| 238 | * @param packageName the new sms package |
| 239 | * @param userId user for which the change was made |
Svetoslav | cdfd230 | 2015-06-25 19:07:31 -0700 | [diff] [blame] | 240 | */ |
Philip P. Moltmann | b0be05c | 2018-09-19 02:46:56 +0000 | [diff] [blame] | 241 | public void onDefaultSmsAppChanged(String packageName, int userId) {} |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 242 | |
| 243 | /** |
Philip P. Moltmann | b0be05c | 2018-09-19 02:46:56 +0000 | [diff] [blame] | 244 | * Called when the package for the default sim call manager changed |
| 245 | * |
| 246 | * @param packageName the new sms package |
| 247 | * @param userId user for which the change was made |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 248 | */ |
Philip P. Moltmann | b0be05c | 2018-09-19 02:46:56 +0000 | [diff] [blame] | 249 | public void onDefaultSimCallManagerAppChanged(String packageName, int userId) {} |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 250 | |
| 251 | /** |
Eric Enslen | 1e423b9 | 2017-12-18 11:30:21 -0800 | [diff] [blame] | 252 | * Requests granting of the default permissions to the current default Use Open Wifi app. |
| 253 | * @param packageName The default use open wifi package name. |
| 254 | * @param userId The user for which to grant the permissions. |
| 255 | */ |
| 256 | public abstract void grantDefaultPermissionsToDefaultUseOpenWifiApp(String packageName, |
| 257 | int userId); |
| 258 | |
| 259 | /** |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 260 | * Sets a list of apps to keep in PM's internal data structures and as APKs even if no user has |
| 261 | * currently installed it. The apps are not preloaded. |
| 262 | * @param packageList List of package names to keep cached. |
| 263 | */ |
| 264 | public abstract void setKeepUninstalledPackages(List<String> packageList); |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 265 | |
| 266 | /** |
| 267 | * Gets whether some of the permissions used by this package require a user |
| 268 | * review before any of the app components can run. |
| 269 | * @param packageName The package name for which to check. |
| 270 | * @param userId The user under which to check. |
| 271 | * @return True a permissions review is required. |
| 272 | */ |
| 273 | public abstract boolean isPermissionsReviewRequired(String packageName, int userId); |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 274 | |
| 275 | /** |
Todd Kennedy | 18211fd | 2017-06-06 09:15:46 -0700 | [diff] [blame] | 276 | * Retrieve all of the information we know about a particular package/application. |
| 277 | * @param filterCallingUid The results will be filtered in the context of this UID instead |
| 278 | * of the calling UID. |
| 279 | * @see PackageManager#getPackageInfo(String, int) |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 280 | */ |
Todd Kennedy | 18211fd | 2017-06-06 09:15:46 -0700 | [diff] [blame] | 281 | public abstract PackageInfo getPackageInfo(String packageName, |
| 282 | @PackageInfoFlags int flags, int filterCallingUid, int userId); |
| 283 | |
| 284 | /** |
Ricky Wai | cf134eb | 2018-10-10 09:26:32 +0100 | [diff] [blame] | 285 | * Return a List of all application packages that are installed on the |
| 286 | * device, for a specific user. If flag GET_UNINSTALLED_PACKAGES has been |
| 287 | * set, a list of all applications including those deleted with |
| 288 | * {@code DONT_DELETE_DATA} (partially installed apps with data directory) |
| 289 | * will be returned. |
| 290 | * |
| 291 | * @param flags Additional option flags to modify the data returned. |
| 292 | * @param userId The user for whom the installed applications are to be |
| 293 | * listed |
| 294 | * @param callingUid The uid of the original caller app |
| 295 | * @return A List of ApplicationInfo objects, one for each installed |
| 296 | * application. In the unlikely case there are no installed |
| 297 | * packages, an empty list is returned. If flag |
| 298 | * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application |
| 299 | * information is retrieved from the list of uninstalled |
| 300 | * applications (which includes installed applications as well as |
| 301 | * applications with data directory i.e. applications which had been |
| 302 | * deleted with {@code DONT_DELETE_DATA} flag set). |
| 303 | */ |
| 304 | public abstract List<ApplicationInfo> getInstalledApplications( |
| 305 | @ApplicationInfoFlags int flags, @UserIdInt int userId, int callingUid); |
| 306 | |
| 307 | /** |
Suprabh Shukla | 19b41f3 | 2018-03-26 22:35:13 -0700 | [diff] [blame] | 308 | * Retrieve launcher extras for a suspended package provided to the system in |
| 309 | * {@link PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, |
Suprabh Shukla | 3c3af14 | 2018-03-30 00:28:37 -0700 | [diff] [blame] | 310 | * PersistableBundle, String)}. |
Suprabh Shukla | 19b41f3 | 2018-03-26 22:35:13 -0700 | [diff] [blame] | 311 | * |
| 312 | * @param packageName The package for which to return launcher extras. |
Suprabh Shukla | 3c3af14 | 2018-03-30 00:28:37 -0700 | [diff] [blame] | 313 | * @param userId The user for which to check. |
Suprabh Shukla | 19b41f3 | 2018-03-26 22:35:13 -0700 | [diff] [blame] | 314 | * @return The launcher extras. |
| 315 | * |
| 316 | * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, |
| 317 | * PersistableBundle, String) |
| 318 | * @see PackageManager#isPackageSuspended() |
| 319 | */ |
| 320 | public abstract Bundle getSuspendedPackageLauncherExtras(String packageName, |
| 321 | int userId); |
| 322 | |
| 323 | /** |
Suprabh Shukla | 69c7142 | 2018-04-02 18:39:01 -0700 | [diff] [blame] | 324 | * Internal api to query the suspended state of a package. |
| 325 | * @param packageName The package to check. |
| 326 | * @param userId The user id to check for. |
| 327 | * @return {@code true} if the package is suspended, {@code false} otherwise. |
| 328 | * @see PackageManager#isPackageSuspended(String) |
| 329 | */ |
| 330 | public abstract boolean isPackageSuspended(String packageName, int userId); |
| 331 | |
| 332 | /** |
Suprabh Shukla | 3c3af14 | 2018-03-30 00:28:37 -0700 | [diff] [blame] | 333 | * Get the name of the package that suspended the given package. Packages can be suspended by |
| 334 | * device administrators or apps holding {@link android.Manifest.permission#MANAGE_USERS} or |
| 335 | * {@link android.Manifest.permission#SUSPEND_APPS}. |
| 336 | * |
| 337 | * @param suspendedPackage The package that has been suspended. |
| 338 | * @param userId The user for which to check. |
| 339 | * @return Name of the package that suspended the given package. Returns {@code null} if the |
| 340 | * given package is not currently suspended and the platform package name - i.e. |
| 341 | * {@code "android"} - if the package was suspended by a device admin. |
| 342 | */ |
| 343 | public abstract String getSuspendingPackage(String suspendedPackage, int userId); |
| 344 | |
| 345 | /** |
Suprabh Shukla | 389cb6f | 2018-10-01 18:20:39 -0700 | [diff] [blame] | 346 | * Get the information describing the dialog to be shown to the user when they try to launch a |
| 347 | * suspended application. |
Suprabh Shukla | 3c3af14 | 2018-03-30 00:28:37 -0700 | [diff] [blame] | 348 | * |
| 349 | * @param suspendedPackage The package that has been suspended. |
| 350 | * @param userId The user for which to check. |
Suprabh Shukla | 389cb6f | 2018-10-01 18:20:39 -0700 | [diff] [blame] | 351 | * @return A {@link SuspendDialogInfo} object describing the dialog to be shown. |
Suprabh Shukla | 3c3af14 | 2018-03-30 00:28:37 -0700 | [diff] [blame] | 352 | */ |
Suprabh Shukla | 389cb6f | 2018-10-01 18:20:39 -0700 | [diff] [blame] | 353 | @Nullable |
| 354 | public abstract SuspendDialogInfo getSuspendedDialogInfo(String suspendedPackage, int userId); |
Suprabh Shukla | 3c3af14 | 2018-03-30 00:28:37 -0700 | [diff] [blame] | 355 | |
| 356 | /** |
Suprabh Shukla | 7900049 | 2018-12-24 17:03:02 -0800 | [diff] [blame] | 357 | * Gets any distraction flags set via |
| 358 | * {@link PackageManager#setDistractingPackageRestrictions(String[], int)} |
| 359 | * |
| 360 | * @param packageName |
| 361 | * @param userId |
| 362 | * @return A bitwise OR of any of the {@link PackageManager.DistractionRestriction} |
| 363 | */ |
| 364 | public abstract @PackageManager.DistractionRestriction int getDistractingPackageRestrictions( |
| 365 | String packageName, int userId); |
| 366 | |
| 367 | /** |
Christopher Tate | a732f01 | 2017-10-26 17:26:53 -0700 | [diff] [blame] | 368 | * Do a straight uid lookup for the given package/application in the given user. |
| 369 | * @see PackageManager#getPackageUidAsUser(String, int, int) |
| 370 | * @return The app's uid, or < 0 if the package was not found in that user |
| 371 | */ |
| 372 | public abstract int getPackageUid(String packageName, |
| 373 | @PackageInfoFlags int flags, int userId); |
| 374 | |
| 375 | /** |
Todd Kennedy | 18211fd | 2017-06-06 09:15:46 -0700 | [diff] [blame] | 376 | * Retrieve all of the information we know about a particular package/application. |
| 377 | * @param filterCallingUid The results will be filtered in the context of this UID instead |
| 378 | * of the calling UID. |
| 379 | * @see PackageManager#getApplicationInfo(String, int) |
| 380 | */ |
| 381 | public abstract ApplicationInfo getApplicationInfo(String packageName, |
| 382 | @ApplicationInfoFlags int flags, int filterCallingUid, int userId); |
| 383 | |
| 384 | /** |
| 385 | * Retrieve all of the information we know about a particular activity class. |
| 386 | * @param filterCallingUid The results will be filtered in the context of this UID instead |
| 387 | * of the calling UID. |
| 388 | * @see PackageManager#getActivityInfo(ComponentName, int) |
| 389 | */ |
| 390 | public abstract ActivityInfo getActivityInfo(ComponentName component, |
| 391 | @ComponentInfoFlags int flags, int filterCallingUid, int userId); |
| 392 | |
| 393 | /** |
| 394 | * Retrieve all activities that can be performed for the given intent. |
| 395 | * @param filterCallingUid The results will be filtered in the context of this UID instead |
| 396 | * of the calling UID. |
| 397 | * @see PackageManager#queryIntentActivities(Intent, int) |
| 398 | */ |
| 399 | public abstract List<ResolveInfo> queryIntentActivities(Intent intent, |
| 400 | @ResolveInfoFlags int flags, int filterCallingUid, int userId); |
Makoto Onuki | 2d5b465 | 2016-03-11 16:09:54 -0800 | [diff] [blame] | 401 | |
| 402 | /** |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 403 | * Retrieve all services that can be performed for the given intent. |
| 404 | * @see PackageManager#queryIntentServices(Intent, int) |
| 405 | */ |
| 406 | public abstract List<ResolveInfo> queryIntentServices( |
| 407 | Intent intent, int flags, int callingUid, int userId); |
| 408 | |
| 409 | /** |
Makoto Onuki | 2d5b465 | 2016-03-11 16:09:54 -0800 | [diff] [blame] | 410 | * Interface to {@link com.android.server.pm.PackageManagerService#getHomeActivitiesAsUser}. |
| 411 | */ |
| 412 | public abstract ComponentName getHomeActivitiesAsUser(List<ResolveInfo> allHomeCandidates, |
| 413 | int userId); |
Makoto Onuki | c29f62c | 2016-06-07 12:19:46 -0700 | [diff] [blame] | 414 | |
| 415 | /** |
Winson Chung | c167427 | 2018-02-21 10:15:17 -0800 | [diff] [blame] | 416 | * @return The default home activity component name. |
| 417 | */ |
| 418 | public abstract ComponentName getDefaultHomeActivity(int userId); |
| 419 | |
| 420 | /** |
Makoto Onuki | c29f62c | 2016-06-07 12:19:46 -0700 | [diff] [blame] | 421 | * Called by DeviceOwnerManagerService to set the package names of device owner and profile |
| 422 | * owners. |
| 423 | */ |
| 424 | public abstract void setDeviceAndProfileOwnerPackages( |
| 425 | int deviceOwnerUserId, String deviceOwner, SparseArray<String> profileOwners); |
| 426 | |
| 427 | /** |
Steven Ng | 9d48a73 | 2016-06-24 19:04:14 +0100 | [diff] [blame] | 428 | * 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] | 429 | */ |
Steven Ng | 9d48a73 | 2016-06-24 19:04:14 +0100 | [diff] [blame] | 430 | public abstract boolean isPackageDataProtected(int userId, String packageName); |
Svet Ganov | 973edd19 | 2016-09-08 20:15:55 -0700 | [diff] [blame] | 431 | |
| 432 | /** |
Benjamin Franz | f81bf7f | 2018-03-26 16:23:04 +0100 | [diff] [blame] | 433 | * Returns {@code true} if a given package's state is protected, e.g. it cannot be force |
| 434 | * stopped, suspended, disabled or hidden. Otherwise, returns {@code false}. |
| 435 | */ |
| 436 | public abstract boolean isPackageStateProtected(String packageName, int userId); |
| 437 | |
| 438 | /** |
Dianne Hackborn | e07641d | 2016-11-09 15:07:23 -0800 | [diff] [blame] | 439 | * Returns {@code true} if a given package is installed as ephemeral. Otherwise, returns |
| 440 | * {@code false}. |
| 441 | */ |
| 442 | public abstract boolean isPackageEphemeral(int userId, String packageName); |
| 443 | |
| 444 | /** |
Svet Ganov | 973edd19 | 2016-09-08 20:15:55 -0700 | [diff] [blame] | 445 | * Gets whether the package was ever launched. |
| 446 | * @param packageName The package name. |
| 447 | * @param userId The user for which to check. |
| 448 | * @return Whether was launched. |
Amith Yamasani | 2cbfa1e | 2017-03-28 10:34:01 -0700 | [diff] [blame] | 449 | * @throws IllegalArgumentException if the package is not found |
Svet Ganov | 973edd19 | 2016-09-08 20:15:55 -0700 | [diff] [blame] | 450 | */ |
| 451 | public abstract boolean wasPackageEverLaunched(String packageName, int userId); |
Nicolas Prevot | 700e1e7 | 2016-09-28 15:17:18 +0100 | [diff] [blame] | 452 | |
| 453 | /** |
| 454 | * Grants a runtime permission |
| 455 | * @param packageName The package name. |
| 456 | * @param name The name of the permission. |
| 457 | * @param userId The userId for which to grant the permission. |
| 458 | * @param overridePolicy If true, grant this permission even if it is fixed by policy. |
| 459 | */ |
| 460 | public abstract void grantRuntimePermission(String packageName, String name, int userId, |
| 461 | boolean overridePolicy); |
| 462 | |
| 463 | /** |
| 464 | * Revokes a runtime permission |
| 465 | * @param packageName The package name. |
| 466 | * @param name The name of the permission. |
| 467 | * @param userId The userId for which to revoke the permission. |
| 468 | * @param overridePolicy If true, revoke this permission even if it is fixed by policy. |
| 469 | */ |
| 470 | public abstract void revokeRuntimePermission(String packageName, String name, int userId, |
| 471 | boolean overridePolicy); |
| 472 | |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 473 | /** |
Michal Karpinski | cb67dc9 | 2016-12-13 18:20:23 +0000 | [diff] [blame] | 474 | * Retrieve the official name associated with a uid. This name is |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 475 | * guaranteed to never change, though it is possible for the underlying |
Michal Karpinski | cb67dc9 | 2016-12-13 18:20:23 +0000 | [diff] [blame] | 476 | * uid to be changed. That is, if you are storing information about |
| 477 | * uids in persistent storage, you should use the string returned |
| 478 | * by this function instead of the raw uid. |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 479 | * |
Michal Karpinski | cb67dc9 | 2016-12-13 18:20:23 +0000 | [diff] [blame] | 480 | * @param uid The uid for which you would like to retrieve a name. |
| 481 | * @return Returns a unique name for the given uid, or null if the |
| 482 | * uid is not currently assigned. |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 483 | */ |
| 484 | public abstract String getNameForUid(int uid); |
| 485 | |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 486 | /** |
| 487 | * Request to perform the second phase of ephemeral resolution. |
| 488 | * @param responseObj The response of the first phase of ephemeral resolution |
| 489 | * @param origIntent The original intent that triggered ephemeral resolution |
| 490 | * @param resolvedType The resolved type of the intent |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 491 | * @param callingPackage The name of the package requesting the ephemeral application |
Chad Brubaker | 0606861 | 2017-04-06 09:43:47 -0700 | [diff] [blame] | 492 | * @param verificationBundle Optional bundle to pass to the installer for additional |
| 493 | * verification |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 494 | * @param userId The ID of the user that triggered ephemeral resolution |
| 495 | */ |
Todd Kennedy | e991022 | 2017-02-21 16:00:11 -0800 | [diff] [blame] | 496 | public abstract void requestInstantAppResolutionPhaseTwo(AuxiliaryResolveInfo responseObj, |
| 497 | Intent origIntent, String resolvedType, String callingPackage, |
Chad Brubaker | 0606861 | 2017-04-06 09:43:47 -0700 | [diff] [blame] | 498 | Bundle verificationBundle, int userId); |
Svetoslav Ganov | e080da9 | 2016-12-21 17:10:35 -0800 | [diff] [blame] | 499 | |
| 500 | /** |
Todd Kennedy | 0e989d0 | 2017-01-13 14:15:36 -0800 | [diff] [blame] | 501 | * Grants access to the package metadata for an ephemeral application. |
| 502 | * <p> |
| 503 | * When an ephemeral application explicitly tries to interact with a full |
| 504 | * install application [via an activity, service or provider that has been |
| 505 | * exposed using the {@code visibleToInstantApp} attribute], the normal |
| 506 | * application must be able to see metadata about the connecting ephemeral |
| 507 | * app. If the ephemeral application uses an implicit intent [ie action VIEW, |
| 508 | * category BROWSABLE], it remains hidden from the launched activity. |
| 509 | * <p> |
| 510 | * If the {@code sourceUid} is not for an ephemeral app or {@code targetUid} |
| 511 | * is not for a fully installed app, this method will be a no-op. |
| 512 | * |
| 513 | * @param userId the user |
| 514 | * @param intent the intent that triggered the grant |
| 515 | * @param targetAppId The app ID of the fully installed application |
| 516 | * @param ephemeralAppId The app ID of the ephemeral application |
| 517 | */ |
| 518 | public abstract void grantEphemeralAccess(int userId, Intent intent, |
| 519 | int targetAppId, int ephemeralAppId); |
| 520 | |
Todd Kennedy | b21be12 | 2017-03-24 14:10:01 -0700 | [diff] [blame] | 521 | public abstract boolean isInstantAppInstallerComponent(ComponentName component); |
Todd Kennedy | 0e989d0 | 2017-01-13 14:15:36 -0800 | [diff] [blame] | 522 | /** |
Svetoslav Ganov | 096d304 | 2017-01-30 16:34:13 -0800 | [diff] [blame] | 523 | * Prunes instant apps and state associated with uninstalled |
| 524 | * instant apps according to the current platform policy. |
| 525 | */ |
| 526 | public abstract void pruneInstantApps(); |
| 527 | |
| 528 | /** |
Svetoslav Ganov | e080da9 | 2016-12-21 17:10:35 -0800 | [diff] [blame] | 529 | * @return The SetupWizard package name. |
| 530 | */ |
| 531 | public abstract String getSetupWizardPackageName(); |
Suprabh Shukla | aef2513 | 2017-01-23 18:09:03 -0800 | [diff] [blame] | 532 | |
| 533 | public interface ExternalSourcesPolicy { |
| 534 | |
| 535 | int USER_TRUSTED = 0; // User has trusted the package to install apps |
| 536 | int USER_BLOCKED = 1; // User has blocked the package to install apps |
| 537 | int USER_DEFAULT = 2; // Default code to use when user response is unavailable |
| 538 | |
| 539 | /** |
| 540 | * Checks the user preference for whether a package is trusted to request installs through |
| 541 | * package installer |
| 542 | * |
| 543 | * @param packageName The package to check for |
| 544 | * @param uid the uid in which the package is running |
Philip P. Moltmann | b0be05c | 2018-09-19 02:46:56 +0000 | [diff] [blame] | 545 | * @return {@link #USER_TRUSTED} if the user has trusted the package, {@link #USER_BLOCKED} |
| 546 | * if user has blocked requests from the package, {@link #USER_DEFAULT} if the user response |
Suprabh Shukla | aef2513 | 2017-01-23 18:09:03 -0800 | [diff] [blame] | 547 | * is not yet available |
| 548 | */ |
| 549 | int getPackageTrustedToInstallApps(String packageName, int uid); |
| 550 | } |
| 551 | |
| 552 | public abstract void setExternalSourcesPolicy(ExternalSourcesPolicy policy); |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 553 | |
| 554 | /** |
Dianne Hackborn | b1e7776 | 2017-02-13 11:42:18 -0800 | [diff] [blame] | 555 | * Return true if the given package is a persistent app process. |
| 556 | */ |
| 557 | public abstract boolean isPackagePersistent(String packageName); |
| 558 | |
| 559 | /** |
Todd Kennedy | c29b11a | 2017-10-23 15:55:59 -0700 | [diff] [blame] | 560 | * Returns whether or not the given package represents a legacy system application released |
| 561 | * prior to runtime permissions. |
| 562 | */ |
| 563 | public abstract boolean isLegacySystemApp(PackageParser.Package pkg); |
| 564 | |
| 565 | /** |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 566 | * Get all overlay packages for a user. |
| 567 | * @param userId The user for which to get the overlays. |
| 568 | * @return A list of overlay packages. An empty list is returned if the |
| 569 | * user has no installed overlay packages. |
| 570 | */ |
| 571 | public abstract List<PackageInfo> getOverlayPackages(int userId); |
| 572 | |
| 573 | /** |
| 574 | * Get the names of all target packages for a user. |
| 575 | * @param userId The user for which to get the package names. |
| 576 | * @return A list of target package names. This list includes the "android" package. |
| 577 | */ |
| 578 | public abstract List<String> getTargetPackageNames(int userId); |
| 579 | |
| 580 | /** |
| 581 | * Set which overlay to use for a package. |
| 582 | * @param userId The user for which to update the overlays. |
| 583 | * @param targetPackageName The package name of the package for which to update the overlays. |
| 584 | * @param overlayPackageNames The complete list of overlay packages that should be enabled for |
| 585 | * the target. Previously enabled overlays not specified in the list |
| 586 | * will be disabled. Pass in null or an empty list to disable |
| 587 | * all overlays. The order of the items is significant if several |
| 588 | * overlays modify the same resource. |
| 589 | * @return true if all packages names were known by the package manager, false otherwise |
| 590 | */ |
| 591 | public abstract boolean setEnabledOverlayPackages(int userId, String targetPackageName, |
| 592 | List<String> overlayPackageNames); |
Todd Kennedy | 4d1de7d | 2017-02-23 10:32:18 -0800 | [diff] [blame] | 593 | |
| 594 | /** |
Todd Kennedy | 51b3aac | 2017-03-30 17:50:42 -0700 | [diff] [blame] | 595 | * Resolves an activity intent, allowing instant apps to be resolved. |
Todd Kennedy | 4d1de7d | 2017-02-23 10:32:18 -0800 | [diff] [blame] | 596 | */ |
| 597 | public abstract ResolveInfo resolveIntent(Intent intent, String resolvedType, |
Patrick Baumann | 7838027 | 2018-04-04 10:41:01 -0700 | [diff] [blame] | 598 | int flags, int userId, boolean resolveForStart, int filterCallingUid); |
Chad Brubaker | 0f28a80 | 2017-03-29 14:05:52 -0700 | [diff] [blame] | 599 | |
| 600 | /** |
Todd Kennedy | 51b3aac | 2017-03-30 17:50:42 -0700 | [diff] [blame] | 601 | * Resolves a service intent, allowing instant apps to be resolved. |
| 602 | */ |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 603 | public abstract ResolveInfo resolveService(Intent intent, String resolvedType, |
Todd Kennedy | 51b3aac | 2017-03-30 17:50:42 -0700 | [diff] [blame] | 604 | int flags, int userId, int callingUid); |
| 605 | |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 606 | /** |
| 607 | * Resolves a content provider intent. |
| 608 | */ |
| 609 | public abstract ProviderInfo resolveContentProvider(String name, int flags, int userId); |
| 610 | |
Todd Kennedy | 51b3aac | 2017-03-30 17:50:42 -0700 | [diff] [blame] | 611 | /** |
Chad Brubaker | 0f28a80 | 2017-03-29 14:05:52 -0700 | [diff] [blame] | 612 | * Track the creator of a new isolated uid. |
| 613 | * @param isolatedUid The newly created isolated uid. |
| 614 | * @param ownerUid The uid of the app that created the isolated process. |
| 615 | */ |
| 616 | public abstract void addIsolatedUid(int isolatedUid, int ownerUid); |
| 617 | |
| 618 | /** |
| 619 | * Track removal of an isolated uid. |
| 620 | * @param isolatedUid isolated uid that is no longer being used. |
| 621 | */ |
| 622 | public abstract void removeIsolatedUid(int isolatedUid); |
Makoto Onuki | e92f794 | 2017-04-26 14:38:18 -0700 | [diff] [blame] | 623 | |
| 624 | /** |
| 625 | * Return the taget SDK version for the app with the given UID. |
| 626 | */ |
| 627 | public abstract int getUidTargetSdkVersion(int uid); |
Makoto Onuki | ad62301 | 2017-05-15 09:29:34 -0700 | [diff] [blame] | 628 | |
Jeff Sharkey | 9252b34 | 2018-01-19 07:58:35 +0900 | [diff] [blame] | 629 | /** |
| 630 | * Return the taget SDK version for the app with the given package name. |
| 631 | */ |
| 632 | public abstract int getPackageTargetSdkVersion(String packageName); |
| 633 | |
Makoto Onuki | ad62301 | 2017-05-15 09:29:34 -0700 | [diff] [blame] | 634 | /** Whether the binder caller can access instant apps. */ |
Todd Kennedy | 3051caa | 2017-05-23 15:54:18 -0700 | [diff] [blame] | 635 | public abstract boolean canAccessInstantApps(int callingUid, int userId); |
Svet Ganov | f935a70 | 2017-08-22 12:15:58 -0700 | [diff] [blame] | 636 | |
Todd Kennedy | 662504f | 2018-03-14 08:09:00 -0700 | [diff] [blame] | 637 | /** Whether the binder caller can access the given component. */ |
| 638 | public abstract boolean canAccessComponent(int callingUid, ComponentName component, int userId); |
| 639 | |
Svet Ganov | f935a70 | 2017-08-22 12:15:58 -0700 | [diff] [blame] | 640 | /** |
| 641 | * Returns {@code true} if a given package has instant application meta-data. |
| 642 | * Otherwise, returns {@code false}. Meta-data is state (eg. cookie, app icon, etc) |
| 643 | * associated with an instant app. It may be kept after the instant app has been uninstalled. |
| 644 | */ |
| 645 | public abstract boolean hasInstantApplicationMetadata(String packageName, int userId); |
Todd Kennedy | df113c3 | 2017-08-31 16:10:29 -0700 | [diff] [blame] | 646 | |
| 647 | /** |
| 648 | * Updates a package last used time. |
| 649 | */ |
| 650 | public abstract void notifyPackageUse(String packageName, int reason); |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 651 | |
| 652 | /** |
| 653 | * Returns a package object for the given package name. |
| 654 | */ |
| 655 | public abstract @Nullable PackageParser.Package getPackage(@NonNull String packageName); |
| 656 | |
| 657 | /** |
Todd Kennedy | 42d6160 | 2017-12-12 14:44:19 -0800 | [diff] [blame] | 658 | * Returns a list without a change observer. |
| 659 | * |
Philip P. Moltmann | b0be05c | 2018-09-19 02:46:56 +0000 | [diff] [blame] | 660 | * @see #getPackageList(PackageListObserver) |
Todd Kennedy | 42d6160 | 2017-12-12 14:44:19 -0800 | [diff] [blame] | 661 | */ |
| 662 | public @NonNull PackageList getPackageList() { |
| 663 | return getPackageList(null); |
| 664 | } |
| 665 | |
| 666 | /** |
| 667 | * Returns the list of packages installed at the time of the method call. |
| 668 | * <p>The given observer is notified when the list of installed packages |
| 669 | * changes [eg. a package was installed or uninstalled]. It will not be |
| 670 | * notified if a package is updated. |
| 671 | * <p>The package list will not be updated automatically as packages are |
| 672 | * installed / uninstalled. Any changes must be handled within the observer. |
| 673 | */ |
| 674 | public abstract @NonNull PackageList getPackageList(@Nullable PackageListObserver observer); |
| 675 | |
| 676 | /** |
| 677 | * Removes the observer. |
| 678 | * <p>Generally not needed. {@link #getPackageList(PackageListObserver)} will automatically |
| 679 | * remove the observer. |
| 680 | * <p>Does nothing if the observer isn't currently registered. |
| 681 | * <p>Observers are notified asynchronously and it's possible for an observer to be |
| 682 | * invoked after its been removed. |
| 683 | */ |
| 684 | public abstract void removePackageListObserver(@NonNull PackageListObserver observer); |
| 685 | |
| 686 | /** |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 687 | * Returns a package object for the disabled system package name. |
| 688 | */ |
Philip P. Moltmann | b0be05c | 2018-09-19 02:46:56 +0000 | [diff] [blame] | 689 | public abstract @Nullable PackageParser.Package getDisabledSystemPackage( |
| 690 | @NonNull String packageName); |
| 691 | |
| 692 | /** |
| 693 | * Returns the package name for the disabled system package. |
| 694 | * |
| 695 | * This is equivalent to |
| 696 | * {@link #getDisabledSystemPackage(String)}.{@link PackageParser.Package#packageName} |
| 697 | */ |
| 698 | public abstract @Nullable String getDisabledSystemPackageName(@NonNull String packageName); |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 699 | |
| 700 | /** |
| 701 | * Returns whether or not the component is the resolver activity. |
| 702 | */ |
| 703 | public abstract boolean isResolveActivityComponent(@NonNull ComponentInfo component); |
| 704 | |
| 705 | /** |
| 706 | * Returns the package name for a known package. |
| 707 | */ |
| 708 | public abstract @Nullable String getKnownPackageName( |
| 709 | @KnownPackage int knownPackage, int userId); |
| 710 | |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 711 | /** |
| 712 | * Returns whether the package is an instant app. |
| 713 | */ |
| 714 | public abstract boolean isInstantApp(String packageName, int userId); |
| 715 | |
| 716 | /** |
| 717 | * Returns whether the package is an instant app. |
| 718 | */ |
| 719 | public abstract @Nullable String getInstantAppPackageName(int uid); |
| 720 | |
| 721 | /** |
| 722 | * Returns whether or not access to the application should be filtered. |
| 723 | * <p> |
| 724 | * Access may be limited based upon whether the calling or target applications |
| 725 | * are instant applications. |
| 726 | * |
Philip P. Moltmann | b0be05c | 2018-09-19 02:46:56 +0000 | [diff] [blame] | 727 | * @see #canAccessInstantApps |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 728 | */ |
| 729 | public abstract boolean filterAppAccess( |
| 730 | @Nullable PackageParser.Package pkg, int callingUid, int userId); |
| 731 | |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 732 | /* |
| 733 | * NOTE: The following methods are temporary until permissions are extracted from |
| 734 | * the package manager into a component specifically for handling permissions. |
| 735 | */ |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 736 | /** Returns the flags for the given permission. */ |
| 737 | public abstract @Nullable int getPermissionFlagsTEMP(@NonNull String permName, |
| 738 | @NonNull String packageName, int userId); |
| 739 | /** Updates the flags for the given permission. */ |
| 740 | public abstract void updatePermissionFlagsTEMP(@NonNull String permName, |
| 741 | @NonNull String packageName, int flagMask, int flagValues, int userId); |
Michal Karpinski | 528c3e5 | 2018-02-07 17:47:10 +0000 | [diff] [blame] | 742 | |
Philip P. Moltmann | b0be05c | 2018-09-19 02:46:56 +0000 | [diff] [blame] | 743 | /** Returns whether the given package was signed by the platform */ |
| 744 | public abstract boolean isPlatformSigned(String pkg); |
| 745 | |
Michal Karpinski | 528c3e5 | 2018-02-07 17:47:10 +0000 | [diff] [blame] | 746 | /** |
| 747 | * Returns true if it's still safe to restore data backed up from this app's version |
| 748 | * that was signed with restoringFromSigHash. |
| 749 | */ |
| 750 | public abstract boolean isDataRestoreSafe(@NonNull byte[] restoringFromSigHash, |
| 751 | @NonNull String packageName); |
| 752 | |
| 753 | /** |
| 754 | * Returns true if it's still safe to restore data backed up from this app's version |
| 755 | * that was signed with restoringFromSig. |
| 756 | */ |
| 757 | public abstract boolean isDataRestoreSafe(@NonNull Signature restoringFromSig, |
| 758 | @NonNull String packageName); |
Dan Cashman | 303c4bb | 2018-04-10 07:41:16 -0700 | [diff] [blame] | 759 | |
Dan Cashman | 303c4bb | 2018-04-10 07:41:16 -0700 | [diff] [blame] | 760 | /** |
Todd Kennedy | cf82703 | 2018-07-03 13:17:22 -0700 | [diff] [blame] | 761 | * Returns {@code true} if the the signing information for {@code clientUid} is sufficient |
| 762 | * to gain access gated by {@code capability}. This can happen if the two UIDs have the |
| 763 | * same signing information, if the signing information {@code clientUid} indicates that |
| 764 | * it has the signing certificate for {@code serverUid} in its signing history (if it was |
| 765 | * previously signed by it), or if the signing certificate for {@code clientUid} is in the |
| 766 | * signing history for {@code serverUid} and with the {@code capability} specified. |
Dan Cashman | 303c4bb | 2018-04-10 07:41:16 -0700 | [diff] [blame] | 767 | */ |
| 768 | public abstract boolean hasSignatureCapability(int serverUid, int clientUid, |
| 769 | @PackageParser.SigningDetails.CertCapabilities int capability); |
Svet Ganov | d873ae6 | 2018-06-25 16:39:23 -0700 | [diff] [blame] | 770 | |
| 771 | /** |
| 772 | * Get the delegate to influence permission checking. |
| 773 | * |
| 774 | * @return The delegate instance or null to clear. |
| 775 | */ |
| 776 | public abstract @Nullable CheckPermissionDelegate getCheckPermissionDelegate(); |
| 777 | |
| 778 | /** |
| 779 | * Set a delegate to influence permission checking. |
| 780 | * |
| 781 | * @param delegate A delegate instance or null to clear. |
| 782 | */ |
| 783 | public abstract void setCheckPermissionDelegate(@Nullable CheckPermissionDelegate delegate); |
Sudheer Shanka | 0a541a5 | 2018-07-31 13:21:11 -0700 | [diff] [blame] | 784 | |
| 785 | /** |
| 786 | * Get appIds of all available apps which specified android:sharedUserId in the manifest. |
| 787 | * |
| 788 | * @return a SparseArray mapping from appId to it's sharedUserId. |
| 789 | */ |
| 790 | public abstract SparseArray<String> getAppsWithSharedUserIds(); |
Jeff Sharkey | 5790af0 | 2018-08-13 17:42:54 -0600 | [diff] [blame] | 791 | |
| 792 | /** |
Sudheer Shanka | 2ac25a9 | 2018-10-25 10:59:32 -0700 | [diff] [blame] | 793 | * Get the value of attribute android:sharedUserId for the given packageName if specified, |
| 794 | * otherwise {@code null}. |
| 795 | */ |
| 796 | public abstract String getSharedUserIdForPackage(@NonNull String packageName); |
| 797 | |
| 798 | /** |
| 799 | * Get all packages which specified the given sharedUserId as android:sharedUserId attribute |
| 800 | * or an empty array if no package specified it. |
| 801 | */ |
| 802 | public abstract String[] getPackagesForSharedUserId(@NonNull String sharedUserId, int userId); |
| 803 | |
| 804 | /** |
Jeff Sharkey | 5790af0 | 2018-08-13 17:42:54 -0600 | [diff] [blame] | 805 | * Return if device is currently in a "core" boot environment, typically |
| 806 | * used to support full-disk encryption. Only apps marked with |
| 807 | * {@code coreApp} attribute are available. |
| 808 | */ |
| 809 | public abstract boolean isOnlyCoreApps(); |
| 810 | |
| 811 | /** |
| 812 | * Make a best-effort attempt to provide the requested free disk space by |
| 813 | * deleting cached files. |
| 814 | * |
| 815 | * @throws IOException if the request was unable to be fulfilled. |
| 816 | */ |
| 817 | public abstract void freeStorage(String volumeUuid, long bytes, int storageFlags) |
| 818 | throws IOException; |
Todd Kennedy | cf82703 | 2018-07-03 13:17:22 -0700 | [diff] [blame] | 819 | |
| 820 | /** Returns {@code true} if the specified component is enabled and matches the given flags. */ |
| 821 | public abstract boolean isEnabledAndMatches(@NonNull ComponentInfo info, int flags, int userId); |
| 822 | |
| 823 | /** Returns {@code true} if the given user requires extra badging for icons. */ |
| 824 | public abstract boolean userNeedsBadging(int userId); |
Eugene Susla | abdefba | 2018-11-09 18:06:43 -0800 | [diff] [blame] | 825 | |
| 826 | /** |
| 827 | * Perform the given action for each package. |
| 828 | * Note that packages lock will be held while performin the actions. |
| 829 | * |
| 830 | * @param actionLocked action to be performed |
| 831 | */ |
| 832 | public abstract void forEachPackage(Consumer<PackageParser.Package> actionLocked); |
| 833 | |
| 834 | /** Returns the list of enabled components */ |
| 835 | public abstract ArraySet<String> getEnabledComponents(String packageName, int userId); |
| 836 | |
| 837 | /** Returns the list of disabled components */ |
| 838 | public abstract ArraySet<String> getDisabledComponents(String packageName, int userId); |
| 839 | |
| 840 | /** Returns whether the given package is enabled for the given user */ |
| 841 | public abstract @PackageManager.EnabledState int getApplicationEnabledState( |
| 842 | String packageName, int userId); |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 843 | |
| 844 | /** |
| 845 | * Extra field name for the token of a request to enable rollback for a |
| 846 | * package. |
| 847 | */ |
| 848 | public static final String EXTRA_ENABLE_ROLLBACK_TOKEN = |
| 849 | "android.content.pm.extra.ENABLE_ROLLBACK_TOKEN"; |
| 850 | |
| 851 | /** |
| 852 | * Extra field name for the installFlags of a request to enable rollback |
| 853 | * for a package. |
| 854 | */ |
| 855 | public static final String EXTRA_ENABLE_ROLLBACK_INSTALL_FLAGS = |
| 856 | "android.content.pm.extra.ENABLE_ROLLBACK_INSTALL_FLAGS"; |
| 857 | |
| 858 | /** |
Narayan Kamath | 869f706 | 2019-01-10 12:24:15 +0000 | [diff] [blame] | 859 | * Extra field name for the set of installed users for a given rollback package. |
| 860 | */ |
| 861 | public static final String EXTRA_ENABLE_ROLLBACK_INSTALLED_USERS = |
| 862 | "android.content.pm.extra.ENABLE_ROLLBACK_INSTALLED_USERS"; |
| 863 | |
| 864 | /** |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 865 | * Used as the {@code enableRollbackCode} argument for |
| 866 | * {@link PackageManagerInternal#setEnableRollbackCode} to indicate that |
| 867 | * enabling rollback succeeded. |
| 868 | */ |
| 869 | public static final int ENABLE_ROLLBACK_SUCCEEDED = 1; |
| 870 | |
| 871 | /** |
| 872 | * Used as the {@code enableRollbackCode} argument for |
| 873 | * {@link PackageManagerInternal#setEnableRollbackCode} to indicate that |
| 874 | * enabling rollback failed. |
| 875 | */ |
| 876 | public static final int ENABLE_ROLLBACK_FAILED = -1; |
| 877 | |
| 878 | /** |
| 879 | * Allows the rollback manager listening to the |
| 880 | * {@link Intent#ACTION_PACKAGE_ENABLE_ROLLBACK enable rollback broadcast} |
| 881 | * to respond to the package manager. The response must include the |
| 882 | * {@code enableRollbackCode} which is one of |
| 883 | * {@link PackageManager#ENABLE_ROLLBACK_SUCCEEDED} or |
| 884 | * {@link PackageManager#ENABLE_ROLLBACK_FAILED}. |
| 885 | * |
| 886 | * @param token pending package identifier as passed via the |
| 887 | * {@link PackageManager#EXTRA_ENABLE_ROLLBACK_TOKEN} Intent extra. |
| 888 | * @param enableRollbackCode the status code result of enabling rollback |
| 889 | * @throws SecurityException if the caller does not have the |
| 890 | * PACKAGE_ROLLBACK_AGENT permission. |
| 891 | */ |
| 892 | public abstract void setEnableRollbackCode(int token, int enableRollbackCode); |
Eric Holk | a1485f6 | 2019-01-07 13:58:25 -0800 | [diff] [blame] | 893 | |
| 894 | /** |
| 895 | * Ask the package manager to compile layouts in the given package. |
| 896 | */ |
| 897 | public abstract boolean compileLayouts(String packageName); |
Narayan Kamath | 869f706 | 2019-01-10 12:24:15 +0000 | [diff] [blame] | 898 | |
| 899 | /* |
| 900 | * Inform the package manager that the pending package install identified by |
| 901 | * {@code token} can be completed. |
| 902 | */ |
| 903 | public abstract void finishPackageInstall(int token, boolean didLaunch); |
Hai Zhang | a22cd83 | 2019-01-30 13:38:43 -0800 | [diff] [blame] | 904 | |
| 905 | /** |
| 906 | * Remove the default browser stored in the legacy package settings. |
| 907 | * |
| 908 | * @param userId the user id |
| 909 | * |
| 910 | * @return the package name of the default browser, or {@code null} if none |
| 911 | */ |
| 912 | @Nullable |
| 913 | public abstract String removeLegacyDefaultBrowserPackageName(int userId); |
Hai Zhang | 85fd062 | 2019-02-01 14:06:04 -0800 | [diff] [blame] | 914 | |
| 915 | /** |
| 916 | * Sets the default browser provider. |
| 917 | * |
| 918 | * @param provider the provider |
| 919 | */ |
| 920 | public abstract void setDefaultBrowserProvider(@NonNull DefaultBrowserProvider provider); |
Hai Zhang | 8be463f | 2019-02-11 16:44:45 -0800 | [diff] [blame] | 921 | |
| 922 | /** |
| 923 | * Sets the default home provider. |
| 924 | * |
| 925 | * @param provider the provider |
| 926 | */ |
| 927 | public abstract void setDefaultHomeProvider(@NonNull DefaultHomeProvider provider); |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 928 | } |