Merge "Add extra logging" am: 47b98a2d38
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2056510 Change-Id: I78420f3608389fa69a46f44e98f93a7ee0f01f26 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -57,9 +57,11 @@ public final class VcnCellUnderlyingNetworkTemplate extends VcnUnderlyingNetwork
|
|||||||
@NonNull private final Set<Integer> mAllowedSpecificCarrierIds;
|
@NonNull private final Set<Integer> mAllowedSpecificCarrierIds;
|
||||||
|
|
||||||
private static final String ROAMING_MATCH_KEY = "mRoamingMatchCriteria";
|
private static final String ROAMING_MATCH_KEY = "mRoamingMatchCriteria";
|
||||||
|
private static final int DEFAULT_ROAMING_MATCH_CRITERIA = MATCH_ANY;
|
||||||
private final int mRoamingMatchCriteria;
|
private final int mRoamingMatchCriteria;
|
||||||
|
|
||||||
private static final String OPPORTUNISTIC_MATCH_KEY = "mOpportunisticMatchCriteria";
|
private static final String OPPORTUNISTIC_MATCH_KEY = "mOpportunisticMatchCriteria";
|
||||||
|
private static final int DEFAULT_OPPORTUNISTIC_MATCH_CRITERIA = MATCH_ANY;
|
||||||
private final int mOpportunisticMatchCriteria;
|
private final int mOpportunisticMatchCriteria;
|
||||||
|
|
||||||
private VcnCellUnderlyingNetworkTemplate(
|
private VcnCellUnderlyingNetworkTemplate(
|
||||||
@@ -253,23 +255,31 @@ public final class VcnCellUnderlyingNetworkTemplate extends VcnUnderlyingNetwork
|
|||||||
/** @hide */
|
/** @hide */
|
||||||
@Override
|
@Override
|
||||||
void dumpTransportSpecificFields(IndentingPrintWriter pw) {
|
void dumpTransportSpecificFields(IndentingPrintWriter pw) {
|
||||||
pw.println("mAllowedNetworkPlmnIds: " + mAllowedNetworkPlmnIds.toString());
|
if (!mAllowedNetworkPlmnIds.isEmpty()) {
|
||||||
pw.println("mAllowedSpecificCarrierIds: " + mAllowedSpecificCarrierIds.toString());
|
pw.println("mAllowedNetworkPlmnIds: " + mAllowedNetworkPlmnIds);
|
||||||
pw.println("mRoamingMatchCriteria: " + getMatchCriteriaString(mRoamingMatchCriteria));
|
}
|
||||||
pw.println(
|
if (!mAllowedNetworkPlmnIds.isEmpty()) {
|
||||||
"mOpportunisticMatchCriteria: "
|
pw.println("mAllowedSpecificCarrierIds: " + mAllowedSpecificCarrierIds);
|
||||||
+ getMatchCriteriaString(mOpportunisticMatchCriteria));
|
}
|
||||||
|
if (mRoamingMatchCriteria != DEFAULT_ROAMING_MATCH_CRITERIA) {
|
||||||
|
pw.println("mRoamingMatchCriteria: " + getMatchCriteriaString(mRoamingMatchCriteria));
|
||||||
|
}
|
||||||
|
if (mOpportunisticMatchCriteria != DEFAULT_OPPORTUNISTIC_MATCH_CRITERIA) {
|
||||||
|
pw.println(
|
||||||
|
"mOpportunisticMatchCriteria: "
|
||||||
|
+ getMatchCriteriaString(mOpportunisticMatchCriteria));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This class is used to incrementally build VcnCellUnderlyingNetworkTemplate objects. */
|
/** This class is used to incrementally build VcnCellUnderlyingNetworkTemplate objects. */
|
||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
private int mMeteredMatchCriteria = MATCH_ANY;
|
private int mMeteredMatchCriteria = DEFAULT_METERED_MATCH_CRITERIA;
|
||||||
|
|
||||||
@NonNull private final Set<String> mAllowedNetworkPlmnIds = new ArraySet<>();
|
@NonNull private final Set<String> mAllowedNetworkPlmnIds = new ArraySet<>();
|
||||||
@NonNull private final Set<Integer> mAllowedSpecificCarrierIds = new ArraySet<>();
|
@NonNull private final Set<Integer> mAllowedSpecificCarrierIds = new ArraySet<>();
|
||||||
|
|
||||||
private int mRoamingMatchCriteria = MATCH_ANY;
|
private int mRoamingMatchCriteria = DEFAULT_ROAMING_MATCH_CRITERIA;
|
||||||
private int mOpportunisticMatchCriteria = MATCH_ANY;
|
private int mOpportunisticMatchCriteria = DEFAULT_OPPORTUNISTIC_MATCH_CRITERIA;
|
||||||
|
|
||||||
private int mMinEntryUpstreamBandwidthKbps = DEFAULT_MIN_BANDWIDTH_KBPS;
|
private int mMinEntryUpstreamBandwidthKbps = DEFAULT_MIN_BANDWIDTH_KBPS;
|
||||||
private int mMinExitUpstreamBandwidthKbps = DEFAULT_MIN_BANDWIDTH_KBPS;
|
private int mMinExitUpstreamBandwidthKbps = DEFAULT_MIN_BANDWIDTH_KBPS;
|
||||||
|
|||||||
@@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package android.net.vcn;
|
package android.net.vcn;
|
||||||
|
|
||||||
import static android.net.vcn.VcnUnderlyingNetworkTemplate.MATCH_ANY;
|
|
||||||
|
|
||||||
import static com.android.internal.annotations.VisibleForTesting.Visibility;
|
import static com.android.internal.annotations.VisibleForTesting.Visibility;
|
||||||
|
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
@@ -88,6 +86,9 @@ public abstract class VcnUnderlyingNetworkTemplate {
|
|||||||
/** @hide */
|
/** @hide */
|
||||||
static final String METERED_MATCH_KEY = "mMeteredMatchCriteria";
|
static final String METERED_MATCH_KEY = "mMeteredMatchCriteria";
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
static final int DEFAULT_METERED_MATCH_CRITERIA = MATCH_ANY;
|
||||||
|
|
||||||
private final int mMeteredMatchCriteria;
|
private final int mMeteredMatchCriteria;
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -237,11 +238,21 @@ public abstract class VcnUnderlyingNetworkTemplate {
|
|||||||
pw.println(this.getClass().getSimpleName() + ":");
|
pw.println(this.getClass().getSimpleName() + ":");
|
||||||
pw.increaseIndent();
|
pw.increaseIndent();
|
||||||
|
|
||||||
pw.println("mMeteredMatchCriteria: " + getMatchCriteriaString(mMeteredMatchCriteria));
|
if (mMeteredMatchCriteria != DEFAULT_METERED_MATCH_CRITERIA) {
|
||||||
pw.println("mMinEntryUpstreamBandwidthKbps: " + mMinEntryUpstreamBandwidthKbps);
|
pw.println("mMeteredMatchCriteria: " + getMatchCriteriaString(mMeteredMatchCriteria));
|
||||||
pw.println("mMinExitUpstreamBandwidthKbps: " + mMinExitUpstreamBandwidthKbps);
|
}
|
||||||
pw.println("mMinEntryDownstreamBandwidthKbps: " + mMinEntryDownstreamBandwidthKbps);
|
if (mMinEntryUpstreamBandwidthKbps != DEFAULT_MIN_BANDWIDTH_KBPS) {
|
||||||
pw.println("mMinExitDownstreamBandwidthKbps: " + mMinExitDownstreamBandwidthKbps);
|
pw.println("mMinEntryUpstreamBandwidthKbps: " + mMinEntryUpstreamBandwidthKbps);
|
||||||
|
}
|
||||||
|
if (mMinExitUpstreamBandwidthKbps != DEFAULT_MIN_BANDWIDTH_KBPS) {
|
||||||
|
pw.println("mMinExitUpstreamBandwidthKbps: " + mMinExitUpstreamBandwidthKbps);
|
||||||
|
}
|
||||||
|
if (mMinEntryDownstreamBandwidthKbps != DEFAULT_MIN_BANDWIDTH_KBPS) {
|
||||||
|
pw.println("mMinEntryDownstreamBandwidthKbps: " + mMinEntryDownstreamBandwidthKbps);
|
||||||
|
}
|
||||||
|
if (mMinExitDownstreamBandwidthKbps != DEFAULT_MIN_BANDWIDTH_KBPS) {
|
||||||
|
pw.println("mMinExitDownstreamBandwidthKbps: " + mMinExitDownstreamBandwidthKbps);
|
||||||
|
}
|
||||||
dumpTransportSpecificFields(pw);
|
dumpTransportSpecificFields(pw);
|
||||||
|
|
||||||
pw.decreaseIndent();
|
pw.decreaseIndent();
|
||||||
|
|||||||
@@ -147,7 +147,9 @@ public final class VcnWifiUnderlyingNetworkTemplate extends VcnUnderlyingNetwork
|
|||||||
/** @hide */
|
/** @hide */
|
||||||
@Override
|
@Override
|
||||||
void dumpTransportSpecificFields(IndentingPrintWriter pw) {
|
void dumpTransportSpecificFields(IndentingPrintWriter pw) {
|
||||||
pw.println("mSsids: " + mSsids);
|
if (!mSsids.isEmpty()) {
|
||||||
|
pw.println("mSsids: " + mSsids);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class VcnManagementService extends IVcnManagementService.Stub {
|
public class VcnManagementService extends IVcnManagementService.Stub {
|
||||||
@NonNull private static final String TAG = VcnManagementService.class.getSimpleName();
|
@NonNull private static final String TAG = VcnManagementService.class.getSimpleName();
|
||||||
private static final long DUMP_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(5);
|
private static final long DUMP_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(5);
|
||||||
private static final int LOCAL_LOG_LINE_COUNT = 128;
|
private static final int LOCAL_LOG_LINE_COUNT = 512;
|
||||||
|
|
||||||
// Public for use in all other VCN classes
|
// Public for use in all other VCN classes
|
||||||
@NonNull public static final LocalLog LOCAL_LOG = new LocalLog(LOCAL_LOG_LINE_COUNT);
|
@NonNull public static final LocalLog LOCAL_LOG = new LocalLog(LOCAL_LOG_LINE_COUNT);
|
||||||
@@ -456,7 +456,7 @@ public class VcnManagementService extends IVcnManagementService.Stub {
|
|||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
final TelephonySubscriptionSnapshot oldSnapshot = mLastSnapshot;
|
final TelephonySubscriptionSnapshot oldSnapshot = mLastSnapshot;
|
||||||
mLastSnapshot = snapshot;
|
mLastSnapshot = snapshot;
|
||||||
logDbg("new snapshot: " + mLastSnapshot);
|
logInfo("new snapshot: " + mLastSnapshot);
|
||||||
|
|
||||||
// Start any VCN instances as necessary
|
// Start any VCN instances as necessary
|
||||||
for (Entry<ParcelUuid, VcnConfig> entry : mConfigs.entrySet()) {
|
for (Entry<ParcelUuid, VcnConfig> entry : mConfigs.entrySet()) {
|
||||||
@@ -522,6 +522,8 @@ public class VcnManagementService extends IVcnManagementService.Stub {
|
|||||||
|
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
private void stopVcnLocked(@NonNull ParcelUuid uuidToTeardown) {
|
private void stopVcnLocked(@NonNull ParcelUuid uuidToTeardown) {
|
||||||
|
logInfo("Stopping VCN config for subGrp: " + uuidToTeardown);
|
||||||
|
|
||||||
// Remove in 2 steps. Make sure teardownAsync is triggered before removing from the map.
|
// Remove in 2 steps. Make sure teardownAsync is triggered before removing from the map.
|
||||||
final Vcn vcnToTeardown = mVcns.get(uuidToTeardown);
|
final Vcn vcnToTeardown = mVcns.get(uuidToTeardown);
|
||||||
if (vcnToTeardown == null) {
|
if (vcnToTeardown == null) {
|
||||||
@@ -567,7 +569,7 @@ public class VcnManagementService extends IVcnManagementService.Stub {
|
|||||||
|
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
private void startVcnLocked(@NonNull ParcelUuid subscriptionGroup, @NonNull VcnConfig config) {
|
private void startVcnLocked(@NonNull ParcelUuid subscriptionGroup, @NonNull VcnConfig config) {
|
||||||
logDbg("Starting VCN config for subGrp: " + subscriptionGroup);
|
logInfo("Starting VCN config for subGrp: " + subscriptionGroup);
|
||||||
|
|
||||||
// TODO(b/193687515): Support multiple VCNs active at the same time
|
// TODO(b/193687515): Support multiple VCNs active at the same time
|
||||||
if (!mVcns.isEmpty()) {
|
if (!mVcns.isEmpty()) {
|
||||||
@@ -626,7 +628,7 @@ public class VcnManagementService extends IVcnManagementService.Stub {
|
|||||||
if (!config.getProvisioningPackageName().equals(opPkgName)) {
|
if (!config.getProvisioningPackageName().equals(opPkgName)) {
|
||||||
throw new IllegalArgumentException("Mismatched caller and VcnConfig creator");
|
throw new IllegalArgumentException("Mismatched caller and VcnConfig creator");
|
||||||
}
|
}
|
||||||
logDbg("VCN config updated for subGrp: " + subscriptionGroup);
|
logInfo("VCN config updated for subGrp: " + subscriptionGroup);
|
||||||
|
|
||||||
mContext.getSystemService(AppOpsManager.class)
|
mContext.getSystemService(AppOpsManager.class)
|
||||||
.checkPackage(mDeps.getBinderCallingUid(), config.getProvisioningPackageName());
|
.checkPackage(mDeps.getBinderCallingUid(), config.getProvisioningPackageName());
|
||||||
@@ -652,7 +654,7 @@ public class VcnManagementService extends IVcnManagementService.Stub {
|
|||||||
public void clearVcnConfig(@NonNull ParcelUuid subscriptionGroup, @NonNull String opPkgName) {
|
public void clearVcnConfig(@NonNull ParcelUuid subscriptionGroup, @NonNull String opPkgName) {
|
||||||
requireNonNull(subscriptionGroup, "subscriptionGroup was null");
|
requireNonNull(subscriptionGroup, "subscriptionGroup was null");
|
||||||
requireNonNull(opPkgName, "opPkgName was null");
|
requireNonNull(opPkgName, "opPkgName was null");
|
||||||
logDbg("VCN config cleared for subGrp: " + subscriptionGroup);
|
logInfo("VCN config cleared for subGrp: " + subscriptionGroup);
|
||||||
|
|
||||||
mContext.getSystemService(AppOpsManager.class)
|
mContext.getSystemService(AppOpsManager.class)
|
||||||
.checkPackage(mDeps.getBinderCallingUid(), opPkgName);
|
.checkPackage(mDeps.getBinderCallingUid(), opPkgName);
|
||||||
@@ -1050,24 +1052,34 @@ public class VcnManagementService extends IVcnManagementService.Stub {
|
|||||||
Slog.d(TAG, msg, tr);
|
Slog.d(TAG, msg, tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void logInfo(String msg) {
|
||||||
|
Slog.i(TAG, msg);
|
||||||
|
LOCAL_LOG.log("[INFO] [" + TAG + "] " + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logInfo(String msg, Throwable tr) {
|
||||||
|
Slog.i(TAG, msg, tr);
|
||||||
|
LOCAL_LOG.log("[INFO] [" + TAG + "] " + msg + tr);
|
||||||
|
}
|
||||||
|
|
||||||
private void logErr(String msg) {
|
private void logErr(String msg) {
|
||||||
Slog.e(TAG, msg);
|
Slog.e(TAG, msg);
|
||||||
LOCAL_LOG.log(TAG + " ERR: " + msg);
|
LOCAL_LOG.log("[ERR] [" + TAG + "] " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logErr(String msg, Throwable tr) {
|
private void logErr(String msg, Throwable tr) {
|
||||||
Slog.e(TAG, msg, tr);
|
Slog.e(TAG, msg, tr);
|
||||||
LOCAL_LOG.log(TAG + " ERR: " + msg + tr);
|
LOCAL_LOG.log("[ERR ] [" + TAG + "] " + msg + tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logWtf(String msg) {
|
private void logWtf(String msg) {
|
||||||
Slog.wtf(TAG, msg);
|
Slog.wtf(TAG, msg);
|
||||||
LOCAL_LOG.log(TAG + " WTF: " + msg);
|
LOCAL_LOG.log("[WTF] [" + TAG + "] " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logWtf(String msg, Throwable tr) {
|
private void logWtf(String msg, Throwable tr) {
|
||||||
Slog.wtf(TAG, msg, tr);
|
Slog.wtf(TAG, msg, tr);
|
||||||
LOCAL_LOG.log(TAG + " WTF: " + msg + tr);
|
LOCAL_LOG.log("[WTF ] [" + TAG + "] " + msg + tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -341,6 +341,9 @@ public class Vcn extends Handler {
|
|||||||
if (gatewayConnection == null) {
|
if (gatewayConnection == null) {
|
||||||
logWtf("Found gatewayConnectionConfig without GatewayConnection");
|
logWtf("Found gatewayConnectionConfig without GatewayConnection");
|
||||||
} else {
|
} else {
|
||||||
|
logInfo(
|
||||||
|
"Config updated, restarting gateway "
|
||||||
|
+ gatewayConnection.getLogPrefix());
|
||||||
gatewayConnection.teardownAsynchronously();
|
gatewayConnection.teardownAsynchronously();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -397,7 +400,7 @@ public class Vcn extends Handler {
|
|||||||
// If preexisting VcnGatewayConnection(s) satisfy request, return
|
// If preexisting VcnGatewayConnection(s) satisfy request, return
|
||||||
for (VcnGatewayConnectionConfig gatewayConnectionConfig : mVcnGatewayConnections.keySet()) {
|
for (VcnGatewayConnectionConfig gatewayConnectionConfig : mVcnGatewayConnections.keySet()) {
|
||||||
if (isRequestSatisfiedByGatewayConnectionConfig(request, gatewayConnectionConfig)) {
|
if (isRequestSatisfiedByGatewayConnectionConfig(request, gatewayConnectionConfig)) {
|
||||||
logDbg("Request already satisfied by existing VcnGatewayConnection: " + request);
|
logVdbg("Request already satisfied by existing VcnGatewayConnection: " + request);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -407,8 +410,6 @@ public class Vcn extends Handler {
|
|||||||
for (VcnGatewayConnectionConfig gatewayConnectionConfig :
|
for (VcnGatewayConnectionConfig gatewayConnectionConfig :
|
||||||
mConfig.getGatewayConnectionConfigs()) {
|
mConfig.getGatewayConnectionConfigs()) {
|
||||||
if (isRequestSatisfiedByGatewayConnectionConfig(request, gatewayConnectionConfig)) {
|
if (isRequestSatisfiedByGatewayConnectionConfig(request, gatewayConnectionConfig)) {
|
||||||
logDbg("Bringing up new VcnGatewayConnection for request " + request);
|
|
||||||
|
|
||||||
if (getExposedCapabilitiesForMobileDataState(gatewayConnectionConfig).isEmpty()) {
|
if (getExposedCapabilitiesForMobileDataState(gatewayConnectionConfig).isEmpty()) {
|
||||||
// Skip; this network does not provide any services if mobile data is disabled.
|
// Skip; this network does not provide any services if mobile data is disabled.
|
||||||
continue;
|
continue;
|
||||||
@@ -424,6 +425,7 @@ public class Vcn extends Handler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logInfo("Bringing up new VcnGatewayConnection for request " + request);
|
||||||
final VcnGatewayConnection vcnGatewayConnection =
|
final VcnGatewayConnection vcnGatewayConnection =
|
||||||
mDeps.newVcnGatewayConnection(
|
mDeps.newVcnGatewayConnection(
|
||||||
mVcnContext,
|
mVcnContext,
|
||||||
@@ -455,7 +457,7 @@ public class Vcn extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleGatewayConnectionQuit(VcnGatewayConnectionConfig config) {
|
private void handleGatewayConnectionQuit(VcnGatewayConnectionConfig config) {
|
||||||
logDbg("VcnGatewayConnection quit: " + config);
|
logInfo("VcnGatewayConnection quit: " + config);
|
||||||
mVcnGatewayConnections.remove(config);
|
mVcnGatewayConnections.remove(config);
|
||||||
|
|
||||||
// Trigger a re-evaluation of all NetworkRequests (to make sure any that can be satisfied
|
// Trigger a re-evaluation of all NetworkRequests (to make sure any that can be satisfied
|
||||||
@@ -534,7 +536,7 @@ public class Vcn extends Handler {
|
|||||||
// Trigger re-evaluation of all requests; mobile data state impacts supported caps.
|
// Trigger re-evaluation of all requests; mobile data state impacts supported caps.
|
||||||
mVcnContext.getVcnNetworkProvider().resendAllRequests(mRequestListener);
|
mVcnContext.getVcnNetworkProvider().resendAllRequests(mRequestListener);
|
||||||
|
|
||||||
logDbg("Mobile data " + (mIsMobileDataEnabled ? "enabled" : "disabled"));
|
logInfo("Mobile data " + (mIsMobileDataEnabled ? "enabled" : "disabled"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,11 +571,11 @@ public class Vcn extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getLogPrefix() {
|
private String getLogPrefix() {
|
||||||
return "["
|
return "("
|
||||||
+ LogUtils.getHashedSubscriptionGroup(mSubscriptionGroup)
|
+ LogUtils.getHashedSubscriptionGroup(mSubscriptionGroup)
|
||||||
+ "-"
|
+ "-"
|
||||||
+ System.identityHashCode(this)
|
+ System.identityHashCode(this)
|
||||||
+ "] ";
|
+ ") ";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logVdbg(String msg) {
|
private void logVdbg(String msg) {
|
||||||
|
|||||||
@@ -732,14 +732,11 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
logDbg("Triggering async teardown");
|
logDbg("Triggering async teardown");
|
||||||
sendDisconnectRequestedAndAcquireWakelock(
|
sendDisconnectRequestedAndAcquireWakelock(
|
||||||
DISCONNECT_REASON_TEARDOWN, true /* shouldQuit */);
|
DISCONNECT_REASON_TEARDOWN, true /* shouldQuit */);
|
||||||
|
|
||||||
// TODO: Notify VcnInstance (via callbacks) of permanent teardown of this tunnel, since this
|
|
||||||
// is also called asynchronously when a NetworkAgent becomes unwanted
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onQuitting() {
|
protected void onQuitting() {
|
||||||
logDbg("Quitting VcnGatewayConnection");
|
logInfo("Quitting VcnGatewayConnection");
|
||||||
|
|
||||||
if (mNetworkAgent != null) {
|
if (mNetworkAgent != null) {
|
||||||
logWtf("NetworkAgent was non-null in onQuitting");
|
logWtf("NetworkAgent was non-null in onQuitting");
|
||||||
@@ -794,7 +791,7 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
// TODO(b/180132994): explore safely removing this Thread check
|
// TODO(b/180132994): explore safely removing this Thread check
|
||||||
mVcnContext.ensureRunningOnLooperThread();
|
mVcnContext.ensureRunningOnLooperThread();
|
||||||
|
|
||||||
logDbg(
|
logInfo(
|
||||||
"Selected underlying network changed: "
|
"Selected underlying network changed: "
|
||||||
+ (underlying == null ? null : underlying.network));
|
+ (underlying == null ? null : underlying.network));
|
||||||
|
|
||||||
@@ -1335,7 +1332,7 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
protected void handleDisconnectRequested(EventDisconnectRequestedInfo info) {
|
protected void handleDisconnectRequested(EventDisconnectRequestedInfo info) {
|
||||||
// TODO(b/180526152): notify VcnStatusCallback for Network loss
|
// TODO(b/180526152): notify VcnStatusCallback for Network loss
|
||||||
|
|
||||||
logDbg("Tearing down. Cause: " + info.reason);
|
logInfo("Tearing down. Cause: " + info.reason + "; quitting = " + info.shouldQuit);
|
||||||
if (info.shouldQuit) {
|
if (info.shouldQuit) {
|
||||||
mIsQuitting.setTrue();
|
mIsQuitting.setTrue();
|
||||||
}
|
}
|
||||||
@@ -1353,7 +1350,7 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
|
|
||||||
protected void handleSafeModeTimeoutExceeded() {
|
protected void handleSafeModeTimeoutExceeded() {
|
||||||
mSafeModeTimeoutAlarm = null;
|
mSafeModeTimeoutAlarm = null;
|
||||||
logDbg("Entering safe mode after timeout exceeded");
|
logInfo("Entering safe mode after timeout exceeded");
|
||||||
|
|
||||||
// Connectivity for this GatewayConnection is broken; tear down the Network.
|
// Connectivity for this GatewayConnection is broken; tear down the Network.
|
||||||
teardownNetwork();
|
teardownNetwork();
|
||||||
@@ -1362,7 +1359,7 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void logUnexpectedEvent(int what) {
|
protected void logUnexpectedEvent(int what) {
|
||||||
logDbg(
|
logVdbg(
|
||||||
"Unexpected event code "
|
"Unexpected event code "
|
||||||
+ what
|
+ what
|
||||||
+ " in state "
|
+ " in state "
|
||||||
@@ -1672,7 +1669,7 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logDbg("NetworkAgent was unwanted");
|
logInfo("NetworkAgent was unwanted");
|
||||||
teardownAsynchronously();
|
teardownAsynchronously();
|
||||||
} /* networkUnwantedCallback */,
|
} /* networkUnwantedCallback */,
|
||||||
(status) -> {
|
(status) -> {
|
||||||
@@ -1748,7 +1745,7 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
tunnelIface, IpSecManager.DIRECTION_FWD, transform);
|
tunnelIface, IpSecManager.DIRECTION_FWD, transform);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logDbg("Transform application failed for network " + token, e);
|
logInfo("Transform application failed for network " + token, e);
|
||||||
sessionLost(token, e);
|
sessionLost(token, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1782,7 +1779,7 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
tunnelIface.removeAddress(address.getAddress(), address.getPrefixLength());
|
tunnelIface.removeAddress(address.getAddress(), address.getPrefixLength());
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logDbg("Adding address to tunnel failed for token " + token, e);
|
logInfo("Adding address to tunnel failed for token " + token, e);
|
||||||
sessionLost(token, e);
|
sessionLost(token, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1862,7 +1859,7 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleMigrationCompleted(EventMigrationCompletedInfo migrationCompletedInfo) {
|
private void handleMigrationCompleted(EventMigrationCompletedInfo migrationCompletedInfo) {
|
||||||
logDbg("Migration completed: " + mUnderlying.network);
|
logInfo("Migration completed: " + mUnderlying.network);
|
||||||
|
|
||||||
applyTransform(
|
applyTransform(
|
||||||
mCurrentToken,
|
mCurrentToken,
|
||||||
@@ -1890,7 +1887,7 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
mUnderlying = ((EventUnderlyingNetworkChangedInfo) msg.obj).newUnderlying;
|
mUnderlying = ((EventUnderlyingNetworkChangedInfo) msg.obj).newUnderlying;
|
||||||
|
|
||||||
if (mUnderlying == null) {
|
if (mUnderlying == null) {
|
||||||
logDbg("Underlying network lost");
|
logInfo("Underlying network lost");
|
||||||
|
|
||||||
// Ignored for now; a new network may be coming up. If none does, the delayed
|
// Ignored for now; a new network may be coming up. If none does, the delayed
|
||||||
// NETWORK_LOST disconnect will be fired, and tear down the session + network.
|
// NETWORK_LOST disconnect will be fired, and tear down the session + network.
|
||||||
@@ -1900,7 +1897,7 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
// mUnderlying assumed non-null, given check above.
|
// mUnderlying assumed non-null, given check above.
|
||||||
// If network changed, migrate. Otherwise, update any existing networkAgent.
|
// If network changed, migrate. Otherwise, update any existing networkAgent.
|
||||||
if (oldUnderlying == null || !oldUnderlying.network.equals(mUnderlying.network)) {
|
if (oldUnderlying == null || !oldUnderlying.network.equals(mUnderlying.network)) {
|
||||||
logDbg("Migrating to new network: " + mUnderlying.network);
|
logInfo("Migrating to new network: " + mUnderlying.network);
|
||||||
mIkeSession.setNetwork(mUnderlying.network);
|
mIkeSession.setNetwork(mUnderlying.network);
|
||||||
} else {
|
} else {
|
||||||
// oldUnderlying is non-null & underlying network itself has not changed
|
// oldUnderlying is non-null & underlying network itself has not changed
|
||||||
@@ -2168,13 +2165,13 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClosedExceptionally(@NonNull IkeException exception) {
|
public void onClosedExceptionally(@NonNull IkeException exception) {
|
||||||
logDbg("IkeClosedExceptionally for token " + mToken, exception);
|
logInfo("IkeClosedExceptionally for token " + mToken, exception);
|
||||||
sessionClosed(mToken, exception);
|
sessionClosed(mToken, exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(@NonNull IkeProtocolException exception) {
|
public void onError(@NonNull IkeProtocolException exception) {
|
||||||
logDbg("IkeError for token " + mToken, exception);
|
logInfo("IkeError for token " + mToken, exception);
|
||||||
// Non-fatal, log and continue.
|
// Non-fatal, log and continue.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2208,7 +2205,7 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClosedExceptionally(@NonNull IkeException exception) {
|
public void onClosedExceptionally(@NonNull IkeException exception) {
|
||||||
logDbg("ChildClosedExceptionally for token " + mToken, exception);
|
logInfo("ChildClosedExceptionally for token " + mToken, exception);
|
||||||
sessionLost(mToken, exception);
|
sessionLost(mToken, exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2234,14 +2231,19 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getLogPrefix() {
|
// Used in Vcn.java, but must be public for mockito to mock this.
|
||||||
return "["
|
public String getLogPrefix() {
|
||||||
|
return "("
|
||||||
+ LogUtils.getHashedSubscriptionGroup(mSubscriptionGroup)
|
+ LogUtils.getHashedSubscriptionGroup(mSubscriptionGroup)
|
||||||
+ "-"
|
+ "-"
|
||||||
+ mConnectionConfig.getGatewayConnectionName()
|
+ mConnectionConfig.getGatewayConnectionName()
|
||||||
+ "-"
|
+ "-"
|
||||||
+ System.identityHashCode(this)
|
+ System.identityHashCode(this)
|
||||||
+ "] ";
|
+ ") ";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getTagLogPrefix() {
|
||||||
|
return "[ " + TAG + " " + getLogPrefix() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logVdbg(String msg) {
|
private void logVdbg(String msg) {
|
||||||
@@ -2258,34 +2260,44 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
Slog.d(TAG, getLogPrefix() + msg, tr);
|
Slog.d(TAG, getLogPrefix() + msg, tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void logInfo(String msg) {
|
||||||
|
Slog.i(TAG, getLogPrefix() + msg);
|
||||||
|
LOCAL_LOG.log("[INFO] " + getTagLogPrefix() + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logInfo(String msg, Throwable tr) {
|
||||||
|
Slog.i(TAG, getLogPrefix() + msg, tr);
|
||||||
|
LOCAL_LOG.log("[INFO] " + getTagLogPrefix() + msg + tr);
|
||||||
|
}
|
||||||
|
|
||||||
private void logWarn(String msg) {
|
private void logWarn(String msg) {
|
||||||
Slog.w(TAG, getLogPrefix() + msg);
|
Slog.w(TAG, getLogPrefix() + msg);
|
||||||
LOCAL_LOG.log(getLogPrefix() + "WARN: " + msg);
|
LOCAL_LOG.log("[WARN] " + getTagLogPrefix() + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logWarn(String msg, Throwable tr) {
|
private void logWarn(String msg, Throwable tr) {
|
||||||
Slog.w(TAG, getLogPrefix() + msg, tr);
|
Slog.w(TAG, getLogPrefix() + msg, tr);
|
||||||
LOCAL_LOG.log(getLogPrefix() + "WARN: " + msg + tr);
|
LOCAL_LOG.log("[WARN] " + getTagLogPrefix() + msg + tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logErr(String msg) {
|
private void logErr(String msg) {
|
||||||
Slog.e(TAG, getLogPrefix() + msg);
|
Slog.e(TAG, getLogPrefix() + msg);
|
||||||
LOCAL_LOG.log(getLogPrefix() + "ERR: " + msg);
|
LOCAL_LOG.log("[ERR ] " + getTagLogPrefix() + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logErr(String msg, Throwable tr) {
|
private void logErr(String msg, Throwable tr) {
|
||||||
Slog.e(TAG, getLogPrefix() + msg, tr);
|
Slog.e(TAG, getLogPrefix() + msg, tr);
|
||||||
LOCAL_LOG.log(getLogPrefix() + "ERR: " + msg + tr);
|
LOCAL_LOG.log("[ERR ] " + getTagLogPrefix() + msg + tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logWtf(String msg) {
|
private void logWtf(String msg) {
|
||||||
Slog.wtf(TAG, getLogPrefix() + msg);
|
Slog.wtf(TAG, getLogPrefix() + msg);
|
||||||
LOCAL_LOG.log(getLogPrefix() + "WTF: " + msg);
|
LOCAL_LOG.log("[WTF ] " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logWtf(String msg, Throwable tr) {
|
private void logWtf(String msg, Throwable tr) {
|
||||||
Slog.wtf(TAG, getLogPrefix() + msg, tr);
|
Slog.wtf(TAG, getLogPrefix() + msg, tr);
|
||||||
LOCAL_LOG.log(getLogPrefix() + "WTF: " + msg + tr);
|
LOCAL_LOG.log("[WTF ] " + msg + tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import com.android.internal.annotations.VisibleForTesting;
|
|||||||
import com.android.internal.util.IndentingPrintWriter;
|
import com.android.internal.util.IndentingPrintWriter;
|
||||||
import com.android.server.vcn.TelephonySubscriptionTracker.TelephonySubscriptionSnapshot;
|
import com.android.server.vcn.TelephonySubscriptionTracker.TelephonySubscriptionSnapshot;
|
||||||
import com.android.server.vcn.VcnContext;
|
import com.android.server.vcn.VcnContext;
|
||||||
|
import com.android.server.vcn.util.LogUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -368,6 +369,18 @@ public class UnderlyingNetworkController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String allNetworkPriorities = "";
|
||||||
|
for (UnderlyingNetworkRecord record : sorted) {
|
||||||
|
if (!allNetworkPriorities.isEmpty()) {
|
||||||
|
allNetworkPriorities += ", ";
|
||||||
|
}
|
||||||
|
allNetworkPriorities += record.network + ": " + record.getPriorityClass();
|
||||||
|
}
|
||||||
|
logInfo(
|
||||||
|
"Selected network changed to "
|
||||||
|
+ (candidate == null ? null : candidate.network)
|
||||||
|
+ ", selected from list: "
|
||||||
|
+ allNetworkPriorities);
|
||||||
mCurrentRecord = candidate;
|
mCurrentRecord = candidate;
|
||||||
mCb.onSelectedUnderlyingNetworkChanged(mCurrentRecord);
|
mCb.onSelectedUnderlyingNetworkChanged(mCurrentRecord);
|
||||||
}
|
}
|
||||||
@@ -478,14 +491,38 @@ public class UnderlyingNetworkController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void logWtf(String msg) {
|
private String getLogPrefix() {
|
||||||
Slog.wtf(TAG, msg);
|
return "("
|
||||||
LOCAL_LOG.log(TAG + " WTF: " + msg);
|
+ LogUtils.getHashedSubscriptionGroup(mSubscriptionGroup)
|
||||||
|
+ "-"
|
||||||
|
+ mConnectionConfig.getGatewayConnectionName()
|
||||||
|
+ "-"
|
||||||
|
+ System.identityHashCode(this)
|
||||||
|
+ ") ";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void logWtf(String msg, Throwable tr) {
|
private String getTagLogPrefix() {
|
||||||
|
return "[ " + TAG + " " + getLogPrefix() + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logInfo(String msg) {
|
||||||
|
Slog.i(TAG, getLogPrefix() + msg);
|
||||||
|
LOCAL_LOG.log("[INFO] " + getTagLogPrefix() + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logInfo(String msg, Throwable tr) {
|
||||||
|
Slog.i(TAG, getLogPrefix() + msg, tr);
|
||||||
|
LOCAL_LOG.log("[INFO] " + getTagLogPrefix() + msg + tr);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logWtf(String msg) {
|
||||||
|
Slog.wtf(TAG, msg);
|
||||||
|
LOCAL_LOG.log(TAG + "[WTF ] " + getTagLogPrefix() + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logWtf(String msg, Throwable tr) {
|
||||||
Slog.wtf(TAG, msg, tr);
|
Slog.wtf(TAG, msg, tr);
|
||||||
LOCAL_LOG.log(TAG + " WTF: " + msg + tr);
|
LOCAL_LOG.log(TAG + "[WTF ] " + getTagLogPrefix() + msg + tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Dumps the state of this record for logging and debugging purposes. */
|
/** Dumps the state of this record for logging and debugging purposes. */
|
||||||
|
|||||||
@@ -41,11 +41,15 @@ import java.util.Objects;
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public class UnderlyingNetworkRecord {
|
public class UnderlyingNetworkRecord {
|
||||||
|
private static final int PRIORITY_CLASS_INVALID = Integer.MAX_VALUE;
|
||||||
|
|
||||||
@NonNull public final Network network;
|
@NonNull public final Network network;
|
||||||
@NonNull public final NetworkCapabilities networkCapabilities;
|
@NonNull public final NetworkCapabilities networkCapabilities;
|
||||||
@NonNull public final LinkProperties linkProperties;
|
@NonNull public final LinkProperties linkProperties;
|
||||||
public final boolean isBlocked;
|
public final boolean isBlocked;
|
||||||
|
|
||||||
|
private int mPriorityClass = PRIORITY_CLASS_INVALID;
|
||||||
|
|
||||||
@VisibleForTesting(visibility = Visibility.PRIVATE)
|
@VisibleForTesting(visibility = Visibility.PRIVATE)
|
||||||
public UnderlyingNetworkRecord(
|
public UnderlyingNetworkRecord(
|
||||||
@NonNull Network network,
|
@NonNull Network network,
|
||||||
@@ -58,6 +62,34 @@ public class UnderlyingNetworkRecord {
|
|||||||
this.isBlocked = isBlocked;
|
this.isBlocked = isBlocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getOrCalculatePriorityClass(
|
||||||
|
VcnContext vcnContext,
|
||||||
|
List<VcnUnderlyingNetworkTemplate> underlyingNetworkTemplates,
|
||||||
|
ParcelUuid subscriptionGroup,
|
||||||
|
TelephonySubscriptionSnapshot snapshot,
|
||||||
|
UnderlyingNetworkRecord currentlySelected,
|
||||||
|
PersistableBundle carrierConfig) {
|
||||||
|
// Never changes after the underlying network record is created.
|
||||||
|
if (mPriorityClass == PRIORITY_CLASS_INVALID) {
|
||||||
|
mPriorityClass =
|
||||||
|
NetworkPriorityClassifier.calculatePriorityClass(
|
||||||
|
vcnContext,
|
||||||
|
this,
|
||||||
|
underlyingNetworkTemplates,
|
||||||
|
subscriptionGroup,
|
||||||
|
snapshot,
|
||||||
|
currentlySelected,
|
||||||
|
carrierConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mPriorityClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Used in UnderlyingNetworkController
|
||||||
|
int getPriorityClass() {
|
||||||
|
return mPriorityClass;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
@@ -84,18 +116,16 @@ public class UnderlyingNetworkRecord {
|
|||||||
PersistableBundle carrierConfig) {
|
PersistableBundle carrierConfig) {
|
||||||
return (left, right) -> {
|
return (left, right) -> {
|
||||||
final int leftIndex =
|
final int leftIndex =
|
||||||
NetworkPriorityClassifier.calculatePriorityClass(
|
left.getOrCalculatePriorityClass(
|
||||||
vcnContext,
|
vcnContext,
|
||||||
left,
|
|
||||||
underlyingNetworkTemplates,
|
underlyingNetworkTemplates,
|
||||||
subscriptionGroup,
|
subscriptionGroup,
|
||||||
snapshot,
|
snapshot,
|
||||||
currentlySelected,
|
currentlySelected,
|
||||||
carrierConfig);
|
carrierConfig);
|
||||||
final int rightIndex =
|
final int rightIndex =
|
||||||
NetworkPriorityClassifier.calculatePriorityClass(
|
right.getOrCalculatePriorityClass(
|
||||||
vcnContext,
|
vcnContext,
|
||||||
right,
|
|
||||||
underlyingNetworkTemplates,
|
underlyingNetworkTemplates,
|
||||||
subscriptionGroup,
|
subscriptionGroup,
|
||||||
snapshot,
|
snapshot,
|
||||||
@@ -142,16 +172,15 @@ public class UnderlyingNetworkRecord {
|
|||||||
pw.increaseIndent();
|
pw.increaseIndent();
|
||||||
|
|
||||||
final int priorityIndex =
|
final int priorityIndex =
|
||||||
NetworkPriorityClassifier.calculatePriorityClass(
|
getOrCalculatePriorityClass(
|
||||||
vcnContext,
|
vcnContext,
|
||||||
this,
|
|
||||||
underlyingNetworkTemplates,
|
underlyingNetworkTemplates,
|
||||||
subscriptionGroup,
|
subscriptionGroup,
|
||||||
snapshot,
|
snapshot,
|
||||||
currentlySelected,
|
currentlySelected,
|
||||||
carrierConfig);
|
carrierConfig);
|
||||||
|
|
||||||
pw.println("Priority index:" + priorityIndex);
|
pw.println("Priority index: " + priorityIndex);
|
||||||
pw.println("mNetwork: " + network);
|
pw.println("mNetwork: " + network);
|
||||||
pw.println("mNetworkCapabilities: " + networkCapabilities);
|
pw.println("mNetworkCapabilities: " + networkCapabilities);
|
||||||
pw.println("mLinkProperties: " + linkProperties);
|
pw.println("mLinkProperties: " + linkProperties);
|
||||||
|
|||||||
Reference in New Issue
Block a user