| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2011 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 | */ | 
|  | 16 |  | 
|  | 17 | #ifndef _UI_INPUT_APPLICATION_H | 
|  | 18 | #define _UI_INPUT_APPLICATION_H | 
|  | 19 |  | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 20 | #include <string> | 
|  | 21 |  | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 22 | #include <input/Input.h> | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 23 | #include <utils/RefBase.h> | 
|  | 24 | #include <utils/Timers.h> | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 25 |  | 
|  | 26 | namespace android { | 
|  | 27 |  | 
|  | 28 | /* | 
|  | 29 | * Describes the properties of an application that can receive input. | 
|  | 30 | */ | 
|  | 31 | struct InputApplicationInfo { | 
| Siarhei Vishniakou | f93fcf4 | 2017-11-22 16:00:14 -0800 | [diff] [blame] | 32 | std::string name; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 33 | nsecs_t dispatchingTimeout; | 
|  | 34 | }; | 
|  | 35 |  | 
|  | 36 |  | 
|  | 37 | /* | 
|  | 38 | * Handle for an application that can receive input. | 
|  | 39 | * | 
|  | 40 | * Used by the native input dispatcher as a handle for the window manager objects | 
|  | 41 | * that describe an application. | 
|  | 42 | */ | 
|  | 43 | class InputApplicationHandle : public RefBase { | 
|  | 44 | public: | 
|  | 45 | inline const InputApplicationInfo* getInfo() const { | 
|  | 46 | return mInfo; | 
|  | 47 | } | 
|  | 48 |  | 
| Siarhei Vishniakou | f93fcf4 | 2017-11-22 16:00:14 -0800 | [diff] [blame] | 49 | inline std::string getName() const { | 
|  | 50 | return mInfo ? mInfo->name : "<invalid>"; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 51 | } | 
|  | 52 |  | 
|  | 53 | inline nsecs_t getDispatchingTimeout(nsecs_t defaultValue) const { | 
|  | 54 | return mInfo ? mInfo->dispatchingTimeout : defaultValue; | 
|  | 55 | } | 
|  | 56 |  | 
|  | 57 | /** | 
|  | 58 | * Requests that the state of this object be updated to reflect | 
|  | 59 | * the most current available information about the application. | 
|  | 60 | * | 
|  | 61 | * This method should only be called from within the input dispatcher's | 
|  | 62 | * critical section. | 
|  | 63 | * | 
|  | 64 | * Returns true on success, or false if the handle is no longer valid. | 
|  | 65 | */ | 
|  | 66 | virtual bool updateInfo() = 0; | 
|  | 67 |  | 
|  | 68 | /** | 
|  | 69 | * Releases the storage used by the associated information when it is | 
|  | 70 | * no longer needed. | 
|  | 71 | */ | 
|  | 72 | void releaseInfo(); | 
|  | 73 |  | 
|  | 74 | protected: | 
|  | 75 | InputApplicationHandle(); | 
|  | 76 | virtual ~InputApplicationHandle(); | 
|  | 77 |  | 
|  | 78 | InputApplicationInfo* mInfo; | 
|  | 79 | }; | 
|  | 80 |  | 
|  | 81 | } // namespace android | 
|  | 82 |  | 
|  | 83 | #endif // _UI_INPUT_APPLICATION_H |