Add new MotionEvent flag for partially obscured windows.

Due to more complex window layouts resulting in lots of overlapping
windows, the policy around FLAG_WINDOW_IS_OBSCURED has changed to
only be set when the point at which the window was touched is
obscured. Unfortunately, this doesn't prevent tapjacking attacks that
overlay the dialog's text, making a potentially dangerous operation
seem innocuous. To avoid this on particularly sensitive dialogs,
introduce a new flag that really does tell you when your window is
being even partially overlapped.

We aren't exposing this as API since we plan on making the original
flag more robust. This is really a workaround for system dialogs
since we generally know their layout and screen position, and that
they're unlikely to be overlapped by other applications.

Bug: 26677796
Change-Id: I9e336afe90f262ba22015876769a9c510048fd47

 String8 InputDispatcher::checkWindowReadyForMoreInputLocked(nsecs_t currentTime,
         const sp<InputWindowHandle>& windowHandle, const EventEntry* eventEntry,
         const char* targetType) {
 if (windowHandle->getInfo()->paused) {
 return String8::format("Waiting because the %s window is paused.", targetType);
 }

 ssize_t connectionIndex = getConnectionIndexLocked(windowHandle->getInputChannel());
 if (connectionIndex < 0) {
 return String8::format("Waiting because the %s window's input channel is not "
 "registered with the input dispatcher.  The window may be in the process "
 "of being removed.", targetType);
 }

    sp<Connection> connection = mConnectionsByFd.valueAt(connectionIndex);
 if (connection->status != Connection::STATUS_NORMAL) {
 return String8::format("Waiting because the %s window's input connection is %s."
 "The window may be in the process of being removed.", targetType,
                connection->getStatusLabel());
 }

 if (connection->inputPublisherBlocked) {
 return String8::format("Waiting because the %s window's input channel is full.  "
 "Outbound queue length: %d.  Wait queue length: %d.",
                targetType, connection->outboundQueue.count(), connection->waitQueue.count());
 }

 if (eventEntry->type == EventEntry::TYPE_KEY) {
 if (!connection->outboundQueue.isEmpty() || !connection->waitQueue.isEmpty()) {
 return String8::format("Waiting to send key event because the %s window has not "
 "finished processing all of the input events that were previously "
 "delivered to it.  Outbound queue length: %d.  Wait queue length: %d.",
                    targetType, connection->outboundQueue.count(), connection->waitQueue.count());
 }
 } else {
 if (!connection->waitQueue.isEmpty()
 && currentTime >= connection->waitQueue.head->deliveryTime
 + STREAM_AHEAD_EVENT_TIMEOUT) {
 return String8::format("Waiting to send non-key event because the %s window has not "
 "finished processing certain input events that were delivered to it over "
 "%0.1fms ago.  Wait queue length: %d.  Wait queue head age: %0.1fms.",
                    targetType, STREAM_AHEAD_EVENT_TIMEOUT * 0.000001f,
                    connection->waitQueue.count(),
 (currentTime - connection->waitQueue.head->deliveryTime) * 0.000001f);
 }
 }
 return String8::empty();
}

 String8 InputDispatcher::checkWindowReadyForMoreInputLocked(nsecs_t currentTime,
         const sp<InputWindowHandle>& windowHandle, const EventEntry* eventEntry,
         const char* targetType) {
 if (windowHandle->getInfo()->paused) {
 return String8::format("Waiting because the %s window is paused.", targetType);
 }

 ssize_t connectionIndex = getConnectionIndexLocked(windowHandle->getInputChannel());
 if (connectionIndex < 0) {
 return String8::format("Waiting because the %s window's input channel is not "
 "registered with the input dispatcher.  The window may be in the process "
 "of being removed.", targetType);
 }

    sp<Connection> connection = mConnectionsByFd.valueAt(connectionIndex);
 if (connection->status != Connection::STATUS_NORMAL) {
 return String8::format("Waiting because the %s window's input connection is %s."
 "The window may be in the process of being removed.", targetType,
                connection->getStatusLabel());
 }

 if (connection->inputPublisherBlocked) {
 return String8::format("Waiting because the %s window's input channel is full.  "
 "Outbound queue length: %d.  Wait queue length: %d.",
                targetType, connection->outboundQueue.count(), connection->waitQueue.count());
 }

 if (eventEntry->type == EventEntry::TYPE_KEY) {
 if (!connection->outboundQueue.isEmpty() || !connection->waitQueue.isEmpty()) {
 return String8::format("Waiting to send key event because the %s window has not "
 "finished processing all of the input events that were previously "
 "delivered to it.  Outbound queue length: %d.  Wait queue length: %d.",
                    targetType, connection->outboundQueue.count(), connection->waitQueue.count());
 }
 } else {
 if (!connection->waitQueue.isEmpty()
 && currentTime >= connection->waitQueue.head->deliveryTime
 + STREAM_AHEAD_EVENT_TIMEOUT) {
 return String8::format("Waiting to send non-key event because the %s window has not "
 "finished processing certain input events that were delivered to it over "
 "%0.1fms ago.  Wait queue length: %d.  Wait queue head age: %0.1fms.",
                    targetType, STREAM_AHEAD_EVENT_TIMEOUT * 0.000001f,
                    connection->waitQueue.count(),
 (currentTime - connection->waitQueue.head->deliveryTime) * 0.000001f);
 }
 }
 return String8::empty();
}
