diff options
Diffstat (limited to 'PermissionController/role-controller/java/com/android/role/controller/behavior/CompanionDeviceComputerRoleBehavior.java')
-rw-r--r-- | PermissionController/role-controller/java/com/android/role/controller/behavior/CompanionDeviceComputerRoleBehavior.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/PermissionController/role-controller/java/com/android/role/controller/behavior/CompanionDeviceComputerRoleBehavior.java b/PermissionController/role-controller/java/com/android/role/controller/behavior/CompanionDeviceComputerRoleBehavior.java index c59d5e58d..c5de0d848 100644 --- a/PermissionController/role-controller/java/com/android/role/controller/behavior/CompanionDeviceComputerRoleBehavior.java +++ b/PermissionController/role-controller/java/com/android/role/controller/behavior/CompanionDeviceComputerRoleBehavior.java @@ -17,12 +17,15 @@ package com.android.role.controller.behavior; import android.content.Context; +import android.os.Process; +import android.os.UserHandle; import androidx.annotation.NonNull; import com.android.role.controller.model.Role; import com.android.role.controller.model.RoleBehavior; import com.android.role.controller.util.NotificationUtils; +import com.android.role.controller.util.UserUtils; /** * Class for behavior of the "Computer" Companion device profile role. @@ -31,11 +34,17 @@ public class CompanionDeviceComputerRoleBehavior implements RoleBehavior { @Override public void grant(@NonNull Role role, @NonNull String packageName, @NonNull Context context) { - NotificationUtils.grantNotificationAccessForPackage(context, packageName); + UserHandle user = Process.myUserHandle(); + if (!UserUtils.isManagedProfile(user, context)) { + NotificationUtils.grantNotificationAccessForPackage(context, packageName); + } } @Override public void revoke(@NonNull Role role, @NonNull String packageName, @NonNull Context context) { - NotificationUtils.revokeNotificationAccessForPackage(context, packageName); + UserHandle user = Process.myUserHandle(); + if (!UserUtils.isManagedProfile(user, context)) { + NotificationUtils.revokeNotificationAccessForPackage(context, packageName); + } } } |