VDBG guard common verbose logging in Vcn

This change ensures that debugging logs are not fired for the most
common of cases.

Test: atest FrameworksVcnTests
Change-Id: I101d8949d5cfcf6d6cec5289ebc613c863d062e5
This commit is contained in:
Benedict Wong
2021-02-05 12:01:23 -08:00
parent 072c9b4cc4
commit 3996801c60
2 changed files with 32 additions and 12 deletions

View File

@@ -16,6 +16,7 @@
package com.android.server.vcn;
import static com.android.server.VcnManagementService.VDBG;
import android.annotation.NonNull;
import android.net.NetworkCapabilities;
@@ -225,7 +226,7 @@ public class Vcn extends Handler {
private void handleConfigUpdated(@NonNull VcnConfig config) {
// TODO: Add a dump function in VcnConfig that omits PII. Until then, use hashCode()
Slog.v(getLogTag(), String.format("Config updated: config = %s", config.hashCode()));
Slog.v(getLogTag(), "Config updated: config = " + config.hashCode());
mConfig = config;
@@ -251,17 +252,29 @@ public class Vcn extends Handler {
private void handleNetworkRequested(
@NonNull NetworkRequest request, int score, int providerId) {
if (score > getNetworkScore()) {
Slog.v(getLogTag(),
"Request already satisfied by higher-scoring (" + score + ") network from "
+ "provider " + providerId + ": " + request);
if (VDBG) {
Slog.v(
getLogTag(),
"Request already satisfied by higher-scoring ("
+ score
+ ") network from "
+ "provider "
+ providerId
+ ": "
+ request);
}
return;
}
// If preexisting VcnGatewayConnection(s) satisfy request, return
for (VcnGatewayConnectionConfig gatewayConnectionConfig : mVcnGatewayConnections.keySet()) {
if (requestSatisfiedByGatewayConnectionConfig(request, gatewayConnectionConfig)) {
Slog.v(getLogTag(),
"Request already satisfied by existing VcnGatewayConnection: " + request);
if (VDBG) {
Slog.v(
getLogTag(),
"Request already satisfied by existing VcnGatewayConnection: "
+ request);
}
return;
}
}
@@ -308,7 +321,7 @@ public class Vcn extends Handler {
}
private String getLogTag() {
return String.format("%s [%d]", TAG, mSubscriptionGroup.hashCode());
return TAG + " [" + mSubscriptionGroup.hashCode() + "]";
}
/** Retrieves the network score for a VCN Network */

View File

@@ -16,6 +16,8 @@
package com.android.server.vcn;
import static com.android.server.VcnManagementService.VDBG;
import android.annotation.NonNull;
import android.content.Context;
import android.net.NetworkProvider;
@@ -83,11 +85,16 @@ public class VcnNetworkProvider extends NetworkProvider {
@Override
public void onNetworkRequested(@NonNull NetworkRequest request, int score, int providerId) {
Slog.v(
TAG,
String.format(
"Network requested: Request = %s, score = %d, providerId = %d",
request, score, providerId));
if (VDBG) {
Slog.v(
TAG,
"Network requested: Request = "
+ request
+ ", score = "
+ score
+ ", providerId = "
+ providerId);
}
final NetworkRequestEntry entry = new NetworkRequestEntry(request, score, providerId);