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

Commit a639d142 authored by Patrick Baumann's avatar Patrick Baumann
Browse files

Resets system flags when updating PackageSettings

In the case that we're updating a system app, we will in-place
update the PackageSetting object. This works for most fields but
breaks when updating flag fields as we're executing a binary or
on the existing flags, thus not unsetting bits when we should be.

This change resets all system-related flags before setting the new
flag values.

Test: manual - move app from priv-app to app, install update,
               verify that app does not receive priv flag
Fixes: 75993951
Fixes: 78265024

Change-Id: I3c88a3583ddb85c4b6b0e3b4d7b6d1d0db93ac17
parent 5685dffd
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -844,7 +844,12 @@ public final class Settings {
        }
        // If what we are scanning is a system (and possibly privileged) package,
        // then make it so, regardless of whether it was previously installed only
        // in the data partition.
        // in the data partition. Reset first.
        pkgSetting.pkgFlags &= ~ApplicationInfo.FLAG_SYSTEM;
        pkgSetting.pkgPrivateFlags &= ~(ApplicationInfo.PRIVATE_FLAG_PRIVILEGED
                | ApplicationInfo.PRIVATE_FLAG_OEM
                | ApplicationInfo.PRIVATE_FLAG_VENDOR
                | ApplicationInfo.PRIVATE_FLAG_PRODUCT);
        pkgSetting.pkgFlags |= pkgFlags & ApplicationInfo.FLAG_SYSTEM;
        pkgSetting.pkgPrivateFlags |=
                pkgPrivateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED;