widget/gonk/libui/InputManager.h

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 /*
     2  * Copyright (C) 2010 The Android Open Source Project
     3  *
     4  * Licensed under the Apache License, Version 2.0 (the "License");
     5  * you may not use this file except in compliance with the License.
     6  * You may obtain a copy of the License at
     7  *
     8  *      http://www.apache.org/licenses/LICENSE-2.0
     9  *
    10  * Unless required by applicable law or agreed to in writing, software
    11  * distributed under the License is distributed on an "AS IS" BASIS,
    12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  * See the License for the specific language governing permissions and
    14  * limitations under the License.
    15  */
    17 #ifndef _UI_INPUT_MANAGER_H
    18 #define _UI_INPUT_MANAGER_H
    20 /**
    21  * Native input manager.
    22  */
    24 #include "EventHub.h"
    25 #include "InputReader.h"
    26 #include "InputDispatcher.h"
    28 #include "Input.h"
    29 #include "InputTransport.h"
    30 #include <utils/Errors.h>
    31 #include <utils/Vector.h>
    32 #include <utils/Timers.h>
    33 #include <utils/RefBase.h>
    34 #include <utils/String8.h>
    36 namespace android {
    38 /*
    39  * The input manager is the core of the system event processing.
    40  *
    41  * The input manager uses two threads.
    42  *
    43  * 1. The InputReaderThread (called "InputReader") reads and preprocesses raw input events,
    44  *    applies policy, and posts messages to a queue managed by the DispatcherThread.
    45  * 2. The InputDispatcherThread (called "InputDispatcher") thread waits for new events on the
    46  *    queue and asynchronously dispatches them to applications.
    47  *
    48  * By design, the InputReaderThread class and InputDispatcherThread class do not share any
    49  * internal state.  Moreover, all communication is done one way from the InputReaderThread
    50  * into the InputDispatcherThread and never the reverse.  Both classes may interact with the
    51  * InputDispatchPolicy, however.
    52  *
    53  * The InputManager class never makes any calls into Java itself.  Instead, the
    54  * InputDispatchPolicy is responsible for performing all external interactions with the
    55  * system, including calling DVM services.
    56  */
    57 class InputManagerInterface : public virtual RefBase {
    58 protected:
    59     InputManagerInterface() { }
    60     virtual ~InputManagerInterface() { }
    62 public:
    63     /* Starts the input manager threads. */
    64     virtual status_t start() = 0;
    66     /* Stops the input manager threads and waits for them to exit. */
    67     virtual status_t stop() = 0;
    69     /* Gets the input reader. */
    70     virtual sp<InputReaderInterface> getReader() = 0;
    72     /* Gets the input dispatcher. */
    73     virtual sp<InputDispatcherInterface> getDispatcher() = 0;
    74 };
    76 class InputManager : public InputManagerInterface {
    77 protected:
    78     virtual ~InputManager();
    80 public:
    81     InputManager(
    82             const sp<EventHubInterface>& eventHub,
    83             const sp<InputReaderPolicyInterface>& readerPolicy,
    84             const sp<InputDispatcherPolicyInterface>& dispatcherPolicy);
    86     // (used for testing purposes)
    87     InputManager(
    88             const sp<InputReaderInterface>& reader,
    89             const sp<InputDispatcherInterface>& dispatcher);
    91     virtual status_t start();
    92     virtual status_t stop();
    94     virtual sp<InputReaderInterface> getReader();
    95     virtual sp<InputDispatcherInterface> getDispatcher();
    97 private:
    98     sp<InputReaderInterface> mReader;
    99     sp<InputReaderThread> mReaderThread;
   101     sp<InputDispatcherInterface> mDispatcher;
   102     sp<InputDispatcherThread> mDispatcherThread;
   104     void initialize();
   105 };
   107 } // namespace android
   109 #endif // _UI_INPUT_MANAGER_H

mercurial