Loading src/com/android/settings/notification/NotificationBackend.java +7 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,13 @@ public class NotificationBackend { } catch (RemoteException e) { Log.w(TAG, "Error calling NMS", e); } // The permission system cannot make role permissions 'fixed', so check for these // roles explicitly List<String> roles = rm.getHeldRolesFromController(app.packageName); if (roles.contains(RoleManager.ROLE_DIALER) || roles.contains(RoleManager.ROLE_EMERGENCY)) { row.systemApp = row.lockedImportance = true; } } else { row.systemApp = Utils.isSystemPackage(context.getResources(), pm, app); List<String> roles = rm.getHeldRolesFromController(app.packageName); Loading tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,30 @@ public class NotificationBackendTest { assertTrue(appRow.systemApp); } @Test public void testMarkAppRow_fixedPermission_withRole() throws Exception { Secure.putIntForUser(RuntimeEnvironment.application.getContentResolver(), Settings.Secure.NOTIFICATION_PERMISSION_ENABLED, 1, USER_SYSTEM); PackageInfo pi = new PackageInfo(); pi.packageName = "test"; pi.applicationInfo = new ApplicationInfo(); pi.applicationInfo.packageName = "test"; pi.applicationInfo.uid = 123; List<String> roles = new ArrayList<>(); roles.add(RoleManager.ROLE_DIALER); RoleManager rm = mock(RoleManager.class); when(rm.getHeldRolesFromController(anyString())).thenReturn(roles); when(mInm.isPermissionFixed(pi.packageName, 0)).thenReturn(false); AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application, mock(PackageManager.class), rm, pi); assertTrue(appRow.systemApp); assertTrue(appRow.lockedImportance); } @Test public void testMarkAppRow_fixedPermission() throws Exception { Secure.putIntForUser(RuntimeEnvironment.application.getContentResolver(), Loading Loading
src/com/android/settings/notification/NotificationBackend.java +7 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,13 @@ public class NotificationBackend { } catch (RemoteException e) { Log.w(TAG, "Error calling NMS", e); } // The permission system cannot make role permissions 'fixed', so check for these // roles explicitly List<String> roles = rm.getHeldRolesFromController(app.packageName); if (roles.contains(RoleManager.ROLE_DIALER) || roles.contains(RoleManager.ROLE_EMERGENCY)) { row.systemApp = row.lockedImportance = true; } } else { row.systemApp = Utils.isSystemPackage(context.getResources(), pm, app); List<String> roles = rm.getHeldRolesFromController(app.packageName); Loading
tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,30 @@ public class NotificationBackendTest { assertTrue(appRow.systemApp); } @Test public void testMarkAppRow_fixedPermission_withRole() throws Exception { Secure.putIntForUser(RuntimeEnvironment.application.getContentResolver(), Settings.Secure.NOTIFICATION_PERMISSION_ENABLED, 1, USER_SYSTEM); PackageInfo pi = new PackageInfo(); pi.packageName = "test"; pi.applicationInfo = new ApplicationInfo(); pi.applicationInfo.packageName = "test"; pi.applicationInfo.uid = 123; List<String> roles = new ArrayList<>(); roles.add(RoleManager.ROLE_DIALER); RoleManager rm = mock(RoleManager.class); when(rm.getHeldRolesFromController(anyString())).thenReturn(roles); when(mInm.isPermissionFixed(pi.packageName, 0)).thenReturn(false); AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application, mock(PackageManager.class), rm, pi); assertTrue(appRow.systemApp); assertTrue(appRow.lockedImportance); } @Test public void testMarkAppRow_fixedPermission() throws Exception { Secure.putIntForUser(RuntimeEnvironment.application.getContentResolver(), Loading