Check proto argument in arguments for service
Commit f5ea44c adds pid information for non-proto dump.
But the common usage of tests pass the proto argument
for the target service instead of dumpsys, e.g.
dumpsys activity --proto activities
In this case, asProto is still false that leads to the
pid information in text format is contained in proto dump.
Fix: 141371622
Test: atest DumpsysTest
Test: atest DisplaySizeTest
Change-Id: I6b3fb180985b33e7c97849556f8ba47b4776ca86
diff --git a/cmds/dumpsys/dumpsys.cpp b/cmds/dumpsys/dumpsys.cpp
index 68b3907..7646285 100644
--- a/cmds/dumpsys/dumpsys.cpp
+++ b/cmds/dumpsys/dumpsys.cpp
@@ -201,7 +201,13 @@
if (i == optind) {
services.add(String16(argv[i]));
} else {
- args.add(String16(argv[i]));
+ const String16 arg(argv[i]);
+ args.add(arg);
+ // For backward compatible, if the proto argument is passed to the service, the
+ // dump request is also considered to use proto.
+ if (!asProto && !arg.compare(String16(PriorityDumper::PROTO_ARG))) {
+ asProto = true;
+ }
}
}
}