Android13 --- POST_NOTIFICATIONS permission cannot be turned off

   Android 13 (API level 33) and higher supports a runtime permission for sending non-exempt (including Front Desk Services [FGS]) notifications from apps: POST_NOTIFICATIONS. This change helps users focus on the most important notifications.
Notification runtime permissions | Android Developers | Android Developers
   On the Android 13 platform, if an application wants to send notifications, it must apply for the POST_NOTIFICATIONS permission. This permission is a runtime permission and requires dynamic authorization.
   However, the system app cannot turn off this permission in the permission list.

 

   The reason is that Google has exempted system apps and granted this permission by default.
/frameworks/base/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java

private void grantSignatureAppsNotificationPermissions(PackageManagerWrapper pm, int userId) {
        Log.i(TAG, "Granting Notification permissions to platform signature apps for user "
                + userId);
        List<PackageInfo> packages = mContext.getPackageManager().getInstalledPackagesAsUser(
                DEFAULT_PACKAGE_INFO_QUERY_FLAGS, UserHandle.USER_SYSTEM);
        for (PackageInfo pkg : packages) {
            if (pkg == null || !pkg.applicationInfo.isSystemApp()
                    || !pkg.applicationInfo.isSignedWithPlatformKey()) {
                continue;
            }
            grantRuntimePermissionsForSystemPackage(pm, userId, pkg, NOTIFICATION_PERMISSIONS);
        }

    }

Guess you like

Origin blog.csdn.net/m0_50408097/article/details/128728806