Merge "(ATSPI) Add ATSPI for Say(), Pause(), Resume(), SetForcefully(), GetStatus...
[platform/core/uifw/dali-adaptor.git] / dali / integration-api / adaptor-framework / android / android-framework.h
1 #ifndef DALI_INTEGRATION_ANDROID_FRAMEWORK_H
2 #define DALI_INTEGRATION_ANDROID_FRAMEWORK_H
3
4 /*
5  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <jni.h>
23 #include <android/asset_manager.h>
24 #include <android/asset_manager_jni.h>
25 #include <android/configuration.h>
26 #include <android/native_window.h>
27 #include <android/native_window_jni.h>
28
29 #ifndef _ANDROID_NATIVE_APP_GLUE_H
30 extern "C"
31 {
32 struct android_app;
33 }
34 #endif
35
36 #include <dali/public-api/common/dali-common.h>
37 #include <dali/public-api/dali-adaptor-common.h>
38
39 namespace Dali
40 {
41
42 namespace Internal DALI_INTERNAL
43 {
44
45 namespace Adaptor
46 {
47 class AndroidFramework;
48 }
49
50 }
51
52 namespace Integration
53 {
54
55 /**
56  * AndroidFramework provides setter/getter for Android native interfaces for Android DALi Adaptor.
57  * It is also used to pass Android application events to Android DALi Adaptor.
58  */
59 class DALI_ADAPTOR_API AndroidFramework
60 {
61 public:
62   /**
63    * @brief Create a new Android framework instance. Can be only one per application.
64    *
65    * @return a reference to the framework
66    */
67   static AndroidFramework& New();
68
69   /**
70    * @brief Delete an Android framework instance.
71    */
72   static void Delete();
73
74   /**
75    * @brief Sets the Android native application glue struct
76    * @param[in] application A pointer to the application glue struct
77    */
78   void SetNativeApplication( android_app* application );
79
80   /**
81    * @brief Gets the Android native application glue struct
82    * @return the native application glue struct
83    */
84   android_app* GetNativeApplication() const;
85
86   /**
87    * @brief Sets the Android JVM
88    * @param[in] jvm A pointer to Android JVM
89    */
90   void SetJVM( JavaVM* jvm );
91
92   /**
93    * @brief Sets the JVM
94    * @return A pointer to JVM
95    */
96   JavaVM* GetJVM() const;
97
98   /**
99    *  Sets the Android application assets manager.
100    *  @param[in] assets A pointer to assets manager
101    */
102   void SetApplicationAssets( AAssetManager* assets );
103
104   /**
105    * @brief Gets the Android application assets manager.
106    * @return The application assets manager
107    */
108   AAssetManager* GetApplicationAssets() const;
109
110   /**
111    * @brief Sets the Android application configuration
112    * @param[in] configuration A pointer to Android application configuration
113    */
114   void SetApplicationConfiguration( AConfiguration* configuration );
115
116   /**
117    * @brief Gets the Android application configuration
118    * @return A Android application configuration
119    */
120   AConfiguration* GetApplicationConfiguration() const;
121
122   /**
123    * @brief Sets the Android application native window
124    * @return A native window
125    */
126   void SetApplicationWindow( ANativeWindow* window );
127
128   /**
129    * @brief Gets the Android application native window
130    * @param[in] window A native window
131    */
132   ANativeWindow* GetApplicationWindow() const;
133
134   /**
135    * Invoked when the Android application is to be terminated.
136    */
137   void OnTerminate();
138
139   /**
140    * Invoked when the Android application is to be paused.
141    */
142   void OnPause();
143
144   /**
145    * Invoked when the Android application is to be resumed.
146    */
147   void OnResume();
148
149   /**
150    * Invoked when the Android application native window is created.
151    */
152   void OnWindowCreated( ANativeWindow* window );
153
154   /**
155    * Invoked when the Android application native window is deleted.
156    */
157   void OnWindowDestroyed( ANativeWindow* window );
158
159   /**
160    * @brief Returns a reference to the instance of the Android framework used by the current thread.
161    *
162    * @return A reference to the framework.
163    * @note This is only valid in the main thread.
164    */
165   static AndroidFramework& Get();
166
167   /**
168    * @brief Virtual Destructor.
169    */
170   virtual ~AndroidFramework();
171
172   // Not copyable or movable
173   AndroidFramework( const AndroidFramework& ) = delete; ///< Deleted copy constructor
174   AndroidFramework( AndroidFramework&& ) = delete; ///< Deleted move constructor
175   AndroidFramework& operator=( const AndroidFramework& ) = delete; ///< Deleted copy assignment operator
176   AndroidFramework& operator=( AndroidFramework&& ) = delete; ///< Deleted move assignment operator
177
178 private:
179
180   /**
181    * @brief Create an uninitialized AndroidFramework.
182    */
183   AndroidFramework();
184
185   Internal::Adaptor::AndroidFramework* mImpl; ///< Implementation object
186   friend class Internal::Adaptor::AndroidFramework;
187 };
188
189 } // namespace Integration
190
191 } // namespace Dali
192
193 #endif // DALI_INTEGRATION_ANDROID_FRAMEWORK_H
194