Add 'watch' command to CameraService
Currently there is no way to monitor tags and dump per frame data from
Camera devices without calling dumpsys, which in turn dumps a lot of
unnecessary information.
This CL adds a 'watch' command to CameraService which can be called
through `cmd`. 'watch' provides a path to manage tag monitoring without
dumpsys. 'watch' currently has four functions:
1. start <taglist>: starts mornitoring the provided tags in attached
devices.
2. stop: stop monitoring all tags
3. live: prints monitored information to the terminal live
4. dump: dumps any collected camera traces
This CL adds a function to camera device each for the three tag
monitoring function listed above.
Test: n/a
Bug: 199746421
Change-Id: Ia5ce13f6e50c82085afcc676309cdbffef915a41
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index 7a69123..f701d30 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -272,6 +272,10 @@
// Internal dump method to be called by CameraService
virtual status_t dumpClient(int fd, const Vector<String16>& args) = 0;
+ virtual status_t startWatchingTags(const String8 &tags, int outFd);
+ virtual status_t stopWatchingTags(int outFd);
+ virtual status_t dumpWatchedEventsToVector(std::vector<std::string> &out);
+
// Return the package name for this client
virtual String16 getPackageName() const;
@@ -1149,6 +1153,26 @@
// Set the camera mute state
status_t handleSetCameraMute(const Vector<String16>& args);
+ // Handle 'watch' command as passed through 'cmd'
+ status_t handleWatchCommand(const Vector<String16> &args, int out);
+
+ // Enable tag monitoring of the given tags in all attached clients
+ status_t startWatchingTags(const String16 &tags, int outFd);
+
+ // Disable tag monitoring in all attached clients
+ status_t stopWatchingTags(int outFd);
+
+ // Print events of monitored tags in all attached devices as they are captured
+ // NOTE: This function does not terminate unless interrupted.
+ status_t printWatchedTagsUntilInterrupt(const Vector<String16> &args, int outFd);
+
+ // Print all events in vector `events' that came after lastPrintedEvent
+ static void printNewWatchedEvents(int outFd,
+ const char *cameraId,
+ const String16 &packageName,
+ const std::vector<std::string> &events,
+ const std::string &lastPrintedEvent);
+
// Prints the shell command help
status_t printHelp(int out);