InputApplication.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #ifndef _UI_INPUT_APPLICATION_H
  17. #define _UI_INPUT_APPLICATION_H
  18. #include <input/Input.h>
  19. #include <utils/RefBase.h>
  20. #include <utils/Timers.h>
  21. #include <utils/String8.h>
  22. namespace android {
  23. /*
  24. * Describes the properties of an application that can receive input.
  25. */
  26. struct InputApplicationInfo {
  27. String8 name;
  28. nsecs_t dispatchingTimeout;
  29. };
  30. /*
  31. * Handle for an application that can receive input.
  32. *
  33. * Used by the native input dispatcher as a handle for the window manager objects
  34. * that describe an application.
  35. */
  36. class InputApplicationHandle : public RefBase {
  37. public:
  38. inline const InputApplicationInfo* getInfo() const {
  39. return mInfo;
  40. }
  41. inline String8 getName() const {
  42. return mInfo ? mInfo->name : String8("<invalid>");
  43. }
  44. inline nsecs_t getDispatchingTimeout(nsecs_t defaultValue) const {
  45. return mInfo ? mInfo->dispatchingTimeout : defaultValue;
  46. }
  47. /**
  48. * Requests that the state of this object be updated to reflect
  49. * the most current available information about the application.
  50. *
  51. * This method should only be called from within the input dispatcher's
  52. * critical section.
  53. *
  54. * Returns true on success, or false if the handle is no longer valid.
  55. */
  56. virtual bool updateInfo() = 0;
  57. /**
  58. * Releases the storage used by the associated information when it is
  59. * no longer needed.
  60. */
  61. void releaseInfo();
  62. protected:
  63. InputApplicationHandle();
  64. virtual ~InputApplicationHandle();
  65. InputApplicationInfo* mInfo;
  66. };
  67. } // namespace android
  68. #endif // _UI_INPUT_APPLICATION_H