Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 1 | /* |
Philip P. Moltmann | 4845667 | 2019-01-20 13:14:03 -0800 | [diff] [blame] | 2 | * Copyright (C) 2019 The Android Open Source Project |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server.pm.permission; |
| 18 | |
Nate Myren | d3a6385 | 2019-06-07 13:11:58 -0700 | [diff] [blame] | 19 | import android.annotation.AppIdInt; |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 20 | import android.annotation.NonNull; |
| 21 | import android.annotation.Nullable; |
Philip P. Moltmann | c91ff6f | 2019-06-14 14:35:42 -0700 | [diff] [blame] | 22 | import android.annotation.UserIdInt; |
Svet Ganov | d8eb8b2 | 2019-04-05 18:52:08 -0700 | [diff] [blame] | 23 | import android.content.pm.PackageManager; |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 24 | import android.content.pm.PermissionInfo; |
Philip P. Moltmann | 4845667 | 2019-01-20 13:14:03 -0800 | [diff] [blame] | 25 | import android.permission.PermissionManagerInternal; |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 26 | |
Winson | 5e0a1d5 | 2020-01-24 12:00:33 -0800 | [diff] [blame] | 27 | import com.android.server.pm.parsing.pkg.AndroidPackage; |
| 28 | |
Philip P. Moltmann | fae8a528 | 2018-04-10 12:15:32 -0700 | [diff] [blame] | 29 | import java.util.ArrayList; |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 30 | import java.util.List; |
Todd Kennedy | 583378d | 2019-07-12 06:50:30 -0700 | [diff] [blame] | 31 | import java.util.function.Consumer; |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 32 | |
| 33 | /** |
Philip P. Moltmann | 4845667 | 2019-01-20 13:14:03 -0800 | [diff] [blame] | 34 | * Internal interfaces services. |
| 35 | * |
| 36 | * TODO: Should be merged into PermissionManagerInternal, but currently uses internal classes. |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 37 | */ |
Philip P. Moltmann | 4845667 | 2019-01-20 13:14:03 -0800 | [diff] [blame] | 38 | public abstract class PermissionManagerServiceInternal extends PermissionManagerInternal { |
Winson | 10d5188 | 2020-05-26 10:52:23 -0700 | [diff] [blame] | 39 | |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 40 | /** |
Todd Kennedy | 583378d | 2019-07-12 06:50:30 -0700 | [diff] [blame] | 41 | * Provider for package names. |
| 42 | */ |
| 43 | public interface PackagesProvider { |
| 44 | |
| 45 | /** |
| 46 | * Gets the packages for a given user. |
| 47 | * @param userId The user id. |
| 48 | * @return The package names. |
| 49 | */ |
| 50 | String[] getPackages(int userId); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Provider for package names. |
| 55 | */ |
| 56 | public interface SyncAdapterPackagesProvider { |
| 57 | |
| 58 | /** |
| 59 | * Gets the sync adapter packages for given authority and user. |
| 60 | * @param authority The authority. |
| 61 | * @param userId The user id. |
| 62 | * @return The package names. |
| 63 | */ |
| 64 | String[] getPackages(String authority, int userId); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Provider for default browser |
| 69 | */ |
| 70 | public interface DefaultBrowserProvider { |
| 71 | |
| 72 | /** |
| 73 | * Get the package name of the default browser. |
| 74 | * |
| 75 | * @param userId the user id |
| 76 | * |
| 77 | * @return the package name of the default browser, or {@code null} if none |
| 78 | */ |
| 79 | @Nullable |
| 80 | String getDefaultBrowser(@UserIdInt int userId); |
| 81 | |
| 82 | /** |
| 83 | * Set the package name of the default browser. |
| 84 | * |
| 85 | * @param packageName package name of the default browser, or {@code null} to remove |
| 86 | * @param userId the user id |
| 87 | * |
| 88 | * @return whether the default browser was successfully set. |
| 89 | */ |
| 90 | boolean setDefaultBrowser(@Nullable String packageName, @UserIdInt int userId); |
| 91 | |
| 92 | /** |
| 93 | * Set the package name of the default browser asynchronously. |
| 94 | * |
| 95 | * @param packageName package name of the default browser, or {@code null} to remove |
| 96 | * @param userId the user id |
| 97 | */ |
| 98 | void setDefaultBrowserAsync(@Nullable String packageName, @UserIdInt int userId); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Provider for default dialer |
| 103 | */ |
| 104 | public interface DefaultDialerProvider { |
| 105 | |
| 106 | /** |
| 107 | * Get the package name of the default dialer. |
| 108 | * |
| 109 | * @param userId the user id |
| 110 | * |
| 111 | * @return the package name of the default dialer, or {@code null} if none |
| 112 | */ |
| 113 | @Nullable |
| 114 | String getDefaultDialer(@UserIdInt int userId); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Provider for default home |
| 119 | */ |
| 120 | public interface DefaultHomeProvider { |
| 121 | |
| 122 | /** |
| 123 | * Get the package name of the default home. |
| 124 | * |
| 125 | * @param userId the user id |
| 126 | * |
| 127 | * @return the package name of the default home, or {@code null} if none |
| 128 | */ |
| 129 | @Nullable |
| 130 | String getDefaultHome(@UserIdInt int userId); |
| 131 | |
| 132 | /** |
| 133 | * Set the package name of the default home. |
| 134 | * |
| 135 | * @param packageName package name of the default home, or {@code null} to remove |
| 136 | * @param userId the user id |
| 137 | * @param callback the callback made after the default home as been updated |
| 138 | */ |
| 139 | void setDefaultHomeAsync(@Nullable String packageName, @UserIdInt int userId, |
| 140 | @NonNull Consumer<Boolean> callback); |
| 141 | } |
| 142 | |
| 143 | /** |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 144 | * Callbacks invoked when interesting actions have been taken on a permission. |
| 145 | * <p> |
| 146 | * NOTE: The current arguments are merely to support the existing use cases. This |
| 147 | * needs to be properly thought out with appropriate arguments for each of the |
| 148 | * callback methods. |
| 149 | */ |
| 150 | public static class PermissionCallback { |
Nate Myren | d3a6385 | 2019-06-07 13:11:58 -0700 | [diff] [blame] | 151 | public void onGidsChanged(@AppIdInt int appId, @UserIdInt int userId) { |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 152 | } |
| 153 | public void onPermissionChanged() { |
| 154 | } |
Nate Myren | d3a6385 | 2019-06-07 13:11:58 -0700 | [diff] [blame] | 155 | public void onPermissionGranted(int uid, @UserIdInt int userId) { |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 156 | } |
| 157 | public void onInstallPermissionGranted() { |
| 158 | } |
Evan Severson | aacd48b | 2020-06-22 16:45:03 -0700 | [diff] [blame] | 159 | public void onPermissionRevoked(int uid, @UserIdInt int userId, String reason) { |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 160 | } |
| 161 | public void onInstallPermissionRevoked() { |
| 162 | } |
Nate Myren | d3a6385 | 2019-06-07 13:11:58 -0700 | [diff] [blame] | 163 | public void onPermissionUpdated(@UserIdInt int[] updatedUserIds, boolean sync) { |
| 164 | } |
| 165 | public void onPermissionUpdatedNotifyListener(@UserIdInt int[] updatedUserIds, boolean sync, |
| 166 | int uid) { |
Nate Myren | cc9e2c7 | 2019-11-08 14:57:15 -0800 | [diff] [blame] | 167 | onPermissionUpdated(updatedUserIds, sync); |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 168 | } |
| 169 | public void onPermissionRemoved() { |
| 170 | } |
| 171 | public void onInstallPermissionUpdated() { |
| 172 | } |
Nate Myren | d3a6385 | 2019-06-07 13:11:58 -0700 | [diff] [blame] | 173 | public void onInstallPermissionUpdatedNotifyListener(int uid) { |
Nate Myren | cc9e2c7 | 2019-11-08 14:57:15 -0800 | [diff] [blame] | 174 | onInstallPermissionUpdated(); |
Nate Myren | d3a6385 | 2019-06-07 13:11:58 -0700 | [diff] [blame] | 175 | } |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 176 | } |
| 177 | |
Todd Kennedy | c29b11a | 2017-10-23 15:55:59 -0700 | [diff] [blame] | 178 | public abstract void systemReady(); |
| 179 | |
Winson | 14ff717 | 2019-10-23 10:42:27 -0700 | [diff] [blame] | 180 | public abstract boolean isPermissionsReviewRequired(@NonNull AndroidPackage pkg, |
Philip P. Moltmann | c91ff6f | 2019-06-14 14:35:42 -0700 | [diff] [blame] | 181 | @UserIdInt int userId); |
Todd Kennedy | c29b11a | 2017-10-23 15:55:59 -0700 | [diff] [blame] | 182 | |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 183 | public abstract void grantRequestedRuntimePermissions( |
Winson | 14ff717 | 2019-10-23 10:42:27 -0700 | [diff] [blame] | 184 | @NonNull AndroidPackage pkg, @NonNull int[] userIds, |
Todd Kennedy | c971a45 | 2019-07-08 16:04:52 -0700 | [diff] [blame] | 185 | @NonNull String[] grantedPermissions, int callingUid); |
Svet Ganov | d8eb8b2 | 2019-04-05 18:52:08 -0700 | [diff] [blame] | 186 | public abstract void setWhitelistedRestrictedPermissions( |
Winson | 14ff717 | 2019-10-23 10:42:27 -0700 | [diff] [blame] | 187 | @NonNull AndroidPackage pkg, @NonNull int[] userIds, |
Svet Ganov | d8eb8b2 | 2019-04-05 18:52:08 -0700 | [diff] [blame] | 188 | @NonNull List<String> permissions, int callingUid, |
Todd Kennedy | c971a45 | 2019-07-08 16:04:52 -0700 | [diff] [blame] | 189 | @PackageManager.PermissionWhitelistFlags int whitelistFlags); |
Todd Kennedy | 7e3dd3a | 2019-07-08 10:34:29 -0700 | [diff] [blame] | 190 | /** Sets the whitelisted, restricted permissions for the given package. */ |
| 191 | public abstract void setWhitelistedRestrictedPermissions( |
| 192 | @NonNull String packageName, @NonNull List<String> permissions, |
Eugene Susla | 922cd08 | 2020-03-11 12:38:17 -0700 | [diff] [blame] | 193 | @PackageManager.PermissionWhitelistFlags int flags, int userId); |
| 194 | public abstract void setAutoRevokeWhitelisted( |
| 195 | @NonNull String packageName, boolean whitelisted, int userId); |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 196 | |
Philip P. Moltmann | dc65aa3 | 2019-03-28 12:02:45 -0700 | [diff] [blame] | 197 | /** |
| 198 | * Update permissions when a package changed. |
| 199 | * |
| 200 | * <p><ol> |
| 201 | * <li>Reconsider the ownership of permission</li> |
| 202 | * <li>Update the state (grant, flags) of the permissions</li> |
| 203 | * </ol> |
| 204 | * |
| 205 | * @param packageName The package that is updated |
| 206 | * @param pkg The package that is updated, or {@code null} if package is deleted |
| 207 | * @param allPackages All currently known packages |
| 208 | * @param callback Callback to call after permission changes |
| 209 | */ |
| 210 | public abstract void updatePermissions(@NonNull String packageName, |
Winson | 14ff717 | 2019-10-23 10:42:27 -0700 | [diff] [blame] | 211 | @Nullable AndroidPackage pkg); |
Philip P. Moltmann | dc65aa3 | 2019-03-28 12:02:45 -0700 | [diff] [blame] | 212 | |
| 213 | /** |
| 214 | * Update all permissions for all apps. |
| 215 | * |
| 216 | * <p><ol> |
| 217 | * <li>Reconsider the ownership of permission</li> |
| 218 | * <li>Update the state (grant, flags) of the permissions</li> |
| 219 | * </ol> |
| 220 | * |
| 221 | * @param volumeUuid The volume of the packages to be updated, {@code null} for all volumes |
| 222 | * @param allPackages All currently known packages |
| 223 | * @param callback Callback to call after permission changes |
| 224 | */ |
Todd Kennedy | c971a45 | 2019-07-08 16:04:52 -0700 | [diff] [blame] | 225 | public abstract void updateAllPermissions(@Nullable String volumeUuid, boolean sdkUpdate); |
| 226 | |
| 227 | /** |
| 228 | * Resets any user permission state changes (eg. permissions and flags) of all |
| 229 | * packages installed for the given user. |
| 230 | * |
Winson | 14ff717 | 2019-10-23 10:42:27 -0700 | [diff] [blame] | 231 | * @see #resetRuntimePermissions(AndroidPackage, int) |
Todd Kennedy | c971a45 | 2019-07-08 16:04:52 -0700 | [diff] [blame] | 232 | */ |
| 233 | public abstract void resetAllRuntimePermissions(@UserIdInt int userId); |
| 234 | |
| 235 | /** |
| 236 | * Resets any user permission state changes (eg. permissions and flags) of the |
| 237 | * specified package for the given user. |
| 238 | */ |
Winson | 14ff717 | 2019-10-23 10:42:27 -0700 | [diff] [blame] | 239 | public abstract void resetRuntimePermissions(@NonNull AndroidPackage pkg, |
Todd Kennedy | c971a45 | 2019-07-08 16:04:52 -0700 | [diff] [blame] | 240 | @UserIdInt int userId); |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 241 | |
Todd Kennedy | c842393 | 2017-10-05 08:58:36 -0700 | [diff] [blame] | 242 | /** |
Philip P. Moltmann | fae8a528 | 2018-04-10 12:15:32 -0700 | [diff] [blame] | 243 | * We might auto-grant permissions if any permission of the group is already granted. Hence if |
| 244 | * the group of a granted permission changes we need to revoke it to avoid having permissions of |
| 245 | * the new group auto-granted. |
| 246 | * |
| 247 | * @param newPackage The new package that was installed |
| 248 | * @param oldPackage The old package that was updated |
| 249 | * @param allPackageNames All packages |
Philip P. Moltmann | fae8a528 | 2018-04-10 12:15:32 -0700 | [diff] [blame] | 250 | */ |
| 251 | public abstract void revokeRuntimePermissionsIfGroupChanged( |
Winson | 14ff717 | 2019-10-23 10:42:27 -0700 | [diff] [blame] | 252 | @NonNull AndroidPackage newPackage, |
| 253 | @NonNull AndroidPackage oldPackage, |
Todd Kennedy | c971a45 | 2019-07-08 16:04:52 -0700 | [diff] [blame] | 254 | @NonNull ArrayList<String> allPackageNames); |
Philip P. Moltmann | fae8a528 | 2018-04-10 12:15:32 -0700 | [diff] [blame] | 255 | |
| 256 | /** |
Todd Kennedy | c842393 | 2017-10-05 08:58:36 -0700 | [diff] [blame] | 257 | * Add all permissions in the given package. |
| 258 | * <p> |
| 259 | * NOTE: argument {@code groupTEMP} is temporary until mPermissionGroups is moved to |
| 260 | * the permission settings. |
| 261 | */ |
Winson | 14ff717 | 2019-10-23 10:42:27 -0700 | [diff] [blame] | 262 | public abstract void addAllPermissions(@NonNull AndroidPackage pkg, boolean chatty); |
| 263 | public abstract void addAllPermissionGroups(@NonNull AndroidPackage pkg, boolean chatty); |
| 264 | public abstract void removeAllPermissions(@NonNull AndroidPackage pkg, boolean chatty); |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 265 | |
Todd Kennedy | 8f13598 | 2019-07-02 07:35:15 -0700 | [diff] [blame] | 266 | /** Retrieve the packages that have requested the given app op permission */ |
| 267 | public abstract @Nullable String[] getAppOpPermissionPackages( |
| 268 | @NonNull String permName, int callingUid); |
Todd Kennedy | c842393 | 2017-10-05 08:58:36 -0700 | [diff] [blame] | 269 | |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 270 | /** |
| 271 | * Enforces the request is from the system or an app that has INTERACT_ACROSS_USERS |
| 272 | * or INTERACT_ACROSS_USERS_FULL permissions, if the {@code userid} is not for the caller. |
| 273 | * @param checkShell whether to prevent shell from access if there's a debugging restriction |
| 274 | * @param message the message to log on security exception |
| 275 | */ |
| 276 | public abstract void enforceCrossUserPermission(int callingUid, int userId, |
| 277 | boolean requireFullPermission, boolean checkShell, @NonNull String message); |
kholoud mohamed | 67ac7c6 | 2019-12-06 16:33:48 +0000 | [diff] [blame] | 278 | |
| 279 | /** |
| 280 | * Similar to {@link #enforceCrossUserPermission(int, int, boolean, boolean, String)} |
| 281 | * but also allows INTERACT_ACROSS_PROFILES permission if calling user and {@code userId} are |
| 282 | * in the same profile group. |
| 283 | */ |
| 284 | public abstract void enforceCrossUserOrProfilePermission(int callingUid, int userId, |
| 285 | boolean requireFullPermission, boolean checkShell, @NonNull String message); |
| 286 | |
Todd Kennedy | ef9acb6 | 2018-05-29 15:18:06 -0700 | [diff] [blame] | 287 | /** |
| 288 | * @see #enforceCrossUserPermission(int, int, boolean, boolean, String) |
| 289 | * @param requirePermissionWhenSameUser When {@code true}, still require the cross user |
| 290 | * permission to be held even if the callingUid and userId reference the same user. |
| 291 | */ |
| 292 | public abstract void enforceCrossUserPermission(int callingUid, int userId, |
| 293 | boolean requireFullPermission, boolean checkShell, |
| 294 | boolean requirePermissionWhenSameUser, @NonNull String message); |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 295 | public abstract void enforceGrantRevokeRuntimePermissionPermissions(@NonNull String message); |
| 296 | |
| 297 | public abstract @NonNull PermissionSettings getPermissionSettings(); |
Todd Kennedy | 583378d | 2019-07-12 06:50:30 -0700 | [diff] [blame] | 298 | |
| 299 | /** Grants default browser permissions to the given package */ |
| 300 | public abstract void grantDefaultPermissionsToDefaultBrowser( |
| 301 | @NonNull String packageName, @UserIdInt int userId); |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 302 | |
| 303 | /** HACK HACK methods to allow for partial migration of data to the PermissionManager class */ |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 304 | public abstract @Nullable BasePermission getPermissionTEMP(@NonNull String permName); |
Philip P. Moltmann | fad1a8f | 2019-06-14 09:02:24 -0700 | [diff] [blame] | 305 | |
Hai Zhang | a7c60c0 | 2020-03-05 16:03:35 -0800 | [diff] [blame] | 306 | /** Get all permissions that have a certain protection */ |
| 307 | public abstract @NonNull ArrayList<PermissionInfo> getAllPermissionsWithProtection( |
Hai Zhang | 57bc312 | 2019-10-21 16:04:15 -0700 | [diff] [blame] | 308 | @PermissionInfo.Protection int protection); |
Todd Kennedy | ca1ea17 | 2019-07-03 15:02:28 -0700 | [diff] [blame] | 309 | |
Hai Zhang | a7c60c0 | 2020-03-05 16:03:35 -0800 | [diff] [blame] | 310 | /** Get all permissions that have certain protection flags */ |
| 311 | public abstract @NonNull ArrayList<PermissionInfo> getAllPermissionsWithProtectionFlags( |
| 312 | @PermissionInfo.ProtectionFlags int protectionFlags); |
| 313 | |
Todd Kennedy | ca1ea17 | 2019-07-03 15:02:28 -0700 | [diff] [blame] | 314 | /** |
| 315 | * Returns the delegate used to influence permission checking. |
| 316 | * |
| 317 | * @return The delegate instance. |
| 318 | */ |
| 319 | public abstract @Nullable CheckPermissionDelegate getCheckPermissionDelegate(); |
| 320 | |
| 321 | /** |
| 322 | * Sets the delegate used to influence permission checking. |
| 323 | * |
| 324 | * @param delegate A delegate instance or {@code null} to clear. |
| 325 | */ |
| 326 | public abstract void setCheckPermissionDelegate(@Nullable CheckPermissionDelegate delegate); |
Todd Kennedy | 583378d | 2019-07-12 06:50:30 -0700 | [diff] [blame] | 327 | |
| 328 | /** |
| 329 | * Sets the dialer application packages provider. |
| 330 | * @param provider The provider. |
| 331 | */ |
| 332 | public abstract void setDialerAppPackagesProvider(PackagesProvider provider); |
| 333 | |
| 334 | /** |
| 335 | * Set the location extra packages provider. |
| 336 | * @param provider The packages provider. |
| 337 | */ |
| 338 | public abstract void setLocationExtraPackagesProvider(PackagesProvider provider); |
| 339 | |
| 340 | /** |
| 341 | * Sets the location provider packages provider. |
| 342 | * @param provider The packages provider. |
| 343 | */ |
| 344 | public abstract void setLocationPackagesProvider(PackagesProvider provider); |
| 345 | |
| 346 | /** |
| 347 | * Sets the SIM call manager packages provider. |
| 348 | * @param provider The provider. |
| 349 | */ |
| 350 | public abstract void setSimCallManagerPackagesProvider(PackagesProvider provider); |
| 351 | |
| 352 | /** |
| 353 | * Sets the SMS application packages provider. |
| 354 | * @param provider The provider. |
| 355 | */ |
| 356 | public abstract void setSmsAppPackagesProvider(PackagesProvider provider); |
| 357 | |
| 358 | /** |
| 359 | * Sets the sync adapter packages provider. |
| 360 | * @param provider The provider. |
| 361 | */ |
| 362 | public abstract void setSyncAdapterPackagesProvider(SyncAdapterPackagesProvider provider); |
| 363 | |
| 364 | /** |
| 365 | * Sets the Use Open Wifi packages provider. |
| 366 | * @param provider The packages provider. |
| 367 | */ |
| 368 | public abstract void setUseOpenWifiAppPackagesProvider(PackagesProvider provider); |
| 369 | |
| 370 | /** |
| 371 | * Sets the voice interaction packages provider. |
| 372 | * @param provider The packages provider. |
| 373 | */ |
| 374 | public abstract void setVoiceInteractionPackagesProvider(PackagesProvider provider); |
| 375 | |
| 376 | /** |
| 377 | * Sets the default browser provider. |
| 378 | * |
| 379 | * @param provider the provider |
| 380 | */ |
| 381 | public abstract void setDefaultBrowserProvider(@NonNull DefaultBrowserProvider provider); |
| 382 | |
| 383 | /** |
| 384 | * Sets the package name of the default browser provider for the given user. |
| 385 | * |
| 386 | * @param packageName The package name of the default browser or {@code null} |
| 387 | * to clear the default browser |
| 388 | * @param async If {@code true}, set the default browser asynchronously, |
| 389 | * otherwise set it synchronously |
| 390 | * @param doGrant If {@code true} and if {@code packageName} is not {@code null}, |
| 391 | * perform default permission grants on the browser, otherwise skip the |
| 392 | * default permission grants. |
| 393 | * @param userId The user to set the default browser for. |
| 394 | */ |
| 395 | public abstract void setDefaultBrowser(@Nullable String packageName, boolean async, |
| 396 | boolean doGrant, @UserIdInt int userId); |
| 397 | |
| 398 | /** |
| 399 | * Sets the default dialer provider. |
| 400 | * |
| 401 | * @param provider the provider |
| 402 | */ |
| 403 | public abstract void setDefaultDialerProvider(@NonNull DefaultDialerProvider provider); |
| 404 | |
| 405 | /** |
| 406 | * Sets the default home provider. |
| 407 | * |
| 408 | * @param provider the provider |
| 409 | */ |
| 410 | public abstract void setDefaultHomeProvider(@NonNull DefaultHomeProvider provider); |
| 411 | |
| 412 | /** |
| 413 | * Asynchronously sets the package name of the default home provider for the given user. |
| 414 | * |
| 415 | * @param packageName The package name of the default home or {@code null} |
| 416 | * to clear the default browser |
| 417 | * @param userId The user to set the default browser for |
| 418 | * @param callback Invoked after the default home has been set |
| 419 | */ |
| 420 | public abstract void setDefaultHome(@Nullable String packageName, @UserIdInt int userId, |
| 421 | @NonNull Consumer<Boolean> callback); |
| 422 | |
| 423 | /** |
| 424 | * Returns the default browser package name for the given user. |
| 425 | */ |
| 426 | @Nullable |
| 427 | public abstract String getDefaultBrowser(@UserIdInt int userId); |
| 428 | |
| 429 | /** |
| 430 | * Returns the default dialer package name for the given user. |
| 431 | */ |
| 432 | @Nullable |
| 433 | public abstract String getDefaultDialer(@UserIdInt int userId); |
| 434 | |
| 435 | /** |
| 436 | * Returns the default home package name for the given user. |
| 437 | */ |
| 438 | @Nullable |
| 439 | public abstract String getDefaultHome(@UserIdInt int userId); |
| 440 | |
| 441 | /** |
| 442 | * Requests granting of the default permissions to the current default Use Open Wifi app. |
| 443 | * @param packageName The default use open wifi package name. |
| 444 | * @param userId The user for which to grant the permissions. |
| 445 | */ |
| 446 | public abstract void grantDefaultPermissionsToDefaultSimCallManager( |
| 447 | @NonNull String packageName, @UserIdInt int userId); |
| 448 | |
| 449 | /** |
| 450 | * Requests granting of the default permissions to the current default Use Open Wifi app. |
| 451 | * @param packageName The default use open wifi package name. |
| 452 | * @param userId The user for which to grant the permissions. |
| 453 | */ |
| 454 | public abstract void grantDefaultPermissionsToDefaultUseOpenWifiApp( |
| 455 | @NonNull String packageName, @UserIdInt int userId); |
| 456 | |
Todd Kennedy | 583378d | 2019-07-12 06:50:30 -0700 | [diff] [blame] | 457 | /** Called when a new user has been created. */ |
| 458 | public abstract void onNewUserCreated(@UserIdInt int userId); |
Winson | 10d5188 | 2020-05-26 10:52:23 -0700 | [diff] [blame] | 459 | |
| 460 | /** |
| 461 | * Removes invalid permissions which are not {@link PermissionInfo#FLAG_HARD_RESTRICTED} or |
| 462 | * {@link PermissionInfo#FLAG_SOFT_RESTRICTED} from the input. |
| 463 | */ |
| 464 | public abstract void retainHardAndSoftRestrictedPermissions(@NonNull List<String> permissions); |
Chad Brubaker | 4b5ca63 | 2018-11-20 12:53:22 -0800 | [diff] [blame] | 465 | } |