diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-11 21:39:47 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-11 21:39:47 +0000 |
commit | 3e7fc5fbd3f844730bc541e641b9ca6dcc4298e3 (patch) | |
tree | dcdbeadac0469fbfdfc711740b56e2adcc89d4ef | |
parent | bf4695fd93d0055cf1089e14157a9f17286aff59 (diff) | |
parent | a58cd83876534ca5656b77f95ec04dfb5c048f6e (diff) | |
download | Permission-android-platform-12.1.0_r26.tar.gz |
Merge cherrypicks of ['googleplex-android-review.googlesource.com/25238864'] into sc-v2-platform-release.android-platform-12.1.0_r27android-platform-12.1.0_r26android-platform-12.1.0_r25android-platform-12.1.0_r24android12L-platform-release
Change-Id: Idcc65f67b760cbc45cf45e8a7d7d8c2527b82013
-rw-r--r-- | PermissionController/src/com/android/permissioncontroller/role/model/CompanionDeviceWatchRoleBehavior.java | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/PermissionController/src/com/android/permissioncontroller/role/model/CompanionDeviceWatchRoleBehavior.java b/PermissionController/src/com/android/permissioncontroller/role/model/CompanionDeviceWatchRoleBehavior.java index 98d56de42..a8b24378f 100644 --- a/PermissionController/src/com/android/permissioncontroller/role/model/CompanionDeviceWatchRoleBehavior.java +++ b/PermissionController/src/com/android/permissioncontroller/role/model/CompanionDeviceWatchRoleBehavior.java @@ -23,6 +23,8 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; +import android.os.Process; +import android.os.UserHandle; import android.service.notification.NotificationListenerService; import android.util.Log; @@ -32,6 +34,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import com.android.permissioncontroller.role.utils.UserUtils; + /** * Class for behavior of the "watch" Companion device profile role. */ @@ -41,9 +45,12 @@ public class CompanionDeviceWatchRoleBehavior implements RoleBehavior { @Override public void grant(@NonNull Role role, @NonNull String packageName, @NonNull Context context) { - List<ComponentName> notificationListenersForPackage = - getNotificationListenersForPackage(packageName, context); - setNotificationGrantState(context, notificationListenersForPackage, true); + UserHandle user = Process.myUserHandle(); + if (!UserUtils.isWorkProfile(user, context)) { + List<ComponentName> notificationListenersForPackage = + getNotificationListenersForPackage(packageName, context); + setNotificationGrantState(context, notificationListenersForPackage, true); + } } private void setNotificationGrantState(@NonNull Context context, @@ -80,10 +87,13 @@ public class CompanionDeviceWatchRoleBehavior implements RoleBehavior { @Override public void revoke(@NonNull Role role, @NonNull String packageName, @NonNull Context context) { - NotificationManager notificationManager = - context.getSystemService(NotificationManager.class); - List<ComponentName> enabledNotificationListeners = - notificationManager.getEnabledNotificationListeners(); - setNotificationGrantState(context, enabledNotificationListeners, false); + UserHandle user = Process.myUserHandle(); + if (!UserUtils.isWorkProfile(user, context)) { + NotificationManager notificationManager = + context.getSystemService(NotificationManager.class); + List<ComponentName> enabledNotificationListeners = + notificationManager.getEnabledNotificationListeners(); + setNotificationGrantState(context, enabledNotificationListeners, false); + } } } |