Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 51ac3550 authored by Eino-Ville Talvala's avatar Eino-Ville Talvala Committed by Android (Google) Code Review
Browse files

Merge "Camera service: Updates in preparation for HIDL"

parents 439caf85 f51fca27
Loading
Loading
Loading
Loading
+18 −20
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ namespace android {

namespace hardware {

status_t CameraInfo::writeToParcel(Parcel* parcel) const {
status_t CameraInfo::writeToParcel(android::Parcel* parcel) const {
    status_t res;
    res = parcel->writeInt32(facing);
    if (res != OK) return res;
@@ -47,7 +47,7 @@ status_t CameraInfo::writeToParcel(Parcel* parcel) const {
    return res;
}

status_t CameraInfo::readFromParcel(const Parcel* parcel) {
status_t CameraInfo::readFromParcel(const android::Parcel* parcel) {
    status_t res;
    res = parcel->readInt32(&facing);
    if (res != OK) return res;
@@ -55,8 +55,24 @@ status_t CameraInfo::readFromParcel(const Parcel* parcel) {
    return res;
}

status_t CameraStatus::writeToParcel(android::Parcel* parcel) const {
    status_t res;
    res = parcel->writeString8(cameraId);
    if (res != OK) return res;
    res = parcel->writeInt32(status);
    return res;
}

status_t CameraStatus::readFromParcel(const android::Parcel* parcel) {
    status_t res;
    res = parcel->readString8(&cameraId);
    if (res != OK) return res;
    res = parcel->readInt32(&status);
    return res;
}

} // namespace hardware

namespace {
    sp<::android::hardware::ICameraService> gCameraService;
    const int                 kCameraServicePollDelay = 500000; // 0.5s
@@ -239,24 +255,6 @@ status_t CameraBase<TCam, TCamTraits>::getCameraInfo(int cameraId,
    return res.isOk() ? OK : res.serviceSpecificErrorCode();
}

template <typename TCam, typename TCamTraits>
status_t CameraBase<TCam, TCamTraits>::addServiceListener(
        const sp<::android::hardware::ICameraServiceListener>& listener) {
    const sp<::android::hardware::ICameraService>& cs = getCameraService();
    if (cs == 0) return UNKNOWN_ERROR;
    binder::Status res = cs->addListener(listener);
    return res.isOk() ? OK : res.serviceSpecificErrorCode();
}

template <typename TCam, typename TCamTraits>
status_t CameraBase<TCam, TCamTraits>::removeServiceListener(
        const sp<::android::hardware::ICameraServiceListener>& listener) {
    const sp<::android::hardware::ICameraService>& cs = getCameraService();
    if (cs == 0) return UNKNOWN_ERROR;
    binder::Status res = cs->removeListener(listener);
    return res.isOk() ? OK : res.serviceSpecificErrorCode();
}

template class CameraBase<Camera>;

} // namespace android
+4 −4
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ bool CaptureResultExtras::isValid() {
    return requestId >= 0;
}

status_t CaptureResultExtras::readFromParcel(const Parcel *parcel) {
status_t CaptureResultExtras::readFromParcel(const android::Parcel *parcel) {
    if (parcel == NULL) {
        ALOGE("%s: Null parcel", __FUNCTION__);
        return BAD_VALUE;
@@ -43,7 +43,7 @@ status_t CaptureResultExtras::readFromParcel(const Parcel *parcel) {
    return OK;
}

status_t CaptureResultExtras::writeToParcel(Parcel *parcel) const {
status_t CaptureResultExtras::writeToParcel(android::Parcel *parcel) const {
    if (parcel == NULL) {
        ALOGE("%s: Null parcel", __FUNCTION__);
        return BAD_VALUE;
@@ -69,7 +69,7 @@ CaptureResult::CaptureResult(const CaptureResult &otherResult) {
    mMetadata = otherResult.mMetadata;
}

status_t CaptureResult::readFromParcel(Parcel *parcel) {
status_t CaptureResult::readFromParcel(android::Parcel *parcel) {

    ALOGV("%s: parcel = %p", __FUNCTION__, parcel);

@@ -100,7 +100,7 @@ status_t CaptureResult::readFromParcel(Parcel *parcel) {
    return OK;
}

status_t CaptureResult::writeToParcel(Parcel *parcel) const {
status_t CaptureResult::writeToParcel(android::Parcel *parcel) const {

    ALOGV("%s: parcel = %p", __FUNCTION__, parcel);

+2 −2
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ void VendorTagDescriptor::copyFrom(const VendorTagDescriptor& src) {
    mVendorOps = src.mVendorOps;
}

status_t VendorTagDescriptor::readFromParcel(const Parcel* parcel) {
status_t VendorTagDescriptor::readFromParcel(const android::Parcel* parcel) {
    status_t res = OK;
    if (parcel == NULL) {
        ALOGE("%s: parcel argument was NULL.", __FUNCTION__);
@@ -244,7 +244,7 @@ int VendorTagDescriptor::getTagType(uint32_t tag) const {
    return mTagToTypeMap.valueFor(tag);
}

status_t VendorTagDescriptor::writeToParcel(Parcel* parcel) const {
status_t VendorTagDescriptor::writeToParcel(android::Parcel* parcel) const {
    status_t res = OK;
    if (parcel == NULL) {
        ALOGE("%s: parcel argument was NULL.", __FUNCTION__);
+20 −0
Original line number Diff line number Diff line
/*
 * 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;

/** @hide */
parcelable CameraStatus cpp_header "camera/CameraBase.h";
+15 −6
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.hardware.camera2.params.VendorTagDescriptor;
import android.hardware.camera2.impl.CameraMetadataNative;
import android.hardware.ICameraServiceListener;
import android.hardware.CameraInfo;
import android.hardware.CameraStatus;

/**
 * Binder interface for the native camera service running in mediaserver.
@@ -83,7 +84,7 @@ interface ICameraService
     * Only supported for device HAL versions >= 3.2
     */
    ICameraDeviceUser connectDevice(ICameraDeviceCallbacks callbacks,
            int cameraId,
            String cameraId,
            String opPackageName,
            int clientUid);

@@ -102,16 +103,24 @@ interface ICameraService
            int clientUid);

    /**
     * Add/remove listeners for changes to camera device and flashlight state
     * Add listener for changes to camera device and flashlight state.
     *
     * Also returns the set of currently-known camera IDs and state of each device.
     * Adding a listener will trigger the torch status listener to fire for all
     * devices that have a flash unit
     */
    CameraStatus[] addListener(ICameraServiceListener listener);

    /**
     * Remove listener for changes to camera device and flashlight state.
     */
    void addListener(ICameraServiceListener listener);
    void removeListener(ICameraServiceListener listener);

    /**
     * Read the static camera metadata for a camera device.
     * Only supported for device HAL versions >= 3.2
     */
    CameraMetadataNative getCameraCharacteristics(int cameraId);
    CameraMetadataNative getCameraCharacteristics(String cameraId);

    /**
     * Read in the vendor tag descriptors from the camera module HAL.
@@ -132,9 +141,9 @@ interface ICameraService
    const int API_VERSION_2 = 2;

    // Determines if a particular API version is supported directly
    boolean supportsCameraApi(int cameraId, int apiVersion);
    boolean supportsCameraApi(String cameraId, int apiVersion);

    void setTorchMode(String CameraId, boolean enabled, IBinder clientBinder);
    void setTorchMode(String cameraId, boolean enabled, IBinder clientBinder);

    /**
     * Notify the camera service of a system event.  Should only be called from system_server.
Loading