Disable app toggle for some T+ apps
Specifically, apps that haven't requested the notif permission in their manifest, as we cannot grant/revoke the permission unless they do Test: NotificationBackendTest, AppStateNotificationBridgeTest Fixes: 218315122 Change-Id: Icd936de806d7642809ef6c79d2d169bd673c2659
This commit is contained in:
@@ -37,7 +37,9 @@ import android.content.ComponentName;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PermissionInfo;
|
||||
import android.net.MacAddress;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
import android.provider.Settings;
|
||||
|
||||
@@ -177,6 +179,51 @@ public class NotificationBackendTest {
|
||||
assertFalse(appRow.lockedImportance);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarkAppRow_targetsT_noPermissionRequest() 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;
|
||||
pi.applicationInfo.targetSdkVersion= Build.VERSION_CODES.TIRAMISU;
|
||||
pi.requestedPermissions = new String[] {"something"};
|
||||
|
||||
when(mInm.isPermissionFixed(pi.packageName, 0)).thenReturn(false);
|
||||
|
||||
AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application,
|
||||
mock(PackageManager.class), mock(RoleManager.class), pi);
|
||||
|
||||
assertFalse(appRow.systemApp);
|
||||
assertTrue(appRow.lockedImportance);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarkAppRow_targetsT_permissionRequest() 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;
|
||||
pi.applicationInfo.targetSdkVersion= Build.VERSION_CODES.TIRAMISU;
|
||||
pi.requestedPermissions = new String[] {"something",
|
||||
android.Manifest.permission.POST_NOTIFICATIONS};
|
||||
|
||||
when(mInm.isPermissionFixed(pi.packageName, 0)).thenReturn(false);
|
||||
|
||||
AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application,
|
||||
mock(PackageManager.class), mock(RoleManager.class), pi);
|
||||
|
||||
assertFalse(appRow.systemApp);
|
||||
assertFalse(appRow.lockedImportance);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarkAppRow_notDefaultPackage() {
|
||||
PackageInfo pi = new PackageInfo();
|
||||
|
Reference in New Issue
Block a user