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

Commit 0fa848d7 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

MTP: Add support for device property changed events

Also fixed bug in MtpProperty::write() for device properties

Bug: 7342482
Change-Id: If0099095d101409d131564e55b1939895c69c202
parent 3a06522f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -190,8 +190,8 @@ void MtpProperty::write(MtpDataPacket& packet) {
            if (deviceProp)
                writeValue(packet, mCurrentValue);
    }
    packet.putUInt32(mGroupCode);
    if (!deviceProp)
        packet.putUInt32(mGroupCode);
    packet.putUInt8(mFormFlag);
    if (mFormFlag == kFormRange) {
            writeValue(packet, mMinimumValue);
+6 −0
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ static const MtpEventCode kSupportedEventCodes[] = {
    MTP_EVENT_OBJECT_REMOVED,
    MTP_EVENT_STORE_ADDED,
    MTP_EVENT_STORE_REMOVED,
    MTP_EVENT_DEVICE_PROP_CHANGED,
};

MtpServer::MtpServer(int fd, MtpDatabase* database, bool ptp,
@@ -261,6 +262,11 @@ void MtpServer::sendStoreRemoved(MtpStorageID id) {
    sendEvent(MTP_EVENT_STORE_REMOVED, id);
}

void MtpServer::sendDevicePropertyChanged(MtpDeviceProperty property) {
    ALOGV("sendDevicePropertyChanged %d\n", property);
    sendEvent(MTP_EVENT_DEVICE_PROP_CHANGED, property);
}

void MtpServer::sendEvent(MtpEventCode code, uint32_t param1) {
    if (mSessionOpen) {
        mEvent.setEventCode(code);
+1 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ public:

    void                sendObjectAdded(MtpObjectHandle handle);
    void                sendObjectRemoved(MtpObjectHandle handle);
    void                sendDevicePropertyChanged(MtpDeviceProperty property);

private:
    void                sendStoreAdded(MtpStorageID id);