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

Commit 1ae81a54 authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Mark perm DB version as -1 when upgrading from P

So that we can implement different behavior between Android P and Q.

Test: Upgraded P->Q and booted fresh install of Q. Checked DB after boot
Bug: 131427665
Change-Id: I89f9dc1fc11129c95c03834e21628c6be75f2875
parent 3fb12ba4
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -68,7 +68,8 @@ public final class PermissionManager {
    /**
    /**
     * Gets the version of the runtime permission database.
     * Gets the version of the runtime permission database.
     *
     *
     * @return The database version.
     * @return The database version, -1 when this is an upgrade from pre-Q, 0 when this is a fresh
     * install.
     *
     *
     * @hide
     * @hide
     */
     */
+5 −2
Original line number Original line Diff line number Diff line
@@ -5102,6 +5102,7 @@ public final class Settings {
        private static final long WRITE_PERMISSIONS_DELAY_MILLIS = 200;
        private static final long WRITE_PERMISSIONS_DELAY_MILLIS = 200;
        private static final long MAX_WRITE_PERMISSIONS_DELAY_MILLIS = 2000;
        private static final long MAX_WRITE_PERMISSIONS_DELAY_MILLIS = 2000;


        private static final int UPGRADE_VERSION = -1;
        private static final int INITIAL_VERSION = 0;
        private static final int INITIAL_VERSION = 0;


        private final Handler mHandler = new MyHandler();
        private final Handler mHandler = new MyHandler();
@@ -5133,7 +5134,7 @@ public final class Settings {


        @GuardedBy("Settings.this.mLock")
        @GuardedBy("Settings.this.mLock")
        int getVersionLPr(int userId) {
        int getVersionLPr(int userId) {
            return mVersions.get(userId);
            return mVersions.get(userId, INITIAL_VERSION);
        }
        }


        @GuardedBy("Settings.this.mLock")
        @GuardedBy("Settings.this.mLock")
@@ -5365,8 +5366,10 @@ public final class Settings {


                switch (parser.getName()) {
                switch (parser.getName()) {
                    case TAG_RUNTIME_PERMISSIONS: {
                    case TAG_RUNTIME_PERMISSIONS: {
                        // If the permisions settings file exists but the version is not set this is
                        // an upgrade from P->Q. Hence mark it with the special UPGRADE_VERSION
                        int version = XmlUtils.readIntAttribute(parser, ATTR_VERSION,
                        int version = XmlUtils.readIntAttribute(parser, ATTR_VERSION,
                                INITIAL_VERSION);
                                UPGRADE_VERSION);
                        mVersions.put(userId, version);
                        mVersions.put(userId, version);
                        String fingerprint = parser.getAttributeValue(null, ATTR_FINGERPRINT);
                        String fingerprint = parser.getAttributeValue(null, ATTR_FINGERPRINT);
                        mFingerprints.put(userId, fingerprint);
                        mFingerprints.put(userId, fingerprint);