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

Commit fc24492a authored by Siarhei Vishniakou's avatar Siarhei Vishniakou Committed by Android (Google) Code Review
Browse files

Merge "Use enum class for EventEntry"

parents d0d7ce9a 49483274
Loading
Loading
Loading
Loading
+5 −5
Original line number Original line Diff line number Diff line
@@ -60,7 +60,7 @@ static std::string keyActionToString(int32_t action) {


// --- EventEntry ---
// --- EventEntry ---


EventEntry::EventEntry(uint32_t sequenceNum, int32_t type, nsecs_t eventTime, uint32_t policyFlags)
EventEntry::EventEntry(uint32_t sequenceNum, Type type, nsecs_t eventTime, uint32_t policyFlags)
      : sequenceNum(sequenceNum),
      : sequenceNum(sequenceNum),
        refCount(1),
        refCount(1),
        type(type),
        type(type),
@@ -92,7 +92,7 @@ void EventEntry::releaseInjectionState() {
// --- ConfigurationChangedEntry ---
// --- ConfigurationChangedEntry ---


ConfigurationChangedEntry::ConfigurationChangedEntry(uint32_t sequenceNum, nsecs_t eventTime)
ConfigurationChangedEntry::ConfigurationChangedEntry(uint32_t sequenceNum, nsecs_t eventTime)
      : EventEntry(sequenceNum, TYPE_CONFIGURATION_CHANGED, eventTime, 0) {}
      : EventEntry(sequenceNum, Type::CONFIGURATION_CHANGED, eventTime, 0) {}


ConfigurationChangedEntry::~ConfigurationChangedEntry() {}
ConfigurationChangedEntry::~ConfigurationChangedEntry() {}


@@ -103,7 +103,7 @@ void ConfigurationChangedEntry::appendDescription(std::string& msg) const {
// --- DeviceResetEntry ---
// --- DeviceResetEntry ---


DeviceResetEntry::DeviceResetEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId)
DeviceResetEntry::DeviceResetEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId)
      : EventEntry(sequenceNum, TYPE_DEVICE_RESET, eventTime, 0), deviceId(deviceId) {}
      : EventEntry(sequenceNum, Type::DEVICE_RESET, eventTime, 0), deviceId(deviceId) {}


DeviceResetEntry::~DeviceResetEntry() {}
DeviceResetEntry::~DeviceResetEntry() {}


@@ -117,7 +117,7 @@ KeyEntry::KeyEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, ui
                   int32_t displayId, uint32_t policyFlags, int32_t action, int32_t flags,
                   int32_t displayId, uint32_t policyFlags, int32_t action, int32_t flags,
                   int32_t keyCode, int32_t scanCode, int32_t metaState, int32_t repeatCount,
                   int32_t keyCode, int32_t scanCode, int32_t metaState, int32_t repeatCount,
                   nsecs_t downTime)
                   nsecs_t downTime)
      : EventEntry(sequenceNum, TYPE_KEY, eventTime, policyFlags),
      : EventEntry(sequenceNum, Type::KEY, eventTime, policyFlags),
        deviceId(deviceId),
        deviceId(deviceId),
        source(source),
        source(source),
        displayId(displayId),
        displayId(displayId),
@@ -165,7 +165,7 @@ MotionEntry::MotionEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t device
                         float xCursorPosition, float yCursorPosition, nsecs_t downTime,
                         float xCursorPosition, float yCursorPosition, nsecs_t downTime,
                         uint32_t pointerCount, const PointerProperties* pointerProperties,
                         uint32_t pointerCount, const PointerProperties* pointerProperties,
                         const PointerCoords* pointerCoords, float xOffset, float yOffset)
                         const PointerCoords* pointerCoords, float xOffset, float yOffset)
      : EventEntry(sequenceNum, TYPE_MOTION, eventTime, policyFlags),
      : EventEntry(sequenceNum, Type::MOTION, eventTime, policyFlags),
        eventTime(eventTime),
        eventTime(eventTime),
        deviceId(deviceId),
        deviceId(deviceId),
        source(source),
        source(source),
+16 −3
Original line number Original line Diff line number Diff line
@@ -33,11 +33,24 @@ namespace android::inputdispatcher {
constexpr uint32_t SYNTHESIZED_EVENT_SEQUENCE_NUM = 0;
constexpr uint32_t SYNTHESIZED_EVENT_SEQUENCE_NUM = 0;


struct EventEntry {
struct EventEntry {
    enum { TYPE_CONFIGURATION_CHANGED, TYPE_DEVICE_RESET, TYPE_KEY, TYPE_MOTION };
    enum class Type { CONFIGURATION_CHANGED, DEVICE_RESET, KEY, MOTION };

    static const char* typeToString(Type type) {
        switch (type) {
            case Type::CONFIGURATION_CHANGED:
                return "CONFIGURATION_CHANGED";
            case Type::DEVICE_RESET:
                return "DEVICE_RESET";
            case Type::KEY:
                return "KEY";
            case Type::MOTION:
                return "MOTION";
        }
    }


    uint32_t sequenceNum;
    uint32_t sequenceNum;
    mutable int32_t refCount;
    mutable int32_t refCount;
    int32_t type;
    Type type;
    nsecs_t eventTime;
    nsecs_t eventTime;
    uint32_t policyFlags;
    uint32_t policyFlags;
    InjectionState* injectionState;
    InjectionState* injectionState;
@@ -66,7 +79,7 @@ struct EventEntry {
    virtual void appendDescription(std::string& msg) const = 0;
    virtual void appendDescription(std::string& msg) const = 0;


protected:
protected:
    EventEntry(uint32_t sequenceNum, int32_t type, nsecs_t eventTime, uint32_t policyFlags);
    EventEntry(uint32_t sequenceNum, Type type, nsecs_t eventTime, uint32_t policyFlags);
    virtual ~EventEntry();
    virtual ~EventEntry();
    void releaseInjectionState();
    void releaseInjectionState();
};
};
+55 −28
Original line number Original line Diff line number Diff line
@@ -386,7 +386,7 @@ void InputDispatcher::dispatchOnceInnerLocked(nsecs_t* nextWakeupTime) {
    }
    }


    switch (mPendingEvent->type) {
    switch (mPendingEvent->type) {
        case EventEntry::TYPE_CONFIGURATION_CHANGED: {
        case EventEntry::Type::CONFIGURATION_CHANGED: {
            ConfigurationChangedEntry* typedEntry =
            ConfigurationChangedEntry* typedEntry =
                    static_cast<ConfigurationChangedEntry*>(mPendingEvent);
                    static_cast<ConfigurationChangedEntry*>(mPendingEvent);
            done = dispatchConfigurationChangedLocked(currentTime, typedEntry);
            done = dispatchConfigurationChangedLocked(currentTime, typedEntry);
@@ -394,14 +394,14 @@ void InputDispatcher::dispatchOnceInnerLocked(nsecs_t* nextWakeupTime) {
            break;
            break;
        }
        }


        case EventEntry::TYPE_DEVICE_RESET: {
        case EventEntry::Type::DEVICE_RESET: {
            DeviceResetEntry* typedEntry = static_cast<DeviceResetEntry*>(mPendingEvent);
            DeviceResetEntry* typedEntry = static_cast<DeviceResetEntry*>(mPendingEvent);
            done = dispatchDeviceResetLocked(currentTime, typedEntry);
            done = dispatchDeviceResetLocked(currentTime, typedEntry);
            dropReason = DropReason::NOT_DROPPED; // device resets are never dropped
            dropReason = DropReason::NOT_DROPPED; // device resets are never dropped
            break;
            break;
        }
        }


        case EventEntry::TYPE_KEY: {
        case EventEntry::Type::KEY: {
            KeyEntry* typedEntry = static_cast<KeyEntry*>(mPendingEvent);
            KeyEntry* typedEntry = static_cast<KeyEntry*>(mPendingEvent);
            if (isAppSwitchDue) {
            if (isAppSwitchDue) {
                if (isAppSwitchKeyEvent(*typedEntry)) {
                if (isAppSwitchKeyEvent(*typedEntry)) {
@@ -421,7 +421,7 @@ void InputDispatcher::dispatchOnceInnerLocked(nsecs_t* nextWakeupTime) {
            break;
            break;
        }
        }


        case EventEntry::TYPE_MOTION: {
        case EventEntry::Type::MOTION: {
            MotionEntry* typedEntry = static_cast<MotionEntry*>(mPendingEvent);
            MotionEntry* typedEntry = static_cast<MotionEntry*>(mPendingEvent);
            if (dropReason == DropReason::NOT_DROPPED && isAppSwitchDue) {
            if (dropReason == DropReason::NOT_DROPPED && isAppSwitchDue) {
                dropReason = DropReason::APP_SWITCH;
                dropReason = DropReason::APP_SWITCH;
@@ -435,10 +435,6 @@ void InputDispatcher::dispatchOnceInnerLocked(nsecs_t* nextWakeupTime) {
            done = dispatchMotionLocked(currentTime, typedEntry, &dropReason, nextWakeupTime);
            done = dispatchMotionLocked(currentTime, typedEntry, &dropReason, nextWakeupTime);
            break;
            break;
        }
        }

        default:
            ALOG_ASSERT(false);
            break;
    }
    }


    if (done) {
    if (done) {
@@ -458,7 +454,7 @@ bool InputDispatcher::enqueueInboundEventLocked(EventEntry* entry) {
    traceInboundQueueLengthLocked();
    traceInboundQueueLengthLocked();


    switch (entry->type) {
    switch (entry->type) {
        case EventEntry::TYPE_KEY: {
        case EventEntry::Type::KEY: {
            // Optimize app switch latency.
            // Optimize app switch latency.
            // If the application takes too long to catch up then we drop all events preceding
            // If the application takes too long to catch up then we drop all events preceding
            // the app switch key.
            // the app switch key.
@@ -480,7 +476,7 @@ bool InputDispatcher::enqueueInboundEventLocked(EventEntry* entry) {
            break;
            break;
        }
        }


        case EventEntry::TYPE_MOTION: {
        case EventEntry::Type::MOTION: {
            // Optimize case where the current application is unresponsive and the user
            // Optimize case where the current application is unresponsive and the user
            // decides to touch a window in a different application.
            // decides to touch a window in a different application.
            // If the application takes too long to catch up then we drop all events preceding
            // If the application takes too long to catch up then we drop all events preceding
@@ -508,6 +504,11 @@ bool InputDispatcher::enqueueInboundEventLocked(EventEntry* entry) {
            }
            }
            break;
            break;
        }
        }
        case EventEntry::Type::CONFIGURATION_CHANGED:
        case EventEntry::Type::DEVICE_RESET: {
            // nothing to do
            break;
        }
    }
    }


    return needWake;
    return needWake;
@@ -627,12 +628,12 @@ void InputDispatcher::dropInboundEventLocked(const EventEntry& entry, DropReason
    }
    }


    switch (entry.type) {
    switch (entry.type) {
        case EventEntry::TYPE_KEY: {
        case EventEntry::Type::KEY: {
            CancelationOptions options(CancelationOptions::CANCEL_NON_POINTER_EVENTS, reason);
            CancelationOptions options(CancelationOptions::CANCEL_NON_POINTER_EVENTS, reason);
            synthesizeCancelationEventsForAllConnectionsLocked(options);
            synthesizeCancelationEventsForAllConnectionsLocked(options);
            break;
            break;
        }
        }
        case EventEntry::TYPE_MOTION: {
        case EventEntry::Type::MOTION: {
            const MotionEntry& motionEntry = static_cast<const MotionEntry&>(entry);
            const MotionEntry& motionEntry = static_cast<const MotionEntry&>(entry);
            if (motionEntry.source & AINPUT_SOURCE_CLASS_POINTER) {
            if (motionEntry.source & AINPUT_SOURCE_CLASS_POINTER) {
                CancelationOptions options(CancelationOptions::CANCEL_POINTER_EVENTS, reason);
                CancelationOptions options(CancelationOptions::CANCEL_POINTER_EVENTS, reason);
@@ -643,6 +644,11 @@ void InputDispatcher::dropInboundEventLocked(const EventEntry& entry, DropReason
            }
            }
            break;
            break;
        }
        }
        case EventEntry::Type::CONFIGURATION_CHANGED:
        case EventEntry::Type::DEVICE_RESET: {
            LOG_ALWAYS_FATAL("Should not drop %s events", EventEntry::typeToString(entry.type));
            break;
        }
    }
    }
}
}


@@ -1174,18 +1180,19 @@ void InputDispatcher::resetANRTimeoutsLocked() {
int32_t InputDispatcher::getTargetDisplayId(const EventEntry& entry) {
int32_t InputDispatcher::getTargetDisplayId(const EventEntry& entry) {
    int32_t displayId;
    int32_t displayId;
    switch (entry.type) {
    switch (entry.type) {
        case EventEntry::TYPE_KEY: {
        case EventEntry::Type::KEY: {
            const KeyEntry& keyEntry = static_cast<const KeyEntry&>(entry);
            const KeyEntry& keyEntry = static_cast<const KeyEntry&>(entry);
            displayId = keyEntry.displayId;
            displayId = keyEntry.displayId;
            break;
            break;
        }
        }
        case EventEntry::TYPE_MOTION: {
        case EventEntry::Type::MOTION: {
            const MotionEntry& motionEntry = static_cast<const MotionEntry&>(entry);
            const MotionEntry& motionEntry = static_cast<const MotionEntry&>(entry);
            displayId = motionEntry.displayId;
            displayId = motionEntry.displayId;
            break;
            break;
        }
        }
        default: {
        case EventEntry::Type::CONFIGURATION_CHANGED:
            ALOGE("Unsupported event type '%" PRId32 "' for target display.", entry.type);
        case EventEntry::Type::DEVICE_RESET: {
            ALOGE("%s events do not have a target display", EventEntry::typeToString(entry.type));
            return ADISPLAY_ID_NONE;
            return ADISPLAY_ID_NONE;
        }
        }
    }
    }
@@ -1849,7 +1856,7 @@ std::string InputDispatcher::checkWindowReadyForMoreInputLocked(
    }
    }


    // Ensure that the dispatch queues aren't too far backed up for this event.
    // Ensure that the dispatch queues aren't too far backed up for this event.
    if (eventEntry.type == EventEntry::TYPE_KEY) {
    if (eventEntry.type == EventEntry::Type::KEY) {
        // If the event is a key event, then we must wait for all previous events to
        // If the event is a key event, then we must wait for all previous events to
        // complete before delivering it because previous events may have the
        // complete before delivering it because previous events may have the
        // side-effect of transferring focus to a different window and we want to
        // side-effect of transferring focus to a different window and we want to
@@ -1937,7 +1944,7 @@ void InputDispatcher::pokeUserActivityLocked(const EventEntry& eventEntry) {


    int32_t eventType = USER_ACTIVITY_EVENT_OTHER;
    int32_t eventType = USER_ACTIVITY_EVENT_OTHER;
    switch (eventEntry.type) {
    switch (eventEntry.type) {
        case EventEntry::TYPE_MOTION: {
        case EventEntry::Type::MOTION: {
            const MotionEntry& motionEntry = static_cast<const MotionEntry&>(eventEntry);
            const MotionEntry& motionEntry = static_cast<const MotionEntry&>(eventEntry);
            if (motionEntry.action == AMOTION_EVENT_ACTION_CANCEL) {
            if (motionEntry.action == AMOTION_EVENT_ACTION_CANCEL) {
                return;
                return;
@@ -1948,7 +1955,7 @@ void InputDispatcher::pokeUserActivityLocked(const EventEntry& eventEntry) {
            }
            }
            break;
            break;
        }
        }
        case EventEntry::TYPE_KEY: {
        case EventEntry::Type::KEY: {
            const KeyEntry& keyEntry = static_cast<const KeyEntry&>(eventEntry);
            const KeyEntry& keyEntry = static_cast<const KeyEntry&>(eventEntry);
            if (keyEntry.flags & AKEY_EVENT_FLAG_CANCELED) {
            if (keyEntry.flags & AKEY_EVENT_FLAG_CANCELED) {
                return;
                return;
@@ -1956,6 +1963,12 @@ void InputDispatcher::pokeUserActivityLocked(const EventEntry& eventEntry) {
            eventType = USER_ACTIVITY_EVENT_BUTTON;
            eventType = USER_ACTIVITY_EVENT_BUTTON;
            break;
            break;
        }
        }
        case EventEntry::Type::CONFIGURATION_CHANGED:
        case EventEntry::Type::DEVICE_RESET: {
            LOG_ALWAYS_FATAL("%s events are not user activity",
                             EventEntry::typeToString(eventEntry.type));
            break;
        }
    }
    }


    std::unique_ptr<CommandEntry> commandEntry =
    std::unique_ptr<CommandEntry> commandEntry =
@@ -1996,7 +2009,7 @@ void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime,


    // Split a motion event if needed.
    // Split a motion event if needed.
    if (inputTarget->flags & InputTarget::FLAG_SPLIT) {
    if (inputTarget->flags & InputTarget::FLAG_SPLIT) {
        ALOG_ASSERT(eventEntry->type == EventEntry::TYPE_MOTION);
        ALOG_ASSERT(eventEntry->type == EventEntry::Type::MOTION);


        const MotionEntry& originalMotionEntry = static_cast<const MotionEntry&>(*eventEntry);
        const MotionEntry& originalMotionEntry = static_cast<const MotionEntry&>(*eventEntry);
        if (inputTarget->pointerIds.count() != originalMotionEntry.pointerCount) {
        if (inputTarget->pointerIds.count() != originalMotionEntry.pointerCount) {
@@ -2080,7 +2093,7 @@ void InputDispatcher::enqueueDispatchEntryLocked(const sp<Connection>& connectio


    // Apply target flags and update the connection's input state.
    // Apply target flags and update the connection's input state.
    switch (eventEntry->type) {
    switch (eventEntry->type) {
        case EventEntry::TYPE_KEY: {
        case EventEntry::Type::KEY: {
            const KeyEntry& keyEntry = static_cast<const KeyEntry&>(*eventEntry);
            const KeyEntry& keyEntry = static_cast<const KeyEntry&>(*eventEntry);
            dispatchEntry->resolvedAction = keyEntry.action;
            dispatchEntry->resolvedAction = keyEntry.action;
            dispatchEntry->resolvedFlags = keyEntry.flags;
            dispatchEntry->resolvedFlags = keyEntry.flags;
@@ -2097,7 +2110,7 @@ void InputDispatcher::enqueueDispatchEntryLocked(const sp<Connection>& connectio
            break;
            break;
        }
        }


        case EventEntry::TYPE_MOTION: {
        case EventEntry::Type::MOTION: {
            const MotionEntry& motionEntry = static_cast<const MotionEntry&>(*eventEntry);
            const MotionEntry& motionEntry = static_cast<const MotionEntry&>(*eventEntry);
            if (dispatchMode & InputTarget::FLAG_DISPATCH_AS_OUTSIDE) {
            if (dispatchMode & InputTarget::FLAG_DISPATCH_AS_OUTSIDE) {
                dispatchEntry->resolvedAction = AMOTION_EVENT_ACTION_OUTSIDE;
                dispatchEntry->resolvedAction = AMOTION_EVENT_ACTION_OUTSIDE;
@@ -2147,6 +2160,12 @@ void InputDispatcher::enqueueDispatchEntryLocked(const sp<Connection>& connectio


            break;
            break;
        }
        }
        case EventEntry::Type::CONFIGURATION_CHANGED:
        case EventEntry::Type::DEVICE_RESET: {
            LOG_ALWAYS_FATAL("%s events should not go to apps",
                             EventEntry::typeToString(eventEntry->type));
            break;
        }
    }
    }


    // Remember that we are waiting for this dispatch to complete.
    // Remember that we are waiting for this dispatch to complete.
@@ -2206,7 +2225,7 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
        status_t status;
        status_t status;
        EventEntry* eventEntry = dispatchEntry->eventEntry;
        EventEntry* eventEntry = dispatchEntry->eventEntry;
        switch (eventEntry->type) {
        switch (eventEntry->type) {
            case EventEntry::TYPE_KEY: {
            case EventEntry::Type::KEY: {
                KeyEntry* keyEntry = static_cast<KeyEntry*>(eventEntry);
                KeyEntry* keyEntry = static_cast<KeyEntry*>(eventEntry);


                // Publish the key event.
                // Publish the key event.
@@ -2221,7 +2240,7 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
                break;
                break;
            }
            }


            case EventEntry::TYPE_MOTION: {
            case EventEntry::Type::MOTION: {
                MotionEntry* motionEntry = static_cast<MotionEntry*>(eventEntry);
                MotionEntry* motionEntry = static_cast<MotionEntry*>(eventEntry);


                PointerCoords scaledCoords[MAX_POINTERS];
                PointerCoords scaledCoords[MAX_POINTERS];
@@ -2502,16 +2521,24 @@ void InputDispatcher::synthesizeCancelationEventsForConnectionLocked(
        for (size_t i = 0; i < cancelationEvents.size(); i++) {
        for (size_t i = 0; i < cancelationEvents.size(); i++) {
            EventEntry* cancelationEventEntry = cancelationEvents[i];
            EventEntry* cancelationEventEntry = cancelationEvents[i];
            switch (cancelationEventEntry->type) {
            switch (cancelationEventEntry->type) {
                case EventEntry::TYPE_KEY:
                case EventEntry::Type::KEY: {
                    logOutboundKeyDetails("cancel - ",
                    logOutboundKeyDetails("cancel - ",
                                          static_cast<const KeyEntry&>(*cancelationEventEntry));
                                          static_cast<const KeyEntry&>(*cancelationEventEntry));
                    break;
                    break;
                case EventEntry::TYPE_MOTION:
                }
                case EventEntry::Type::MOTION: {
                    logOutboundMotionDetails("cancel - ",
                    logOutboundMotionDetails("cancel - ",
                                             static_cast<const MotionEntry&>(
                                             static_cast<const MotionEntry&>(
                                                     *cancelationEventEntry));
                                                     *cancelationEventEntry));
                    break;
                    break;
                }
                }
                case EventEntry::Type::CONFIGURATION_CHANGED:
                case EventEntry::Type::DEVICE_RESET: {
                    LOG_ALWAYS_FATAL("%s event should not be found inside Connections's queue",
                                     EventEntry::typeToString(cancelationEventEntry->type));
                    break;
                }
            }


            InputTarget target;
            InputTarget target;
            sp<InputWindowHandle> windowHandle =
            sp<InputWindowHandle> windowHandle =
@@ -4237,11 +4264,11 @@ void InputDispatcher::doDispatchCycleFinishedLockedInterruptible(CommandEntry* c
    }
    }


    bool restartEvent;
    bool restartEvent;
    if (dispatchEntry->eventEntry->type == EventEntry::TYPE_KEY) {
    if (dispatchEntry->eventEntry->type == EventEntry::Type::KEY) {
        KeyEntry* keyEntry = static_cast<KeyEntry*>(dispatchEntry->eventEntry);
        KeyEntry* keyEntry = static_cast<KeyEntry*>(dispatchEntry->eventEntry);
        restartEvent =
        restartEvent =
                afterKeyEventLockedInterruptible(connection, dispatchEntry, keyEntry, handled);
                afterKeyEventLockedInterruptible(connection, dispatchEntry, keyEntry, handled);
    } else if (dispatchEntry->eventEntry->type == EventEntry::TYPE_MOTION) {
    } else if (dispatchEntry->eventEntry->type == EventEntry::Type::MOTION) {
        MotionEntry* motionEntry = static_cast<MotionEntry*>(dispatchEntry->eventEntry);
        MotionEntry* motionEntry = static_cast<MotionEntry*>(dispatchEntry->eventEntry);
        restartEvent = afterMotionEventLockedInterruptible(connection, dispatchEntry, motionEntry,
        restartEvent = afterMotionEventLockedInterruptible(connection, dispatchEntry, motionEntry,
                                                           handled);
                                                           handled);
+2 −2
Original line number Original line Diff line number Diff line
@@ -56,8 +56,8 @@ void SwitchInputMapper::processSwitch(int32_t switchCode, int32_t switchValue) {
void SwitchInputMapper::sync(nsecs_t when) {
void SwitchInputMapper::sync(nsecs_t when) {
    if (mUpdatedSwitchMask) {
    if (mUpdatedSwitchMask) {
        uint32_t updatedSwitchValues = mSwitchValues & mUpdatedSwitchMask;
        uint32_t updatedSwitchValues = mSwitchValues & mUpdatedSwitchMask;
        NotifySwitchArgs args(mContext->getNextSequenceNum(), when, 0, updatedSwitchValues,
        NotifySwitchArgs args(mContext->getNextSequenceNum(), when, 0 /*policyFlags*/,
                              mUpdatedSwitchMask);
                              updatedSwitchValues, mUpdatedSwitchMask);
        getListener()->notifySwitch(&args);
        getListener()->notifySwitch(&args);


        mUpdatedSwitchMask = 0;
        mUpdatedSwitchMask = 0;