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