Merge "Move mSessionKey into Ikev2VpnRunner and make it to be a final var" into tm-dev am: e7dad46f07
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18115171 Change-Id: If864b46715e5d8bb1d52b88b1fac6c2d74a61f98 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -209,7 +209,6 @@ public class Vpn {
|
|||||||
private final NetworkInfo mNetworkInfo;
|
private final NetworkInfo mNetworkInfo;
|
||||||
private int mLegacyState;
|
private int mLegacyState;
|
||||||
@VisibleForTesting protected String mPackage;
|
@VisibleForTesting protected String mPackage;
|
||||||
private String mSessionKey;
|
|
||||||
private int mOwnerUID;
|
private int mOwnerUID;
|
||||||
private boolean mIsPackageTargetingAtLeastQ;
|
private boolean mIsPackageTargetingAtLeastQ;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -1991,9 +1990,7 @@ public class Vpn {
|
|||||||
public synchronized int getActiveVpnType() {
|
public synchronized int getActiveVpnType() {
|
||||||
if (!mNetworkInfo.isConnectedOrConnecting()) return VpnManager.TYPE_VPN_NONE;
|
if (!mNetworkInfo.isConnectedOrConnecting()) return VpnManager.TYPE_VPN_NONE;
|
||||||
if (mVpnRunner == null) return VpnManager.TYPE_VPN_SERVICE;
|
if (mVpnRunner == null) return VpnManager.TYPE_VPN_SERVICE;
|
||||||
return mVpnRunner instanceof IkeV2VpnRunner
|
return isIkev2VpnRunner() ? VpnManager.TYPE_VPN_PLATFORM : VpnManager.TYPE_VPN_LEGACY;
|
||||||
? VpnManager.TYPE_VPN_PLATFORM
|
|
||||||
: VpnManager.TYPE_VPN_LEGACY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAlwaysOnNotification(DetailedState networkState) {
|
private void updateAlwaysOnNotification(DetailedState networkState) {
|
||||||
@@ -2531,6 +2528,7 @@ public class Vpn {
|
|||||||
@Nullable private IpSecTunnelInterface mTunnelIface;
|
@Nullable private IpSecTunnelInterface mTunnelIface;
|
||||||
@Nullable private IkeSession mSession;
|
@Nullable private IkeSession mSession;
|
||||||
@Nullable private Network mActiveNetwork;
|
@Nullable private Network mActiveNetwork;
|
||||||
|
private final String mSessionKey;
|
||||||
|
|
||||||
IkeV2VpnRunner(@NonNull Ikev2VpnProfile profile) {
|
IkeV2VpnRunner(@NonNull Ikev2VpnProfile profile) {
|
||||||
super(TAG);
|
super(TAG);
|
||||||
@@ -2876,7 +2874,6 @@ public class Vpn {
|
|||||||
*/
|
*/
|
||||||
private void disconnectVpnRunner() {
|
private void disconnectVpnRunner() {
|
||||||
mActiveNetwork = null;
|
mActiveNetwork = null;
|
||||||
mSessionKey = null;
|
|
||||||
mIsRunning = false;
|
mIsRunning = false;
|
||||||
|
|
||||||
resetIkeState();
|
resetIkeState();
|
||||||
@@ -3306,7 +3303,7 @@ public class Vpn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCurrentIkev2VpnLocked(@NonNull String packageName) {
|
private boolean isCurrentIkev2VpnLocked(@NonNull String packageName) {
|
||||||
return isCurrentPreparedPackage(packageName) && mVpnRunner instanceof IkeV2VpnRunner;
|
return isCurrentPreparedPackage(packageName) && isIkev2VpnRunner();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3360,6 +3357,16 @@ public class Vpn {
|
|||||||
return VpnProfile.decode("" /* Key unused */, encoded);
|
return VpnProfile.decode("" /* Key unused */, encoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isIkev2VpnRunner() {
|
||||||
|
return (mVpnRunner instanceof IkeV2VpnRunner);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GuardedBy("this")
|
||||||
|
@Nullable
|
||||||
|
private String getSessionKeyLocked() {
|
||||||
|
return isIkev2VpnRunner() ? ((IkeV2VpnRunner) mVpnRunner).mSessionKey : null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts an already provisioned VPN Profile, keyed by package name.
|
* Starts an already provisioned VPN Profile, keyed by package name.
|
||||||
*
|
*
|
||||||
@@ -3387,7 +3394,11 @@ public class Vpn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startVpnProfilePrivileged(profile, packageName);
|
startVpnProfilePrivileged(profile, packageName);
|
||||||
return mSessionKey;
|
if (!isIkev2VpnRunner()) {
|
||||||
|
throw new IllegalStateException("mVpnRunner shouldn't be null and should also be "
|
||||||
|
+ "an instance of Ikev2VpnRunner");
|
||||||
|
}
|
||||||
|
return getSessionKeyLocked();
|
||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(token);
|
Binder.restoreCallingIdentity(token);
|
||||||
}
|
}
|
||||||
@@ -3490,11 +3501,8 @@ public class Vpn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private VpnProfileState makeVpnProfileState() {
|
private VpnProfileState makeVpnProfileState() {
|
||||||
// TODO: mSessionKey will be moved to Ikev2VpnRunner once aosp/2007077 is merged, so after
|
return new VpnProfileState(getStateFromLegacyState(mLegacyState),
|
||||||
// merging aosp/2007077, here should check Ikev2VpnRunner is null or not. Session key will
|
isIkev2VpnRunner() ? getSessionKeyLocked() : null, mAlwaysOn, mLockdown);
|
||||||
// be null if Ikev2VpnRunner is null.
|
|
||||||
return new VpnProfileState(getStateFromLegacyState(mLegacyState), mSessionKey, mAlwaysOn,
|
|
||||||
mLockdown);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user