Camera service: Updates in preparation for HIDL
- For all camera2 paths, and anything shared between the legacy API and
camera2, switch to using strings for camera IDs
- Update ICameraService.addListener to return current set of known
devices and their status, to allow for immediate return of camera
devices when first connecting to camera service
- Remove unused code path for getCameraCharacteristics with HALv1
- Add namespace qualifiers to Binder objects that are also used by
hardware binder.
- Switch to using new HIDL DeviceStatus and TorchStatus enumerations
for better type safety in the service; map more clearly between
the HAL, service-internal, and Binder enums.
Test: cts-tradefed run cts -m Camera --skip-connectivity-check -d -o --abi armeabi-v7a --disable-reboot
Bug: 32991422
Change-Id: I765951d9a21000a8432bed9aa0e3604709daa4b1
diff --git a/include/camera/CameraBase.h b/include/camera/CameraBase.h
index 0692a27..03fbdfd 100644
--- a/include/camera/CameraBase.h
+++ b/include/camera/CameraBase.h
@@ -17,7 +17,10 @@
#ifndef ANDROID_HARDWARE_CAMERA_BASE_H
#define ANDROID_HARDWARE_CAMERA_BASE_H
+#include <android/hardware/ICameraServiceListener.h>
+
#include <utils/Mutex.h>
+#include <binder/BinderService.h>
struct camera_frame_metadata;
@@ -29,6 +32,13 @@
class ICameraService;
class ICameraServiceListener;
+enum {
+ /** The facing of the camera is opposite to that of the screen. */
+ CAMERA_FACING_BACK = 0,
+ /** The facing of the camera is the same as that of the screen. */
+ CAMERA_FACING_FRONT = 1,
+};
+
struct CameraInfo : public android::Parcelable {
/**
* The direction that the camera faces to. It should be CAMERA_FACING_BACK
@@ -50,11 +60,33 @@
*/
int orientation;
- virtual status_t writeToParcel(Parcel* parcel) const;
- virtual status_t readFromParcel(const Parcel* parcel);
+ virtual status_t writeToParcel(android::Parcel* parcel) const;
+ virtual status_t readFromParcel(const android::Parcel* parcel);
};
+/**
+ * Basic status information about a camera device - its name and its current
+ * state.
+ */
+struct CameraStatus : public android::Parcelable {
+ /**
+ * The name of the camera device
+ */
+ String8 cameraId;
+
+ /**
+ * Its current status, one of the ICameraService::STATUS_* fields
+ */
+ int32_t status;
+
+ virtual status_t writeToParcel(android::Parcel* parcel) const;
+ virtual status_t readFromParcel(const android::Parcel* parcel);
+
+ CameraStatus(String8 id, int32_t s) : cameraId(id), status(s) {}
+ CameraStatus() : status(ICameraServiceListener::STATUS_PRESENT) {}
+};
+
} // namespace hardware
using hardware::CameraInfo;
@@ -86,12 +118,6 @@
/*out*/
struct hardware::CameraInfo* cameraInfo);
- static status_t addServiceListener(
- const sp<::android::hardware::ICameraServiceListener>& listener);
-
- static status_t removeServiceListener(
- const sp<::android::hardware::ICameraServiceListener>& listener);
-
sp<TCamUser> remote();
// Status is set to 'UNKNOWN_ERROR' after successful (re)connection
diff --git a/include/camera/CaptureResult.h b/include/camera/CaptureResult.h
index 45e4518..917d953 100644
--- a/include/camera/CaptureResult.h
+++ b/include/camera/CaptureResult.h
@@ -88,8 +88,8 @@
*/
bool isValid();
- virtual status_t readFromParcel(const Parcel* parcel) override;
- virtual status_t writeToParcel(Parcel* parcel) const override;
+ virtual status_t readFromParcel(const android::Parcel* parcel) override;
+ virtual status_t writeToParcel(android::Parcel* parcel) const override;
};
} // namespace impl
} // namespace camera2
@@ -105,8 +105,8 @@
CaptureResult(const CaptureResult& otherResult);
- status_t readFromParcel(Parcel* parcel);
- status_t writeToParcel(Parcel* parcel) const;
+ status_t readFromParcel(android::Parcel* parcel);
+ status_t writeToParcel(android::Parcel* parcel) const;
};
}
diff --git a/include/camera/VendorTagDescriptor.h b/include/camera/VendorTagDescriptor.h
index bfc8c96..adfc8c7 100644
--- a/include/camera/VendorTagDescriptor.h
+++ b/include/camera/VendorTagDescriptor.h
@@ -76,7 +76,7 @@
*/
virtual status_t writeToParcel(
/*out*/
- Parcel* parcel) const override;
+ android::Parcel* parcel) const override;
/**
* Convenience method to get a vector containing all vendor tag
@@ -103,7 +103,7 @@
*
* Returns OK on success, or a negative error code.
*/
- virtual status_t readFromParcel(const Parcel* parcel) override;
+ virtual status_t readFromParcel(const android::Parcel* parcel) override;
protected:
KeyedVector<String8, KeyedVector<String8, uint32_t>*> mReverseMapping;
diff --git a/include/camera/android/hardware/ICamera.h b/include/camera/android/hardware/ICamera.h
index 3b12afe..315669e 100644
--- a/include/camera/android/hardware/ICamera.h
+++ b/include/camera/android/hardware/ICamera.h
@@ -33,7 +33,7 @@
class ICameraClient;
-class ICamera: public IInterface
+class ICamera: public android::IInterface
{
/**
* Keep up-to-date with ICamera.aidl in frameworks/base
@@ -139,7 +139,7 @@
// ----------------------------------------------------------------------------
-class BnCamera: public BnInterface<ICamera>
+class BnCamera: public android::BnInterface<ICamera>
{
public:
virtual status_t onTransact( uint32_t code,
diff --git a/include/camera/android/hardware/ICameraClient.h b/include/camera/android/hardware/ICameraClient.h
index 3f835a9..f6ee311 100644
--- a/include/camera/android/hardware/ICameraClient.h
+++ b/include/camera/android/hardware/ICameraClient.h
@@ -27,7 +27,7 @@
namespace android {
namespace hardware {
-class ICameraClient: public IInterface
+class ICameraClient: public android::IInterface
{
public:
DECLARE_META_INTERFACE(CameraClient);
@@ -45,7 +45,7 @@
// ----------------------------------------------------------------------------
-class BnCameraClient: public BnInterface<ICameraClient>
+class BnCameraClient: public android::BnInterface<ICameraClient>
{
public:
virtual status_t onTransact( uint32_t code,
diff --git a/include/camera/camera2/CaptureRequest.h b/include/camera/camera2/CaptureRequest.h
index c989f26..978f48d 100644
--- a/include/camera/camera2/CaptureRequest.h
+++ b/include/camera/camera2/CaptureRequest.h
@@ -37,8 +37,8 @@
/**
* Keep impl up-to-date with CaptureRequest.java in frameworks/base
*/
- status_t readFromParcel(const Parcel* parcel) override;
- status_t writeToParcel(Parcel* parcel) const override;
+ status_t readFromParcel(const android::Parcel* parcel) override;
+ status_t writeToParcel(android::Parcel* parcel) const override;
};
} // namespace camera2
diff --git a/include/camera/camera2/OutputConfiguration.h b/include/camera/camera2/OutputConfiguration.h
index cf8f3c6..cb04c0e 100644
--- a/include/camera/camera2/OutputConfiguration.h
+++ b/include/camera/camera2/OutputConfiguration.h
@@ -47,9 +47,9 @@
/**
* Keep impl up-to-date with OutputConfiguration.java in frameworks/base
*/
- virtual status_t writeToParcel(Parcel* parcel) const override;
+ virtual status_t writeToParcel(android::Parcel* parcel) const override;
- virtual status_t readFromParcel(const Parcel* parcel) override;
+ virtual status_t readFromParcel(const android::Parcel* parcel) override;
// getGraphicBufferProducer will be NULL
// getRotation will be INVALID_ROTATION
@@ -59,7 +59,7 @@
// getGraphicBufferProducer will be NULL if error occurred
// getRotation will be INVALID_ROTATION if error occurred
// getSurfaceSetID will be INVALID_SET_ID if error occurred
- OutputConfiguration(const Parcel& parcel);
+ OutputConfiguration(const android::Parcel& parcel);
OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation,
int surfaceSetID = INVALID_SET_ID);
@@ -105,7 +105,7 @@
int mWidth;
int mHeight;
// helper function
- static String16 readMaybeEmptyString16(const Parcel* parcel);
+ static String16 readMaybeEmptyString16(const android::Parcel* parcel);
};
} // namespace params
} // namespace camera2
diff --git a/include/camera/camera2/SubmitInfo.h b/include/camera/camera2/SubmitInfo.h
index 3b47b32..8f271c0 100644
--- a/include/camera/camera2/SubmitInfo.h
+++ b/include/camera/camera2/SubmitInfo.h
@@ -31,8 +31,8 @@
int32_t mRequestId;
int64_t mLastFrameNumber;
- virtual status_t writeToParcel(Parcel *parcel) const override;
- virtual status_t readFromParcel(const Parcel* parcel) override;
+ virtual status_t writeToParcel(android::Parcel *parcel) const override;
+ virtual status_t readFromParcel(const android::Parcel* parcel) override;
};