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
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
- 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
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
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
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
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
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
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
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
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
... 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
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