Loading services/core/java/com/android/server/notification/NotificationManagerService.java +15 −5 Original line number Diff line number Diff line Loading @@ -98,6 +98,8 @@ import android.app.NotificationManager; import android.app.NotificationManager.Policy; import android.app.PendingIntent; import android.app.StatusBarManager; import android.app.admin.DeviceAdminInfo; import android.app.admin.DevicePolicyManagerInternal; import android.app.backup.BackupManager; import android.app.usage.UsageEvents; import android.app.usage.UsageStatsManagerInternal; Loading Loading @@ -366,6 +368,7 @@ public class NotificationManagerService extends SystemService { private AppOpsManager mAppOps; private UsageStatsManagerInternal mAppUsageStats; private DevicePolicyManagerInternal mDpm; private Archive mArchive; Loading Loading @@ -1355,7 +1358,7 @@ public class NotificationManagerService extends SystemService { ICompanionDeviceManager companionManager, SnoozeHelper snoozeHelper, NotificationUsageStats usageStats, AtomicFile policyFile, ActivityManager activityManager, GroupHelper groupHelper, IActivityManager am, UsageStatsManagerInternal appUsageStats) { UsageStatsManagerInternal appUsageStats, DevicePolicyManagerInternal dpm) { Resources resources = getContext().getResources(); mMaxPackageEnqueueRate = Settings.Global.getFloat(getContext().getContentResolver(), Settings.Global.MAX_NOTIFICATION_ENQUEUE_RATE, Loading @@ -1374,6 +1377,8 @@ public class NotificationManagerService extends SystemService { mActivityManager = activityManager; mDeviceIdleController = IDeviceIdleController.Stub.asInterface( ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER)); mDpm = dpm; try { mPermissionOwner = mAm.newUriPermissionOwner("notification"); } catch (RemoteException e) { Loading Loading @@ -1512,7 +1517,8 @@ public class NotificationManagerService extends SystemService { new AtomicFile(new File(systemDir, "notification_policy.xml"), "notification-policy"), (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE), getGroupHelper(), ActivityManager.getService(), LocalServices.getService(UsageStatsManagerInternal.class)); LocalServices.getService(UsageStatsManagerInternal.class), LocalServices.getService(DevicePolicyManagerInternal.class)); // register for various Intents IntentFilter filter = new IntentFilter(); Loading Loading @@ -3090,8 +3096,8 @@ public class NotificationManagerService extends SystemService { private boolean checkPolicyAccess(String pkg) { try { int uid = getContext().getPackageManager().getPackageUidAsUser( pkg, UserHandle.getCallingUserId()); int uid = getContext().getPackageManager().getPackageUidAsUser(pkg, UserHandle.getCallingUserId()); if (PackageManager.PERMISSION_GRANTED == ActivityManager.checkComponentPermission( android.Manifest.permission.MANAGE_NOTIFICATIONS, uid, -1, true)) { Loading @@ -3100,7 +3106,11 @@ public class NotificationManagerService extends SystemService { } catch (NameNotFoundException e) { return false; } return checkPackagePolicyAccess(pkg) || mListeners.isComponentEnabledForPackage(pkg); return checkPackagePolicyAccess(pkg) || mListeners.isComponentEnabledForPackage(pkg) || (mDpm != null && mDpm.isActiveAdminWithPolicy(Binder.getCallingUid(), DeviceAdminInfo.USES_POLICY_PROFILE_OWNER)); } @Override Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +4 −1 Original line number Diff line number Diff line Loading @@ -68,6 +68,8 @@ import android.app.Notification.MessagingStyle.Message; import android.app.NotificationChannel; import android.app.NotificationChannelGroup; import android.app.NotificationManager; import android.app.admin.DeviceAdminInfo; import android.app.admin.DevicePolicyManagerInternal; import android.app.usage.UsageStatsManagerInternal; import android.companion.ICompanionDeviceManager; import android.content.ComponentName; Loading Loading @@ -265,7 +267,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { mPackageManager, mPackageManagerClient, mockLightsManager, mListeners, mAssistants, mConditionProviders, mCompanionMgr, mSnoozeHelper, mUsageStats, mPolicyFile, mActivityManager, mGroupHelper, mAm, mock(UsageStatsManagerInternal.class)); mGroupHelper, mAm, mock(UsageStatsManagerInternal.class), mock(DevicePolicyManagerInternal.class)); } catch (SecurityException e) { if (!e.getMessage().contains("Permission Denial: not allowed to send broadcast")) { throw e; Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +15 −5 Original line number Diff line number Diff line Loading @@ -98,6 +98,8 @@ import android.app.NotificationManager; import android.app.NotificationManager.Policy; import android.app.PendingIntent; import android.app.StatusBarManager; import android.app.admin.DeviceAdminInfo; import android.app.admin.DevicePolicyManagerInternal; import android.app.backup.BackupManager; import android.app.usage.UsageEvents; import android.app.usage.UsageStatsManagerInternal; Loading Loading @@ -366,6 +368,7 @@ public class NotificationManagerService extends SystemService { private AppOpsManager mAppOps; private UsageStatsManagerInternal mAppUsageStats; private DevicePolicyManagerInternal mDpm; private Archive mArchive; Loading Loading @@ -1355,7 +1358,7 @@ public class NotificationManagerService extends SystemService { ICompanionDeviceManager companionManager, SnoozeHelper snoozeHelper, NotificationUsageStats usageStats, AtomicFile policyFile, ActivityManager activityManager, GroupHelper groupHelper, IActivityManager am, UsageStatsManagerInternal appUsageStats) { UsageStatsManagerInternal appUsageStats, DevicePolicyManagerInternal dpm) { Resources resources = getContext().getResources(); mMaxPackageEnqueueRate = Settings.Global.getFloat(getContext().getContentResolver(), Settings.Global.MAX_NOTIFICATION_ENQUEUE_RATE, Loading @@ -1374,6 +1377,8 @@ public class NotificationManagerService extends SystemService { mActivityManager = activityManager; mDeviceIdleController = IDeviceIdleController.Stub.asInterface( ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER)); mDpm = dpm; try { mPermissionOwner = mAm.newUriPermissionOwner("notification"); } catch (RemoteException e) { Loading Loading @@ -1512,7 +1517,8 @@ public class NotificationManagerService extends SystemService { new AtomicFile(new File(systemDir, "notification_policy.xml"), "notification-policy"), (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE), getGroupHelper(), ActivityManager.getService(), LocalServices.getService(UsageStatsManagerInternal.class)); LocalServices.getService(UsageStatsManagerInternal.class), LocalServices.getService(DevicePolicyManagerInternal.class)); // register for various Intents IntentFilter filter = new IntentFilter(); Loading Loading @@ -3090,8 +3096,8 @@ public class NotificationManagerService extends SystemService { private boolean checkPolicyAccess(String pkg) { try { int uid = getContext().getPackageManager().getPackageUidAsUser( pkg, UserHandle.getCallingUserId()); int uid = getContext().getPackageManager().getPackageUidAsUser(pkg, UserHandle.getCallingUserId()); if (PackageManager.PERMISSION_GRANTED == ActivityManager.checkComponentPermission( android.Manifest.permission.MANAGE_NOTIFICATIONS, uid, -1, true)) { Loading @@ -3100,7 +3106,11 @@ public class NotificationManagerService extends SystemService { } catch (NameNotFoundException e) { return false; } return checkPackagePolicyAccess(pkg) || mListeners.isComponentEnabledForPackage(pkg); return checkPackagePolicyAccess(pkg) || mListeners.isComponentEnabledForPackage(pkg) || (mDpm != null && mDpm.isActiveAdminWithPolicy(Binder.getCallingUid(), DeviceAdminInfo.USES_POLICY_PROFILE_OWNER)); } @Override Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +4 −1 Original line number Diff line number Diff line Loading @@ -68,6 +68,8 @@ import android.app.Notification.MessagingStyle.Message; import android.app.NotificationChannel; import android.app.NotificationChannelGroup; import android.app.NotificationManager; import android.app.admin.DeviceAdminInfo; import android.app.admin.DevicePolicyManagerInternal; import android.app.usage.UsageStatsManagerInternal; import android.companion.ICompanionDeviceManager; import android.content.ComponentName; Loading Loading @@ -265,7 +267,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { mPackageManager, mPackageManagerClient, mockLightsManager, mListeners, mAssistants, mConditionProviders, mCompanionMgr, mSnoozeHelper, mUsageStats, mPolicyFile, mActivityManager, mGroupHelper, mAm, mock(UsageStatsManagerInternal.class)); mGroupHelper, mAm, mock(UsageStatsManagerInternal.class), mock(DevicePolicyManagerInternal.class)); } catch (SecurityException e) { if (!e.getMessage().contains("Permission Denial: not allowed to send broadcast")) { throw e; Loading