Add additional dump information for UnderlyingNetworkTracker

This change adds additional dump information to facilitate the
resolution of bug reports.

Additionally, this method cleans up dump formatting.

Bug: 188842647
Test: atest FrameworksVcnTests
Test: adb shell dumpsys vcn_management
Change-Id: I5ce7fe05eb21a89c2034079223ef44f05db2a087
This commit is contained in:
Benedict Wong
2021-05-20 17:12:47 -07:00
parent 9d92b77ad7
commit 02cb0d7b45
4 changed files with 69 additions and 33 deletions

View File

@@ -998,30 +998,18 @@ public class VcnManagementService extends IVcnManagementService.Stub {
protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
mContext.enforceCallingOrSelfPermission(DUMP, TAG);
final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " ");
final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "| ");
// Post to handler thread to prevent ConcurrentModificationExceptions, and avoid lock-hell.
mHandler.runWithScissors(() -> {
pw.println("VcnManagementService dump:");
pw.increaseIndent();
pw.println("mNetworkProvider:");
pw.increaseIndent();
mNetworkProvider.dump(pw);
pw.decreaseIndent();
pw.println();
pw.println("mTrackingNetworkCallback:");
pw.increaseIndent();
mTrackingNetworkCallback.dump(pw);
pw.decreaseIndent();
pw.println();
synchronized (mLock) {
pw.println("mLastSnapshot:");
pw.increaseIndent();
mLastSnapshot.dump(pw);
pw.decreaseIndent();
pw.println();
pw.println("mConfigs:");
@@ -1041,8 +1029,6 @@ public class VcnManagementService extends IVcnManagementService.Stub {
pw.decreaseIndent();
pw.println();
}
pw.decreaseIndent();
}, DUMP_TIMEOUT_MILLIS);
}

View File

@@ -40,6 +40,7 @@ import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager;
import android.util.ArrayMap;
import android.util.Slog;
import android.util.SparseArray;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting.Visibility;
@@ -106,6 +107,17 @@ public class UnderlyingNetworkTracker {
@VisibleForTesting(visibility = Visibility.PRIVATE)
static final int PRIORITY_ANY = Integer.MAX_VALUE;
private static final SparseArray<String> PRIORITY_TO_STRING_MAP = new SparseArray<>();
static {
PRIORITY_TO_STRING_MAP.put(
PRIORITY_OPPORTUNISTIC_CELLULAR, "PRIORITY_OPPORTUNISTIC_CELLULAR");
PRIORITY_TO_STRING_MAP.put(PRIORITY_WIFI_IN_USE, "PRIORITY_WIFI_IN_USE");
PRIORITY_TO_STRING_MAP.put(PRIORITY_WIFI_PROSPECTIVE, "PRIORITY_WIFI_PROSPECTIVE");
PRIORITY_TO_STRING_MAP.put(PRIORITY_MACRO_CELLULAR, "PRIORITY_MACRO_CELLULAR");
PRIORITY_TO_STRING_MAP.put(PRIORITY_ANY, "PRIORITY_ANY");
}
@NonNull private final VcnContext mVcnContext;
@NonNull private final ParcelUuid mSubscriptionGroup;
@NonNull private final Set<Integer> mRequiredUnderlyingNetworkCapabilities;
@@ -403,12 +415,12 @@ public class UnderlyingNetworkTracker {
}
private void reevaluateNetworks() {
TreeSet<UnderlyingNetworkRecord> sorted =
new TreeSet<>(
UnderlyingNetworkRecord.getComparator(
mSubscriptionGroup, mLastSnapshot, mCurrentRecord, mCarrierConfig));
sorted.addAll(mRouteSelectionCallback.getUnderlyingNetworks());
if (mRouteSelectionCallback == null) {
return; // UnderlyingNetworkTracker has quit.
}
TreeSet<UnderlyingNetworkRecord> sorted =
mRouteSelectionCallback.getSortedUnderlyingNetworks();
UnderlyingNetworkRecord candidate = sorted.isEmpty() ? null : sorted.first();
if (Objects.equals(mCurrentRecord, candidate)) {
return;
@@ -454,17 +466,23 @@ public class UnderlyingNetworkTracker {
private final Map<Network, UnderlyingNetworkRecord.Builder>
mUnderlyingNetworkRecordBuilders = new ArrayMap<>();
private List<UnderlyingNetworkRecord> getUnderlyingNetworks() {
final List<UnderlyingNetworkRecord> records = new ArrayList<>();
private TreeSet<UnderlyingNetworkRecord> getSortedUnderlyingNetworks() {
TreeSet<UnderlyingNetworkRecord> sorted =
new TreeSet<>(
UnderlyingNetworkRecord.getComparator(
mSubscriptionGroup,
mLastSnapshot,
mCurrentRecord,
mCarrierConfig));
for (UnderlyingNetworkRecord.Builder builder :
mUnderlyingNetworkRecordBuilders.values()) {
if (builder.isValid()) {
records.add(builder.build());
sorted.add(builder.build());
}
}
return records;
return sorted;
}
@Override
@@ -668,10 +686,21 @@ public class UnderlyingNetworkTracker {
}
/** Dumps the state of this record for logging and debugging purposes. */
public void dump(IndentingPrintWriter pw) {
private void dump(
IndentingPrintWriter pw,
ParcelUuid subscriptionGroup,
TelephonySubscriptionSnapshot snapshot,
UnderlyingNetworkRecord currentlySelected,
PersistableBundle carrierConfig) {
pw.println("UnderlyingNetworkRecord:");
pw.increaseIndent();
final int priorityClass =
calculatePriorityClass(
subscriptionGroup, snapshot, currentlySelected, carrierConfig);
pw.println(
"Priority class: " + PRIORITY_TO_STRING_MAP.get(priorityClass) + " ("
+ priorityClass + ")");
pw.println("mNetwork: " + network);
pw.println("mNetworkCapabilities: " + networkCapabilities);
pw.println("mLinkProperties: " + linkProperties);
@@ -741,6 +770,30 @@ public class UnderlyingNetworkTracker {
}
}
/** Dumps the state of this record for logging and debugging purposes. */
public void dump(IndentingPrintWriter pw) {
pw.println("UnderlyingNetworkTracker:");
pw.increaseIndent();
pw.println("Carrier WiFi Entry Threshold: " + getWifiEntryRssiThreshold(mCarrierConfig));
pw.println("Carrier WiFi Exit Threshold: " + getWifiExitRssiThreshold(mCarrierConfig));
pw.println(
"Currently selected: " + (mCurrentRecord == null ? null : mCurrentRecord.network));
pw.println("Underlying networks:");
pw.increaseIndent();
if (mRouteSelectionCallback != null) {
for (UnderlyingNetworkRecord record :
mRouteSelectionCallback.getSortedUnderlyingNetworks()) {
record.dump(pw, mSubscriptionGroup, mLastSnapshot, mCurrentRecord, mCarrierConfig);
}
}
pw.decreaseIndent();
pw.println();
pw.decreaseIndent();
}
private class VcnActiveDataSubscriptionIdListener extends TelephonyCallback
implements ActiveDataSubscriptionIdListener {
@Override

View File

@@ -557,11 +557,14 @@ public class Vcn extends Handler {
pw.println("mCurrentStatus: " + mCurrentStatus);
pw.println("mIsMobileDataEnabled: " + mIsMobileDataEnabled);
pw.println();
pw.println("mVcnGatewayConnections:");
pw.increaseIndent();
for (VcnGatewayConnection gw : mVcnGatewayConnections.values()) {
gw.dump(pw);
}
pw.decreaseIndent();
pw.println();
pw.decreaseIndent();

View File

@@ -2188,15 +2188,9 @@ public class VcnGatewayConnection extends StateMachine {
pw.println(
"mNetworkAgent.getNetwork(): "
+ (mNetworkAgent == null ? null : mNetworkAgent.getNetwork()));
pw.println();
pw.println("mUnderlying:");
pw.increaseIndent();
if (mUnderlying != null) {
mUnderlying.dump(pw);
} else {
pw.println("null");
}
pw.decreaseIndent();
mUnderlyingNetworkTracker.dump(pw);
pw.println();
pw.decreaseIndent();