Merge "Always check roles for non-blockability"

This commit is contained in:
Julia Reynolds
2022-01-11 19:46:52 +00:00
committed by Android (Google) Code Review
2 changed files with 31 additions and 0 deletions

View File

@@ -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(),