2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/adaptor/android/android-framework-impl.h>
32 AndroidFramework* gAndroidFramework = nullptr; // raw specific pointer to allow AndroidFramework::Get
35 Dali::Integration::AndroidFramework& AndroidFramework::New()
37 Dali::Integration::AndroidFramework* androidFramework = new Dali::Integration::AndroidFramework;
38 AndroidFramework* impl = new AndroidFramework( androidFramework );
39 androidFramework->mImpl = impl;
40 return *androidFramework;
43 void AndroidFramework::Delete()
45 DALI_ASSERT_ALWAYS( gAndroidFramework != nullptr && "Cannot delete already deleted AndroidFramework." );
47 delete gAndroidFramework->mAndroidFramework;
48 gAndroidFramework = nullptr;
51 void AndroidFramework::SetNativeApplication( android_app* application )
53 mNativeApplication = application;
56 android_app* AndroidFramework::GetNativeApplication() const
58 return mNativeApplication;
61 void AndroidFramework::SetJVM( JavaVM* jvm )
66 JavaVM* AndroidFramework::GetJVM() const
71 void AndroidFramework::SetApplicationAssets( AAssetManager* assets )
76 AAssetManager* AndroidFramework::GetApplicationAssets() const
81 void AndroidFramework::SetInternalDataPath( const std::string& path )
83 mInternalDataPath = path;
86 std::string AndroidFramework::GetInternalDataPath() const
88 return mInternalDataPath;
91 void AndroidFramework::SetApplicationConfiguration( AConfiguration* configuration )
93 mConfiguration = configuration;
96 AConfiguration* AndroidFramework::GetApplicationConfiguration() const
98 return mConfiguration;
101 void AndroidFramework::SetApplicationWindow( ANativeWindow* window )
106 ANativeWindow* AndroidFramework::GetApplicationWindow() const
111 void AndroidFramework::OnTerminate()
113 mFramework->AppStatusHandler( APP_DESTROYED, nullptr );
116 void AndroidFramework::OnPause()
118 mFramework->AppStatusHandler( APP_PAUSE, nullptr );
121 void AndroidFramework::OnResume()
123 mFramework->AppStatusHandler( APP_RESUME, nullptr );
126 void AndroidFramework::OnWindowCreated( ANativeWindow* window )
128 mFramework->AppStatusHandler( APP_WINDOW_CREATED, window );
131 void AndroidFramework::OnWindowDestroyed( ANativeWindow* window )
133 mFramework->AppStatusHandler( APP_WINDOW_DESTROYED, window );
136 Dali::Integration::AndroidFramework& AndroidFramework::Get()
138 DALI_ASSERT_ALWAYS( gAndroidFramework != nullptr && "AndroidFramework not instantiated" );
140 return *gAndroidFramework->mAndroidFramework;
143 AndroidFramework::AndroidFramework( Dali::Integration::AndroidFramework* androidFramework )
144 : mAndroidFramework( androidFramework ),
145 mFramework( nullptr ),
146 mNativeApplication( nullptr ),
149 mConfiguration( nullptr ),
152 DALI_ASSERT_ALWAYS( gAndroidFramework == nullptr && "Cannot create more than one AndroidFramework." );
154 gAndroidFramework = this;
157 AndroidFramework::~AndroidFramework()
159 gAndroidFramework = nullptr;
162 } // namespace Adaptor
164 } // namespace Internal