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

Commit 0a37a2c5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add toString and remove default case"

parents fc542f6c 3b37f9a0
Loading
Loading
Loading
Loading
+73 −74
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
static constexpr bool DEBUG_CHANNEL_LIFECYCLE = false;

// Log debug messages about transport actions
#define DEBUG_TRANSPORT_ACTIONS 0
static constexpr bool DEBUG_TRANSPORT_ACTIONS = false;

// Log debug messages about touch event resampling
#define DEBUG_RESAMPLING 0
@@ -88,6 +88,10 @@ inline static bool isPointerEvent(int32_t source) {
    return (source & AINPUT_SOURCE_CLASS_POINTER) == AINPUT_SOURCE_CLASS_POINTER;
}

inline static const char* toString(bool value) {
    return value ? "true" : "false";
}

// --- InputMessage ---

bool InputMessage::isValid(size_t actualSize) const {
@@ -216,10 +220,6 @@ void InputMessage::getSanitizedCopy(InputMessage* msg) const {
            msg->body.finished.handled = body.finished.handled;
            break;
        }
        default: {
            LOG_FATAL("Unexpected message type %i", header.type);
            break;
        }
    }
}

@@ -432,14 +432,13 @@ status_t InputPublisher::publishKeyEvent(
                mChannel->getName().c_str(), keyCode);
        ATRACE_NAME(message.c_str());
    }
#if DEBUG_TRANSPORT_ACTIONS
    if (DEBUG_TRANSPORT_ACTIONS) {
        ALOGD("channel '%s' publisher ~ publishKeyEvent: seq=%u, deviceId=%d, source=0x%x, "
              "action=0x%x, flags=0x%x, keyCode=%d, scanCode=%d, metaState=0x%x, repeatCount=%d,"
              "downTime=%" PRId64 ", eventTime=%" PRId64,
            mChannel->getName().c_str(), seq,
            deviceId, source, action, flags, keyCode, scanCode, metaState, repeatCount,
            downTime, eventTime);
#endif
              mChannel->getName().c_str(), seq, deviceId, source, action, flags, keyCode, scanCode,
              metaState, repeatCount, downTime, eventTime);
    }

    if (!seq) {
        ALOGE("Attempted to publish a key event with sequence number 0.");
@@ -476,18 +475,18 @@ status_t InputPublisher::publishMotionEvent(
                mChannel->getName().c_str(), action);
        ATRACE_NAME(message.c_str());
    }
#if DEBUG_TRANSPORT_ACTIONS
    if (DEBUG_TRANSPORT_ACTIONS) {
        ALOGD("channel '%s' publisher ~ publishMotionEvent: seq=%u, deviceId=%d, source=0x%x, "
              "displayId=%" PRId32 ", "
              "action=0x%x, actionButton=0x%08x, flags=0x%x, edgeFlags=0x%x, "
              "metaState=0x%x, buttonState=0x%x, classification=%s, xOffset=%f, yOffset=%f, "
              "xPrecision=%f, yPrecision=%f, downTime=%" PRId64 ", eventTime=%" PRId64 ", "
              "pointerCount=%" PRIu32,
            mChannel->getName().c_str(), seq,
            deviceId, source, displayId, action, actionButton, flags, edgeFlags, metaState,
            buttonState, motionClassificationToString(classification),
            xOffset, yOffset, xPrecision, yPrecision, downTime, eventTime, pointerCount);
#endif
              mChannel->getName().c_str(), seq, deviceId, source, displayId, action, actionButton,
              flags, edgeFlags, metaState, buttonState,
              motionClassificationToString(classification), xOffset, yOffset, xPrecision,
              yPrecision, downTime, eventTime, pointerCount);
    }

    if (!seq) {
        ALOGE("Attempted to publish a motion event with sequence number 0.");
@@ -531,10 +530,9 @@ status_t InputPublisher::publishMotionEvent(
}

status_t InputPublisher::receiveFinishedSignal(uint32_t* outSeq, bool* outHandled) {
#if DEBUG_TRANSPORT_ACTIONS
    ALOGD("channel '%s' publisher ~ receiveFinishedSignal",
            mChannel->getName().c_str());
#endif
    if (DEBUG_TRANSPORT_ACTIONS) {
        ALOGD("channel '%s' publisher ~ receiveFinishedSignal", mChannel->getName().c_str());
    }

    InputMessage msg;
    status_t result = mChannel->receiveMessage(&msg);
@@ -569,10 +567,10 @@ bool InputConsumer::isTouchResamplingEnabled() {

status_t InputConsumer::consume(InputEventFactoryInterface* factory,
        bool consumeBatches, nsecs_t frameTime, uint32_t* outSeq, InputEvent** outEvent) {
#if DEBUG_TRANSPORT_ACTIONS
    if (DEBUG_TRANSPORT_ACTIONS) {
        ALOGD("channel '%s' consumer ~ consume: consumeBatches=%s, frameTime=%" PRId64,
            mChannel->getName().c_str(), consumeBatches ? "true" : "false", frameTime);
#endif
              mChannel->getName().c_str(), toString(consumeBatches), frameTime);
    }

    *outSeq = 0;
    *outEvent = nullptr;
@@ -592,10 +590,10 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory,
                if (consumeBatches || result != WOULD_BLOCK) {
                    result = consumeBatch(factory, frameTime, outSeq, outEvent);
                    if (*outEvent) {
#if DEBUG_TRANSPORT_ACTIONS
                        if (DEBUG_TRANSPORT_ACTIONS) {
                            ALOGD("channel '%s' consumer ~ consumed batch event, seq=%u",
                                  mChannel->getName().c_str(), *outSeq);
#endif
                        }
                        break;
                    }
                }
@@ -611,10 +609,10 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory,
                initializeKeyEvent(keyEvent, &mMsg);
                *outSeq = mMsg.body.key.seq;
                *outEvent = keyEvent;
#if DEBUG_TRANSPORT_ACTIONS
                if (DEBUG_TRANSPORT_ACTIONS) {
                    ALOGD("channel '%s' consumer ~ consumed key event, seq=%u",
                          mChannel->getName().c_str(), *outSeq);
#endif
                }
            break;
            }

@@ -624,10 +622,10 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory,
                    Batch& batch = mBatches.editItemAt(batchIndex);
                    if (canAddSample(batch, &mMsg)) {
                        batch.samples.push(mMsg);
#if DEBUG_TRANSPORT_ACTIONS
                        if (DEBUG_TRANSPORT_ACTIONS) {
                            ALOGD("channel '%s' consumer ~ appended to batch event",
                                  mChannel->getName().c_str());
#endif
                        }
                    break;
                    } else if (isPointerEvent(mMsg.body.motion.source) &&
                               mMsg.body.motion.action == AMOTION_EVENT_ACTION_CANCEL) {
@@ -649,25 +647,25 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory,
                        if (result) {
                            return result;
                        }
#if DEBUG_TRANSPORT_ACTIONS
                        if (DEBUG_TRANSPORT_ACTIONS) {
                            ALOGD("channel '%s' consumer ~ consumed batch event and "
                                  "deferred current event, seq=%u",
                                  mChannel->getName().c_str(), *outSeq);
#endif
                        }
                    break;
                    }
                }

                // Start a new batch if needed.
            if (mMsg.body.motion.action == AMOTION_EVENT_ACTION_MOVE
                    || mMsg.body.motion.action == AMOTION_EVENT_ACTION_HOVER_MOVE) {
                if (mMsg.body.motion.action == AMOTION_EVENT_ACTION_MOVE ||
                    mMsg.body.motion.action == AMOTION_EVENT_ACTION_HOVER_MOVE) {
                    mBatches.push();
                    Batch& batch = mBatches.editTop();
                    batch.samples.push(mMsg);
#if DEBUG_TRANSPORT_ACTIONS
                    if (DEBUG_TRANSPORT_ACTIONS) {
                        ALOGD("channel '%s' consumer ~ started batch event",
                              mChannel->getName().c_str());
#endif
                    }
                    break;
                }

@@ -679,17 +677,18 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory,
            *outSeq = mMsg.body.motion.seq;
            *outEvent = motionEvent;

#if DEBUG_TRANSPORT_ACTIONS
            if (DEBUG_TRANSPORT_ACTIONS) {
                ALOGD("channel '%s' consumer ~ consumed motion event, seq=%u",
                      mChannel->getName().c_str(), *outSeq);
#endif
            }
            break;
            }

        default:
            ALOGE("channel '%s' consumer ~ Received unexpected message of type %d",
                    mChannel->getName().c_str(), mMsg.header.type);
            return UNKNOWN_ERROR;
            case InputMessage::Type::FINISHED: {
                LOG_ALWAYS_FATAL("Consumed a FINISHED message, which should never be seen by "
                                 "InputConsumer!");
                break;
            }
        }
    }
    return OK;
@@ -1014,10 +1013,10 @@ bool InputConsumer::shouldResampleTool(int32_t toolType) {
}

status_t InputConsumer::sendFinishedSignal(uint32_t seq, bool handled) {
#if DEBUG_TRANSPORT_ACTIONS
    if (DEBUG_TRANSPORT_ACTIONS) {
        ALOGD("channel '%s' consumer ~ sendFinishedSignal: seq=%u, handled=%s",
            mChannel->getName().c_str(), seq, handled ? "true" : "false");
#endif
              mChannel->getName().c_str(), seq, toString(handled));
    }

    if (!seq) {
        ALOGE("Attempted to send a finished signal with sequence number 0.");
+5 −3
Original line number Diff line number Diff line
@@ -2295,11 +2295,13 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
                reportTouchEventForStatistics(*motionEntry);
                break;
            }

            default:
                ALOG_ASSERT(false);
            case EventEntry::Type::CONFIGURATION_CHANGED:
            case EventEntry::Type::DEVICE_RESET: {
                LOG_ALWAYS_FATAL("Should never start dispatch cycles for %s events",
                                 EventEntry::typeToString(eventEntry->type));
                return;
            }
        }

        // Check the result.
        if (status) {