summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Felipe Leme <felipeal@google.com> 2022-02-03 14:08:40 -0800
committer Felipe Leme <felipeal@google.com> 2022-02-03 22:04:23 -0800
commit92d145c886fbe6df809ab7eceb2844b730033485 (patch)
tree678a7a483c89285b851a40a0ea368874c935f699
parent84380108d8687da9cf5137219ace4aa6faeb9695 (diff)
Replaces com.android.server.Dumpable by android.util.Dumpable.
Test: adb shell dumpsys system_server_dumper Bug: 149254050 Change-Id: I4e027599ef46b58963c8b0f97d66e510902f05c7
-rw-r--r--services/core/java/com/android/server/Dumpable.java44
-rw-r--r--services/core/java/com/android/server/SystemServerInitThreadPool.java10
-rw-r--r--services/core/java/com/android/server/SystemServiceManager.java15
-rw-r--r--services/java/com/android/server/SystemServer.java8
4 files changed, 25 insertions, 52 deletions
diff --git a/services/core/java/com/android/server/Dumpable.java b/services/core/java/com/android/server/Dumpable.java
deleted file mode 100644
index 004f923774e1..000000000000
--- a/services/core/java/com/android/server/Dumpable.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.server;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.util.IndentingPrintWriter;
-
-/**
- * Interface used to dump {@link SystemServer} state that is not associated with any service.
- *
- * <p>See {@link SystemServer.SystemServerDumper} for usage example.
- */
-// TODO(b/149254050): replace / merge with package android.util.Dumpable (it would require
-// exporting IndentingPrintWriter as @SystemApi) and/or changing the method to use a prefix
-public interface Dumpable {
-
- /**
- * Dumps the state.
- */
- void dump(@NonNull IndentingPrintWriter pw, @Nullable String[] args);
-
- /**
- * Gets the name of the dumpable.
- *
- * <p>If not overridden, will return the simple class name.
- */
- default String getDumpableName() {
- return Dumpable.this.getClass().getSimpleName();
- }
-}
diff --git a/services/core/java/com/android/server/SystemServerInitThreadPool.java b/services/core/java/com/android/server/SystemServerInitThreadPool.java
index 53b660533ce2..63e7563af6d1 100644
--- a/services/core/java/com/android/server/SystemServerInitThreadPool.java
+++ b/services/core/java/com/android/server/SystemServerInitThreadPool.java
@@ -19,7 +19,7 @@ package com.android.server;
import android.annotation.NonNull;
import android.os.Build;
import android.os.Process;
-import android.util.IndentingPrintWriter;
+import android.util.Dumpable;
import android.util.Slog;
import com.android.internal.annotations.GuardedBy;
@@ -28,6 +28,7 @@ import com.android.internal.util.Preconditions;
import com.android.server.am.ActivityManagerService;
import com.android.server.utils.TimingsTraceAndSlog;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -196,7 +197,12 @@ public final class SystemServerInitThreadPool implements Dumpable {
}
@Override
- public void dump(IndentingPrintWriter pw, String[] args) {
+ public String getDumpableName() {
+ return SystemServerInitThreadPool.class.getSimpleName();
+ }
+
+ @Override
+ public void dump(PrintWriter pw, String[] args) {
synchronized (LOCK) {
pw.printf("has instance: %b\n", (sInstance != null));
}
diff --git a/services/core/java/com/android/server/SystemServiceManager.java b/services/core/java/com/android/server/SystemServiceManager.java
index d719d77ea1be..12e438d1f2a9 100644
--- a/services/core/java/com/android/server/SystemServiceManager.java
+++ b/services/core/java/com/android/server/SystemServiceManager.java
@@ -27,8 +27,8 @@ import android.os.SystemClock;
import android.os.Trace;
import android.os.UserHandle;
import android.util.ArraySet;
+import android.util.Dumpable;
import android.util.EventLog;
-import android.util.IndentingPrintWriter;
import android.util.Slog;
import android.util.SparseArray;
@@ -44,6 +44,7 @@ import com.android.server.utils.TimingsTraceAndSlog;
import dalvik.system.PathClassLoader;
import java.io.File;
+import java.io.PrintWriter;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
@@ -687,7 +688,12 @@ public final class SystemServiceManager implements Dumpable {
}
@Override
- public void dump(IndentingPrintWriter pw, String[] args) {
+ public String getDumpableName() {
+ return SystemServiceManager.class.getSimpleName();
+ }
+
+ @Override
+ public void dump(PrintWriter pw, String[] args) {
pw.printf("Current phase: %d\n", mCurrentPhase);
synchronized (mTargetUsers) {
if (mCurrentUser != null) {
@@ -711,14 +717,13 @@ public final class SystemServiceManager implements Dumpable {
}
}
final int startedLen = mServices.size();
+ String prefix = " ";
if (startedLen > 0) {
pw.printf("%d started services:\n", startedLen);
- pw.increaseIndent();
for (int i = 0; i < startedLen; i++) {
final SystemService service = mServices.get(i);
- pw.println(service.getClass().getCanonicalName());
+ pw.print(prefix); pw.println(service.getClass().getCanonicalName());
}
- pw.decreaseIndent();
} else {
pw.println("No started services");
}
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index c2dec067c870..82d7881138ea 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -85,6 +85,7 @@ import android.system.Os;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.DisplayMetrics;
+import android.util.Dumpable;
import android.util.EventLog;
import android.util.IndentingPrintWriter;
import android.util.Pair;
@@ -663,7 +664,12 @@ public final class SystemServer implements Dumpable {
}
@Override
- public void dump(IndentingPrintWriter pw, String[] args) {
+ public String getDumpableName() {
+ return SystemServer.class.getSimpleName();
+ }
+
+ @Override
+ public void dump(PrintWriter pw, String[] args) {
pw.printf("Runtime restart: %b\n", mRuntimeRestart);
pw.printf("Start count: %d\n", mStartCount);
pw.print("Runtime start-up time: ");