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

Commit c1d9854e authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 1164 into donut

* changes:
  Add new binder methods to camera client to support generic callbacks This is the first step in a multi-step change to move from the old specific callbacks to a generic callback. This will allow future flexibility in the interface without requiring binder rewrites. Bug 1837832
parents ba87f083 9b35233e
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -143,6 +143,8 @@ public:
    virtual void        errorCallback(status_t error);
    virtual void        errorCallback(status_t error);
    virtual void        autoFocusCallback(bool focused);
    virtual void        autoFocusCallback(bool focused);
    virtual void        recordingCallback(const sp<IMemory>& frame);
    virtual void        recordingCallback(const sp<IMemory>& frame);
    virtual void        notifyCallback(int32_t msgType, int32_t ext, int32_t ext2);
    virtual void        dataCallback(int32_t msgType, const sp<IMemory>& frame);


    sp<ICamera>         remote();
    sp<ICamera>         remote();


+19 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,23 @@ class ICameraClient: public IInterface
public:
public:
    DECLARE_META_INTERFACE(CameraClient);
    DECLARE_META_INTERFACE(CameraClient);


    // msgType in notifyCallback function
    enum {
        ERROR,
        SHUTTER,
        FOCUSED,
        ZOOM
    } notify_callback_message_type;

    // msgType in dataCallback function
    enum {
        PREVIEW,
        RECORD,
        POSTVIEW,
        RAW,
        COMPRESSED
    } data_callback_message_type;

    virtual void            shutterCallback() = 0;
    virtual void            shutterCallback() = 0;
    virtual void            rawCallback(const sp<IMemory>& picture) = 0;
    virtual void            rawCallback(const sp<IMemory>& picture) = 0;
    virtual void            jpegCallback(const sp<IMemory>& picture) = 0;
    virtual void            jpegCallback(const sp<IMemory>& picture) = 0;
@@ -36,6 +53,8 @@ public:
    virtual void            errorCallback(status_t error) = 0;
    virtual void            errorCallback(status_t error) = 0;
    virtual void            autoFocusCallback(bool focused) = 0;
    virtual void            autoFocusCallback(bool focused) = 0;
    virtual void            recordingCallback(const sp<IMemory>& frame) = 0;
    virtual void            recordingCallback(const sp<IMemory>& frame) = 0;
    virtual void            notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2) = 0;
    virtual void            dataCallback(int32_t msgType, const sp<IMemory>& data) = 0;


};
};


+12 −0
Original line number Original line Diff line number Diff line
@@ -397,6 +397,18 @@ void Camera::errorCallback(status_t error)
    }
    }
}
}


// callback from camera service
void Camera::notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2)
{
    LOGV("notifyCallback");
}

// callback from camera service when image is ready
void Camera::dataCallback(int32_t msgType, const sp<IMemory>& frame)
{
    LOGV("dataCallback");
}

void Camera::binderDied(const wp<IBinder>& who) {
void Camera::binderDied(const wp<IBinder>& who) {
    LOGW("ICamera died");
    LOGW("ICamera died");
    if (mErrorCallback) {
    if (mErrorCallback) {
+43 −0
Original line number Original line Diff line number Diff line
@@ -32,6 +32,8 @@ enum {
    ERROR_CALLBACK,
    ERROR_CALLBACK,
    AUTOFOCUS_CALLBACK,
    AUTOFOCUS_CALLBACK,
    RECORDING_CALLBACK,
    RECORDING_CALLBACK,
    NOTIFY_CALLBACK,
    DATA_CALLBACK,
};
};


class BpCameraClient: public BpInterface<ICameraClient>
class BpCameraClient: public BpInterface<ICameraClient>
@@ -110,6 +112,30 @@ public:
        data.writeInt32(focused);
        data.writeInt32(focused);
        remote()->transact(AUTOFOCUS_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
        remote()->transact(AUTOFOCUS_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
    }
    }

    // generic callback from camera service to app
    void notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2)
    {
        LOGV("notifyCallback");
        Parcel data, reply;
        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
        data.writeInt32(msgType);
        data.writeInt32(ext1);
        data.writeInt32(ext2);
        remote()->transact(NOTIFY_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
    }

    // generic data callback from camera service to app with image data
    void dataCallback(int32_t msgType, const sp<IMemory>& imageData)
    {
        LOGV("dataCallback");
        Parcel data, reply;
        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
        data.writeInt32(msgType);
        data.writeStrongBinder(imageData->asBinder());
        remote()->transact(DATA_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
    }

};
};


IMPLEMENT_META_INTERFACE(CameraClient, "android.hardware.ICameraClient");
IMPLEMENT_META_INTERFACE(CameraClient, "android.hardware.ICameraClient");
@@ -174,6 +200,23 @@ status_t BnCameraClient::onTransact(
            autoFocusCallback(focused);
            autoFocusCallback(focused);
            return NO_ERROR;
            return NO_ERROR;
        } break;
        } break;
        case NOTIFY_CALLBACK: {
            LOGV("NOTIFY_CALLBACK");
            CHECK_INTERFACE(ICameraClient, data, reply);
            int32_t msgType = data.readInt32();
            int32_t ext1 = data.readInt32();
            int32_t ext2 = data.readInt32();
            notifyCallback(msgType, ext1, ext2);
            return NO_ERROR;
        } break;
        case DATA_CALLBACK: {
            LOGV("RAW_CALLBACK");
            CHECK_INTERFACE(ICameraClient, data, reply);
            int32_t msgType = data.readInt32();
            sp<IMemory> imageData = interface_cast<IMemory>(data.readStrongBinder());
            dataCallback(msgType, imageData);
            return NO_ERROR;
        } break;
        default:
        default:
            return BBinder::onTransact(code, data, reply, flags);
            return BBinder::onTransact(code, data, reply, flags);
    }
    }