summaryrefslogtreecommitdiff
path: root/services/print
diff options
context:
space:
mode:
authorPhilip P. Moltmann <moltmann@google.com>2018-01-17 09:33:14 -0800
committerPhilip P. Moltmann <moltmann@google.com>2018-01-17 09:33:14 -0800
commitbd62e9ae145c638845e41286156eca6e2d44a8ea (patch)
tree8915d0bb16167d39332e9a609dd3e538ff9d304e /services/print
parent99dbbf937cda5b497abb8a289dc6080938c03754 (diff)
Follow up I1f0c56651eaa59f0ce90cdb08c71e89a96c48dd4
Beside addressing the comments on this change, this adds a check that the token in end( is correct and prints a message if not. This is useful when creating new dumping methods. Test: adb shell dumpsys print Change-Id: Ic2e6152cbd82f98d9d305a15edffc69c55fd1fd3
Diffstat (limited to 'services/print')
-rw-r--r--services/print/java/com/android/server/print/PrintManagerService.java10
-rw-r--r--services/print/java/com/android/server/print/RemotePrintSpooler.java12
-rw-r--r--services/print/java/com/android/server/print/UserState.java66
3 files changed, 45 insertions, 43 deletions
diff --git a/services/print/java/com/android/server/print/PrintManagerService.java b/services/print/java/com/android/server/print/PrintManagerService.java
index 1dc9d2687dc7..cd4e8f977d60 100644
--- a/services/print/java/com/android/server/print/PrintManagerService.java
+++ b/services/print/java/com/android/server/print/PrintManagerService.java
@@ -685,16 +685,16 @@ public final class PrintManagerService extends SystemService {
}
}
- private void dump(@NonNull DualDumpOutputStream proto,
+ private void dump(@NonNull DualDumpOutputStream dumpStream,
@NonNull ArrayList<UserState> userStatesToDump) {
final int userStateCount = userStatesToDump.size();
for (int i = 0; i < userStateCount; i++) {
- long token = proto.start("user_states", PrintServiceDumpProto.USER_STATES);
- userStatesToDump.get(i).dump(proto);
- proto.end(token);
+ long token = dumpStream.start("user_states", PrintServiceDumpProto.USER_STATES);
+ userStatesToDump.get(i).dump(dumpStream);
+ dumpStream.end(token);
}
- proto.flush();
+ dumpStream.flush();
}
private void registerContentObservers() {
diff --git a/services/print/java/com/android/server/print/RemotePrintSpooler.java b/services/print/java/com/android/server/print/RemotePrintSpooler.java
index 5520255c8d13..a69baa110f5a 100644
--- a/services/print/java/com/android/server/print/RemotePrintSpooler.java
+++ b/services/print/java/com/android/server/print/RemotePrintSpooler.java
@@ -556,18 +556,18 @@ final class RemotePrintSpooler {
}
}
- public void dump(@NonNull DualDumpOutputStream proto) {
+ public void dump(@NonNull DualDumpOutputStream dumpStream) {
synchronized (mLock) {
- proto.write("is_destroyed", PrintSpoolerStateProto.IS_DESTROYED, mDestroyed);
- proto.write("is_bound", PrintSpoolerStateProto.IS_BOUND, mRemoteInstance != null);
+ dumpStream.write("is_destroyed", PrintSpoolerStateProto.IS_DESTROYED, mDestroyed);
+ dumpStream.write("is_bound", PrintSpoolerStateProto.IS_BOUND, mRemoteInstance != null);
}
try {
- if (proto.isProto()) {
- proto.write(null, PrintSpoolerStateProto.INTERNAL_STATE,
+ if (dumpStream.isProto()) {
+ dumpStream.write(null, PrintSpoolerStateProto.INTERNAL_STATE,
TransferPipe.dumpAsync(getRemoteInstanceLazy().asBinder(), "--proto"));
} else {
- proto.writeNested("internal_state", TransferPipe.dumpAsync(
+ dumpStream.writeNested("internal_state", TransferPipe.dumpAsync(
getRemoteInstanceLazy().asBinder()));
}
} catch (IOException | TimeoutException | RemoteException | InterruptedException e) {
diff --git a/services/print/java/com/android/server/print/UserState.java b/services/print/java/com/android/server/print/UserState.java
index 318e481a6223..e2808e8245e5 100644
--- a/services/print/java/com/android/server/print/UserState.java
+++ b/services/print/java/com/android/server/print/UserState.java
@@ -815,61 +815,63 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks,
mDestroyed = true;
}
- public void dump(@NonNull DualDumpOutputStream proto) {
+ public void dump(@NonNull DualDumpOutputStream dumpStream) {
synchronized (mLock) {
- proto.write("user_id", PrintUserStateProto.USER_ID, mUserId);
+ dumpStream.write("user_id", PrintUserStateProto.USER_ID, mUserId);
final int installedServiceCount = mInstalledServices.size();
for (int i = 0; i < installedServiceCount; i++) {
- long token = proto.start("installed_services",
+ long token = dumpStream.start("installed_services",
PrintUserStateProto.INSTALLED_SERVICES);
PrintServiceInfo installedService = mInstalledServices.get(i);
ResolveInfo resolveInfo = installedService.getResolveInfo();
- writeComponentName(proto, "component_name",
+ writeComponentName(dumpStream, "component_name",
InstalledPrintServiceProto.COMPONENT_NAME,
new ComponentName(resolveInfo.serviceInfo.packageName,
resolveInfo.serviceInfo.name));
- writeStringIfNotNull(proto, "settings_activity",
+ writeStringIfNotNull(dumpStream, "settings_activity",
InstalledPrintServiceProto.SETTINGS_ACTIVITY,
installedService.getSettingsActivityName());
- writeStringIfNotNull(proto, "add_printers_activity",
+ writeStringIfNotNull(dumpStream, "add_printers_activity",
InstalledPrintServiceProto.ADD_PRINTERS_ACTIVITY,
installedService.getAddPrintersActivityName());
- writeStringIfNotNull(proto, "advanced_options_activity",
+ writeStringIfNotNull(dumpStream, "advanced_options_activity",
InstalledPrintServiceProto.ADVANCED_OPTIONS_ACTIVITY,
installedService.getAdvancedOptionsActivityName());
- proto.end(token);
+ dumpStream.end(token);
}
for (ComponentName disabledService : mDisabledServices) {
- writeComponentName(proto, "disabled_services",
+ writeComponentName(dumpStream, "disabled_services",
PrintUserStateProto.DISABLED_SERVICES, disabledService);
}
final int activeServiceCount = mActiveServices.size();
for (int i = 0; i < activeServiceCount; i++) {
- long token = proto.start("actives_services", PrintUserStateProto.ACTIVE_SERVICES);
- mActiveServices.valueAt(i).dump(proto);
- proto.end(token);
+ long token = dumpStream.start("actives_services",
+ PrintUserStateProto.ACTIVE_SERVICES);
+ mActiveServices.valueAt(i).dump(dumpStream);
+ dumpStream.end(token);
}
- mPrintJobForAppCache.dumpLocked(proto);
+ mPrintJobForAppCache.dumpLocked(dumpStream);
if (mPrinterDiscoverySession != null) {
- long token = proto.start("discovery_service",
+ long token = dumpStream.start("discovery_service",
PrintUserStateProto.DISCOVERY_SESSIONS);
- mPrinterDiscoverySession.dumpLocked(proto);
- proto.end(token);
+ mPrinterDiscoverySession.dumpLocked(dumpStream);
+ dumpStream.end(token);
}
}
- long token = proto.start("print_spooler_state", PrintUserStateProto.PRINT_SPOOLER_STATE);
- mSpooler.dump(proto);
- proto.end(token);
+ long token = dumpStream.start("print_spooler_state",
+ PrintUserStateProto.PRINT_SPOOLER_STATE);
+ mSpooler.dump(dumpStream);
+ dumpStream.end(token);
}
private void readConfigurationLocked() {
@@ -1597,16 +1599,16 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks,
}
}
- public void dumpLocked(@NonNull DualDumpOutputStream proto) {
- proto.write("is_destroyed", PrinterDiscoverySessionProto.IS_DESTROYED, mDestroyed);
- proto.write("is_printer_discovery_in_progress",
+ public void dumpLocked(@NonNull DualDumpOutputStream dumpStream) {
+ dumpStream.write("is_destroyed", PrinterDiscoverySessionProto.IS_DESTROYED, mDestroyed);
+ dumpStream.write("is_printer_discovery_in_progress",
PrinterDiscoverySessionProto.IS_PRINTER_DISCOVERY_IN_PROGRESS,
!mStartedPrinterDiscoveryTokens.isEmpty());
final int observerCount = mDiscoveryObservers.beginBroadcast();
for (int i = 0; i < observerCount; i++) {
IPrinterDiscoveryObserver observer = mDiscoveryObservers.getBroadcastItem(i);
- proto.write("printer_discovery_observers",
+ dumpStream.write("printer_discovery_observers",
PrinterDiscoverySessionProto.PRINTER_DISCOVERY_OBSERVERS,
observer.toString());
}
@@ -1615,21 +1617,21 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks,
final int tokenCount = this.mStartedPrinterDiscoveryTokens.size();
for (int i = 0; i < tokenCount; i++) {
IBinder token = mStartedPrinterDiscoveryTokens.get(i);
- proto.write("discovery_requests",
+ dumpStream.write("discovery_requests",
PrinterDiscoverySessionProto.DISCOVERY_REQUESTS, token.toString());
}
final int trackedPrinters = mStateTrackedPrinters.size();
for (int i = 0; i < trackedPrinters; i++) {
PrinterId printer = mStateTrackedPrinters.get(i);
- writePrinterId(proto, "tracked_printer_requests",
+ writePrinterId(dumpStream, "tracked_printer_requests",
PrinterDiscoverySessionProto.TRACKED_PRINTER_REQUESTS, printer);
}
final int printerCount = mPrinters.size();
for (int i = 0; i < printerCount; i++) {
PrinterInfo printer = mPrinters.valueAt(i);
- writePrinterInfo(mContext, proto, "printer",
+ writePrinterInfo(mContext, dumpStream, "printer",
PrinterDiscoverySessionProto.PRINTER, printer);
}
}
@@ -1843,22 +1845,22 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks,
}
}
- public void dumpLocked(@NonNull DualDumpOutputStream proto) {
+ public void dumpLocked(@NonNull DualDumpOutputStream dumpStream) {
final int bucketCount = mPrintJobsForRunningApp.size();
for (int i = 0; i < bucketCount; i++) {
final int appId = mPrintJobsForRunningApp.keyAt(i);
List<PrintJobInfo> bucket = mPrintJobsForRunningApp.valueAt(i);
final int printJobCount = bucket.size();
for (int j = 0; j < printJobCount; j++) {
- long token = proto.start("cached_print_jobs",
+ long token = dumpStream.start("cached_print_jobs",
PrintUserStateProto.CACHED_PRINT_JOBS);
- proto.write("app_id", CachedPrintJobProto.APP_ID, appId);
+ dumpStream.write("app_id", CachedPrintJobProto.APP_ID, appId);
- writePrintJobInfo(mContext, proto, "print_job", CachedPrintJobProto.PRINT_JOB,
- bucket.get(j));
+ writePrintJobInfo(mContext, dumpStream, "print_job",
+ CachedPrintJobProto.PRINT_JOB, bucket.get(j));
- proto.end(token);
+ dumpStream.end(token);
}
}
}