Loading core/java/android/view/View.java +1 −1 Original line number Diff line number Diff line Loading @@ -1678,7 +1678,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility public static final int STATUS_BAR_VISIBLE = 0; /** * View has requested the status bar to be visible (the default). * View has requested the status bar to be hidden. * * @see #setSystemUiVisibility(int) */ Loading include/ui/Input.h +8 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,14 @@ enum { AINPUT_SOURCE_SWITCH = 0x80000000, }; /* * SystemUiVisibility constants from View. */ enum { ASYSTEM_UI_VISIBILITY_STATUS_BAR_VISIBLE = 0, ASYSTEM_UI_VISIBILITY_STATUS_BAR_HIDDEN = 0x00000001, }; /* * Maximum number of pointers supported per motion event. * Smallest number of pointers is 1. Loading include/ui/Keyboard.h +5 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,11 @@ extern const char* getAxisLabel(int32_t axisId); */ extern int32_t updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState); /** * Returns true if a key is a meta key like ALT or CAPS_LOCK. */ extern bool isMetaKey(int32_t keyCode); } // namespace android #endif // _UI_KEYBOARD_H include/utils/Looper.h +107 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,51 @@ struct ALooper { namespace android { /** * A message that can be posted to a Looper. */ struct Message { Message() : what(0) { } Message(int what) : what(what) { } /* The message type. (interpretation is left up to the handler) */ int what; }; /** * Interface for a Looper message handler. * * The Looper holds a strong reference to the message handler whenever it has * a message to deliver to it. Make sure to call Looper::removeMessages * to remove any pending messages destined for the handler so that the handler * can be destroyed. */ class MessageHandler : public virtual RefBase { protected: virtual ~MessageHandler() { } public: /** * Handles a message. */ virtual void handleMessage(const Message& message) = 0; }; /** * A simple proxy that holds a weak reference to a message handler. */ class WeakMessageHandler : public MessageHandler { public: WeakMessageHandler(const wp<MessageHandler>& handler); virtual void handleMessage(const Message& message); private: wp<MessageHandler> mHandler; }; /** * A polling loop that supports monitoring file descriptor events, optionally * using callbacks. The implementation uses epoll() internally. Loading Loading @@ -165,6 +210,52 @@ public: */ int removeFd(int fd); /** * Enqueues a message to be processed by the specified handler. * * The handler must not be null. * This method can be called on any thread. */ void sendMessage(const sp<MessageHandler>& handler, const Message& message); /** * Enqueues a message to be processed by the specified handler after all pending messages * after the specified delay. * * The time delay is specified in uptime nanoseconds. * The handler must not be null. * This method can be called on any thread. */ void sendMessageDelayed(nsecs_t uptimeDelay, const sp<MessageHandler>& handler, const Message& message); /** * Enqueues a message to be processed by the specified handler after all pending messages * at the specified time. * * The time is specified in uptime nanoseconds. * The handler must not be null. * This method can be called on any thread. */ void sendMessageAtTime(nsecs_t uptime, const sp<MessageHandler>& handler, const Message& message); /** * Removes all messages for the specified handler from the queue. * * The handler must not be null. * This method can be called on any thread. */ void removeMessages(const sp<MessageHandler>& handler); /** * Removes all messages of a particular type for the specified handler from the queue. * * The handler must not be null. * This method can be called on any thread. */ void removeMessages(const sp<MessageHandler>& handler, int what); /** * Prepares a looper associated with the calling thread, and returns it. * If the thread already has a looper, it is returned. Otherwise, a new Loading Loading @@ -201,12 +292,27 @@ private: Request request; }; struct MessageEnvelope { MessageEnvelope() : uptime(0) { } MessageEnvelope(nsecs_t uptime, const sp<MessageHandler> handler, const Message& message) : uptime(uptime), handler(handler), message(message) { } nsecs_t uptime; sp<MessageHandler> handler; Message message; }; const bool mAllowNonCallbacks; // immutable int mWakeReadPipeFd; // immutable int mWakeWritePipeFd; // immutable Mutex mLock; Vector<MessageEnvelope> mMessageEnvelopes; // guarded by mLock bool mSendingMessage; // guarded by mLock #ifdef LOOPER_USES_EPOLL int mEpollFd; // immutable Loading Loading @@ -256,6 +362,7 @@ private: // it runs on a single thread. Vector<Response> mResponses; size_t mResponseIndex; nsecs_t mNextMessageUptime; // set to LLONG_MAX when none int pollInner(int timeoutMillis); void awoken(); Loading libs/ui/Keyboard.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -322,5 +322,26 @@ int32_t updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState) { } } bool isMetaKey(int32_t keyCode) { switch (keyCode) { case AKEYCODE_ALT_LEFT: case AKEYCODE_ALT_RIGHT: case AKEYCODE_SHIFT_LEFT: case AKEYCODE_SHIFT_RIGHT: case AKEYCODE_SYM: case AKEYCODE_FUNCTION: case AKEYCODE_CTRL_LEFT: case AKEYCODE_CTRL_RIGHT: case AKEYCODE_META_LEFT: case AKEYCODE_META_RIGHT: case AKEYCODE_CAPS_LOCK: case AKEYCODE_NUM_LOCK: case AKEYCODE_SCROLL_LOCK: return true; default: return false; } } } // namespace android Loading
core/java/android/view/View.java +1 −1 Original line number Diff line number Diff line Loading @@ -1678,7 +1678,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility public static final int STATUS_BAR_VISIBLE = 0; /** * View has requested the status bar to be visible (the default). * View has requested the status bar to be hidden. * * @see #setSystemUiVisibility(int) */ Loading
include/ui/Input.h +8 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,14 @@ enum { AINPUT_SOURCE_SWITCH = 0x80000000, }; /* * SystemUiVisibility constants from View. */ enum { ASYSTEM_UI_VISIBILITY_STATUS_BAR_VISIBLE = 0, ASYSTEM_UI_VISIBILITY_STATUS_BAR_HIDDEN = 0x00000001, }; /* * Maximum number of pointers supported per motion event. * Smallest number of pointers is 1. Loading
include/ui/Keyboard.h +5 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,11 @@ extern const char* getAxisLabel(int32_t axisId); */ extern int32_t updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState); /** * Returns true if a key is a meta key like ALT or CAPS_LOCK. */ extern bool isMetaKey(int32_t keyCode); } // namespace android #endif // _UI_KEYBOARD_H
include/utils/Looper.h +107 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,51 @@ struct ALooper { namespace android { /** * A message that can be posted to a Looper. */ struct Message { Message() : what(0) { } Message(int what) : what(what) { } /* The message type. (interpretation is left up to the handler) */ int what; }; /** * Interface for a Looper message handler. * * The Looper holds a strong reference to the message handler whenever it has * a message to deliver to it. Make sure to call Looper::removeMessages * to remove any pending messages destined for the handler so that the handler * can be destroyed. */ class MessageHandler : public virtual RefBase { protected: virtual ~MessageHandler() { } public: /** * Handles a message. */ virtual void handleMessage(const Message& message) = 0; }; /** * A simple proxy that holds a weak reference to a message handler. */ class WeakMessageHandler : public MessageHandler { public: WeakMessageHandler(const wp<MessageHandler>& handler); virtual void handleMessage(const Message& message); private: wp<MessageHandler> mHandler; }; /** * A polling loop that supports monitoring file descriptor events, optionally * using callbacks. The implementation uses epoll() internally. Loading Loading @@ -165,6 +210,52 @@ public: */ int removeFd(int fd); /** * Enqueues a message to be processed by the specified handler. * * The handler must not be null. * This method can be called on any thread. */ void sendMessage(const sp<MessageHandler>& handler, const Message& message); /** * Enqueues a message to be processed by the specified handler after all pending messages * after the specified delay. * * The time delay is specified in uptime nanoseconds. * The handler must not be null. * This method can be called on any thread. */ void sendMessageDelayed(nsecs_t uptimeDelay, const sp<MessageHandler>& handler, const Message& message); /** * Enqueues a message to be processed by the specified handler after all pending messages * at the specified time. * * The time is specified in uptime nanoseconds. * The handler must not be null. * This method can be called on any thread. */ void sendMessageAtTime(nsecs_t uptime, const sp<MessageHandler>& handler, const Message& message); /** * Removes all messages for the specified handler from the queue. * * The handler must not be null. * This method can be called on any thread. */ void removeMessages(const sp<MessageHandler>& handler); /** * Removes all messages of a particular type for the specified handler from the queue. * * The handler must not be null. * This method can be called on any thread. */ void removeMessages(const sp<MessageHandler>& handler, int what); /** * Prepares a looper associated with the calling thread, and returns it. * If the thread already has a looper, it is returned. Otherwise, a new Loading Loading @@ -201,12 +292,27 @@ private: Request request; }; struct MessageEnvelope { MessageEnvelope() : uptime(0) { } MessageEnvelope(nsecs_t uptime, const sp<MessageHandler> handler, const Message& message) : uptime(uptime), handler(handler), message(message) { } nsecs_t uptime; sp<MessageHandler> handler; Message message; }; const bool mAllowNonCallbacks; // immutable int mWakeReadPipeFd; // immutable int mWakeWritePipeFd; // immutable Mutex mLock; Vector<MessageEnvelope> mMessageEnvelopes; // guarded by mLock bool mSendingMessage; // guarded by mLock #ifdef LOOPER_USES_EPOLL int mEpollFd; // immutable Loading Loading @@ -256,6 +362,7 @@ private: // it runs on a single thread. Vector<Response> mResponses; size_t mResponseIndex; nsecs_t mNextMessageUptime; // set to LLONG_MAX when none int pollInner(int timeoutMillis); void awoken(); Loading
libs/ui/Keyboard.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -322,5 +322,26 @@ int32_t updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState) { } } bool isMetaKey(int32_t keyCode) { switch (keyCode) { case AKEYCODE_ALT_LEFT: case AKEYCODE_ALT_RIGHT: case AKEYCODE_SHIFT_LEFT: case AKEYCODE_SHIFT_RIGHT: case AKEYCODE_SYM: case AKEYCODE_FUNCTION: case AKEYCODE_CTRL_LEFT: case AKEYCODE_CTRL_RIGHT: case AKEYCODE_META_LEFT: case AKEYCODE_META_RIGHT: case AKEYCODE_CAPS_LOCK: case AKEYCODE_NUM_LOCK: case AKEYCODE_SCROLL_LOCK: return true; default: return false; } } } // namespace android