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::SetApplicationConfiguration( AConfiguration* configuration )
83 mConfiguration = configuration;
86 AConfiguration* AndroidFramework::GetApplicationConfiguration() const
88 return mConfiguration;
91 void AndroidFramework::SetApplicationWindow( ANativeWindow* window )
96 ANativeWindow* AndroidFramework::GetApplicationWindow() const
101 void AndroidFramework::OnTerminate()
103 mFramework->AppStatusHandler( APP_DESTROYED, nullptr );
106 void AndroidFramework::OnPause()
108 mFramework->AppStatusHandler( APP_PAUSE, nullptr );
111 void AndroidFramework::OnResume()
113 mFramework->AppStatusHandler( APP_RESUME, nullptr );
116 void AndroidFramework::OnWindowCreated( ANativeWindow* window )
118 mFramework->AppStatusHandler( APP_WINDOW_CREATED, window );
121 void AndroidFramework::OnWindowDestroyed( ANativeWindow* window )
123 mFramework->AppStatusHandler( APP_WINDOW_DESTROYED, window );
126 Dali::Integration::AndroidFramework& AndroidFramework::Get()
128 DALI_ASSERT_ALWAYS( gAndroidFramework != nullptr && "AndroidFramework not instantiated" );
130 return *gAndroidFramework->mAndroidFramework;
133 AndroidFramework::AndroidFramework( Dali::Integration::AndroidFramework* androidFramework )
134 : mAndroidFramework( androidFramework ),
135 mFramework( nullptr ),
136 mNativeApplication( nullptr ),
139 mConfiguration( nullptr ),
142 DALI_ASSERT_ALWAYS( gAndroidFramework == nullptr && "Cannot create more than one AndroidFramework." );
144 gAndroidFramework = this;
147 AndroidFramework::~AndroidFramework()
149 gAndroidFramework = nullptr;
152 } // namespace Adaptor
154 } // namespace Internal