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

Commit 2fd2440d authored by Wu-cheng Li's avatar Wu-cheng Li
Browse files

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

The purpose is to let face unlock always get the camera
successfully. What happened was the camera applications may
have opened the camera in onResume under the lock screen.
This API lets face unlock take the camera from the camera
application. A new permission will be added, so other
applicatoins won't be able to take the camera from the face
unlock.

bug:5584464

Change-Id: Ib3d9dcbc2161815b68db42327dc01148453704c6
parent cbcd6e86
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