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

Commit dc453d4e authored by Mike Lockwood's avatar Mike Lockwood
Browse files

MTP: Only send events to host if we have an open session.



Change-Id: I7b2d0c88c2d2ae0490247703d0fb1b862154db92
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent cbaea357
Loading
Loading
Loading
Loading
+16 −12
Original line number Diff line number Diff line
@@ -245,6 +245,7 @@ MtpProperty* MtpServer::getDeviceProperty(MtpPropertyCode propCode) {
}

void MtpServer::sendObjectAdded(MtpObjectHandle handle) {
    if (mSessionOpen) {
        LOGD("sendObjectAdded %d\n", handle);
        mEvent.setEventCode(MTP_EVENT_OBJECT_ADDED);
        mEvent.setTransactionID(mRequest.getTransactionID());
@@ -252,8 +253,10 @@ void MtpServer::sendObjectAdded(MtpObjectHandle handle) {
        int ret = mEvent.write(mFD);
        LOGD("mEvent.write returned %d\n", ret);
    }
}

void MtpServer::sendObjectRemoved(MtpObjectHandle handle) {
    if (mSessionOpen) {
        LOGD("sendObjectRemoved %d\n", handle);
        mEvent.setEventCode(MTP_EVENT_OBJECT_REMOVED);
        mEvent.setTransactionID(mRequest.getTransactionID());
@@ -261,6 +264,7 @@ void MtpServer::sendObjectRemoved(MtpObjectHandle handle) {
        int ret = mEvent.write(mFD);
        LOGD("mEvent.write returned %d\n", ret);
    }
}

void MtpServer::initObjectProperties() {
    mObjectProperties.push(new MtpProperty(MTP_PROPERTY_STORAGE_ID, MTP_TYPE_UINT16));