Commit Graph

70 Commits

Author SHA1 Message Date
Evan Severson
43e17e0369 Create permission for managing one-time permission sessions
Test: Manual
Bug: 136219229
Change-Id: I6870c7782f2dd51c655eea37bcb2487e5e29dfff
2020-01-03 13:49:33 -08:00
Evan Severson
b252d8bdbf Create system server component for one-time permissions
In this change we introduce new system api to manage tracking apps for
inactivity when they hold one-time permissions. The api includes adding
a package, removing a package, and a callback to notify the app has gone
inactive and which permissions are considered one-time.

Also introduce a new permission flag so that it is possible to determine
if a currently granted permission is one-time.

Test: Manual
Bug: 136219229
Change-Id: Iac3cb776a0204c64953f0a03abe76c8e320c9e56
2019-12-18 11:01:33 -08:00
Eugene Susla
d91d606ed8 Merge "Rename updateUSerSensitive API" 2019-12-12 15:10:33 +00:00
Peter Wang
56dec3f134 [Telephony Mainline] Refactored grantDefaultPermissionsToActiveLuiApp
and revokeDefaultPermissionsFromLuiApps from PermissionManagerService to
Permmission Manager

Bug: 142019744
Test: Build
Change-Id: Ic39e1a66b650e7969242eb2116f342de488b1ca6
2019-12-05 13:23:02 -08:00
Eugene Susla
5fb3f0eed7 Rename updateUSerSensitive API
Fixes: 141226832
Test: presubmit
Change-Id: I545f710296a4f05db01bb64c4014eba96373b526
2019-11-14 11:11:53 -08:00
Philip P. Moltmann
4a6c5de60a Allow an app to drive permission backup+restore
In AOSP the permission backup+restore is driven by the system server,
but some OEMs might drive it from an app. Hence allow a privilidged app
to backup + restore permission backups.

Test: atest CtsBackupTestCases
Fixes: 141007569
Change-Id: Ic89b476948872c491de8ea54b83667afc0183bb4
2019-10-07 14:58:24 -07:00
Eugene Susla
27455541e9 updateUserSensitive asynchronously
This is known to take 500ms and affects only UI,
so can be done async

Test: Ensure nothing looks badly broken; presubmit
Fixes: 139485700
Change-Id: I2b83b51ec5b002e08986019b4b6be3d681741544
2019-09-13 10:41:17 -07:00
Anthony Hugh
de787d4a83 Refactor PermissionManager.SPLIT_PERMISSIONS
Creating a SystemConfig from a non-system process is taking 500+ ms.
This CL instead exposes the needed split permissions from system_server
to optimize performance.

Tested locally and creating PermissionManager / retrieving SystemConfig
is now less than 1 ms.

Bug: 139828734
Bug: 139485700
Fixes: 139828734
Test: Added systrace / logs to PermissionController app and traced
runtime of onGrantDefaultRoles().

Change-Id: I111403e8dae3bc2b0acafc32e61aa5cd890fea29
2019-09-04 15:00:24 -07:00
Aurimas Liutikas
4d1699da48 Add missing nullability annotations.
To prepare for enabling MissingNullability Metalava check this CL
works on adding missing nullability issues that metalava flags if
we tell it to flag new things since API 29.

This is not a complete CL, mostly addresses public api and
toString/equals for @SystemApi

Exempt-From-Owner-Approval: Large scale nullability clean up
Bug: 124515653
Test: make -j checkapi
Change-Id: I109260842cfc25f06e40694997fcbb4afa02c867
2019-08-29 17:15:44 -07:00
Todd Kennedy
c5b0e860a4 Move few remaining permission methods
This should be the last method movement. More work needs to
happen with the intenral APIs between the permission manager
and the package manager. There is still a lot of package
manager internal logic inside the permission manager.

Bug: 135279435
Test: atest PermissionUpdateListenerTest
Test: atest android.content.pm.cts.PackageManagerTest
Test: atest android.permission2.cts.RestrictedPermissionsTest
Change-Id: Iec118d198cb4ce3c4789991ddbdd2928dbc4bf6f
2019-07-17 15:29:42 -07:00
Todd Kennedy
583378df9c Move providers to permission manager
Bug: 135279435
Test: atest PermissionUpdateListenerTest
Test: atest android.content.pm.cts.PackageManagerTest
Test: atest android.permission2.cts.RestrictedPermissionsTest
Test: atest TeleServiceTests
Test: atest DataConnectionTest
Change-Id: Ife563589929b2662c60e1a0ab0ec8f6a2d7e4c12
2019-07-16 13:09:33 -07:00
Todd Kennedy
c971a45e65 Move grant/revoke permission APIs
These were the last few APIs that used the permission callback.
Completely remove it from the package manager and full implement
in the permission manager.

Bug: 135279435
Test: atest PermissionUpdateListenerTest
Test: android.content.pm.cts.PackageManagerTest
Test: android.permission2.cts.RestrictedPermissionsTest
Change-Id: Iab7c20215c907f4718f78a98fb96afec9fef6780
2019-07-11 14:14:02 -07:00
Todd Kennedy
7e3dd3afe2 Move whitelist permissions to permission manager
Also while doing this, it made sense to move the permission change
listener to the permission manager [it resulted in fewer hacks to
get the two sides to talk to one another].

Bug: 135279435
Test: atest PermissionUpdateListenerTest
Test: android.content.pm.cts.PackageManagerTest
Test: android.permission2.cts.RestrictedPermissionsTest
Change-Id: Ie08701dfe999cd435335103f4b4daeaa0b31ef10
2019-07-11 14:14:02 -07:00
Todd Kennedy
ca1ea17a3e Move check permission methods
Bug: 135279435
Test: atest android.content.pm.PackageManagerTests
Test: atest CtsCameraApi25TestCases
Change-Id: Id96093e4106edcd5302fd8aaa020d1ab83f68258
2019-07-11 14:14:02 -07:00
Todd Kennedy
230c0a7e60 Move permission flag methods
Bug: 135279435
Test: atest android.content.pm.cts.PackageManagerTest
Test: atest android.permission2.cts.RestrictedPermissionsTest
Change-Id: I3a5a7d8d3a3ba9d0b3e0e62d178a18903a94ec26
2019-07-11 14:13:53 -07:00
Todd Kennedy
6ffc5a6eee Move add/remove permission
Bug: 135279435
Test: atest android.content.pm.cts.PackageManagerTest
Change-Id: I40a6d592031483a6dfe61906f6fa011c91910328
2019-07-03 10:14:19 -07:00
Todd Kennedy
1d29b4af0b Move permission info queries
Now begins the parade of methods that can be migrated to the
permission manager service and be removed from the package
manager service.

We will still need to maintain some sub-set of APIs in the
package manager service due to unsupported app usage. When
we finally no longer support these AIDL methods, they can
be removed from package manager service.

Bug: 135279435
Test: Manual. Builds and runs
Change-Id: If12609ffdaeb75445d3ec9bcc7f946b8829ba769
2019-07-03 10:14:09 -07:00
Todd Kennedy
8f135982a8 Create permission manager AIDL
Today, the package manager largely routes any permission related
method to the PermissionManagerService. But, PermissionManagerService
is a service in name only. Instead, we will make the
PermissionManagerService a real service and direct API calls directly
to it.

We will likely need to maintain all of the public permission APIs
that already exist on PackageManager. However, the public -> private
implementation will go directly to PermissionManagerService.

Bug: 135279435
Test: Manual. Device boots
Change-Id: Ia4992ba6d1f4b9050db98c7d7647d51a5d45fcbe
2019-07-02 13:17:05 -07:00
Winson
01045f5d08 Merge "Expose PermissionManager as TestApi and fix SplitPermissionInfo equality" into qt-dev am: d703395fcb am: 7347c0f704
am: 02c612552f

Change-Id: I0e4fbc7d7c7e208d0eb7c029f5dc1ee57afd1ab0
2019-06-10 13:33:41 -07:00
Winson
f27394ee70 Expose PermissionManager as TestApi and fix SplitPermissionInfo equality
Bug: 129200416
Bug: 129200610

Test: atest SplitPermissionsTest

Change-Id: I98795944e6440e5b7ebba134bd7735a6f78ebc4f
2019-06-07 15:09:06 -07:00
Nate Myren
1a4e0bc457 Merge "set RuntimePermissionPresentationInfo, getAppPermissions, and OnGetAppPermissions as Test Api, added Get Runtime Permissions to shell" into qt-dev am: 1ce9983162 am: 40bcb1d3cd
am: 364c09f390

Change-Id: I26127032cd6185632d33e779e33cb7976b9ee2c1
2019-05-28 09:59:45 -07:00
Nate Myren
17f2159181 set RuntimePermissionPresentationInfo, getAppPermissions, and OnGetAppPermissions as Test Api, added Get Runtime Permissions to shell
Test: Run PermissionControllerTest
Fixes: 129200595

Change-Id: I44cf152e52895d9344b39b978b85ac263a5cb37c
2019-05-28 16:15:16 +00:00
Philip P. Moltmann
cc0208bc63 Merge "Mark perm DB version as -1 when upgrading from P" into qt-dev am: da7156d13d am: 2cf8337bcd
am: a0aecd7b46

Change-Id: I58cf36c13a7d728f265c2534863a05043c3d51de
2019-05-24 17:52:39 -07:00
Philip P. Moltmann
1ae81a547e Mark perm DB version as -1 when upgrading from P
So that we can implement different behavior between Android P and Q.

Test: Upgraded P->Q and booted fresh install of Q. Checked DB after boot
Bug: 131427665
Change-Id: I89f9dc1fc11129c95c03834e21628c6be75f2875
2019-05-23 16:14:33 -07:00
Eugene Susla
53f4df30f0 [fixed] Replace RemoteCallback with AndroidFuture in PermControler
This is ag/7529281 + fix ag/7572218

Test: atest AddConfigWidgetTest#testConfigCancelled
atest android.permission.cts.PermissionControllerTest
Change-Id: I9d8f28c0665a7ae4040ea471ed6a0187628a0306
2019-05-17 13:25:53 -07:00
Eugene Susla
8feb3a1df1 Revert "Replace RemoteCallback with AndroidFuture in PermControler"
This reverts commit e7daff9fa3.

Reason for revert: Broke some tests: b/132981879

Change-Id: I3a707c0a67316246532437718132717f0c601255
2019-05-17 20:11:31 +00:00
Eugene Susla
e7daff9fa3 Replace RemoteCallback with AndroidFuture in PermControler
- saves ~3 allocation per ipc
- no longer need to [un]bundleize result
- will become typesafe down the road (b/132732312)

Test: atest android.permission.cts.PermissionControllerTest
Change-Id: I6cd9ec5ae31179474536f22f557afb0d9db6a4b9
2019-05-16 12:46:09 -07:00
Eugene Susla
be4e3af852 Migrate PermissionControllerManager to ServiceConnector
Test: - atest --test-mapping core/java/com/android/internal/infra
  - m -j CtsBackupHostTestCases && atest android.backup.cts.PermissionTest
Change-Id: I6a590194207d08569f41f3c5ac6d56e63737feaa
2019-05-13 18:56:00 -07:00
Tim Murray
d06c6d2932 Revert "Add optional reasons why permissions were denied"
This reverts commit 3623f3219e.

Reason for revert: 40% startup perf regression

Test: revert
Bug 132129453
Exempt-From-Owner-Approval: critical revert

Change-Id: I19dc33e6a71c9254b4096154f4089c059fe408dd
2019-05-07 07:10:30 +00:00
Philip P. Moltmann
3623f3219e Add optional reasons why permissions were denied
Currently only for the ContextImpl.enforcePermission code paths and only
when 'secure debug_package_permission_check' is set.

This feature is disabled on user-builds.

Test: Enabled permission checking for my app and
      - checked runtime permision denial
      - permission denial because app is instant
Bug: 111075456
Change-Id: Ib85777db69ee490608e9dac32a3b97971c0ba215
2019-05-05 21:05:13 -07:00
Howard Chen
fff50fe62b Remove the Build.VERSION_CODES.P0
The Build.VERSION_CODES.P0 was the stub for a potential new API level
after P. Now it's Q thus the usage for P0 field is not valid any more.
This CL also fixed the android.os.cts.BuildTest test failure for
cf_x86_phone-userdebug

Bug: 131601118
Test: presubmit test on ag/7204147
Change-Id: Iee474e95a35e051e6a3f4f96da5d82387d33d013
2019-04-30 14:35:29 +08:00
Philip P. Moltmann
5ad5cdc394 Merge "Don't use Context#getApplicationContext" into qt-dev 2019-04-26 20:30:18 +00:00
Philip P. Moltmann
d56c6bdfa9 Don't use Context#getApplicationContext
as this might be null. In PermissionControllerManager we need a context
that outlives the passed in context as we bind to a service that will
only get destroyed after a delay.

Test: atest PermissionControllerTest
Bug: 131356152
Change-Id: Iabeac669f6464b84a4b9e8f9b2a27959b116c25b
2019-04-25 16:19:20 -07:00
Philip P. Moltmann
a7f181162e Allow PermissionControllerService implementer control own threading
Hence execute on binder-thread and send callback.

Fixes: 131314749
Test: atest --test-mapping packages/apps/PermissionController/src/com/android/packageinstaller/permission/service:presubmit
Change-Id: Ic5286a1b02532bcc0241877d970d0fc933b27f85
2019-04-25 14:00:28 -07:00
Philip P. Moltmann
188e47bbc5 Call PermissionControllerService on workerthread
As otherwise the mainthread is overwhelmed and blocking.

Test: atest CtsPermissionTestCases:android.permission.cts.PermissionControllerTest
Fixes: 130738002
Change-Id: I1d6cbc60411802cef1c8aedbb6e89430e65b2aa9
2019-04-18 11:05:35 -07:00
Svet Ganov
d8eb8b2690 Restricted permission mechanism - framework
This change adds a mechanism for restricting permissions (only runtime
for now), so that an app cannot hold the permission if it is not white
listed. The whitelisting can happen at install or at any later point.

There are three whitelists: system: OS managed with default grants
and role holders being on it; upgrade: only OS puts on this list
apps when upgrading from a pre to post restriction permission database
version and OS and installer on record can remove; installer: only
the installer on record can add and remove (and the system of course).

Added a permission policy service that sits on top of permissions
and app ops and is responsible to sync between permissions and app
ops when there is an interdependecy in any direction.

Added versioning to the runtime permissions database to allow operations
that need to be done once on upgrade such as adding all permissions held
by apps pre upgrade to the upgrade whitelist if the new permisison version
inctroduces a new restricted permission. The upgrade logic is in the
permission controller and we will eventually put the default grants there.

NOTE: This change is reacting to a VP feedback for how we would handle
SMS/CallLog restriction as we pivoted from role based approach to roles
for things the user would understand plus whitelist for everything else.
This would also help us roll out softly the storage permisison as there
is too much churm coming from developer feedback.

Exempt-From-Owner-Approval: trivial change due to APi adjustment

Test: atest CtsAppSecurityHostTestCases:android.appsecurity.cts.PermissionsHostTest
Test: atest CtsPermissionTestCases
Test: atest CtsPermission2TestCases
Test: atest RoleManagerTestCases

bug:124769181

Change-Id: Ic48e3c728387ecf02f89d517ba1fe785ab9c75fd
2019-04-07 22:39:54 -07:00
Michal Karpinski
322df0bb74 Modify AbstractRemoteService#mBindInstantServiceAllowed to #mBindingFlags
in order to support multiple binding flags

And supply BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS for RemoteFillService.

Test: atest CtsAutoFillServiceTestCases
Test: atest AutofillManagerServiceTest
Bug: 126267782
Change-Id: Id5262d6a4e0fde0ad874020f783cfbf72fe201f4
2019-03-26 11:07:33 +00:00
Joel Galenson
4b4798bb73 Use correct type for permission group name.
I forgot to change the type when I moved this from being the albel to
being the name.

Fixes: 128994612
Test: Call API.
Change-Id: Ie2d7a48512015304fe748c834e60a1ad445c4276
2019-03-20 18:26:33 -07:00
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