Merge "Add more logs into dumpsys of VPN"
This commit is contained in:
@@ -769,6 +769,19 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
final StringBuilder sb = new StringBuilder("IkeV2VpnProfile [");
|
||||||
|
sb.append(" MaxMtu=" + mMaxMtu);
|
||||||
|
if (mIsBypassable) sb.append(" Bypassable");
|
||||||
|
if (mRequiresInternetValidation) sb.append(" RequiresInternetValidation");
|
||||||
|
if (mIsRestrictedToTestNetworks) sb.append(" RestrictedToTestNetworks");
|
||||||
|
if (mAutomaticNattKeepaliveTimerEnabled) sb.append(" AutomaticNattKeepaliveTimerEnabled");
|
||||||
|
if (mAutomaticIpVersionSelectionEnabled) sb.append(" AutomaticIpVersionSelectionEnabled");
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/** A incremental builder for IKEv2 VPN profiles */
|
/** A incremental builder for IKEv2 VPN profiles */
|
||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
private int mType = -1;
|
private int mType = -1;
|
||||||
|
|||||||
@@ -365,9 +365,8 @@ public class Vpn {
|
|||||||
return mVpnProfileStore;
|
return mVpnProfileStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int MAX_EVENTS_LOGS = 20;
|
private static final int MAX_EVENTS_LOGS = 100;
|
||||||
private final LocalLog mUnderlyNetworkChanges = new LocalLog(MAX_EVENTS_LOGS);
|
private final LocalLog mEventChanges = new LocalLog(MAX_EVENTS_LOGS);
|
||||||
private final LocalLog mVpnManagerEvents = new LocalLog(MAX_EVENTS_LOGS);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cached Map of <subscription ID, CarrierConfigInfo> since retrieving the PersistableBundle
|
* Cached Map of <subscription ID, CarrierConfigInfo> since retrieving the PersistableBundle
|
||||||
@@ -957,7 +956,7 @@ public class Vpn {
|
|||||||
int errorCode, @NonNull final String packageName, @Nullable final String sessionKey,
|
int errorCode, @NonNull final String packageName, @Nullable final String sessionKey,
|
||||||
@NonNull final VpnProfileState profileState, @Nullable final Network underlyingNetwork,
|
@NonNull final VpnProfileState profileState, @Nullable final Network underlyingNetwork,
|
||||||
@Nullable final NetworkCapabilities nc, @Nullable final LinkProperties lp) {
|
@Nullable final NetworkCapabilities nc, @Nullable final LinkProperties lp) {
|
||||||
mVpnManagerEvents.log("Event class=" + getVpnManagerEventClassName(errorClass)
|
mEventChanges.log("[VMEvent] Event class=" + getVpnManagerEventClassName(errorClass)
|
||||||
+ ", err=" + getVpnManagerEventErrorName(errorCode) + " for " + packageName
|
+ ", err=" + getVpnManagerEventErrorName(errorCode) + " for " + packageName
|
||||||
+ " on session " + sessionKey);
|
+ " on session " + sessionKey);
|
||||||
final Intent intent = buildVpnManagerEventIntent(category, errorClass, errorCode,
|
final Intent intent = buildVpnManagerEventIntent(category, errorClass, errorCode,
|
||||||
@@ -1107,6 +1106,8 @@ public class Vpn {
|
|||||||
mLockdownAllowlist = (mLockdown && lockdownAllowlist != null)
|
mLockdownAllowlist = (mLockdown && lockdownAllowlist != null)
|
||||||
? Collections.unmodifiableList(new ArrayList<>(lockdownAllowlist))
|
? Collections.unmodifiableList(new ArrayList<>(lockdownAllowlist))
|
||||||
: Collections.emptyList();
|
: Collections.emptyList();
|
||||||
|
mEventChanges.log("[LockdownAlwaysOn] Mode changed: lockdown=" + mLockdown + " alwaysOn="
|
||||||
|
+ mAlwaysOn + " calling from " + Binder.getCallingUid());
|
||||||
|
|
||||||
if (isCurrentPreparedPackage(packageName)) {
|
if (isCurrentPreparedPackage(packageName)) {
|
||||||
updateAlwaysOnNotification(mNetworkInfo.getDetailedState());
|
updateAlwaysOnNotification(mNetworkInfo.getDetailedState());
|
||||||
@@ -1736,7 +1737,7 @@ public class Vpn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void logUnderlyNetworkChanges(List<Network> networks) {
|
private void logUnderlyNetworkChanges(List<Network> networks) {
|
||||||
mUnderlyNetworkChanges.log("Switch to "
|
mEventChanges.log("[UnderlyingNW] Switch to "
|
||||||
+ ((networks != null) ? TextUtils.join(", ", networks) : "null"));
|
+ ((networks != null) ? TextUtils.join(", ", networks) : "null"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3003,6 +3004,9 @@ public class Vpn {
|
|||||||
@Override
|
@Override
|
||||||
public void onCarrierConfigChanged(int slotIndex, int subId, int carrierId,
|
public void onCarrierConfigChanged(int slotIndex, int subId, int carrierId,
|
||||||
int specificCarrierId) {
|
int specificCarrierId) {
|
||||||
|
mEventChanges.log("[CarrierConfig] Changed on slot " + slotIndex + " subId="
|
||||||
|
+ subId + " carrerId=" + carrierId
|
||||||
|
+ " specificCarrierId=" + specificCarrierId);
|
||||||
synchronized (Vpn.this) {
|
synchronized (Vpn.this) {
|
||||||
mCachedCarrierConfigInfoPerSubId.remove(subId);
|
mCachedCarrierConfigInfoPerSubId.remove(subId);
|
||||||
|
|
||||||
@@ -3093,6 +3097,8 @@ public class Vpn {
|
|||||||
*/
|
*/
|
||||||
public void onIkeOpened(int token, @NonNull IkeSessionConfiguration ikeConfiguration) {
|
public void onIkeOpened(int token, @NonNull IkeSessionConfiguration ikeConfiguration) {
|
||||||
if (!isActiveToken(token)) {
|
if (!isActiveToken(token)) {
|
||||||
|
mEventChanges.log("[IKEEvent-" + mSessionKey + "] onIkeOpened obsolete token="
|
||||||
|
+ token);
|
||||||
Log.d(TAG, "onIkeOpened called for obsolete token " + token);
|
Log.d(TAG, "onIkeOpened called for obsolete token " + token);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -3100,7 +3106,12 @@ public class Vpn {
|
|||||||
mMobikeEnabled =
|
mMobikeEnabled =
|
||||||
ikeConfiguration.isIkeExtensionEnabled(
|
ikeConfiguration.isIkeExtensionEnabled(
|
||||||
IkeSessionConfiguration.EXTENSION_TYPE_MOBIKE);
|
IkeSessionConfiguration.EXTENSION_TYPE_MOBIKE);
|
||||||
onIkeConnectionInfoChanged(token, ikeConfiguration.getIkeSessionConnectionInfo());
|
final IkeSessionConnectionInfo info = ikeConfiguration.getIkeSessionConnectionInfo();
|
||||||
|
mEventChanges.log("[IKEEvent-" + mSessionKey + "] onIkeOpened token=" + token
|
||||||
|
+ ", localAddr=" + info.getLocalAddress()
|
||||||
|
+ ", network=" + info.getNetwork()
|
||||||
|
+ ", mobikeEnabled= " + mMobikeEnabled);
|
||||||
|
onIkeConnectionInfoChanged(token, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3113,11 +3124,17 @@ public class Vpn {
|
|||||||
*/
|
*/
|
||||||
public void onIkeConnectionInfoChanged(
|
public void onIkeConnectionInfoChanged(
|
||||||
int token, @NonNull IkeSessionConnectionInfo ikeConnectionInfo) {
|
int token, @NonNull IkeSessionConnectionInfo ikeConnectionInfo) {
|
||||||
|
|
||||||
if (!isActiveToken(token)) {
|
if (!isActiveToken(token)) {
|
||||||
|
mEventChanges.log("[IKEEvent-" + mSessionKey
|
||||||
|
+ "] onIkeConnectionInfoChanged obsolete token=" + token);
|
||||||
Log.d(TAG, "onIkeConnectionInfoChanged called for obsolete token " + token);
|
Log.d(TAG, "onIkeConnectionInfoChanged called for obsolete token " + token);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
mEventChanges.log("[IKEEvent-" + mSessionKey
|
||||||
|
+ "] onIkeConnectionInfoChanged token=" + token
|
||||||
|
+ ", localAddr=" + ikeConnectionInfo.getLocalAddress()
|
||||||
|
+ ", network=" + ikeConnectionInfo.getNetwork());
|
||||||
// The update on VPN and the IPsec tunnel will be done when migration is fully complete
|
// The update on VPN and the IPsec tunnel will be done when migration is fully complete
|
||||||
// in onChildMigrated
|
// in onChildMigrated
|
||||||
mIkeConnectionInfo = ikeConnectionInfo;
|
mIkeConnectionInfo = ikeConnectionInfo;
|
||||||
@@ -3131,6 +3148,8 @@ public class Vpn {
|
|||||||
*/
|
*/
|
||||||
public void onChildOpened(int token, @NonNull ChildSessionConfiguration childConfig) {
|
public void onChildOpened(int token, @NonNull ChildSessionConfiguration childConfig) {
|
||||||
if (!isActiveToken(token)) {
|
if (!isActiveToken(token)) {
|
||||||
|
mEventChanges.log("[IKEEvent-" + mSessionKey
|
||||||
|
+ "] onChildOpened obsolete token=" + token);
|
||||||
Log.d(TAG, "onChildOpened called for obsolete token " + token);
|
Log.d(TAG, "onChildOpened called for obsolete token " + token);
|
||||||
|
|
||||||
// Do nothing; this signals that either: (1) a new/better Network was found,
|
// Do nothing; this signals that either: (1) a new/better Network was found,
|
||||||
@@ -3140,7 +3159,9 @@ public class Vpn {
|
|||||||
// sessions are torn down via resetIkeState().
|
// sessions are torn down via resetIkeState().
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
mEventChanges.log("[IKEEvent-" + mSessionKey + "] onChildOpened token=" + token
|
||||||
|
+ ", addr=" + TextUtils.join(", ", childConfig.getInternalAddresses())
|
||||||
|
+ " dns=" + TextUtils.join(", ", childConfig.getInternalDnsServers()));
|
||||||
try {
|
try {
|
||||||
final String interfaceName = mTunnelIface.getInterfaceName();
|
final String interfaceName = mTunnelIface.getInterfaceName();
|
||||||
final List<LinkAddress> internalAddresses = childConfig.getInternalAddresses();
|
final List<LinkAddress> internalAddresses = childConfig.getInternalAddresses();
|
||||||
@@ -3237,6 +3258,8 @@ public class Vpn {
|
|||||||
public void onChildTransformCreated(
|
public void onChildTransformCreated(
|
||||||
int token, @NonNull IpSecTransform transform, int direction) {
|
int token, @NonNull IpSecTransform transform, int direction) {
|
||||||
if (!isActiveToken(token)) {
|
if (!isActiveToken(token)) {
|
||||||
|
mEventChanges.log("[IKEEvent-" + mSessionKey
|
||||||
|
+ "] onChildTransformCreated obsolete token=" + token);
|
||||||
Log.d(TAG, "ChildTransformCreated for obsolete token " + token);
|
Log.d(TAG, "ChildTransformCreated for obsolete token " + token);
|
||||||
|
|
||||||
// Do nothing; this signals that either: (1) a new/better Network was found,
|
// Do nothing; this signals that either: (1) a new/better Network was found,
|
||||||
@@ -3246,7 +3269,9 @@ public class Vpn {
|
|||||||
// sessions are torn down via resetIkeState().
|
// sessions are torn down via resetIkeState().
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
mEventChanges.log("[IKEEvent-" + mSessionKey
|
||||||
|
+ "] onChildTransformCreated token=" + token + ", direction=" + direction
|
||||||
|
+ ", transform=" + transform);
|
||||||
try {
|
try {
|
||||||
mTunnelIface.setUnderlyingNetwork(mIkeConnectionInfo.getNetwork());
|
mTunnelIface.setUnderlyingNetwork(mIkeConnectionInfo.getNetwork());
|
||||||
|
|
||||||
@@ -3271,10 +3296,14 @@ public class Vpn {
|
|||||||
@NonNull IpSecTransform inTransform,
|
@NonNull IpSecTransform inTransform,
|
||||||
@NonNull IpSecTransform outTransform) {
|
@NonNull IpSecTransform outTransform) {
|
||||||
if (!isActiveToken(token)) {
|
if (!isActiveToken(token)) {
|
||||||
|
mEventChanges.log("[IKEEvent-" + mSessionKey
|
||||||
|
+ "] onChildMigrated obsolete token=" + token);
|
||||||
Log.d(TAG, "onChildMigrated for obsolete token " + token);
|
Log.d(TAG, "onChildMigrated for obsolete token " + token);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
mEventChanges.log("[IKEEvent-" + mSessionKey
|
||||||
|
+ "] onChildMigrated token=" + token
|
||||||
|
+ ", in=" + inTransform + ", out=" + outTransform);
|
||||||
// The actual network of this IKE session has migrated to is
|
// The actual network of this IKE session has migrated to is
|
||||||
// mIkeConnectionInfo.getNetwork() instead of mActiveNetwork because mActiveNetwork
|
// mIkeConnectionInfo.getNetwork() instead of mActiveNetwork because mActiveNetwork
|
||||||
// might have been updated after the migration was triggered.
|
// might have been updated after the migration was triggered.
|
||||||
@@ -3702,6 +3731,8 @@ public class Vpn {
|
|||||||
|
|
||||||
/** Called when the NetworkCapabilities of underlying network is changed */
|
/** Called when the NetworkCapabilities of underlying network is changed */
|
||||||
public void onDefaultNetworkCapabilitiesChanged(@NonNull NetworkCapabilities nc) {
|
public void onDefaultNetworkCapabilitiesChanged(@NonNull NetworkCapabilities nc) {
|
||||||
|
mEventChanges.log("[UnderlyingNW] Cap changed from "
|
||||||
|
+ mUnderlyingNetworkCapabilities + " to " + nc);
|
||||||
final NetworkCapabilities oldNc = mUnderlyingNetworkCapabilities;
|
final NetworkCapabilities oldNc = mUnderlyingNetworkCapabilities;
|
||||||
mUnderlyingNetworkCapabilities = nc;
|
mUnderlyingNetworkCapabilities = nc;
|
||||||
if (oldNc == null) {
|
if (oldNc == null) {
|
||||||
@@ -3715,6 +3746,8 @@ public class Vpn {
|
|||||||
|
|
||||||
/** Called when the LinkProperties of underlying network is changed */
|
/** Called when the LinkProperties of underlying network is changed */
|
||||||
public void onDefaultNetworkLinkPropertiesChanged(@NonNull LinkProperties lp) {
|
public void onDefaultNetworkLinkPropertiesChanged(@NonNull LinkProperties lp) {
|
||||||
|
mEventChanges.log("[UnderlyingNW] Lp changed from "
|
||||||
|
+ mUnderlyingLinkProperties + " to " + lp);
|
||||||
mUnderlyingLinkProperties = lp;
|
mUnderlyingLinkProperties = lp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4719,7 +4752,7 @@ public class Vpn {
|
|||||||
// TODO(b/230548427): Remove SDK check once VPN related stuff are decoupled from
|
// TODO(b/230548427): Remove SDK check once VPN related stuff are decoupled from
|
||||||
// ConnectivityServiceTest.
|
// ConnectivityServiceTest.
|
||||||
if (SdkLevel.isAtLeastT()) {
|
if (SdkLevel.isAtLeastT()) {
|
||||||
mVpnManagerEvents.log(packageName + " stopped");
|
mEventChanges.log("[VMEvent] " + packageName + " stopped");
|
||||||
sendEventToVpnManagerApp(intent, packageName);
|
sendEventToVpnManagerApp(intent, packageName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5053,23 +5086,21 @@ public class Vpn {
|
|||||||
pw.println("NetworkCapabilities: " + mNetworkCapabilities);
|
pw.println("NetworkCapabilities: " + mNetworkCapabilities);
|
||||||
if (isIkev2VpnRunner()) {
|
if (isIkev2VpnRunner()) {
|
||||||
final IkeV2VpnRunner runner = ((IkeV2VpnRunner) mVpnRunner);
|
final IkeV2VpnRunner runner = ((IkeV2VpnRunner) mVpnRunner);
|
||||||
pw.println("Token: " + runner.mSessionKey);
|
pw.println("SessionKey: " + runner.mSessionKey);
|
||||||
pw.println("MOBIKE " + (runner.mMobikeEnabled ? "enabled" : "disabled"));
|
pw.println("MOBIKE " + (runner.mMobikeEnabled ? "enabled" : "disabled"));
|
||||||
|
pw.println("Profile: " + runner.mProfile);
|
||||||
|
pw.println("Token: " + runner.mCurrentToken);
|
||||||
if (mDataStallSuspected) pw.println("Data stall suspected");
|
if (mDataStallSuspected) pw.println("Data stall suspected");
|
||||||
if (runner.mScheduledHandleDataStallFuture != null) {
|
if (runner.mScheduledHandleDataStallFuture != null) {
|
||||||
pw.println("Reset session scheduled");
|
pw.println("Reset session scheduled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pw.println();
|
||||||
pw.println("mCachedCarrierConfigInfoPerSubId=" + mCachedCarrierConfigInfoPerSubId);
|
pw.println("mCachedCarrierConfigInfoPerSubId=" + mCachedCarrierConfigInfoPerSubId);
|
||||||
|
|
||||||
pw.println("mUnderlyNetworkChanges (most recent first):");
|
pw.println("mEventChanges (most recent first):");
|
||||||
pw.increaseIndent();
|
pw.increaseIndent();
|
||||||
mUnderlyNetworkChanges.reverseDump(pw);
|
mEventChanges.reverseDump(pw);
|
||||||
pw.decreaseIndent();
|
|
||||||
|
|
||||||
pw.println("mVpnManagerEvent (most recent first):");
|
|
||||||
pw.increaseIndent();
|
|
||||||
mVpnManagerEvents.reverseDump(pw);
|
|
||||||
pw.decreaseIndent();
|
pw.decreaseIndent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user