Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17e784a8 authored by Steve Elliott's avatar Steve Elliott
Browse files

Enable notification permission enforcement

This change will guard posting notifications with a new
"android.permission.POST_NOTIFICATIONS" permission introcuded as part of
Android T.

This permission is marked "dangerous" and will require both declaring
usage of the permission in AndroidManifest.xml as well as showing a
runtime prompt to the user in order to be granted the permission.

Packages which are not granted the permission will have their
notifications silently dropped.

Test: atest Cts*
Bug: 194833441

Change-Id: I274738d4d4c3b09902844708327feb2d1d367307
parent b476f8b5
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -3624,7 +3624,7 @@ public class SettingsProvider extends ContentProvider {
        }

        private final class UpgradeController {
            private static final int SETTINGS_VERSION = 208;
            private static final int SETTINGS_VERSION = 209;

            private final int mUserId;

@@ -5497,6 +5497,20 @@ public class SettingsProvider extends ContentProvider {
                    currentVersion = 208;
                }

                if (currentVersion == 208) {
                    // Version 208: Enable enforcement of
                    // android.Manifest.permission#POST_NOTIFICATIONS in order for applications
                    // to post notifications.
                    final SettingsState secureSettings = getSecureSettingsLocked(userId);
                    secureSettings.insertSettingLocked(
                            Secure.NOTIFICATION_PERMISSION_ENABLED,
                            /* enabled= */" 1",
                            /* tag= */ null,
                            /* makeDefault= */ false,
                            SettingsState.SYSTEM_PACKAGE_NAME);
                    currentVersion = 209;
                }

                // vXXX: Add new settings above this point.

                if (currentVersion != newVersion) {