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
This commit is contained in:
Jeff Davidson
2014-10-24 10:35:53 -07:00
parent f83c56cd42
commit be08587510

View File

@@ -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;
}