Add camera ping command and release message.

The problem is both face unlock and camera application try to open
the hardware camera at the same time. A new camera open API is
added to let face unlock take the camera away from the existing
client. The release message is used to notify the existing client,
so it has time to release the hardware camera and clean up.

If existing client tries to use the camera after it is released,
the method will return error. It is still possible that the
camera has been taken and the existing client has not got the
notification. When any method returns error, the existing client
can use ping command to check whether the camera has been released.
If yes, the client can silently finish the app itself or show a
toast if it wants.

bug:5584464

Change-Id: I87f9f7db2f7b2b70ab2405f9b3da0d8946d6a01b
diff --git a/include/system/camera.h b/include/system/camera.h
index 62167cf..b8389b1 100644
--- a/include/system/camera.h
+++ b/include/system/camera.h
@@ -151,11 +151,30 @@
      * arg1 = 0 will disable, while passing arg1 = 1 will enable the callback.
      */
     CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG = 8,
+
+    /**
+     * Ping camera service to see if camera hardware is released.
+     *
+     * When any camera method returns error, the client can use ping command
+     * to see if the camera has been taken away by other clients. If the result
+     * is NO_ERROR, it means the camera hardware is not released. If the result
+     * is not NO_ERROR, the camera has been released and the existing client
+     * can silently finish itself or show a dialog.
+     */
+    CAMERA_CMD_PING = 9,
 };
 
 /** camera fatal errors */
 enum {
     CAMERA_ERROR_UNKNOWN = 1,
+    /**
+     * Camera was released because another client has connected to the camera.
+     * The original client should call Camera::disconnect immediately after
+     * getting this notification. Otherwise, the camera will be released by
+     * camera service in a short time. The client should not call any method
+     * (except disconnect and sending CAMERA_CMD_PING) after getting this.
+     */
+    CAMERA_ERROR_RELEASED = 2,
     CAMERA_ERROR_SERVER_DIED = 100
 };