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 | |
Makoto Onuki | 2d5b465 | 2016-03-11 16:09:54 -0800 | [diff] [blame] | 19 | import android.content.ComponentName; |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 20 | import android.content.Intent; |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 21 | import android.content.pm.PackageManager.NameNotFoundException; |
Makoto Onuki | c29f62c | 2016-06-07 12:19:46 -0700 | [diff] [blame] | 22 | import android.util.SparseArray; |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 23 | |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 24 | import java.util.List; |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * Package manager local system service interface. |
| 28 | * |
| 29 | * @hide Only for use within the system server. |
| 30 | */ |
| 31 | public abstract class PackageManagerInternal { |
| 32 | |
| 33 | /** |
| 34 | * Provider for package names. |
| 35 | */ |
| 36 | public interface PackagesProvider { |
| 37 | |
| 38 | /** |
| 39 | * Gets the packages for a given user. |
| 40 | * @param userId The user id. |
| 41 | * @return The package names. |
| 42 | */ |
| 43 | public String[] getPackages(int userId); |
| 44 | } |
| 45 | |
| 46 | /** |
Svetoslav | 0010b70 | 2015-06-30 18:05:26 -0700 | [diff] [blame] | 47 | * Provider for package names. |
| 48 | */ |
| 49 | public interface SyncAdapterPackagesProvider { |
| 50 | |
| 51 | /** |
| 52 | * Gets the sync adapter packages for given authority and user. |
| 53 | * @param authority The authority. |
| 54 | * @param userId The user id. |
| 55 | * @return The package names. |
| 56 | */ |
| 57 | public String[] getPackages(String authority, int userId); |
| 58 | } |
| 59 | |
| 60 | /** |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 61 | * Sets the location provider packages provider. |
| 62 | * @param provider The packages provider. |
| 63 | */ |
| 64 | public abstract void setLocationPackagesProvider(PackagesProvider provider); |
| 65 | |
| 66 | /** |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 67 | * Sets the voice interaction packages provider. |
| 68 | * @param provider The packages provider. |
| 69 | */ |
| 70 | public abstract void setVoiceInteractionPackagesProvider(PackagesProvider provider); |
Svetoslav | cdfd230 | 2015-06-25 19:07:31 -0700 | [diff] [blame] | 71 | |
| 72 | /** |
| 73 | * Sets the SMS packages provider. |
| 74 | * @param provider The packages provider. |
| 75 | */ |
| 76 | public abstract void setSmsAppPackagesProvider(PackagesProvider provider); |
| 77 | |
| 78 | /** |
| 79 | * Sets the dialer packages provider. |
| 80 | * @param provider The packages provider. |
| 81 | */ |
| 82 | public abstract void setDialerAppPackagesProvider(PackagesProvider provider); |
| 83 | |
| 84 | /** |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 85 | * Sets the sim call manager packages provider. |
| 86 | * @param provider The packages provider. |
| 87 | */ |
| 88 | public abstract void setSimCallManagerPackagesProvider(PackagesProvider provider); |
| 89 | |
| 90 | /** |
Svetoslav | 0010b70 | 2015-06-30 18:05:26 -0700 | [diff] [blame] | 91 | * Sets the sync adapter packages provider. |
| 92 | * @param provider The provider. |
| 93 | */ |
| 94 | public abstract void setSyncAdapterPackagesprovider(SyncAdapterPackagesProvider provider); |
| 95 | |
| 96 | /** |
Svetoslav | cdfd230 | 2015-06-25 19:07:31 -0700 | [diff] [blame] | 97 | * Requests granting of the default permissions to the current default SMS app. |
| 98 | * @param packageName The default SMS package name. |
| 99 | * @param userId The user for which to grant the permissions. |
| 100 | */ |
| 101 | public abstract void grantDefaultPermissionsToDefaultSmsApp(String packageName, int userId); |
| 102 | |
| 103 | /** |
| 104 | * Requests granting of the default permissions to the current default dialer app. |
| 105 | * @param packageName The default dialer package name. |
| 106 | * @param userId The user for which to grant the permissions. |
| 107 | */ |
| 108 | public abstract void grantDefaultPermissionsToDefaultDialerApp(String packageName, int userId); |
Sailesh Nepal | cf85562 | 2015-07-28 19:22:14 -0700 | [diff] [blame] | 109 | |
| 110 | /** |
| 111 | * Requests granting of the default permissions to the current default sim call manager. |
| 112 | * @param packageName The default sim call manager package name. |
| 113 | * @param userId The user for which to grant the permissions. |
| 114 | */ |
| 115 | public abstract void grantDefaultPermissionsToDefaultSimCallManager(String packageName, |
| 116 | int userId); |
Fyodor Kupolov | cb6fd80 | 2015-11-05 14:27:06 -0800 | [diff] [blame] | 117 | |
| 118 | /** |
| 119 | * Sets a list of apps to keep in PM's internal data structures and as APKs even if no user has |
| 120 | * currently installed it. The apps are not preloaded. |
| 121 | * @param packageList List of package names to keep cached. |
| 122 | */ |
| 123 | public abstract void setKeepUninstalledPackages(List<String> packageList); |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 124 | |
| 125 | /** |
| 126 | * Gets whether some of the permissions used by this package require a user |
| 127 | * review before any of the app components can run. |
| 128 | * @param packageName The package name for which to check. |
| 129 | * @param userId The user under which to check. |
| 130 | * @return True a permissions review is required. |
| 131 | */ |
| 132 | public abstract boolean isPermissionsReviewRequired(String packageName, int userId); |
Todd Kennedy | 39bfee5 | 2016-02-24 10:28:21 -0800 | [diff] [blame] | 133 | |
| 134 | /** |
| 135 | * Gets all of the information we know about a particular package. |
| 136 | * |
| 137 | * @param packageName The package name to find. |
| 138 | * @param userId The user under which to check. |
| 139 | * |
| 140 | * @return An {@link ApplicationInfo} containing information about the |
| 141 | * package. |
| 142 | * @throws NameNotFoundException if a package with the given name cannot be |
| 143 | * found on the system. |
| 144 | */ |
| 145 | public abstract ApplicationInfo getApplicationInfo(String packageName, int userId); |
Makoto Onuki | 2d5b465 | 2016-03-11 16:09:54 -0800 | [diff] [blame] | 146 | |
| 147 | /** |
| 148 | * Interface to {@link com.android.server.pm.PackageManagerService#getHomeActivitiesAsUser}. |
| 149 | */ |
| 150 | public abstract ComponentName getHomeActivitiesAsUser(List<ResolveInfo> allHomeCandidates, |
| 151 | int userId); |
Makoto Onuki | c29f62c | 2016-06-07 12:19:46 -0700 | [diff] [blame] | 152 | |
| 153 | /** |
| 154 | * Called by DeviceOwnerManagerService to set the package names of device owner and profile |
| 155 | * owners. |
| 156 | */ |
| 157 | public abstract void setDeviceAndProfileOwnerPackages( |
| 158 | int deviceOwnerUserId, String deviceOwner, SparseArray<String> profileOwners); |
| 159 | |
| 160 | /** |
Steven Ng | 9d48a73 | 2016-06-24 19:04:14 +0100 | [diff] [blame] | 161 | * 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] | 162 | */ |
Steven Ng | 9d48a73 | 2016-06-24 19:04:14 +0100 | [diff] [blame] | 163 | public abstract boolean isPackageDataProtected(int userId, String packageName); |
Svet Ganov | 973edd19 | 2016-09-08 20:15:55 -0700 | [diff] [blame] | 164 | |
| 165 | /** |
Dianne Hackborn | e07641d | 2016-11-09 15:07:23 -0800 | [diff] [blame] | 166 | * Returns {@code true} if a given package is installed as ephemeral. Otherwise, returns |
| 167 | * {@code false}. |
| 168 | */ |
| 169 | public abstract boolean isPackageEphemeral(int userId, String packageName); |
| 170 | |
| 171 | /** |
Svet Ganov | 973edd19 | 2016-09-08 20:15:55 -0700 | [diff] [blame] | 172 | * Gets whether the package was ever launched. |
| 173 | * @param packageName The package name. |
| 174 | * @param userId The user for which to check. |
| 175 | * @return Whether was launched. |
| 176 | */ |
| 177 | public abstract boolean wasPackageEverLaunched(String packageName, int userId); |
Nicolas Prevot | 700e1e7 | 2016-09-28 15:17:18 +0100 | [diff] [blame] | 178 | |
| 179 | /** |
| 180 | * Grants a runtime permission |
| 181 | * @param packageName The package name. |
| 182 | * @param name The name of the permission. |
| 183 | * @param userId The userId for which to grant the permission. |
| 184 | * @param overridePolicy If true, grant this permission even if it is fixed by policy. |
| 185 | */ |
| 186 | public abstract void grantRuntimePermission(String packageName, String name, int userId, |
| 187 | boolean overridePolicy); |
| 188 | |
| 189 | /** |
| 190 | * Revokes a runtime permission |
| 191 | * @param packageName The package name. |
| 192 | * @param name The name of the permission. |
| 193 | * @param userId The userId for which to revoke the permission. |
| 194 | * @param overridePolicy If true, revoke this permission even if it is fixed by policy. |
| 195 | */ |
| 196 | public abstract void revokeRuntimePermission(String packageName, String name, int userId, |
| 197 | boolean overridePolicy); |
| 198 | |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 199 | /** |
Michal Karpinski | cb67dc9 | 2016-12-13 18:20:23 +0000 | [diff] [blame^] | 200 | * Retrieve the official name associated with a uid. This name is |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 201 | * guaranteed to never change, though it is possible for the underlying |
Michal Karpinski | cb67dc9 | 2016-12-13 18:20:23 +0000 | [diff] [blame^] | 202 | * uid to be changed. That is, if you are storing information about |
| 203 | * uids in persistent storage, you should use the string returned |
| 204 | * by this function instead of the raw uid. |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 205 | * |
Michal Karpinski | cb67dc9 | 2016-12-13 18:20:23 +0000 | [diff] [blame^] | 206 | * @param uid The uid for which you would like to retrieve a name. |
| 207 | * @return Returns a unique name for the given uid, or null if the |
| 208 | * uid is not currently assigned. |
Michal Karpinski | f77ee4f | 2016-10-12 16:40:06 +0100 | [diff] [blame] | 209 | */ |
| 210 | public abstract String getNameForUid(int uid); |
| 211 | |
Todd Kennedy | 01ad0c7 | 2016-11-11 15:33:12 -0800 | [diff] [blame] | 212 | /** |
| 213 | * Request to perform the second phase of ephemeral resolution. |
| 214 | * @param responseObj The response of the first phase of ephemeral resolution |
| 215 | * @param origIntent The original intent that triggered ephemeral resolution |
| 216 | * @param resolvedType The resolved type of the intent |
| 217 | * @param launchIntent The intent that would launch if there was no ephemeral application |
| 218 | * @param callingPackage The name of the package requesting the ephemeral application |
| 219 | * @param userId The ID of the user that triggered ephemeral resolution |
| 220 | */ |
| 221 | public abstract void requestEphemeralResolutionPhaseTwo(EphemeralResponse responseObj, |
| 222 | Intent origIntent, String resolvedType, Intent launchIntent, String callingPackage, |
| 223 | int userId); |
Svet Ganov | adc1cf4 | 2015-06-15 16:36:24 -0700 | [diff] [blame] | 224 | } |