2 * Copyright (c) 2021 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>
29 AndroidFramework* gAndroidFramework = nullptr; // raw specific pointer to allow AndroidFramework::Get
32 Dali::Integration::AndroidFramework& AndroidFramework::New()
34 Dali::Integration::AndroidFramework* androidFramework = new Dali::Integration::AndroidFramework;
35 AndroidFramework* impl = new AndroidFramework(androidFramework);
36 androidFramework->mImpl = impl;
37 return *androidFramework;
40 void AndroidFramework::Delete()
42 DALI_ASSERT_ALWAYS(gAndroidFramework != nullptr && "Cannot delete already deleted AndroidFramework.");
44 delete gAndroidFramework->mAndroidFramework;
45 gAndroidFramework = nullptr;
48 void AndroidFramework::SetNativeApplication(android_app* application)
50 mNativeApplication = application;
53 android_app* AndroidFramework::GetNativeApplication() const
55 return mNativeApplication;
58 void AndroidFramework::SetJVM(JavaVM* jvm)
63 JavaVM* AndroidFramework::GetJVM() const
68 void AndroidFramework::SetApplicationAssets(AAssetManager* assets)
73 AAssetManager* AndroidFramework::GetApplicationAssets() const
78 void AndroidFramework::SetInternalDataPath(const std::string& path)
80 mInternalDataPath = path;
83 std::string AndroidFramework::GetInternalDataPath() const
85 return mInternalDataPath;
88 void AndroidFramework::SetApplicationConfiguration(AConfiguration* configuration)
90 mConfiguration = configuration;
93 AConfiguration* AndroidFramework::GetApplicationConfiguration() const
95 return mConfiguration;
98 void AndroidFramework::SetApplicationWindow(ANativeWindow* window)
103 ANativeWindow* AndroidFramework::GetApplicationWindow() const
108 void AndroidFramework::OnTerminate()
110 mFramework->AppStatusHandler(APP_DESTROYED, nullptr);
113 void AndroidFramework::OnPause()
115 mFramework->AppStatusHandler(APP_PAUSE, nullptr);
118 void AndroidFramework::OnResume()
120 mFramework->AppStatusHandler(APP_RESUME, nullptr);
123 void AndroidFramework::OnWindowCreated(ANativeWindow* window)
125 mFramework->AppStatusHandler(APP_WINDOW_CREATED, window);
128 void AndroidFramework::OnWindowDestroyed(ANativeWindow* window)
130 mFramework->AppStatusHandler(APP_WINDOW_DESTROYED, window);
133 Dali::Integration::AndroidFramework& AndroidFramework::Get()
135 DALI_ASSERT_ALWAYS(gAndroidFramework != nullptr && "AndroidFramework not instantiated");
137 return *gAndroidFramework->mAndroidFramework;
140 AndroidFramework::AndroidFramework(Dali::Integration::AndroidFramework* androidFramework)
141 : mAndroidFramework(androidFramework),
143 mNativeApplication(nullptr),
146 mConfiguration(nullptr),
149 DALI_ASSERT_ALWAYS(gAndroidFramework == nullptr && "Cannot create more than one AndroidFramework.");
151 gAndroidFramework = this;
154 AndroidFramework::~AndroidFramework()
156 gAndroidFramework = nullptr;
159 } // namespace Adaptor
161 } // namespace Internal