Camera: HIDLized camera HALs, first set

* Common camera definitions (camera.common/1.0)
  * Basic status codes, shared types
* Provider 2.4 API (camera.provider/2.4), including vendor tag APIs
  * Enumerate and acquire camera device instances
  * Mostly equivalent to legacy camera module v2.4.
* Device 1.0 API (camera.device/1.0)
  * Mostly equivalent to legacy camera HAL v1.0.
* Device 3.2 API (camera.device/3.2)
  * Mostly equivalent to legacy camera HAL v3.2.
* Metadata 3.2 API (camera.metadata/3.2)
  * Definitions for valid metadata fields for device 3.2

Only the key initial interfaces are added; default implementations are
in a later CL. Other interfaces that will likely need to be added:

* Other provider minor versions
* Other device 3.x minor versions

Test: make -j32
Bug: 30985004
Bug: 32991603
Change-Id: I1c6a9a269bf45276055707bbc58cfc50d29fa919
diff --git a/camera/provider/2.4/Android.bp b/camera/provider/2.4/Android.bp
new file mode 100644
index 0000000..9cbd87d
--- /dev/null
+++ b/camera/provider/2.4/Android.bp
@@ -0,0 +1,64 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+    name: "android.hardware.camera.provider@2.4_genc++",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.camera.provider@2.4",
+    srcs: [
+        "ICameraProvider.hal",
+        "ICameraProviderCallback.hal",
+    ],
+    out: [
+        "android/hardware/camera/provider/2.4/CameraProviderAll.cpp",
+        "android/hardware/camera/provider/2.4/CameraProviderCallbackAll.cpp",
+    ],
+}
+
+genrule {
+    name: "android.hardware.camera.provider@2.4_genc++_headers",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.camera.provider@2.4",
+    srcs: [
+        "ICameraProvider.hal",
+        "ICameraProviderCallback.hal",
+    ],
+    out: [
+        "android/hardware/camera/provider/2.4/ICameraProvider.h",
+        "android/hardware/camera/provider/2.4/IHwCameraProvider.h",
+        "android/hardware/camera/provider/2.4/BnCameraProvider.h",
+        "android/hardware/camera/provider/2.4/BpCameraProvider.h",
+        "android/hardware/camera/provider/2.4/BsCameraProvider.h",
+        "android/hardware/camera/provider/2.4/ICameraProviderCallback.h",
+        "android/hardware/camera/provider/2.4/IHwCameraProviderCallback.h",
+        "android/hardware/camera/provider/2.4/BnCameraProviderCallback.h",
+        "android/hardware/camera/provider/2.4/BpCameraProviderCallback.h",
+        "android/hardware/camera/provider/2.4/BsCameraProviderCallback.h",
+    ],
+}
+
+cc_library_shared {
+    name: "android.hardware.camera.provider@2.4",
+    generated_sources: ["android.hardware.camera.provider@2.4_genc++"],
+    generated_headers: ["android.hardware.camera.provider@2.4_genc++_headers"],
+    export_generated_headers: ["android.hardware.camera.provider@2.4_genc++_headers"],
+    shared_libs: [
+        "libhidlbase",
+        "libhidltransport",
+        "libhwbinder",
+        "liblog",
+        "libutils",
+        "libcutils",
+        "android.hardware.camera.common@1.0",
+        "android.hardware.camera.device@1.0",
+        "android.hardware.camera.device@3.2",
+    ],
+    export_shared_lib_headers: [
+        "libhidlbase",
+        "libhidltransport",
+        "libhwbinder",
+        "libutils",
+        "android.hardware.camera.common@1.0",
+        "android.hardware.camera.device@1.0",
+        "android.hardware.camera.device@3.2",
+    ],
+}
diff --git a/camera/provider/2.4/ICameraProvider.hal b/camera/provider/2.4/ICameraProvider.hal
new file mode 100644
index 0000000..564167b
--- /dev/null
+++ b/camera/provider/2.4/ICameraProvider.hal
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.camera.provider@2.4;
+
+import ICameraProviderCallback;
+import android.hardware.camera.common@1.0::types;
+import android.hardware.camera.device@1.0::ICameraDevice;
+import android.hardware.camera.device@3.2::ICameraDevice;
+
+/**
+ * Camera provider HAL, which enumerates the available individual camera devices
+ * known to the provider, and provides updates about changes to device status,
+ * such as connection, disconnection, or torch mode enable/disable.
+ *
+ * The provider is responsible for generating a list of camera device service
+ * names that can then be opened via the hardware service manager.
+ *
+ * Multiple camera provider HALs may be present in a single system.
+ * For discovery, the service names, and process names, must be of the form
+ * "android.hardware.camera.provider@<major>.<minor>/<type>/<instance>"
+ * where
+ *   - <major>/<minor> is the provider HAL HIDL version,
+ *   - <type> is the type of devices this provider knows about, such as
+ *     "internal", "legacy", "usb", or "remote"
+ *   - <instance> is a non-negative integer starting from 0 to disambiguate
+ *     between multiple HALs of the same type.
+ *
+ * The "legacy" type is only used for passthrough legacy HAL mode, and must
+ * not be used by a standalone binderized HAL.
+ *
+ * The device instance names enumerated by the provider must be of the form
+ * "device@<major>.<minor>/<type>/<id>" where
+ * <major>/<minor> is the HIDL version of the interface. <id> is either a small
+ * incrementing integer for "internal" device types, with 0 being the main
+ * back-facing camera and 1 being the main front-facing camera, if they exist.
+ * Or, for external devices such as type "usb", a unique serial number that can
+ * be used to identify the device reliably when it is disconnected and
+ * reconnected. Multiple providers may not enumerate the same device ID.
+ *
+ */
+interface ICameraProvider {
+
+    /**
+     * setCallback:
+     *
+     * Provide a callback interface to the HAL provider to inform framework of
+     * asynchronous camera events. The framework must call this function once
+     * during camera service startup, before any other calls to the provider
+     * (note that in case the camera service restarts, this method must be
+     * invoked again during its startup).
+     *
+     * @param callback
+     *     A non-null callback interface to invoke when camera events occur.
+     * @return status
+     *     Status code for the operation, one of:
+     *     OK:
+     *         On success
+     *     INTERNAL_ERROR:
+     *         An unexpected internal error occurred while setting the callbacks
+     *     ILLEGAL_ARGUMENT:
+     *         The callback argument is invalid (for example, null).
+     *
+     */
+    setCallback(ICameraProviderCallback callback) generates (Status status);
+
+    /**
+     * getVendorTags:
+     *
+     * Retrieve all vendor tags supported by devices discoverable through this
+     * provider. The tags are grouped into sections.
+     *
+     * @return status
+     *     Status code for the operation, one of:
+     *     OK:
+     *         On success
+     *     INTERNAL_ERROR:
+     *         An unexpected internal error occurred while setting the callbacks
+     * @return sections
+     *     The supported vendor tag sections; empty if there are no supported
+     *     vendor tags, or status is not OK.
+     *
+     */
+    getVendorTags() generates (Status status, vec<VendorTagSection> sections);
+
+    /**
+     * getCameraDeviceList:
+     *
+     * Returns the list of internal camera device interfaces known to this
+     * camera provider. These devices can then be accessed via the hardware
+     * service manager.
+     *
+     * External camera devices (camera facing EXTERNAL) must be reported through
+     * the device status change callback, not in this list. Only devices with
+     * facing BACK or FRONT must be listed here.
+     *
+     * @return status Status code for the operation, one of:
+     *     OK:
+     *         On a succesful generation of camera ID list
+     *     INTERNAL_ERROR:
+     *         A camera ID list cannot be created. This may be due to
+     *         a failure to initialize the camera subsystem, for example.
+     * @return cameraDeviceServiceNames The vector of internal camera device
+     *     names known to this provider.
+     */
+    getCameraIdList()
+            generates (Status status, vec<string> cameraDeviceNames);
+
+    /**
+     * getCameraDeviceInterface_VN_x:
+     *
+     * Return a android.hardware.camera.device@N.x/ICameraDevice interface for
+     * the requested device name. This does not power on the camera device, but
+     * simply acquires the interface for querying the device static information,
+     * or to additionally open the device for active use.
+     *
+     * A separate method is required for each major revision of the camera device
+     * HAL interface, since they are not compatible with each other.
+     *
+     * Valid device names for this provider can be obtained via either
+     * getCameraIdList(), or via availability callbacks from
+     * ICameraProviderCallback::cameraDeviceStatusChange().
+     *
+     * The returned interface must be of the highest defined minor version for
+     * the major version; it's the responsibility of the HAL client to ensure
+     * they do not use methods/etc that are not valid for the actual minor
+     * version of the device.
+     *
+     * @param cameraDeviceName the name of the device to get an interface to.
+     * @return status Status code for the operation, one of:
+     *     OK:
+     *         On a succesful generation of camera ID list
+     *     ILLEGAL_ARGUMENT:
+     *         This device name is unknown, or has been disconnected
+     *     OPERATION_NOT_SUPPORTED:
+     *         The specified device does not support this major version of the
+     *         HAL interface.
+     *     INTERNAL_ERROR:
+     *         A camera interface cannot be returned due to an unexpected
+     *         internal error.
+     * @return device The inteface to this camera device, or null in case of
+     *     error.
+     */
+    getCameraDeviceInterface_V1_x(string cameraDeviceName) generates
+            (Status status,
+             android.hardware.camera.device@1.0::ICameraDevice device);
+    getCameraDeviceInterface_V3_x(string cameraDeviceName) generates
+            (Status status,
+             android.hardware.camera.device@3.2::ICameraDevice device);
+
+};
diff --git a/camera/provider/2.4/ICameraProviderCallback.hal b/camera/provider/2.4/ICameraProviderCallback.hal
new file mode 100644
index 0000000..63dd3c5
--- /dev/null
+++ b/camera/provider/2.4/ICameraProviderCallback.hal
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.camera.provider@2.4;
+
+import android.hardware.camera.common@1.0::types;
+
+/**
+ * Callback functions for a camera provider HAL to use to inform the camera
+ * service of changes to the camera subsystem.
+ */
+interface ICameraProviderCallback {
+
+    /**
+     * cameraDeviceStatusChange:
+     *
+     * Callback to the camera service to indicate that the state of a specific
+     * camera device has changed.
+     *
+     * On camera service startup, when ICameraProvider::setCallback is invoked,
+     * the camera service must assume that all internal camera devices are in
+     * the CAMERA_DEVICE_STATUS_PRESENT state.
+     *
+     * The provider must call this method to inform the camera service of any
+     * initially NOT_PRESENT devices, and of any external camera devices that
+     * are already present, as soon as the callbacks are available through
+     * setCallback.
+     *
+     * @param cameraDeviceServiceName The name of the camera device that has a
+     *     new status.
+     * @param newStatus The new status that device is in.
+     *
+     */
+    cameraDeviceStatusChange(string cameraDeviceName,
+            CameraDeviceStatus newStatus);
+
+    /**
+     * torchModeStatusChange:
+     *
+     * Callback to the camera service to indicate that the state of the torch
+     * mode of the flash unit associated with a specific camera device has
+     * changed. At provider registration time, the camera service must assume
+     * the torch modes are in the TORCH_MODE_STATUS_AVAILABLE_OFF state if
+     * android.flash.info.available is reported as true via the
+     * ICameraDevice::getCameraCharacteristics call.
+     *
+     * @param cameraDeviceServiceName The name of the camera device that has a
+     *     new status.
+     * @param newStatus The new status that device is in.
+     *
+     */
+    torchModeStatusChange(string cameraDeviceName,
+            TorchModeStatus newStatus);
+
+};