Show time taken by the rematch
Example log (short version) :
02-26 12:52:49.624 1751 2116 D ConnectivityService: NetReassign [22 :
101 → 100, 25 : 101 → 100, 38 : 101 → 100, 27 : 101 → 100, 32 : 101 →
100, 19 : 101 → 100, 17 : 101 → 100, 34 : 101 → 100, 36 : 101 → 100,
15 : 101 → 100, 1 : 101 → 100, 7 : 101 → 100] [c 0] [a 37] [i 2]
Example log (long version) :
02-26 14:10:32.433 3876 3979 D ConnectivityService: Rematched networks [computed 0ms] [applied 33ms] [issued 2]
02-26 14:10:32.433 3876 3979 D ConnectivityService: NetworkReassignment :
02-26 14:10:32.433 3876 3979 D ConnectivityService: 15 : null → 100
02-26 14:10:32.433 3876 3979 D ConnectivityService: 17 : null → 100
02-26 14:10:32.433 3876 3979 D ConnectivityService: 40 : null → 100
02-26 14:10:32.433 3876 3979 D ConnectivityService: 1 : null → 100
02-26 14:10:32.433 3876 3979 D ConnectivityService: 34 : null → 100
02-26 14:10:32.433 3876 3979 D ConnectivityService: 19 : null → 100
02-26 14:10:32.433 3876 3979 D ConnectivityService: 38 : null → 100
02-26 14:10:32.433 3876 3979 D ConnectivityService: 22 : null → 100
02-26 14:10:32.433 3876 3979 D ConnectivityService: 7 : null → 100
02-26 14:10:32.433 3876 3979 D ConnectivityService: 32 : null → 100
02-26 14:10:32.433 3876 3979 D ConnectivityService: 36 : null → 100
02-26 14:10:32.433 3876 3979 D ConnectivityService: 2 : null → 100
02-26 14:10:32.433 3876 3979 D ConnectivityService: 25 : null → 100
02-26 14:10:32.433 3876 3979 D ConnectivityService: 27 : null → 100
Bug: 238139913
Test: manual
Change-Id: I0f220d1f73cb9b0ddab82842e918ce8101ef1038
diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java
index f94694a..9bf7b65 100644
--- a/service/src/com/android/server/ConnectivityService.java
+++ b/service/src/com/android/server/ConnectivityService.java
@@ -8814,15 +8814,22 @@
@NonNull final Set<NetworkRequestInfo> networkRequests) {
ensureRunningOnConnectivityServiceThread();
// TODO: This may be slow, and should be optimized.
- final long now = SystemClock.elapsedRealtime();
+ final long start = SystemClock.elapsedRealtime();
final NetworkReassignment changes = computeNetworkReassignment(networkRequests);
+ final long computed = SystemClock.elapsedRealtime();
+ applyNetworkReassignment(changes, start);
+ final long applied = SystemClock.elapsedRealtime();
+ issueNetworkNeeds();
+ final long end = SystemClock.elapsedRealtime();
if (VDBG || DDBG) {
+ log(String.format("Rematched networks [computed %dms] [applied %dms] [issued %d]",
+ computed - start, applied - computed, end - applied));
log(changes.debugString());
} else if (DBG) {
- log(changes.toString()); // Shorter form, only one line of log
+ // Shorter form, only one line of log
+ log(String.format("%s [c %d] [a %d] [i %d]", changes.toString(),
+ computed - start, applied - computed, end - applied));
}
- applyNetworkReassignment(changes, now);
- issueNetworkNeeds();
}
private void applyNetworkReassignment(@NonNull final NetworkReassignment changes,