Merge "Trigger gd legacy from legacy dumpsys"
diff --git a/system/btif/src/bluetooth.cc b/system/btif/src/bluetooth.cc
index 56f0b9b..f0ac2c8 100644
--- a/system/btif/src/bluetooth.cc
+++ b/system/btif/src/bluetooth.cc
@@ -331,7 +331,7 @@
   connection_manager::dump(fd);
   bluetooth::bqr::DebugDump(fd);
   if (bluetooth::shim::is_gd_shim_enabled()) {
-    bluetooth::shim::Dump(fd);
+    bluetooth::shim::Dump(fd, arguments);
   } else {
 #if (BTSNOOP_MEM == TRUE)
     btif_debug_btsnoop_dump(fd);
diff --git a/system/gd/shim/dumpsys.cc b/system/gd/shim/dumpsys.cc
index 6f66770..aa7299d 100644
--- a/system/gd/shim/dumpsys.cc
+++ b/system/gd/shim/dumpsys.cc
@@ -35,9 +35,37 @@
 constexpr char kModuleName[] = "shim::Dumpsys";
 }  // namespace
 
+constexpr char kArgumentDeveloper[] = "--dev";
+
+class ParsedDumpsysArgs {
+ public:
+  ParsedDumpsysArgs(const char** args) {
+    if (args == nullptr) return;
+    const char* p = *args;
+    while (p != nullptr) {
+      num_args_++;
+      if (!strcmp(p, kArgumentDeveloper)) {
+        dev_arg_ = true;
+      } else {
+        // silently ignore unexpected option
+      }
+      if (++args == nullptr) break;
+      p = *args;
+    }
+  }
+  bool IsDeveloper() const {
+    return dev_arg_;
+  }
+
+ private:
+  unsigned num_args_{0};
+  bool dev_arg_{false};
+};
+
 struct Dumpsys::impl {
  public:
-  void Dump(int fd, std::promise<void> promise);
+  void DumpWithArgs(int fd, const char** args, std::promise<void> promise);
+
   void RegisterDumpsysFunction(const void* token, DumpsysFunction func);
   void UnregisterDumpsysFunction(const void* token);
 
@@ -49,8 +77,14 @@
 
 const ModuleFactory Dumpsys::Factory = ModuleFactory([]() { return new Dumpsys(); });
 
-void Dumpsys::impl::Dump(int fd, std::promise<void> promise) {
-  dprintf(fd, "%s Registered submodules:%zd\n", kModuleName, dumpsys_functions_.size());
+void Dumpsys::impl::DumpWithArgs(int fd, const char** args, std::promise<void> promise) {
+  ParsedDumpsysArgs parsed_dumpsys_args(args);
+  if (parsed_dumpsys_args.IsDeveloper()) {
+    // TODO(cmanton) Create development Dumper
+  } else {
+    // TODO(cmanton) Create typical Dumper
+  }
+
   std::for_each(dumpsys_functions_.begin(), dumpsys_functions_.end(),
                 [fd](std::pair<const void*, DumpsysFunction> element) { element.second(fd); });
   promise.set_value();
@@ -66,10 +100,10 @@
   dumpsys_functions_.erase(token);
 }
 
-void Dumpsys::Dump(int fd) {
+void Dumpsys::Dump(int fd, const char** args) {
   std::promise<void> promise;
   auto future = promise.get_future();
-  GetHandler()->Post(common::BindOnce(&Dumpsys::impl::Dump, common::Unretained(pimpl_.get()), fd, std::move(promise)));
+  GetHandler()->BindOnceOn(pimpl_.get(), &Dumpsys::impl::DumpWithArgs, fd, args, std::move(promise));
   future.get();
 }
 
diff --git a/system/gd/shim/dumpsys.h b/system/gd/shim/dumpsys.h
index 197ad3e..dfb2978 100644
--- a/system/gd/shim/dumpsys.h
+++ b/system/gd/shim/dumpsys.h
@@ -27,7 +27,8 @@
 
 class Dumpsys : public bluetooth::Module {
  public:
-  void Dump(int fd);
+  void Dump(int fd, const char** args);
+
   void RegisterDumpsysFunction(const void* token, DumpsysFunction func);
   void UnregisterDumpsysFunction(const void* token);
 
diff --git a/system/main/shim/dumpsys.cc b/system/main/shim/dumpsys.cc
index 7f7b10e..2cd8597 100644
--- a/system/main/shim/dumpsys.cc
+++ b/system/main/shim/dumpsys.cc
@@ -41,15 +41,15 @@
   dumpsys_functions_->erase(token);
 }
 
-void bluetooth::shim::Dump(int fd) {
+void bluetooth::shim::Dump(int fd, const char** args) {
   dprintf(fd, "%s Dumping shim legacy targets:%zd\n", kModuleName,
           dumpsys_functions_->size());
   for (auto& dumpsys : *dumpsys_functions_) {
     dumpsys.second(fd);
   }
   if (bluetooth::shim::is_gd_stack_started_up()) {
-    bluetooth::shim::GetDumpsys()->Dump(fd);
+    bluetooth::shim::GetDumpsys()->Dump(fd, args);
   } else {
-    dprintf(fd, "%s gd stack has not started up\n", kModuleName);
+    dprintf(fd, "%s gd stack is enabled but not started\n", kModuleName);
   }
 }
diff --git a/system/main/shim/dumpsys.h b/system/main/shim/dumpsys.h
index 91c4ea7..33702ad 100644
--- a/system/main/shim/dumpsys.h
+++ b/system/main/shim/dumpsys.h
@@ -28,7 +28,7 @@
  * Entrypoint from legacy stack to provide dumpsys functionality
  * for both the legacy shim and the Gabeldorsche stack.
  */
-void Dump(int fd);
+void Dump(int fd, const char** args);
 
 /**
  * Dumpsys access for legacy shim modules.