Clean up + expand dumpsys output for VMS services.
Bug: 134086389
Test: atest AndroidCarApiTest CarServiceTest CarServiceUnitTest
Change-Id: I8306ae03d4b3c0f5bd54dd33ecc49de5d8389f98
diff --git a/service/src/com/android/car/VmsPublisherService.java b/service/src/com/android/car/VmsPublisherService.java
index 0c6ff64..3d9a104 100644
--- a/service/src/com/android/car/VmsPublisherService.java
+++ b/service/src/com/android/car/VmsPublisherService.java
@@ -76,7 +76,7 @@
@Override
public void dump(PrintWriter writer) {
writer.println("*" + getClass().getSimpleName() + "*");
- writer.println("mPublisherProxies:" + mPublisherProxies.keySet());
+ writer.println("mPublisherProxies: " + mPublisherProxies.size());
}
@Override
diff --git a/service/src/com/android/car/hal/VmsHalService.java b/service/src/com/android/car/hal/VmsHalService.java
index 487ec1f..3f39f48 100644
--- a/service/src/com/android/car/hal/VmsHalService.java
+++ b/service/src/com/android/car/hal/VmsHalService.java
@@ -283,15 +283,15 @@
@Override
public void dump(PrintWriter writer) {
- writer.println(TAG);
- writer.println("VmsProperty " + (mIsSupported ? "" : "not") + " supported.");
+ writer.println("*VMS HAL*");
- writer.println(
- "VmsPublisherService " + (mPublisherService != null ? "" : "not") + " registered.");
+ writer.println("VmsProperty: " + (mIsSupported ? "supported" : "unsupported"));
+ writer.println("VmsPublisherService: "
+ + (mPublisherService != null ? "registered " : "unregistered"));
writer.println("mSubscriptionStateSequence: " + mSubscriptionStateSequence);
- writer.println("VmsSubscriberService " + (mSubscriberService != null ? "" : "not")
- + " registered.");
+ writer.println("VmsSubscriberService: "
+ + (mSubscriberService != null ? "registered" : "unregistered"));
writer.println("mAvailableLayersSequence: " + mAvailableLayersSequence);
}
diff --git a/service/src/com/android/car/vms/VmsClientManager.java b/service/src/com/android/car/vms/VmsClientManager.java
index 14ef0a7..ea86ef3 100644
--- a/service/src/com/android/car/vms/VmsClientManager.java
+++ b/service/src/com/android/car/vms/VmsClientManager.java
@@ -40,6 +40,7 @@
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
/**
* Manages service connections lifecycle for VMS publisher clients.
@@ -92,6 +93,9 @@
@GuardedBy("mCurrentUserClients")
private int mCurrentUser;
+ @GuardedBy("mRebindCounts")
+ private final Map<String, AtomicLong> mRebindCounts = new ArrayMap<>();
+
@VisibleForTesting
final Runnable mSystemUserUnlockedListener = () -> {
synchronized (mSystemClients) {
@@ -164,10 +168,30 @@
@Override
public void dump(PrintWriter writer) {
writer.println("*" + getClass().getSimpleName() + "*");
- writer.println("mListeners:" + mListeners);
- writer.println("mSystemClients:" + mSystemClients.keySet());
- writer.println("mCurrentUser:" + mCurrentUser);
- writer.println("mCurrentUserClients:" + mCurrentUserClients.keySet());
+ synchronized (mSystemClients) {
+ writer.println("mHalClient: " + (mHalClient != null ? "connected" : "disconnected"));
+ writer.println("mSystemClients:");
+ dumpConnections(writer, mSystemClients);
+ }
+ synchronized (mCurrentUserClients) {
+ writer.println("mCurrentUserClients:");
+ dumpConnections(writer, mCurrentUserClients);
+ writer.println("mCurrentUser:" + mCurrentUser);
+ }
+ synchronized (mRebindCounts) {
+ writer.println("mRebindCounts:");
+ for (Map.Entry<String, AtomicLong> entry : mRebindCounts.entrySet()) {
+ writer.printf("\t%s: %s\n", entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
+ private void dumpConnections(PrintWriter writer, Map<String, ClientConnection> connectionMap) {
+ for (ClientConnection connection : connectionMap.values()) {
+ writer.printf("\t%s: %s\n",
+ connection.mName.getPackageName(),
+ connection.mIsBound ? "connected" : "disconnected");
+ }
}
/**
@@ -376,6 +400,10 @@
}
if (!mIsTerminated) {
mHandler.postDelayed(this::bind, mMillisBeforeRebind);
+ synchronized (mRebindCounts) {
+ mRebindCounts.computeIfAbsent(mName.getPackageName(), k -> new AtomicLong())
+ .incrementAndGet();
+ }
}
}