Merge "Add more logs into dumpsys of VPN" am: c056bd22a3
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2492459 Change-Id: I3c70356f5ce268937487d1cfb2b0e60a99f9a640 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
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 */
|
||||
public static final class Builder {
|
||||
private int mType = -1;
|
||||
|
||||
@@ -365,9 +365,8 @@ public class Vpn {
|
||||
return mVpnProfileStore;
|
||||
}
|
||||
|
||||
private static final int MAX_EVENTS_LOGS = 20;
|
||||
private final LocalLog mUnderlyNetworkChanges = new LocalLog(MAX_EVENTS_LOGS);
|
||||
private final LocalLog mVpnManagerEvents = new LocalLog(MAX_EVENTS_LOGS);
|
||||
private static final int MAX_EVENTS_LOGS = 100;
|
||||
private final LocalLog mEventChanges = new LocalLog(MAX_EVENTS_LOGS);
|
||||
|
||||
/**
|
||||
* 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,
|
||||
@NonNull final VpnProfileState profileState, @Nullable final Network underlyingNetwork,
|
||||
@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
|
||||
+ " on session " + sessionKey);
|
||||
final Intent intent = buildVpnManagerEventIntent(category, errorClass, errorCode,
|
||||
@@ -1107,6 +1106,8 @@ public class Vpn {
|
||||
mLockdownAllowlist = (mLockdown && lockdownAllowlist != null)
|
||||
? Collections.unmodifiableList(new ArrayList<>(lockdownAllowlist))
|
||||
: Collections.emptyList();
|
||||
mEventChanges.log("[LockdownAlwaysOn] Mode changed: lockdown=" + mLockdown + " alwaysOn="
|
||||
+ mAlwaysOn + " calling from " + Binder.getCallingUid());
|
||||
|
||||
if (isCurrentPreparedPackage(packageName)) {
|
||||
updateAlwaysOnNotification(mNetworkInfo.getDetailedState());
|
||||
@@ -1736,7 +1737,7 @@ public class Vpn {
|
||||
}
|
||||
|
||||
private void logUnderlyNetworkChanges(List<Network> networks) {
|
||||
mUnderlyNetworkChanges.log("Switch to "
|
||||
mEventChanges.log("[UnderlyingNW] Switch to "
|
||||
+ ((networks != null) ? TextUtils.join(", ", networks) : "null"));
|
||||
}
|
||||
|
||||
@@ -3003,6 +3004,9 @@ public class Vpn {
|
||||
@Override
|
||||
public void onCarrierConfigChanged(int slotIndex, int subId, int carrierId,
|
||||
int specificCarrierId) {
|
||||
mEventChanges.log("[CarrierConfig] Changed on slot " + slotIndex + " subId="
|
||||
+ subId + " carrerId=" + carrierId
|
||||
+ " specificCarrierId=" + specificCarrierId);
|
||||
synchronized (Vpn.this) {
|
||||
mCachedCarrierConfigInfoPerSubId.remove(subId);
|
||||
|
||||
@@ -3093,6 +3097,8 @@ public class Vpn {
|
||||
*/
|
||||
public void onIkeOpened(int token, @NonNull IkeSessionConfiguration ikeConfiguration) {
|
||||
if (!isActiveToken(token)) {
|
||||
mEventChanges.log("[IKEEvent-" + mSessionKey + "] onIkeOpened obsolete token="
|
||||
+ token);
|
||||
Log.d(TAG, "onIkeOpened called for obsolete token " + token);
|
||||
return;
|
||||
}
|
||||
@@ -3100,7 +3106,12 @@ public class Vpn {
|
||||
mMobikeEnabled =
|
||||
ikeConfiguration.isIkeExtensionEnabled(
|
||||
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(
|
||||
int token, @NonNull IkeSessionConnectionInfo ikeConnectionInfo) {
|
||||
|
||||
if (!isActiveToken(token)) {
|
||||
mEventChanges.log("[IKEEvent-" + mSessionKey
|
||||
+ "] onIkeConnectionInfoChanged obsolete token=" + token);
|
||||
Log.d(TAG, "onIkeConnectionInfoChanged called for obsolete token " + token);
|
||||
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
|
||||
// in onChildMigrated
|
||||
mIkeConnectionInfo = ikeConnectionInfo;
|
||||
@@ -3131,6 +3148,8 @@ public class Vpn {
|
||||
*/
|
||||
public void onChildOpened(int token, @NonNull ChildSessionConfiguration childConfig) {
|
||||
if (!isActiveToken(token)) {
|
||||
mEventChanges.log("[IKEEvent-" + mSessionKey
|
||||
+ "] onChildOpened 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,
|
||||
@@ -3140,7 +3159,9 @@ public class Vpn {
|
||||
// sessions are torn down via resetIkeState().
|
||||
return;
|
||||
}
|
||||
|
||||
mEventChanges.log("[IKEEvent-" + mSessionKey + "] onChildOpened token=" + token
|
||||
+ ", addr=" + TextUtils.join(", ", childConfig.getInternalAddresses())
|
||||
+ " dns=" + TextUtils.join(", ", childConfig.getInternalDnsServers()));
|
||||
try {
|
||||
final String interfaceName = mTunnelIface.getInterfaceName();
|
||||
final List<LinkAddress> internalAddresses = childConfig.getInternalAddresses();
|
||||
@@ -3237,6 +3258,8 @@ public class Vpn {
|
||||
public void onChildTransformCreated(
|
||||
int token, @NonNull IpSecTransform transform, int direction) {
|
||||
if (!isActiveToken(token)) {
|
||||
mEventChanges.log("[IKEEvent-" + mSessionKey
|
||||
+ "] onChildTransformCreated obsolete token=" + token);
|
||||
Log.d(TAG, "ChildTransformCreated for obsolete token " + token);
|
||||
|
||||
// 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().
|
||||
return;
|
||||
}
|
||||
|
||||
mEventChanges.log("[IKEEvent-" + mSessionKey
|
||||
+ "] onChildTransformCreated token=" + token + ", direction=" + direction
|
||||
+ ", transform=" + transform);
|
||||
try {
|
||||
mTunnelIface.setUnderlyingNetwork(mIkeConnectionInfo.getNetwork());
|
||||
|
||||
@@ -3271,10 +3296,14 @@ public class Vpn {
|
||||
@NonNull IpSecTransform inTransform,
|
||||
@NonNull IpSecTransform outTransform) {
|
||||
if (!isActiveToken(token)) {
|
||||
mEventChanges.log("[IKEEvent-" + mSessionKey
|
||||
+ "] onChildMigrated obsolete token=" + token);
|
||||
Log.d(TAG, "onChildMigrated for obsolete token " + token);
|
||||
return;
|
||||
}
|
||||
|
||||
mEventChanges.log("[IKEEvent-" + mSessionKey
|
||||
+ "] onChildMigrated token=" + token
|
||||
+ ", in=" + inTransform + ", out=" + outTransform);
|
||||
// The actual network of this IKE session has migrated to is
|
||||
// mIkeConnectionInfo.getNetwork() instead of mActiveNetwork because mActiveNetwork
|
||||
// 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 */
|
||||
public void onDefaultNetworkCapabilitiesChanged(@NonNull NetworkCapabilities nc) {
|
||||
mEventChanges.log("[UnderlyingNW] Cap changed from "
|
||||
+ mUnderlyingNetworkCapabilities + " to " + nc);
|
||||
final NetworkCapabilities oldNc = mUnderlyingNetworkCapabilities;
|
||||
mUnderlyingNetworkCapabilities = nc;
|
||||
if (oldNc == null) {
|
||||
@@ -3715,6 +3746,8 @@ public class Vpn {
|
||||
|
||||
/** Called when the LinkProperties of underlying network is changed */
|
||||
public void onDefaultNetworkLinkPropertiesChanged(@NonNull LinkProperties lp) {
|
||||
mEventChanges.log("[UnderlyingNW] Lp changed from "
|
||||
+ mUnderlyingLinkProperties + " to " + lp);
|
||||
mUnderlyingLinkProperties = lp;
|
||||
}
|
||||
|
||||
@@ -4719,7 +4752,7 @@ public class Vpn {
|
||||
// TODO(b/230548427): Remove SDK check once VPN related stuff are decoupled from
|
||||
// ConnectivityServiceTest.
|
||||
if (SdkLevel.isAtLeastT()) {
|
||||
mVpnManagerEvents.log(packageName + " stopped");
|
||||
mEventChanges.log("[VMEvent] " + packageName + " stopped");
|
||||
sendEventToVpnManagerApp(intent, packageName);
|
||||
}
|
||||
}
|
||||
@@ -5053,23 +5086,21 @@ public class Vpn {
|
||||
pw.println("NetworkCapabilities: " + mNetworkCapabilities);
|
||||
if (isIkev2VpnRunner()) {
|
||||
final IkeV2VpnRunner runner = ((IkeV2VpnRunner) mVpnRunner);
|
||||
pw.println("Token: " + runner.mSessionKey);
|
||||
pw.println("SessionKey: " + runner.mSessionKey);
|
||||
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 (runner.mScheduledHandleDataStallFuture != null) {
|
||||
pw.println("Reset session scheduled");
|
||||
}
|
||||
}
|
||||
pw.println();
|
||||
pw.println("mCachedCarrierConfigInfoPerSubId=" + mCachedCarrierConfigInfoPerSubId);
|
||||
|
||||
pw.println("mUnderlyNetworkChanges (most recent first):");
|
||||
pw.println("mEventChanges (most recent first):");
|
||||
pw.increaseIndent();
|
||||
mUnderlyNetworkChanges.reverseDump(pw);
|
||||
pw.decreaseIndent();
|
||||
|
||||
pw.println("mVpnManagerEvent (most recent first):");
|
||||
pw.increaseIndent();
|
||||
mVpnManagerEvents.reverseDump(pw);
|
||||
mEventChanges.reverseDump(pw);
|
||||
pw.decreaseIndent();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user