Loading services/inputflinger/dispatcher/Connection.cpp +1 −14 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ namespace android::inputdispatcher { Connection::Connection(const std::shared_ptr<InputChannel>& inputChannel, bool monitor, const IdGenerator& idGenerator) : status(STATUS_NORMAL), : status(Status::NORMAL), inputChannel(inputChannel), monitor(monitor), inputPublisher(inputChannel), Loading @@ -40,19 +40,6 @@ const std::string Connection::getWindowName() const { return "?"; } const char* Connection::getStatusLabel() const { switch (status) { case STATUS_NORMAL: return "NORMAL"; case STATUS_BROKEN: return "BROKEN"; case STATUS_ZOMBIE: return "ZOMBIE"; default: return "UNKNOWN"; } } std::deque<DispatchEntry*>::iterator Connection::findWaitQueueEntry(uint32_t seq) { for (std::deque<DispatchEntry*>::iterator it = waitQueue.begin(); it != waitQueue.end(); it++) { if ((*it)->seq == seq) { Loading services/inputflinger/dispatcher/Connection.h +7 −5 Original line number Diff line number Diff line Loading @@ -33,13 +33,16 @@ protected: virtual ~Connection(); public: enum Status { enum class Status { // Everything is peachy. STATUS_NORMAL, NORMAL, // An unrecoverable communication error has occurred. STATUS_BROKEN, BROKEN, // The input channel has been unregistered. STATUS_ZOMBIE ZOMBIE, ftl_first = NORMAL, ftl_last = ZOMBIE, }; Status status; Loading @@ -66,7 +69,6 @@ public: inline const std::string getInputChannelName() const { return inputChannel->getName(); } const std::string getWindowName() const; const char* getStatusLabel() const; std::deque<DispatchEntry*>::iterator findWaitQueueEntry(uint32_t seq); }; Loading services/inputflinger/dispatcher/Entry.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -286,11 +286,10 @@ SensorEntry::~SensorEntry() {} std::string SensorEntry::getDescription() const { std::string msg; std::string sensorTypeStr(ftl::enum_name(sensorType).value_or("?")); msg += StringPrintf("SensorEntry(deviceId=%d, source=%s, sensorType=%s, " "accuracy=0x%08x, hwTimestamp=%" PRId64, deviceId, inputEventSourceToString(source).c_str(), sensorTypeStr.c_str(), accuracy, hwTimestamp); deviceId, inputEventSourceToString(source).c_str(), ftl::enum_string(sensorType).c_str(), accuracy, hwTimestamp); if (!GetBoolProperty("ro.debuggable", false)) { for (size_t i = 0; i < values.size(); i++) { Loading services/inputflinger/dispatcher/InputDispatcher.cpp +17 −15 Original line number Diff line number Diff line Loading @@ -1743,7 +1743,7 @@ void InputDispatcher::cancelEventsForAnrLocked(const sp<Connection>& connection) // pile up. ALOGW("Canceling events for %s because it is unresponsive", connection->inputChannel->getName().c_str()); if (connection->status == Connection::STATUS_NORMAL) { if (connection->status == Connection::Status::NORMAL) { CancelationOptions options(CancelationOptions::CANCEL_ALL_EVENTS, "application not responding"); synthesizeCancelationEventsForConnectionLocked(connection, options); Loading Loading @@ -2819,10 +2819,11 @@ void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime, // Skip this event if the connection status is not normal. // We don't want to enqueue additional outbound events if the connection is broken. if (connection->status != Connection::STATUS_NORMAL) { if (connection->status != Connection::Status::NORMAL) { if (DEBUG_DISPATCH_CYCLE) { ALOGD("channel '%s' ~ Dropping event because the channel status is %s", connection->getInputChannelName().c_str(), connection->getStatusLabel()); connection->getInputChannelName().c_str(), ftl::enum_string(connection->status).c_str()); } return; } Loading Loading @@ -3136,7 +3137,7 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime, ALOGD("channel '%s' ~ startDispatchCycle", connection->getInputChannelName().c_str()); } while (connection->status == Connection::STATUS_NORMAL && !connection->outboundQueue.empty()) { while (connection->status == Connection::Status::NORMAL && !connection->outboundQueue.empty()) { DispatchEntry* dispatchEntry = connection->outboundQueue.front(); dispatchEntry->deliveryTime = currentTime; const std::chrono::nanoseconds timeout = Loading Loading @@ -3357,8 +3358,8 @@ void InputDispatcher::finishDispatchCycleLocked(nsecs_t currentTime, connection->getInputChannelName().c_str(), seq, toString(handled)); } if (connection->status == Connection::STATUS_BROKEN || connection->status == Connection::STATUS_ZOMBIE) { if (connection->status == Connection::Status::BROKEN || connection->status == Connection::Status::ZOMBIE) { return; } Loading @@ -3385,8 +3386,8 @@ void InputDispatcher::abortBrokenDispatchCycleLocked(nsecs_t currentTime, // The connection appears to be unrecoverably broken. // Ignore already broken or zombie connections. if (connection->status == Connection::STATUS_NORMAL) { connection->status = Connection::STATUS_BROKEN; if (connection->status == Connection::Status::NORMAL) { connection->status = Connection::Status::BROKEN; if (notify) { // Notify other system components. Loading @@ -3394,7 +3395,7 @@ void InputDispatcher::abortBrokenDispatchCycleLocked(nsecs_t currentTime, connection->getInputChannelName().c_str()); auto command = [this, connection]() REQUIRES(mLock) { if (connection->status == Connection::STATUS_ZOMBIE) return; if (connection->status == Connection::Status::ZOMBIE) return; scoped_unlock unlock(mLock); mPolicy->notifyInputChannelBroken(connection->inputChannel->getConnectionToken()); }; Loading Loading @@ -3530,7 +3531,7 @@ void InputDispatcher::synthesizeCancelationEventsForInputChannelLocked( void InputDispatcher::synthesizeCancelationEventsForConnectionLocked( const sp<Connection>& connection, const CancelationOptions& options) { if (connection->status == Connection::STATUS_BROKEN) { if (connection->status == Connection::Status::BROKEN) { return; } Loading Loading @@ -3603,7 +3604,7 @@ void InputDispatcher::synthesizeCancelationEventsForConnectionLocked( void InputDispatcher::synthesizePointerDownEventsForConnectionLocked( const sp<Connection>& connection) { if (connection->status == Connection::STATUS_BROKEN) { if (connection->status == Connection::Status::BROKEN) { return; } Loading Loading @@ -5271,7 +5272,8 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) { "status=%s, monitor=%s, responsive=%s\n", connection->inputChannel->getFd().get(), connection->getInputChannelName().c_str(), connection->getWindowName().c_str(), connection->getStatusLabel(), connection->getWindowName().c_str(), ftl::enum_string(connection->status).c_str(), toString(connection->monitor), toString(connection->responsive)); if (!connection->outboundQueue.empty()) { Loading Loading @@ -5444,7 +5446,7 @@ status_t InputDispatcher::removeInputChannelLocked(const sp<IBinder>& connection nsecs_t currentTime = now(); abortBrokenDispatchCycleLocked(currentTime, connection, notify); connection->status = Connection::STATUS_ZOMBIE; connection->status = Connection::Status::ZOMBIE; return OK; } Loading Loading @@ -5663,7 +5665,7 @@ void InputDispatcher::doDispatchCycleFinishedCommand(nsecs_t finishTime, } } traceWaitQueueLength(*connection); if (restartEvent && connection->status == Connection::STATUS_NORMAL) { if (restartEvent && connection->status == Connection::Status::NORMAL) { connection->outboundQueue.push_front(dispatchEntry); traceOutboundQueueLength(*connection); } else { Loading Loading @@ -5961,7 +5963,7 @@ bool InputDispatcher::afterKeyEventLockedInterruptable(const sp<Connection>& con mLock.lock(); if (connection->status != Connection::STATUS_NORMAL) { if (connection->status != Connection::Status::NORMAL) { connection->inputState.removeFallbackKey(originalKeyCode); return false; } Loading Loading
services/inputflinger/dispatcher/Connection.cpp +1 −14 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ namespace android::inputdispatcher { Connection::Connection(const std::shared_ptr<InputChannel>& inputChannel, bool monitor, const IdGenerator& idGenerator) : status(STATUS_NORMAL), : status(Status::NORMAL), inputChannel(inputChannel), monitor(monitor), inputPublisher(inputChannel), Loading @@ -40,19 +40,6 @@ const std::string Connection::getWindowName() const { return "?"; } const char* Connection::getStatusLabel() const { switch (status) { case STATUS_NORMAL: return "NORMAL"; case STATUS_BROKEN: return "BROKEN"; case STATUS_ZOMBIE: return "ZOMBIE"; default: return "UNKNOWN"; } } std::deque<DispatchEntry*>::iterator Connection::findWaitQueueEntry(uint32_t seq) { for (std::deque<DispatchEntry*>::iterator it = waitQueue.begin(); it != waitQueue.end(); it++) { if ((*it)->seq == seq) { Loading
services/inputflinger/dispatcher/Connection.h +7 −5 Original line number Diff line number Diff line Loading @@ -33,13 +33,16 @@ protected: virtual ~Connection(); public: enum Status { enum class Status { // Everything is peachy. STATUS_NORMAL, NORMAL, // An unrecoverable communication error has occurred. STATUS_BROKEN, BROKEN, // The input channel has been unregistered. STATUS_ZOMBIE ZOMBIE, ftl_first = NORMAL, ftl_last = ZOMBIE, }; Status status; Loading @@ -66,7 +69,6 @@ public: inline const std::string getInputChannelName() const { return inputChannel->getName(); } const std::string getWindowName() const; const char* getStatusLabel() const; std::deque<DispatchEntry*>::iterator findWaitQueueEntry(uint32_t seq); }; Loading
services/inputflinger/dispatcher/Entry.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -286,11 +286,10 @@ SensorEntry::~SensorEntry() {} std::string SensorEntry::getDescription() const { std::string msg; std::string sensorTypeStr(ftl::enum_name(sensorType).value_or("?")); msg += StringPrintf("SensorEntry(deviceId=%d, source=%s, sensorType=%s, " "accuracy=0x%08x, hwTimestamp=%" PRId64, deviceId, inputEventSourceToString(source).c_str(), sensorTypeStr.c_str(), accuracy, hwTimestamp); deviceId, inputEventSourceToString(source).c_str(), ftl::enum_string(sensorType).c_str(), accuracy, hwTimestamp); if (!GetBoolProperty("ro.debuggable", false)) { for (size_t i = 0; i < values.size(); i++) { Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +17 −15 Original line number Diff line number Diff line Loading @@ -1743,7 +1743,7 @@ void InputDispatcher::cancelEventsForAnrLocked(const sp<Connection>& connection) // pile up. ALOGW("Canceling events for %s because it is unresponsive", connection->inputChannel->getName().c_str()); if (connection->status == Connection::STATUS_NORMAL) { if (connection->status == Connection::Status::NORMAL) { CancelationOptions options(CancelationOptions::CANCEL_ALL_EVENTS, "application not responding"); synthesizeCancelationEventsForConnectionLocked(connection, options); Loading Loading @@ -2819,10 +2819,11 @@ void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime, // Skip this event if the connection status is not normal. // We don't want to enqueue additional outbound events if the connection is broken. if (connection->status != Connection::STATUS_NORMAL) { if (connection->status != Connection::Status::NORMAL) { if (DEBUG_DISPATCH_CYCLE) { ALOGD("channel '%s' ~ Dropping event because the channel status is %s", connection->getInputChannelName().c_str(), connection->getStatusLabel()); connection->getInputChannelName().c_str(), ftl::enum_string(connection->status).c_str()); } return; } Loading Loading @@ -3136,7 +3137,7 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime, ALOGD("channel '%s' ~ startDispatchCycle", connection->getInputChannelName().c_str()); } while (connection->status == Connection::STATUS_NORMAL && !connection->outboundQueue.empty()) { while (connection->status == Connection::Status::NORMAL && !connection->outboundQueue.empty()) { DispatchEntry* dispatchEntry = connection->outboundQueue.front(); dispatchEntry->deliveryTime = currentTime; const std::chrono::nanoseconds timeout = Loading Loading @@ -3357,8 +3358,8 @@ void InputDispatcher::finishDispatchCycleLocked(nsecs_t currentTime, connection->getInputChannelName().c_str(), seq, toString(handled)); } if (connection->status == Connection::STATUS_BROKEN || connection->status == Connection::STATUS_ZOMBIE) { if (connection->status == Connection::Status::BROKEN || connection->status == Connection::Status::ZOMBIE) { return; } Loading @@ -3385,8 +3386,8 @@ void InputDispatcher::abortBrokenDispatchCycleLocked(nsecs_t currentTime, // The connection appears to be unrecoverably broken. // Ignore already broken or zombie connections. if (connection->status == Connection::STATUS_NORMAL) { connection->status = Connection::STATUS_BROKEN; if (connection->status == Connection::Status::NORMAL) { connection->status = Connection::Status::BROKEN; if (notify) { // Notify other system components. Loading @@ -3394,7 +3395,7 @@ void InputDispatcher::abortBrokenDispatchCycleLocked(nsecs_t currentTime, connection->getInputChannelName().c_str()); auto command = [this, connection]() REQUIRES(mLock) { if (connection->status == Connection::STATUS_ZOMBIE) return; if (connection->status == Connection::Status::ZOMBIE) return; scoped_unlock unlock(mLock); mPolicy->notifyInputChannelBroken(connection->inputChannel->getConnectionToken()); }; Loading Loading @@ -3530,7 +3531,7 @@ void InputDispatcher::synthesizeCancelationEventsForInputChannelLocked( void InputDispatcher::synthesizeCancelationEventsForConnectionLocked( const sp<Connection>& connection, const CancelationOptions& options) { if (connection->status == Connection::STATUS_BROKEN) { if (connection->status == Connection::Status::BROKEN) { return; } Loading Loading @@ -3603,7 +3604,7 @@ void InputDispatcher::synthesizeCancelationEventsForConnectionLocked( void InputDispatcher::synthesizePointerDownEventsForConnectionLocked( const sp<Connection>& connection) { if (connection->status == Connection::STATUS_BROKEN) { if (connection->status == Connection::Status::BROKEN) { return; } Loading Loading @@ -5271,7 +5272,8 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) { "status=%s, monitor=%s, responsive=%s\n", connection->inputChannel->getFd().get(), connection->getInputChannelName().c_str(), connection->getWindowName().c_str(), connection->getStatusLabel(), connection->getWindowName().c_str(), ftl::enum_string(connection->status).c_str(), toString(connection->monitor), toString(connection->responsive)); if (!connection->outboundQueue.empty()) { Loading Loading @@ -5444,7 +5446,7 @@ status_t InputDispatcher::removeInputChannelLocked(const sp<IBinder>& connection nsecs_t currentTime = now(); abortBrokenDispatchCycleLocked(currentTime, connection, notify); connection->status = Connection::STATUS_ZOMBIE; connection->status = Connection::Status::ZOMBIE; return OK; } Loading Loading @@ -5663,7 +5665,7 @@ void InputDispatcher::doDispatchCycleFinishedCommand(nsecs_t finishTime, } } traceWaitQueueLength(*connection); if (restartEvent && connection->status == Connection::STATUS_NORMAL) { if (restartEvent && connection->status == Connection::Status::NORMAL) { connection->outboundQueue.push_front(dispatchEntry); traceOutboundQueueLength(*connection); } else { Loading Loading @@ -5961,7 +5963,7 @@ bool InputDispatcher::afterKeyEventLockedInterruptable(const sp<Connection>& con mLock.lock(); if (connection->status != Connection::STATUS_NORMAL) { if (connection->status != Connection::Status::NORMAL) { connection->inputState.removeFallbackKey(originalKeyCode); return false; } Loading