diff options
author | Eran Messeri <eranm@google.com> | 2020-02-10 16:38:40 +0000 |
---|---|---|
committer | Eran Messeri <eranm@google.com> | 2020-02-12 21:15:05 +0000 |
commit | 753bafa7a9e7d3966d3f64ed7103f5fe6eeda35e (patch) | |
tree | 3adb067386ed5f25f7b0df8bff91609f791c7c80 /PermissionController/src/com/android/permissioncontroller/Constants.java | |
parent | 17357b75a4d38492f12d1831034279250f762145 (diff) | |
download | Permission-753bafa7a9e7d3966d3f64ed7103f5fe6eeda35e.tar.gz |
Notify users when admin grants location permission
When the admin grants a location-related permission to an app (using
DevicePolicyManager.setPermissionGrantState), notify the user that the
app got this permission.
Implementation: The AutoGrantPermissionsNotifier introduced in a
previous change is used to present the notification to the user.
In PermissionControllerServiceImpl.onSetRuntimePermissionGrantStateByDeviceAdmin,
when the permission is actually granted to the app, each permission is
logged. Before the method returns,
AutoGrantPermissionsNotifier.notifyOfAutoGrantPermissions method is called,
which issues the notification.
Tapping the notification sends the user to the Settings screen where app
permissions can be seen (but not controlled).
Note that this notification does vibrate and emit a sound, while the
notification shown for permissions granted via policy do not, as the
latter notification is shown in-context, when the app requests (and is
granted) the permission.
Testing:
* Install TestDPC.
* Set TestDPC as Device Owner
* Get the BasicLocation app by checking out
https://github.com/android/location-samples and building it from there.
* Install the app onto the device but do not start it.
* Find "Manage app permissions", choose "Basic Location Sample" from the
drop-down menu.
* Toggle each of the "ACCESS_COARSE_LOCATION" and
"ACCESS_BACKGROUND_LOCATION" to "Allow".
* Observe notification
Bug: 148631522
Test: Manual, see above
Change-Id: I4fef2d5d47718265bec6aaf9b485e86b9da91ec3
Diffstat (limited to 'PermissionController/src/com/android/permissioncontroller/Constants.java')
-rw-r--r-- | PermissionController/src/com/android/permissioncontroller/Constants.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/PermissionController/src/com/android/permissioncontroller/Constants.java b/PermissionController/src/com/android/permissioncontroller/Constants.java index 81883aa48..9011a3234 100644 --- a/PermissionController/src/com/android/permissioncontroller/Constants.java +++ b/PermissionController/src/com/android/permissioncontroller/Constants.java @@ -162,10 +162,18 @@ public class Constants { public static final long INVALID_SESSION_ID = 0; /** - * Key for NotificationManager.notify for the auto-granted permissions notification. + * Key for NotificationManager.notify for auto-granted permissions notification, + * when silently displayed to the user. */ public static final String ADMIN_AUTO_GRANTED_PERMISSIONS_NOTIFICATION_CHANNEL_ID = "auto granted permissions"; + + /** + * Key for NotificationManager.notify the auto-granted permissions notification, + * when alerting the user (with sound and vibration). + */ + public static final String ADMIN_AUTO_GRANTED_PERMISSIONS_ALERTING_NOTIFICATION_CHANNEL_ID = + "alerting auto granted permissions"; /** * ID for notification of auto-granted permissions shown by * {@link com.android.permissioncontroller.permission.ui.AutoGrantPermissionsNotifier}. |