Uses a system property to set dry-run mode.

On Android N, dumpstate was using a #define to set dry-run mode, which
allows dumpstate to run much faster, which in turn is useful when
developing new dumpstate features.

The drawback of this approach is that it requires modifying dumpstate.h
locally, building a new binary, and re-redeploying it in the device; a
better and more flexible approach is to use a system
property (dumpstate.dry_run) so developers can enable /disable it during
runtime.

Change-Id: I41d1e6ae3fa6ca2be23887f59d5ad4e9df7c10e6
Fixes: 30604041
diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h
index a7d14f7..389444e 100644
--- a/cmds/dumpstate/dumpstate.h
+++ b/cmds/dumpstate/dumpstate.h
@@ -14,19 +14,15 @@
  * limitations under the License.
  */
 
-#ifndef _DUMPSTATE_H_
-#define _DUMPSTATE_H_
+#ifndef FRAMEWORK_NATIVE_CMD_DUMPSTATE_H_
+#define FRAMEWORK_NATIVE_CMD_DUMPSTATE_H_
 
-/* When defined, skips the real dumps and just print the section headers.
-   Useful when debugging dumpstate itself. */
-//#define _DUMPSTATE_DRY_RUN_
+#ifndef ON_DRY_RUN_RETURN
+#define ON_DRY_RUN_RETURN(X) if (is_dry_run()) return X
+#endif
 
-#ifdef _DUMPSTATE_DRY_RUN_
-#define ON_DRY_RUN_RETURN(X) return X
-#define ON_DRY_RUN(code) code
-#else
-#define ON_DRY_RUN_RETURN(X)
-#define ON_DRY_RUN(code)
+#ifndef ON_DRY_RUN
+#define ON_DRY_RUN(code) if (is_dry_run()) code
 #endif
 
 #ifndef MYLOGD
@@ -212,6 +208,15 @@
 bool is_user_build();
 
 /*
+ * When running in dry-run mode, skips the real dumps and just print the section headers.
+ *
+ * Useful when debugging dumpstate or other bugreport-related activities.
+ *
+ * Dry-run mode is enabled by setting the system property dumpstate.dry_run to true.
+ */
+bool is_dry_run();
+
+/*
  * Helper class used to report how long it takes for a section to finish.
  *
  * Typical usage:
@@ -238,4 +243,4 @@
 }
 #endif
 
-#endif /* _DUMPSTATE_H_ */
+#endif /* FRAMEWORK_NATIVE_CMD_DUMPSTATE_H_ */