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

Commit be085875 authored by Jeff Davidson's avatar Jeff Davidson
Browse files

Check UID instead of package name when preparing VPN.

If a package is uninstalled and reinstalled, it should no longer be
considered a prepared VPN in prepare(). While the package name remains
constant in this case, the UID should not.

Bug: 17980393
Change-Id: I29edf22ebe0550a7938d5a36c746c83dc068a0f9
parent f83c56cd
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -215,7 +215,7 @@ public class Vpn {
     */
    public synchronized boolean prepare(String oldPackage, String newPackage) {
        // Return false if the package does not match.
        if (oldPackage != null && !oldPackage.equals(mPackage)) {
        if (oldPackage != null && getAppUid(oldPackage, mUserHandle) != mOwnerUID) {
            // The package doesn't match. If this VPN was not previously authorized, return false
            // to force user authorization. Otherwise, revoke the VPN anyway.
            if (!oldPackage.equals(VpnConfig.LEGACY_VPN) && isVpnUserPreConsented(oldPackage)) {
@@ -234,8 +234,8 @@ public class Vpn {
        }

        // Return true if we do not need to revoke.
        if (newPackage == null ||
                (newPackage.equals(mPackage) && !newPackage.equals(VpnConfig.LEGACY_VPN))) {
        if (newPackage == null || (!newPackage.equals(VpnConfig.LEGACY_VPN) &&
                getAppUid(newPackage, mUserHandle) == mOwnerUID)) {
            return true;
        }