1adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov/* 2adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * Copyright (C) 2015 The Android Open Source Project 3adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * 4adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * Licensed under the Apache License, Version 2.0 (the "License"); 5adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * you may not use this file except in compliance with the License. 6adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * You may obtain a copy of the License at 7adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * 8adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * http://www.apache.org/licenses/LICENSE-2.0 9adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * 10adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * Unless required by applicable law or agreed to in writing, software 11adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * distributed under the License is distributed on an "AS IS" BASIS, 12adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * See the License for the specific language governing permissions and 14adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * limitations under the License. 15adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov */ 16adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov 17adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganovpackage android.content.pm; 18adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov 192d5b465fa9235e66ec176f6d6ffaaa0c18143e41Makoto Onukiimport android.content.ComponentName; 2001ad0c7e403794b272494f187d91f57bdfa07c9dTodd Kennedyimport android.content.Intent; 2118211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedyimport android.content.pm.PackageManager.ApplicationInfoFlags; 2218211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedyimport android.content.pm.PackageManager.ComponentInfoFlags; 2339bfee5e3674faea992c32204abc1c03429b8cdaTodd Kennedyimport android.content.pm.PackageManager.NameNotFoundException; 2418211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedyimport android.content.pm.PackageManager.PackageInfoFlags; 2518211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedyimport android.content.pm.PackageManager.ResolveInfoFlags; 260606861de50995e997d7c117e3bab1eb5db06da8Chad Brubakerimport android.os.Bundle; 27c29f62c7388f550da2c7368c5dbc0aec7d1564feMakoto Onukiimport android.util.SparseArray; 2839bfee5e3674faea992c32204abc1c03429b8cdaTodd Kennedy 29cb6fd80721253ffa9dcab5cf8c2f4e9b9cd17cccFyodor Kupolovimport java.util.List; 30adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov 31adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov/** 32adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * Package manager local system service interface. 33adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * 34adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * @hide Only for use within the system server. 35adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov */ 36adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganovpublic abstract class PackageManagerInternal { 37adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov 38adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov /** 39adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * Provider for package names. 40adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov */ 41adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov public interface PackagesProvider { 42adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov 43adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov /** 44adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * Gets the packages for a given user. 45adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * @param userId The user id. 46adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * @return The package names. 47adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov */ 48adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov public String[] getPackages(int userId); 49adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov } 50adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov 51adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov /** 520010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav * Provider for package names. 530010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav */ 540010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav public interface SyncAdapterPackagesProvider { 550010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav 560010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav /** 570010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav * Gets the sync adapter packages for given authority and user. 580010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav * @param authority The authority. 590010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav * @param userId The user id. 600010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav * @return The package names. 610010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav */ 620010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav public String[] getPackages(String authority, int userId); 630010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav } 640010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav 650010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav /** 66adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * Sets the location provider packages provider. 67adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * @param provider The packages provider. 68adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov */ 69adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov public abstract void setLocationPackagesProvider(PackagesProvider provider); 70adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov 71adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov /** 72adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * Sets the voice interaction packages provider. 73adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov * @param provider The packages provider. 74adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov */ 75adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov public abstract void setVoiceInteractionPackagesProvider(PackagesProvider provider); 76cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav 77cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav /** 78cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav * Sets the SMS packages provider. 79cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav * @param provider The packages provider. 80cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav */ 81cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav public abstract void setSmsAppPackagesProvider(PackagesProvider provider); 82cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav 83cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav /** 84cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav * Sets the dialer packages provider. 85cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav * @param provider The packages provider. 86cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav */ 87cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav public abstract void setDialerAppPackagesProvider(PackagesProvider provider); 88cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav 89cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav /** 90cf85562bc9a0f01db51b4088e72f05a8089fc7f1Sailesh Nepal * Sets the sim call manager packages provider. 91cf85562bc9a0f01db51b4088e72f05a8089fc7f1Sailesh Nepal * @param provider The packages provider. 92cf85562bc9a0f01db51b4088e72f05a8089fc7f1Sailesh Nepal */ 93cf85562bc9a0f01db51b4088e72f05a8089fc7f1Sailesh Nepal public abstract void setSimCallManagerPackagesProvider(PackagesProvider provider); 94cf85562bc9a0f01db51b4088e72f05a8089fc7f1Sailesh Nepal 95cf85562bc9a0f01db51b4088e72f05a8089fc7f1Sailesh Nepal /** 960010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav * Sets the sync adapter packages provider. 970010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav * @param provider The provider. 980010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav */ 990010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav public abstract void setSyncAdapterPackagesprovider(SyncAdapterPackagesProvider provider); 1000010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav 1010010b70beae6fafd3faf06e1b02291f59f9f85dbSvetoslav /** 102cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav * Requests granting of the default permissions to the current default SMS app. 103cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav * @param packageName The default SMS package name. 104cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav * @param userId The user for which to grant the permissions. 105cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav */ 106cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav public abstract void grantDefaultPermissionsToDefaultSmsApp(String packageName, int userId); 107cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav 108cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav /** 109cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav * Requests granting of the default permissions to the current default dialer app. 110cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav * @param packageName The default dialer package name. 111cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav * @param userId The user for which to grant the permissions. 112cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav */ 113cdfd230a392d0f0557a3a5bada221b7a05113392Svetoslav public abstract void grantDefaultPermissionsToDefaultDialerApp(String packageName, int userId); 114cf85562bc9a0f01db51b4088e72f05a8089fc7f1Sailesh Nepal 115cf85562bc9a0f01db51b4088e72f05a8089fc7f1Sailesh Nepal /** 116cf85562bc9a0f01db51b4088e72f05a8089fc7f1Sailesh Nepal * Requests granting of the default permissions to the current default sim call manager. 117cf85562bc9a0f01db51b4088e72f05a8089fc7f1Sailesh Nepal * @param packageName The default sim call manager package name. 118cf85562bc9a0f01db51b4088e72f05a8089fc7f1Sailesh Nepal * @param userId The user for which to grant the permissions. 119cf85562bc9a0f01db51b4088e72f05a8089fc7f1Sailesh Nepal */ 120cf85562bc9a0f01db51b4088e72f05a8089fc7f1Sailesh Nepal public abstract void grantDefaultPermissionsToDefaultSimCallManager(String packageName, 121cf85562bc9a0f01db51b4088e72f05a8089fc7f1Sailesh Nepal int userId); 122cb6fd80721253ffa9dcab5cf8c2f4e9b9cd17cccFyodor Kupolov 123cb6fd80721253ffa9dcab5cf8c2f4e9b9cd17cccFyodor Kupolov /** 124cb6fd80721253ffa9dcab5cf8c2f4e9b9cd17cccFyodor Kupolov * Sets a list of apps to keep in PM's internal data structures and as APKs even if no user has 125cb6fd80721253ffa9dcab5cf8c2f4e9b9cd17cccFyodor Kupolov * currently installed it. The apps are not preloaded. 126cb6fd80721253ffa9dcab5cf8c2f4e9b9cd17cccFyodor Kupolov * @param packageList List of package names to keep cached. 127cb6fd80721253ffa9dcab5cf8c2f4e9b9cd17cccFyodor Kupolov */ 128cb6fd80721253ffa9dcab5cf8c2f4e9b9cd17cccFyodor Kupolov public abstract void setKeepUninstalledPackages(List<String> packageList); 1299c165d76010d9f79f5cd71978742a335b6b8d1b4Svet Ganov 1309c165d76010d9f79f5cd71978742a335b6b8d1b4Svet Ganov /** 1319c165d76010d9f79f5cd71978742a335b6b8d1b4Svet Ganov * Gets whether some of the permissions used by this package require a user 1329c165d76010d9f79f5cd71978742a335b6b8d1b4Svet Ganov * review before any of the app components can run. 1339c165d76010d9f79f5cd71978742a335b6b8d1b4Svet Ganov * @param packageName The package name for which to check. 1349c165d76010d9f79f5cd71978742a335b6b8d1b4Svet Ganov * @param userId The user under which to check. 1359c165d76010d9f79f5cd71978742a335b6b8d1b4Svet Ganov * @return True a permissions review is required. 1369c165d76010d9f79f5cd71978742a335b6b8d1b4Svet Ganov */ 1379c165d76010d9f79f5cd71978742a335b6b8d1b4Svet Ganov public abstract boolean isPermissionsReviewRequired(String packageName, int userId); 13839bfee5e3674faea992c32204abc1c03429b8cdaTodd Kennedy 13939bfee5e3674faea992c32204abc1c03429b8cdaTodd Kennedy /** 14018211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy * Retrieve all of the information we know about a particular package/application. 14118211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy * @param filterCallingUid The results will be filtered in the context of this UID instead 14218211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy * of the calling UID. 14318211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy * @see PackageManager#getPackageInfo(String, int) 14418211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy */ 14518211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy public abstract PackageInfo getPackageInfo(String packageName, 14618211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy @PackageInfoFlags int flags, int filterCallingUid, int userId); 14718211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy 14818211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy /** 14918211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy * Retrieve all of the information we know about a particular package/application. 15018211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy * @param filterCallingUid The results will be filtered in the context of this UID instead 15118211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy * of the calling UID. 15218211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy * @see PackageManager#getApplicationInfo(String, int) 15318211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy */ 15418211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy public abstract ApplicationInfo getApplicationInfo(String packageName, 15518211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy @ApplicationInfoFlags int flags, int filterCallingUid, int userId); 15618211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy 15718211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy /** 15818211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy * Retrieve all of the information we know about a particular activity class. 15918211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy * @param filterCallingUid The results will be filtered in the context of this UID instead 16018211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy * of the calling UID. 16118211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy * @see PackageManager#getActivityInfo(ComponentName, int) 16218211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy */ 16318211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy public abstract ActivityInfo getActivityInfo(ComponentName component, 16418211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy @ComponentInfoFlags int flags, int filterCallingUid, int userId); 16518211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy 16618211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy /** 16718211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy * Retrieve all activities that can be performed for the given intent. 16818211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy * @param filterCallingUid The results will be filtered in the context of this UID instead 16918211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy * of the calling UID. 17018211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy * @see PackageManager#queryIntentActivities(Intent, int) 17139bfee5e3674faea992c32204abc1c03429b8cdaTodd Kennedy */ 17218211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 17318211fd8f6ff4a70a4b8b16fab642783d536102bTodd Kennedy @ResolveInfoFlags int flags, int filterCallingUid, int userId); 1742d5b465fa9235e66ec176f6d6ffaaa0c18143e41Makoto Onuki 1752d5b465fa9235e66ec176f6d6ffaaa0c18143e41Makoto Onuki /** 1762d5b465fa9235e66ec176f6d6ffaaa0c18143e41Makoto Onuki * Interface to {@link com.android.server.pm.PackageManagerService#getHomeActivitiesAsUser}. 1772d5b465fa9235e66ec176f6d6ffaaa0c18143e41Makoto Onuki */ 1782d5b465fa9235e66ec176f6d6ffaaa0c18143e41Makoto Onuki public abstract ComponentName getHomeActivitiesAsUser(List<ResolveInfo> allHomeCandidates, 1792d5b465fa9235e66ec176f6d6ffaaa0c18143e41Makoto Onuki int userId); 180c29f62c7388f550da2c7368c5dbc0aec7d1564feMakoto Onuki 181c29f62c7388f550da2c7368c5dbc0aec7d1564feMakoto Onuki /** 182c29f62c7388f550da2c7368c5dbc0aec7d1564feMakoto Onuki * Called by DeviceOwnerManagerService to set the package names of device owner and profile 183c29f62c7388f550da2c7368c5dbc0aec7d1564feMakoto Onuki * owners. 184c29f62c7388f550da2c7368c5dbc0aec7d1564feMakoto Onuki */ 185c29f62c7388f550da2c7368c5dbc0aec7d1564feMakoto Onuki public abstract void setDeviceAndProfileOwnerPackages( 186c29f62c7388f550da2c7368c5dbc0aec7d1564feMakoto Onuki int deviceOwnerUserId, String deviceOwner, SparseArray<String> profileOwners); 187c29f62c7388f550da2c7368c5dbc0aec7d1564feMakoto Onuki 188c29f62c7388f550da2c7368c5dbc0aec7d1564feMakoto Onuki /** 1899d48a731d0a7c016b58bc9c1afc4acd94200650fSteven Ng * Returns {@code true} if a given package can't be wiped. Otherwise, returns {@code false}. 190c29f62c7388f550da2c7368c5dbc0aec7d1564feMakoto Onuki */ 1919d48a731d0a7c016b58bc9c1afc4acd94200650fSteven Ng public abstract boolean isPackageDataProtected(int userId, String packageName); 192973edd19db752483f5958f974068c89fead1371bSvet Ganov 193973edd19db752483f5958f974068c89fead1371bSvet Ganov /** 194e07641d4fbdd0528c18305213e861a6e1aff4a3bDianne Hackborn * Returns {@code true} if a given package is installed as ephemeral. Otherwise, returns 195e07641d4fbdd0528c18305213e861a6e1aff4a3bDianne Hackborn * {@code false}. 196e07641d4fbdd0528c18305213e861a6e1aff4a3bDianne Hackborn */ 197e07641d4fbdd0528c18305213e861a6e1aff4a3bDianne Hackborn public abstract boolean isPackageEphemeral(int userId, String packageName); 198e07641d4fbdd0528c18305213e861a6e1aff4a3bDianne Hackborn 199e07641d4fbdd0528c18305213e861a6e1aff4a3bDianne Hackborn /** 200973edd19db752483f5958f974068c89fead1371bSvet Ganov * Gets whether the package was ever launched. 201973edd19db752483f5958f974068c89fead1371bSvet Ganov * @param packageName The package name. 202973edd19db752483f5958f974068c89fead1371bSvet Ganov * @param userId The user for which to check. 203973edd19db752483f5958f974068c89fead1371bSvet Ganov * @return Whether was launched. 2042cbfa1ec746fa4b3c385ab5c2f707895dd4ecf50Amith Yamasani * @throws IllegalArgumentException if the package is not found 205973edd19db752483f5958f974068c89fead1371bSvet Ganov */ 206973edd19db752483f5958f974068c89fead1371bSvet Ganov public abstract boolean wasPackageEverLaunched(String packageName, int userId); 207700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot 208700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot /** 209700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot * Grants a runtime permission 210700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot * @param packageName The package name. 211700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot * @param name The name of the permission. 212700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot * @param userId The userId for which to grant the permission. 213700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot * @param overridePolicy If true, grant this permission even if it is fixed by policy. 214700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot */ 215700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot public abstract void grantRuntimePermission(String packageName, String name, int userId, 216700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot boolean overridePolicy); 217700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot 218700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot /** 219700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot * Revokes a runtime permission 220700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot * @param packageName The package name. 221700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot * @param name The name of the permission. 222700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot * @param userId The userId for which to revoke the permission. 223700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot * @param overridePolicy If true, revoke this permission even if it is fixed by policy. 224700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot */ 225700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot public abstract void revokeRuntimePermission(String packageName, String name, int userId, 226700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot boolean overridePolicy); 227700e1e7ee8e4ed491768a35ed692a4e8f0ff0d4bNicolas Prevot 228f77ee4f1b79929a77f603e5e879f3616ae464e3eMichal Karpinski /** 229cb67dc9eadf6c6aaa343f48e24b2b43914639c05Michal Karpinski * Retrieve the official name associated with a uid. This name is 230f77ee4f1b79929a77f603e5e879f3616ae464e3eMichal Karpinski * guaranteed to never change, though it is possible for the underlying 231cb67dc9eadf6c6aaa343f48e24b2b43914639c05Michal Karpinski * uid to be changed. That is, if you are storing information about 232cb67dc9eadf6c6aaa343f48e24b2b43914639c05Michal Karpinski * uids in persistent storage, you should use the string returned 233cb67dc9eadf6c6aaa343f48e24b2b43914639c05Michal Karpinski * by this function instead of the raw uid. 234f77ee4f1b79929a77f603e5e879f3616ae464e3eMichal Karpinski * 235cb67dc9eadf6c6aaa343f48e24b2b43914639c05Michal Karpinski * @param uid The uid for which you would like to retrieve a name. 236cb67dc9eadf6c6aaa343f48e24b2b43914639c05Michal Karpinski * @return Returns a unique name for the given uid, or null if the 237cb67dc9eadf6c6aaa343f48e24b2b43914639c05Michal Karpinski * uid is not currently assigned. 238f77ee4f1b79929a77f603e5e879f3616ae464e3eMichal Karpinski */ 239f77ee4f1b79929a77f603e5e879f3616ae464e3eMichal Karpinski public abstract String getNameForUid(int uid); 240f77ee4f1b79929a77f603e5e879f3616ae464e3eMichal Karpinski 24101ad0c7e403794b272494f187d91f57bdfa07c9dTodd Kennedy /** 24201ad0c7e403794b272494f187d91f57bdfa07c9dTodd Kennedy * Request to perform the second phase of ephemeral resolution. 24301ad0c7e403794b272494f187d91f57bdfa07c9dTodd Kennedy * @param responseObj The response of the first phase of ephemeral resolution 24401ad0c7e403794b272494f187d91f57bdfa07c9dTodd Kennedy * @param origIntent The original intent that triggered ephemeral resolution 24501ad0c7e403794b272494f187d91f57bdfa07c9dTodd Kennedy * @param resolvedType The resolved type of the intent 24601ad0c7e403794b272494f187d91f57bdfa07c9dTodd Kennedy * @param callingPackage The name of the package requesting the ephemeral application 2470606861de50995e997d7c117e3bab1eb5db06da8Chad Brubaker * @param verificationBundle Optional bundle to pass to the installer for additional 2480606861de50995e997d7c117e3bab1eb5db06da8Chad Brubaker * verification 24901ad0c7e403794b272494f187d91f57bdfa07c9dTodd Kennedy * @param userId The ID of the user that triggered ephemeral resolution 25001ad0c7e403794b272494f187d91f57bdfa07c9dTodd Kennedy */ 251e991022423c2e5b4386553af7ef3b54da7c54be1Todd Kennedy public abstract void requestInstantAppResolutionPhaseTwo(AuxiliaryResolveInfo responseObj, 252e991022423c2e5b4386553af7ef3b54da7c54be1Todd Kennedy Intent origIntent, String resolvedType, String callingPackage, 2530606861de50995e997d7c117e3bab1eb5db06da8Chad Brubaker Bundle verificationBundle, int userId); 254e080da9ee027fcd030aa92ea26fd0ed9f031674fSvetoslav Ganov 255e080da9ee027fcd030aa92ea26fd0ed9f031674fSvetoslav Ganov /** 2560e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy * Grants access to the package metadata for an ephemeral application. 2570e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy * <p> 2580e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy * When an ephemeral application explicitly tries to interact with a full 2590e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy * install application [via an activity, service or provider that has been 2600e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy * exposed using the {@code visibleToInstantApp} attribute], the normal 2610e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy * application must be able to see metadata about the connecting ephemeral 2620e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy * app. If the ephemeral application uses an implicit intent [ie action VIEW, 2630e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy * category BROWSABLE], it remains hidden from the launched activity. 2640e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy * <p> 2650e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy * If the {@code sourceUid} is not for an ephemeral app or {@code targetUid} 2660e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy * is not for a fully installed app, this method will be a no-op. 2670e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy * 2680e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy * @param userId the user 2690e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy * @param intent the intent that triggered the grant 2700e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy * @param targetAppId The app ID of the fully installed application 2710e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy * @param ephemeralAppId The app ID of the ephemeral application 2720e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy */ 2730e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy public abstract void grantEphemeralAccess(int userId, Intent intent, 2740e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy int targetAppId, int ephemeralAppId); 2750e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy 276b21be12d9db5d0d85afa26e401813eaa360bd2e0Todd Kennedy public abstract boolean isInstantAppInstallerComponent(ComponentName component); 2770e989d00ed1e95be0ccb77c29846ee0b6ac33356Todd Kennedy /** 278096d304ae3d85c1bfcda1a1d9cd4eb13d0815500Svetoslav Ganov * Prunes instant apps and state associated with uninstalled 279096d304ae3d85c1bfcda1a1d9cd4eb13d0815500Svetoslav Ganov * instant apps according to the current platform policy. 280096d304ae3d85c1bfcda1a1d9cd4eb13d0815500Svetoslav Ganov */ 281096d304ae3d85c1bfcda1a1d9cd4eb13d0815500Svetoslav Ganov public abstract void pruneInstantApps(); 282096d304ae3d85c1bfcda1a1d9cd4eb13d0815500Svetoslav Ganov 283096d304ae3d85c1bfcda1a1d9cd4eb13d0815500Svetoslav Ganov /** 284e080da9ee027fcd030aa92ea26fd0ed9f031674fSvetoslav Ganov * @return The SetupWizard package name. 285e080da9ee027fcd030aa92ea26fd0ed9f031674fSvetoslav Ganov */ 286e080da9ee027fcd030aa92ea26fd0ed9f031674fSvetoslav Ganov public abstract String getSetupWizardPackageName(); 287aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla 288aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla public interface ExternalSourcesPolicy { 289aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla 290aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla int USER_TRUSTED = 0; // User has trusted the package to install apps 291aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla int USER_BLOCKED = 1; // User has blocked the package to install apps 292aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla int USER_DEFAULT = 2; // Default code to use when user response is unavailable 293aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla 294aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla /** 295aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla * Checks the user preference for whether a package is trusted to request installs through 296aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla * package installer 297aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla * 298aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla * @param packageName The package to check for 299aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla * @param uid the uid in which the package is running 300aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla * @return {@link USER_TRUSTED} if the user has trusted the package, {@link USER_BLOCKED} 301aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla * if user has blocked requests from the package, {@link USER_DEFAULT} if the user response 302aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla * is not yet available 303aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla */ 304aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla int getPackageTrustedToInstallApps(String packageName, int uid); 305aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla } 306aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla 307aef2513c7157a28236d097a81fe74d7ba6b710c9Suprabh Shukla public abstract void setExternalSourcesPolicy(ExternalSourcesPolicy policy); 308eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad 309eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad /** 310b1e7776e2ca348ad734fdddc68d9bda6eb17c5e0Dianne Hackborn * Return true if the given package is a persistent app process. 311b1e7776e2ca348ad734fdddc68d9bda6eb17c5e0Dianne Hackborn */ 312b1e7776e2ca348ad734fdddc68d9bda6eb17c5e0Dianne Hackborn public abstract boolean isPackagePersistent(String packageName); 313b1e7776e2ca348ad734fdddc68d9bda6eb17c5e0Dianne Hackborn 314b1e7776e2ca348ad734fdddc68d9bda6eb17c5e0Dianne Hackborn /** 315eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad * Get all overlay packages for a user. 316eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad * @param userId The user for which to get the overlays. 317eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad * @return A list of overlay packages. An empty list is returned if the 318eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad * user has no installed overlay packages. 319eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad */ 320eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad public abstract List<PackageInfo> getOverlayPackages(int userId); 321eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad 322eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad /** 323eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad * Get the names of all target packages for a user. 324eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad * @param userId The user for which to get the package names. 325eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad * @return A list of target package names. This list includes the "android" package. 326eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad */ 327eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad public abstract List<String> getTargetPackageNames(int userId); 328eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad 329eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad /** 330eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad * Set which overlay to use for a package. 331eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad * @param userId The user for which to update the overlays. 332eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad * @param targetPackageName The package name of the package for which to update the overlays. 333eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad * @param overlayPackageNames The complete list of overlay packages that should be enabled for 334eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad * the target. Previously enabled overlays not specified in the list 335eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad * will be disabled. Pass in null or an empty list to disable 336eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad * all overlays. The order of the items is significant if several 337eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad * overlays modify the same resource. 338eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad * @return true if all packages names were known by the package manager, false otherwise 339eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad */ 340eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad public abstract boolean setEnabledOverlayPackages(int userId, String targetPackageName, 341eabc9e95768e7ac9acc3b32dc9ac2edf99c9e2c5Mårten Kongstad List<String> overlayPackageNames); 3424d1de7da79010be3e1f0eb85aa50b6002a8241fdTodd Kennedy 3434d1de7da79010be3e1f0eb85aa50b6002a8241fdTodd Kennedy /** 34451b3aaccfe7f8d7a97fb1218c40a37428f26a6a1Todd Kennedy * Resolves an activity intent, allowing instant apps to be resolved. 3454d1de7da79010be3e1f0eb85aa50b6002a8241fdTodd Kennedy */ 3464d1de7da79010be3e1f0eb85aa50b6002a8241fdTodd Kennedy public abstract ResolveInfo resolveIntent(Intent intent, String resolvedType, 3474d1de7da79010be3e1f0eb85aa50b6002a8241fdTodd Kennedy int flags, int userId); 3480f28a80d8e80a3546fe0776999b2deaa3dc2157cChad Brubaker 3490f28a80d8e80a3546fe0776999b2deaa3dc2157cChad Brubaker /** 35051b3aaccfe7f8d7a97fb1218c40a37428f26a6a1Todd Kennedy * Resolves a service intent, allowing instant apps to be resolved. 35151b3aaccfe7f8d7a97fb1218c40a37428f26a6a1Todd Kennedy */ 35251b3aaccfe7f8d7a97fb1218c40a37428f26a6a1Todd Kennedy public abstract ResolveInfo resolveService(Intent intent, String resolvedType, 35351b3aaccfe7f8d7a97fb1218c40a37428f26a6a1Todd Kennedy int flags, int userId, int callingUid); 35451b3aaccfe7f8d7a97fb1218c40a37428f26a6a1Todd Kennedy 35551b3aaccfe7f8d7a97fb1218c40a37428f26a6a1Todd Kennedy /** 3560f28a80d8e80a3546fe0776999b2deaa3dc2157cChad Brubaker * Track the creator of a new isolated uid. 3570f28a80d8e80a3546fe0776999b2deaa3dc2157cChad Brubaker * @param isolatedUid The newly created isolated uid. 3580f28a80d8e80a3546fe0776999b2deaa3dc2157cChad Brubaker * @param ownerUid The uid of the app that created the isolated process. 3590f28a80d8e80a3546fe0776999b2deaa3dc2157cChad Brubaker */ 3600f28a80d8e80a3546fe0776999b2deaa3dc2157cChad Brubaker public abstract void addIsolatedUid(int isolatedUid, int ownerUid); 3610f28a80d8e80a3546fe0776999b2deaa3dc2157cChad Brubaker 3620f28a80d8e80a3546fe0776999b2deaa3dc2157cChad Brubaker /** 3630f28a80d8e80a3546fe0776999b2deaa3dc2157cChad Brubaker * Track removal of an isolated uid. 3640f28a80d8e80a3546fe0776999b2deaa3dc2157cChad Brubaker * @param isolatedUid isolated uid that is no longer being used. 3650f28a80d8e80a3546fe0776999b2deaa3dc2157cChad Brubaker */ 3660f28a80d8e80a3546fe0776999b2deaa3dc2157cChad Brubaker public abstract void removeIsolatedUid(int isolatedUid); 367e92f79450a0e3a55586eb2992577d09fc997761aMakoto Onuki 368e92f79450a0e3a55586eb2992577d09fc997761aMakoto Onuki /** 369e92f79450a0e3a55586eb2992577d09fc997761aMakoto Onuki * Return the taget SDK version for the app with the given UID. 370e92f79450a0e3a55586eb2992577d09fc997761aMakoto Onuki */ 371e92f79450a0e3a55586eb2992577d09fc997761aMakoto Onuki public abstract int getUidTargetSdkVersion(int uid); 372ad623015a119efe9b63f594af9c4703f40a0c27bMakoto Onuki 373ad623015a119efe9b63f594af9c4703f40a0c27bMakoto Onuki /** Whether the binder caller can access instant apps. */ 3743051caac52729c8c059eb538805f4d274a9945a5Todd Kennedy public abstract boolean canAccessInstantApps(int callingUid, int userId); 375adc1cf46045ae756d3a9ccbccf6b0f894e4c1eddSvet Ganov} 376