CameraService: Add more information to service dump.

Add dumpsys information even when there's no active client. Including:
- Camera module version / name / author
- Number of camera devices
- Static information for each device

Change-Id: Ib97e325f6be5f989b342d24f1ae17aa9e796f8ed
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 912ee4a..a83c28f 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -429,17 +429,69 @@
         // failed to lock - CameraService is probably deadlocked
         if (!locked) {
             result.append("CameraService may be deadlocked\n");
+            write(fd, result.string(), result.size());
         }
 
         bool hasClient = false;
+        if (!mModule) {
+            result = String8::format("No camera module available!\n");
+            write(fd, result.string(), result.size());
+            return NO_ERROR;
+        }
+
+        result = String8::format("Camera module HAL API version: 0x%x\n",
+                mModule->common.hal_api_version);
+        result.appendFormat("Camera module API version: 0x%x\n",
+                mModule->common.module_api_version);
+        result.appendFormat("Camera module name: %s\n",
+                mModule->common.name);
+        result.appendFormat("Camera module author: %s\n",
+                mModule->common.author);
+        result.appendFormat("Number of camera devices: %d\n\n", mNumberOfCameras);
+        write(fd, result.string(), result.size());
         for (int i = 0; i < mNumberOfCameras; i++) {
+            result = String8::format("Camera %d static information:\n", i);
+            camera_info info;
+
+            status_t rc = mModule->get_camera_info(i, &info);
+            if (rc != OK) {
+                result.appendFormat("  Error reading static information!\n");
+                write(fd, result.string(), result.size());
+            } else {
+                result.appendFormat("  Facing: %s\n",
+                        info.facing == CAMERA_FACING_BACK ? "BACK" : "FRONT");
+                result.appendFormat("  Orientation: %d\n", info.orientation);
+                int deviceVersion;
+                if (mModule->common.module_api_version <
+                        CAMERA_MODULE_API_VERSION_2_0) {
+                    deviceVersion = CAMERA_DEVICE_API_VERSION_1_0;
+                } else {
+                    deviceVersion = info.device_version;
+                }
+                result.appendFormat("  Device version: 0x%x\n", deviceVersion);
+                if (deviceVersion >= CAMERA_DEVICE_API_VERSION_2_0) {
+                    result.appendFormat("  Device static metadata:\n");
+                    write(fd, result.string(), result.size());
+                    dump_camera_metadata(info.static_camera_characteristics, fd, 2);
+                } else {
+                    write(fd, result.string(), result.size());
+                }
+            }
+
             sp<Client> client = mClient[i].promote();
-            if (client == 0) continue;
+            if (client == 0) {
+                result = String8::format("  Device is closed, no client instance\n");
+                write(fd, result.string(), result.size());
+                continue;
+            }
             hasClient = true;
+            result = String8::format("  Device is open. Client instance dump:\n");
+            write(fd, result.string(), result.size());
             client->dump(fd, args);
         }
         if (!hasClient) {
-            result.append("No camera clients yet.\n");
+            result = String8::format("\nNo active camera clients yet.\n");
+            write(fd, result.string(), result.size());
         }
 
         if (locked) mServiceLock.unlock();
@@ -451,11 +503,12 @@
             if (args[i] == verboseOption) {
                 String8 levelStr(args[i+1]);
                 int level = atoi(levelStr.string());
-                result.appendFormat("Setting log level to %d.\n", level);
+                result = String8::format("\nSetting log level to %d.\n", level);
                 setLogLevel(level);
+                write(fd, result.string(), result.size());
             }
         }
-        write(fd, result.string(), result.size());
+
     }
     return NO_ERROR;
 }