DALi Version 2.2.17
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / android / android-framework-impl.h
1 #ifndef DALI_INTEGRATION_ANDROID_FRAMEWORK_IMPL_H
2 #define DALI_INTEGRATION_ANDROID_FRAMEWORK_IMPL_H
3
4 /*
5  * Copyright (c) 2021 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 <dali/integration-api/adaptor-framework/android/android-framework.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/internal/adaptor/common/framework.h>
26
27 namespace Dali
28 {
29 namespace Internal
30 {
31 namespace Adaptor
32 {
33 /// Android application events
34 enum
35 {
36   APP_WINDOW_CREATED = 0,
37   APP_WINDOW_DESTROYED,
38   APP_PAUSE,
39   APP_RESUME,
40   APP_RESET,
41   APP_LANGUAGE_CHANGE,
42   APP_DESTROYED,
43 };
44
45 /**
46  * AndroidFramework implementation to set/get Android native interfaces for Android Adaptor.
47  * Also passes Android application events to Android Adaptor internal framework.
48  */
49 class AndroidFramework
50 {
51 public:
52   /**
53    * @brief Create a new Android framework.
54    *
55    * @return a reference to the Android framework
56    */
57   static Dali::Integration::AndroidFramework& New();
58
59   /**
60    * @brief Delete an Android framework.
61    */
62   static void Delete();
63
64   /**
65    * @copydoc Dali::Integration::AndroidFramework::SetNativeApplication()
66    */
67   void SetNativeApplication(android_app* application);
68
69   /**
70    * @copydoc Dali::Integration::AndroidFramework::GetNativeApplication()
71    */
72   android_app* GetNativeApplication() const;
73
74   /**
75    * @copydoc Dali::Integration::AndroidFramework::SetJVM()
76    */
77   void SetJVM(JavaVM* jvm);
78
79   /**
80    * @copydoc Dali::Integration::AndroidFramework::GetJVM()
81    */
82   JavaVM* GetJVM() const;
83
84   /**
85    * @copydoc Dali::Integration::AndroidFramework::SetApplicationAssets()
86    */
87   void SetApplicationAssets(AAssetManager* assets);
88
89   /**
90    * @copydoc Dali::Integration::AndroidFramework::GetApplicationAssets()
91    */
92   AAssetManager* GetApplicationAssets() const;
93
94   /**
95    *  copydoc Dali::Integration::AndroidFramework::SetInternalDataPath()
96    */
97   void SetInternalDataPath(const std::string& path);
98
99   /**
100    *  copydoc Dali::Integration::AndroidFramework::GetInternalDataPath()
101    */
102   std::string GetInternalDataPath() const;
103
104   /**
105    * @copydoc Dali::Integration::AndroidFramework::SetApplicationConfiguration()
106    */
107   void SetApplicationConfiguration(AConfiguration* configuration);
108
109   /**
110    * @copydoc Dali::Integration::AndroidFramework::GetApplicationConfiguration()
111    */
112   AConfiguration* GetApplicationConfiguration() const;
113
114   /**
115    * @copydoc Dali::Integration::AndroidFramework::SetApplicationWindow()
116    */
117   void SetApplicationWindow(ANativeWindow* window);
118
119   /**
120    * @copydoc Dali::Integration::AndroidFramework::GetApplicationWindow()
121    */
122   ANativeWindow* GetApplicationWindow() const;
123
124   /**
125    * @copydoc Dali::Integration::AndroidFramework::OnTerminate()
126    */
127   void OnTerminate();
128
129   /**
130    * @copydoc Dali::Integration::AndroidFramework::OnPause()
131    */
132   void OnPause();
133
134   /**
135    * @copydoc Dali::Integration::AndroidFramework::OnResume()
136    */
137   void OnResume();
138
139   /**
140    * @copydoc Dali::Integration::AndroidFramework::OnWindowCreated()
141    */
142   void OnWindowCreated(ANativeWindow* window);
143
144   /**
145    * @copydoc Dali::Integration::AndroidFramework::OnWindowDestroyed()
146    */
147   void OnWindowDestroyed(ANativeWindow* window);
148
149   /**
150    * @copydoc Dali::Integration::AndroidFramework::Get()
151    */
152   static Dali::Integration::AndroidFramework& Get();
153
154   /**
155    * @brief Sets an internal framework.
156    */
157   void SetFramework(Framework* framework)
158   {
159     mFramework = framework;
160   }
161
162   /**
163    * @brief Gets an internal framework.
164    *
165    * @return a pointer to the internal framework
166    */
167   Framework* GetFramework()
168   {
169     return mFramework;
170   }
171
172   /**
173    * Virtual destructor.
174    */
175   virtual ~AndroidFramework();
176
177   // Not copyable or movable
178   AndroidFramework(const AndroidFramework&) = delete;            ///< Deleted copy constructor
179   AndroidFramework(AndroidFramework&&)      = delete;            ///< Deleted move constructor
180   AndroidFramework& operator=(const AndroidFramework&) = delete; ///< Deleted copy assignment operator
181   AndroidFramework& operator=(AndroidFramework&&) = delete;      ///< Deleted move assignment operator
182
183 private:
184   AndroidFramework(Dali::Integration::AndroidFramework* androidFramework);
185   Dali::Integration::AndroidFramework* mAndroidFramework;
186   Framework*                           mFramework;
187
188   android_app*    mNativeApplication;
189   ANativeWindow*  mWindow;
190   AAssetManager*  mAssets;
191   std::string     mInternalDataPath;
192   AConfiguration* mConfiguration;
193   JavaVM*         mJVM;
194
195 public:
196   static AndroidFramework& GetImplementation(Dali::Integration::AndroidFramework& androidFramework)
197   {
198     return *androidFramework.mImpl;
199   }
200   static Framework& GetFramework(Dali::Integration::AndroidFramework& androidFramework)
201   {
202     return *androidFramework.mImpl->mFramework;
203   }
204 };
205
206 } // namespace Adaptor
207
208 } // namespace Internal
209
210 } // namespace Dali
211
212 #endif // DALI_INTEGRATION_ANDROID_FRAMEWORK_IMPL_H