Commit Graph

32 Commits

Author SHA1 Message Date
Philip P. Moltmann
4198dd1cd5 Document delayed permission backup mechanism
Test: n/a
Fixes: 127545019
Change-Id: I62494048e2eeda733fabfddc53898b88827d92ef
2019-03-08 15:42:56 -08:00
Hai Zhang
26f37d35f6 Use RoleControllerService for role related APIs.
Move isApplicationQualifiedForRole() and isRoleVisible() from
PermissionControllerService to RoleControllerService.

Bug: 127691087
Test: manual
Change-Id: Ic9277f9e737e59dceafffabbf1e19526db609e78
2019-03-07 22:02:55 -08:00
Hai Zhang
a4959e569d Add RoleControllerManager for role controller service.
This allows us to expose both system-only and app available APIs for
role in RoleControllerService.

Bug: 127691087
Test: manual
Change-Id: I86fe3736fc28516aae25d48efe3ba599ffdf45d5
2019-03-07 21:33:12 -08:00
TreeHugger Robot
983b500cbf Merge "Add PermissionControllerService.isRoleVisible() for app info shortcut." 2019-03-04 22:49:23 +00:00
Philip P. Moltmann
6ce9003ef0 Merge "Add null-checks: RuntimePermissionPresentationInfo" 2019-03-04 20:14:29 +00:00
Philip P. Moltmann
7622add875 Add null-checks: RuntimePermissionPresentationInfo
Also make sure that nullability
- is enforced during creating
- is enforced during un-parceling

Test: Looked at Settings screens that read this data
Fixes: 126702133
Change-Id: I8cdd3a5583f01276702307b40f65fa8d7ac49bf2
2019-03-01 11:31:47 -08:00
Philip P. Moltmann
051f338090 Nullability of PermissionControllerService#onBind
Only set nullability if super-method specified nullability at the same
place too.

Test: Built
Bug: 126701055
Change-Id: I08b9ac43ecb5f200d192a536449a880bc9a91f38
2019-03-01 10:51:08 -08:00
Jeff Sharkey
9e8f83db6d All Parcelable CREATOR fields are @NonNull.
If they were null, then the Parcelable would fail to work.

Bug: 126726802
Test: manual
Change-Id: I7929ffa2f20e5de1c8e68e8263cca99496e9d014
Exempt-From-Owner-Approval: Trivial API annotations
2019-02-28 23:29:04 -07:00
Hai Zhang
d895953d3c Add PermissionControllerService.isRoleVisible() for app info shortcut.
The default app shortcut in app info inside Settings needs to know if
a role is visible, and whether it is visible is controlled logic in
PermissionController, hence add this API.

Bug: 124452117
Bug: 124457823
Test: manual
Change-Id: I6058dea3bbda8b06d2fb9bab35268397227dd37b
2019-02-28 17:01:46 -08:00
TreeHugger Robot
05675bc0cf Merge "Made AbstractRemoteService.getRemoteRequestMillis() optional." 2019-02-23 03:25:46 +00:00
Philip P. Moltmann
41df9f94ae Ask Perm Controller to set policy-fixed perms
This is much slower than the old way as we need to call into a different
process. On the other hand this handles the following cases correctly:
- foreground / background permissions
- pre-M apps
- split permissions

Test: CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testPermissionGrant,testPermissionPolicy,testPermissionMixedPolicies,testPermissionAppUpdate,testPermissionGrantPreMApp
Change-Id: I5cd139ad29e5b77b77b02e12c75eb774984a7759
Bug: 124128308
2019-02-21 16:56:25 -08:00
Felipe Leme
81299d0d96 Made AbstractRemoteService.getRemoteRequestMillis() optional.
Also split some logic from PendingRequest into BasePendingRequest, so they're
not leaked into the async requests.

Test: atest CtsContentCaptureServiceTestCases CtsAutoFillServiceTestCases
Bug: 117779333
Change-Id: Ife9a3ab3a817944408caf9eae69dd75f48ab90c6
2019-02-21 16:11:26 -08:00
Philip P. Moltmann
cfd2fbc4e3 Make PermissionControllerManager user aware
Most of the commands of PermissionControllerManager should go to the
calling user. If not - and the alternate user is running - we should
use the recommended way to talk to alternate users. This recommended way
is to create a package context for the user and call the method on this
new context.

Hence
- At a time we can have more than one RemoteService (one per user)
- Connect to the user declared in Context#getUser instead of the calling
user

Test: Called methods on work-profiles and saw alternate
PermissionController apps to be spawned.
Change-Id: I9ed87db1f658f18b69d19b39ba9f96361ec5af82
2019-02-16 12:11:38 -08:00
Philip P. Moltmann
4845667a81 Move permission restore code into permission controller.
- Split system-server internal interface in two. One accessible only
  inside of the services part of system server. One accessible
  everywhere. This is necessary as the second part needs to be
  accessible by the PermissionBackupHelper. But the former uses internal
  data structures that should not be moved into android.permission.
- Remove old delayed permission restore code from
  PermissionManagerService and Settings. This code now lives in
  permission controller
- Keep the logic to remember which users still have delayed permissions
  left. It is quite expensive to call into permission controller for
  ever install of an app, hence this check is necessary. Currently this
  mirrors the original logic. This can be improved further later.

Test: Built
Change-Id: Ibc1d5183c361dc55896882db1f7b765e1bee6e84
2019-02-15 08:57:16 -08:00
Philip P. Moltmann
7532c615cb Plumming of perm restore via permission controller
On Android backup restoration first restores and inital state. Then with
the packages getting downloaded the leftover "delayed" backup gets
restored bit by bit.

This currently just created plumming mirroring the previously implemented
behavior.

Bug: 116738135
Test: Built
Change-Id: I528b5f76dfca5bbdc9f69d6402b23b3d2ef11706
2019-02-02 10:00:36 -08:00
Philip P. Moltmann
9b12e37a4f Small fixes in PermissionControllerManager/Service
- better names
- broken javadoc
- missing input paramter checks

Bug: 116738135
Test: Built
Change-Id: I6056b46776cf32937a113b99584d138ff423f039
2019-02-01 11:43:08 -08:00
Philip P. Moltmann
e1436e85ae Flags instead of booleans for countPermissionApps
Test: Checked that the api retunred the results
Change-Id: I3f95bf9beee4a7edae5cbd9457ad4efefe83d1be
Fixes: 123697839
2019-01-31 14:22:39 -08:00
Hai Zhang
1982187691 Add PermissionControllerManager.isApplicationQualifiedForRole().
Settings DefaultAppShortcutPreference needs this info to determine
whether to show the shortcut to default apps on the app info page.

Bug: 110557011
Bug: 123238935
Test: manual
Change-Id: I3ffa62eb199ba9c761bf09a556443f685f6b6b50
2019-01-24 17:38:36 -08:00
Philip P. Moltmann
97142e25d7 Move permission backup into permission controller
As runtime permissions are complex, all runtime permission code is
consolidated into the permission controller app.

Hence the package manager service's permission backup code is now
calling into the PermissionControllerManager which is a interface to the
permission controller app.

Bug: 120907838
Test: Triggered a backup and checked the result via the debugger.
Change-Id: I633162189b728921d902050eee125b4b40b618fd
2019-01-14 16:44:06 -08:00
TreeHugger Robot
4f30490dbe Merge "Call timeout callbacks on executor too" 2019-01-14 21:17:10 +00:00
Joel Galenson
5f63b83949 Add new method to count how many apps have used permissions
Bug: 121256299
Test: Called API and looked at result.
Change-Id: If055093a81598cf36a5d1b745ee5397974ee4106
2019-01-14 10:02:52 -08:00
Philip P. Moltmann
5e5c41e549 Have app global connection as to other managers
Regular ...Manager-s connect to the system server hence there is no
problem establishing a permanent connection via
ServiceManager.getServiceOrThrow.

(1)
PermissionControllerManager connects to an app, hence the binding has to
be dynamic. This is done my using the local RemoteService class.

(2)
...Manager-s are per context. Hence when the context goes away all
service connection started for this service are supposed to also be
cleaned up. There is no callback when the context goes away.

(1) and (2) lead to RemoteService connection to still be bound while the
context goes away which causes a service connection leak.

This change emulates the behavior of regular managers by creating a
permanent RemoteService tied to the application context. Of course
interanlly RemoteService itself binds and unbinds dynamically. Still,
now the RemoteService is not bound to a context that goes away and no
connection is leaked.

Test: atest CtsAppSecurityHostTestCases:android.appsecurity.cts.PermissionsHostTest
      (this test failed before as settings was crashing due to leaked
      remote service connections)
Change-Id: I5b8a4c62070fcce6e390897d046c4b28998e3952
2019-01-13 11:07:26 -08:00
Philip P. Moltmann
1117ca31cc Call timeout callbacks on executor too
Test: atest PermissionControllerTest
Change-Id: I23832d6ff992e7417e0a0128ef94203b2a435cb7
2019-01-12 11:39:31 -08:00
Philip P. Moltmann
7868952db3 Allow apps to bulk revoke permissions with the correct semantics
Test: atest --test-mapping frameworks/base/core/java/android/permission/:presubmit
Fixes: 120269238
Change-Id: Ib9eb244f1c89c09eee1f39e3abb65c1189f7a6f4
2019-01-06 17:51:33 -08:00
Philip P. Moltmann
bc054d8436 Rename RuntimePermissionPresenter to PermissionController
As this has already evolved from just presenting data. In the future any
permission related calls to the permission controller will be added here.

As the calls are protected by different permissions the binding will not
require a permission anymore, but each individual call checks the
permission.

Bug: 120221960
Test: Looked at settings UI showing data from this interface
Change-Id: I6b4a5c3b7ee17b145e11e2c1b6e11a8a232bffed
2019-01-03 11:39:43 -08:00
Philip P. Moltmann
22b8498815 Factor out service handling out of RuntimePermissionPresenter
Fixes: 121270006
Test: Looked at settings page that use RuntimePermissionPresenter
Change-Id: I3030511bce76fd0f30fac1ac922f6ff9f09ca80e
2018-12-19 13:40:17 -08:00
Philip P. Moltmann
08cac8e486 Add new method to count how many apps have permissions
Test: Called API and looked at result
Bug: 120221960
Change-Id: Icb8ee7f46849f26f4625b42e7b482c655409d175
2018-12-04 16:53:23 -08:00
Philip P. Moltmann
dbf78b8127 Move RuntimePermissionPresenter to android.permission
Consolidate all permission related code in a single java package.

Test: atest SettingsLibRoboTests
      Looked at Settings AppInfo UI (uses RuntimePermissionPresenter)
Bug: 120221960
Change-Id: If135e984a8273e9bed80cab9fbf2d70f40a05c7f
2018-12-04 16:53:23 -08:00
Philip P. Moltmann
e1b277a413 Have a map of background -> foreground permssions
This needs to be available before package manager service is ready,
hence set it as soon as possible.

In the future we should also allow access to this mapping from other
processes than the system server.

Test: Built
Change-Id: If4240e5522e175ea9b341e4951ce261f17bbaadc
2018-11-08 09:19:51 -08:00
Zimuzo
cc2932fd81 Grant split permission from config
Instead of defining split permissions in Java file, we now move them to XML allowing us define vendor specific split permissions.

Test: Activity recognition is split correctly and auto granted when below split targetSdk.
Bug: 111411340
Change-Id: Ia5b3f47b73c9feea924373268a4eee142f555091
2018-11-01 16:08:27 +00:00
Philip P. Moltmann
a3ba4d9861 Make PermissionManager use lists
... as requested per API review.

- Sets require iteration via iterators
- Sets are more expensive to construct
- The advantage of sets (faster .contains) is not used
- The system ensures uniqueness of the entires in the list

Test: Built
Bug: 116798569
Change-Id: I2c3b5c6801b78e0bf942073bde1e90299aee39f6
2018-10-11 08:16:16 -07:00
Philip P. Moltmann
039678e13f Add PermissionManager exposing SPLIT_PERMISSIONS
The Permission Controller app (a mainline module) needs to be able to
read the SPLIT_PERMISSIONS. Hence this array needs to be exposed at
least as system-api. We need to make sure that the PackageParser,
PackageManager and Permission Controller app agree on which permissions
are split, hence it is best to define them at a single location.

I think exposing the split permissions to developers is useless and
potentially confusing. The app should never request a permission that
was split. The app should just behave as if split permissions do not
exist. The Permission Controller / Package Manager deal with the
split permissions and add them when needed. Hence I don't think we
should expose this data to 3rd parties.

Bug: 110953302
Test: requested permissions
Change-Id: I6951c52979c89ee5c13a4a14da125e1a01f2e234
2018-09-25 13:48:11 -07:00