widget/gonk/libui/InputManager.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/gonk/libui/InputManager.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,109 @@
     1.4 +/*
     1.5 + * Copyright (C) 2010 The Android Open Source Project
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + *      http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * Unless required by applicable law or agreed to in writing, software
    1.14 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.16 + * See the License for the specific language governing permissions and
    1.17 + * limitations under the License.
    1.18 + */
    1.19 +
    1.20 +#ifndef _UI_INPUT_MANAGER_H
    1.21 +#define _UI_INPUT_MANAGER_H
    1.22 +
    1.23 +/**
    1.24 + * Native input manager.
    1.25 + */
    1.26 +
    1.27 +#include "EventHub.h"
    1.28 +#include "InputReader.h"
    1.29 +#include "InputDispatcher.h"
    1.30 +
    1.31 +#include "Input.h"
    1.32 +#include "InputTransport.h"
    1.33 +#include <utils/Errors.h>
    1.34 +#include <utils/Vector.h>
    1.35 +#include <utils/Timers.h>
    1.36 +#include <utils/RefBase.h>
    1.37 +#include <utils/String8.h>
    1.38 +
    1.39 +namespace android {
    1.40 +
    1.41 +/*
    1.42 + * The input manager is the core of the system event processing.
    1.43 + *
    1.44 + * The input manager uses two threads.
    1.45 + *
    1.46 + * 1. The InputReaderThread (called "InputReader") reads and preprocesses raw input events,
    1.47 + *    applies policy, and posts messages to a queue managed by the DispatcherThread.
    1.48 + * 2. The InputDispatcherThread (called "InputDispatcher") thread waits for new events on the
    1.49 + *    queue and asynchronously dispatches them to applications.
    1.50 + *
    1.51 + * By design, the InputReaderThread class and InputDispatcherThread class do not share any
    1.52 + * internal state.  Moreover, all communication is done one way from the InputReaderThread
    1.53 + * into the InputDispatcherThread and never the reverse.  Both classes may interact with the
    1.54 + * InputDispatchPolicy, however.
    1.55 + *
    1.56 + * The InputManager class never makes any calls into Java itself.  Instead, the
    1.57 + * InputDispatchPolicy is responsible for performing all external interactions with the
    1.58 + * system, including calling DVM services.
    1.59 + */
    1.60 +class InputManagerInterface : public virtual RefBase {
    1.61 +protected:
    1.62 +    InputManagerInterface() { }
    1.63 +    virtual ~InputManagerInterface() { }
    1.64 +
    1.65 +public:
    1.66 +    /* Starts the input manager threads. */
    1.67 +    virtual status_t start() = 0;
    1.68 +
    1.69 +    /* Stops the input manager threads and waits for them to exit. */
    1.70 +    virtual status_t stop() = 0;
    1.71 +
    1.72 +    /* Gets the input reader. */
    1.73 +    virtual sp<InputReaderInterface> getReader() = 0;
    1.74 +
    1.75 +    /* Gets the input dispatcher. */
    1.76 +    virtual sp<InputDispatcherInterface> getDispatcher() = 0;
    1.77 +};
    1.78 +
    1.79 +class InputManager : public InputManagerInterface {
    1.80 +protected:
    1.81 +    virtual ~InputManager();
    1.82 +
    1.83 +public:
    1.84 +    InputManager(
    1.85 +            const sp<EventHubInterface>& eventHub,
    1.86 +            const sp<InputReaderPolicyInterface>& readerPolicy,
    1.87 +            const sp<InputDispatcherPolicyInterface>& dispatcherPolicy);
    1.88 +
    1.89 +    // (used for testing purposes)
    1.90 +    InputManager(
    1.91 +            const sp<InputReaderInterface>& reader,
    1.92 +            const sp<InputDispatcherInterface>& dispatcher);
    1.93 +
    1.94 +    virtual status_t start();
    1.95 +    virtual status_t stop();
    1.96 +
    1.97 +    virtual sp<InputReaderInterface> getReader();
    1.98 +    virtual sp<InputDispatcherInterface> getDispatcher();
    1.99 +
   1.100 +private:
   1.101 +    sp<InputReaderInterface> mReader;
   1.102 +    sp<InputReaderThread> mReaderThread;
   1.103 +
   1.104 +    sp<InputDispatcherInterface> mDispatcher;
   1.105 +    sp<InputDispatcherThread> mDispatcherThread;
   1.106 +
   1.107 +    void initialize();
   1.108 +};
   1.109 +
   1.110 +} // namespace android
   1.111 +
   1.112 +#endif // _UI_INPUT_MANAGER_H

mercurial