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

Commit 49f306f8 authored by Wu-cheng Li's avatar Wu-cheng Li Committed by Android (Google) Code Review
Browse files

Merge "Add a new camera open API that allows taking the ownership."

parents 2f70d9f8 2fd2440d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -116,13 +116,13 @@ status_t Camera::getCameraInfo(int cameraId,
    return cs->getCameraInfo(cameraId, cameraInfo);
}

sp<Camera> Camera::connect(int cameraId)
sp<Camera> Camera::connect(int cameraId, bool force, bool keep)
{
    ALOGV("connect");
    sp<Camera> c = new Camera();
    const sp<ICameraService>& cs = getCameraService();
    if (cs != 0) {
        c->mCamera = cs->connect(c, cameraId);
        c->mCamera = cs->connect(c, cameraId, force, keep);
    }
    if (c->mCamera != 0) {
        c->mCamera->asBinder()->linkToDeath(c);
+8 −3
Original line number Diff line number Diff line
@@ -56,12 +56,15 @@ public:
    }

    // connect to camera service
    virtual sp<ICamera> connect(const sp<ICameraClient>& cameraClient, int cameraId)
    virtual sp<ICamera> connect(const sp<ICameraClient>& cameraClient, int cameraId,
                                bool force, bool keep)
    {
        Parcel data, reply;
        data.writeInterfaceToken(ICameraService::getInterfaceDescriptor());
        data.writeStrongBinder(cameraClient->asBinder());
        data.writeInt32(cameraId);
        data.writeInt32(force);
        data.writeInt32(keep);
        remote()->transact(BnCameraService::CONNECT, data, &reply);
        return interface_cast<ICamera>(reply.readStrongBinder());
    }
@@ -93,7 +96,10 @@ status_t BnCameraService::onTransact(
        case CONNECT: {
            CHECK_INTERFACE(ICameraService, data, reply);
            sp<ICameraClient> cameraClient = interface_cast<ICameraClient>(data.readStrongBinder());
            sp<ICamera> camera = connect(cameraClient, data.readInt32());
            const int cameraId = data.readInt32();
            const int force = data.readInt32();
            const int keep = data.readInt32();
            sp<ICamera> camera = connect(cameraClient, cameraId, force, keep);
            reply->writeStrongBinder(camera->asBinder());
            return NO_ERROR;
        } break;
@@ -105,4 +111,3 @@ status_t BnCameraService::onTransact(
// ----------------------------------------------------------------------------

}; // namespace android
+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ public:
    static  int32_t     getNumberOfCameras();
    static  status_t    getCameraInfo(int cameraId,
                                      struct CameraInfo* cameraInfo);
    static  sp<Camera>  connect(int cameraId);
    static  sp<Camera>  connect(int cameraId, bool force, bool keep);
            virtual     ~Camera();
            void        init();

+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ public:
    virtual status_t        getCameraInfo(int cameraId,
                                          struct CameraInfo* cameraInfo) = 0;
    virtual sp<ICamera>     connect(const sp<ICameraClient>& cameraClient,
                                    int cameraId) = 0;
                                    int cameraId, bool force, bool keep) = 0;
};

// ----------------------------------------------------------------------------
+1 −1
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ status_t CameraSource::isCameraAvailable(
    int32_t cameraId) {

    if (camera == 0) {
        mCamera = Camera::connect(cameraId);
        mCamera = Camera::connect(cameraId, false, false);
        if (mCamera == 0) return -EBUSY;
        mCameraFlags &= ~FLAGS_HOT_CAMERA;
    } else {
Loading