Commit 1d3a43d6f7d92377858f0f655c3659e7881c912a
[dali_1.9.6] Merge branch 'devel/master'
Change-Id: I73f0bc5bd0a10021efda6fb32d39135d659035cb
Showing
15 changed files
with
288 additions
and
130 deletions
README.md
| @@ -78,8 +78,13 @@ Before running make install as normal: | @@ -78,8 +78,13 @@ Before running make install as normal: | ||
| 78 | 78 | ||
| 79 | - Ubuntu 16.04 or later | 79 | - Ubuntu 16.04 or later |
| 80 | - GCC version 6 | 80 | - GCC version 6 |
| 81 | + - Android DALi dependencies | ||
| 81 | 82 | ||
| 82 | ### Building the Repository | 83 | ### Building the Repository |
| 84 | +To download Android DALi dependencies clone https://github.com/dalihub/android-dependencies | ||
| 85 | +in your DALi folder (folder containing dali-demo). | ||
| 86 | + | ||
| 87 | + $ git clone https://github.com/dalihub/android-dependencies.git | ||
| 83 | 88 | ||
| 84 | To build the repository enter the 'build/android' folder: | 89 | To build the repository enter the 'build/android' folder: |
| 85 | 90 | ||
| @@ -93,6 +98,11 @@ For debug build: | @@ -93,6 +98,11 @@ For debug build: | ||
| 93 | 98 | ||
| 94 | $ DEBUG=1 ./build.sh | 99 | $ DEBUG=1 ./build.sh |
| 95 | 100 | ||
| 101 | +To debug from Android Studio set Android DALi enviroment using setenv script in 'build/android' and launch Android Studio from the enviroment: | ||
| 102 | + | ||
| 103 | + $ . setenv | ||
| 104 | + $ <path/to/androidstudio>/bin/studio.sh | ||
| 105 | + | ||
| 96 | To clean the build: | 106 | To clean the build: |
| 97 | 107 | ||
| 98 | $ ./build.sh clean | 108 | $ ./build.sh clean |
| @@ -102,3 +112,4 @@ To install apks: | @@ -102,3 +112,4 @@ To install apks: | ||
| 102 | $ adb install -r ./app/build/outputs/apk/debug/dali-demo-debug.apk | 112 | $ adb install -r ./app/build/outputs/apk/debug/dali-demo-debug.apk |
| 103 | $ adb install -r ./app/build/outputs/apk/release/dali-demo-release.apk | 113 | $ adb install -r ./app/build/outputs/apk/release/dali-demo-release.apk |
| 104 | 114 | ||
| 115 | + |
build/android/app/src/main/AndroidManifest.xml
| @@ -14,13 +14,30 @@ | @@ -14,13 +14,30 @@ | ||
| 14 | android:label="@string/app_name" | 14 | android:label="@string/app_name" |
| 15 | android:name="com.sec.dalidemo.DaliDemoApplication"> | 15 | android:name="com.sec.dalidemo.DaliDemoApplication"> |
| 16 | 16 | ||
| 17 | + <activity android:name="com.sec.dalidemo.DaliDemoNativeActivity" | ||
| 18 | + android:icon="@mipmap/dali_launcher" | ||
| 19 | + android:label="DALi Example" | ||
| 20 | + android:screenOrientation="portrait" | ||
| 21 | + android:windowSoftInputMode="stateAlwaysVisible" | ||
| 22 | + android:process=":example"> | ||
| 23 | + <!-- Tell NativeActivity the name of our .so --> | ||
| 24 | + <meta-data android:name="android.app.lib_name" | ||
| 25 | + android:value="native-activity" /> | ||
| 26 | + <meta-data android:name="start" | ||
| 27 | + android:value="blocks.example" /> | ||
| 28 | + <intent-filter> | ||
| 29 | + <action android:name="android.intent.action.RUN" /> | ||
| 30 | + </intent-filter> | ||
| 31 | + </activity> | ||
| 32 | + | ||
| 17 | <!-- Our activity is the built-in NativeActivity framework class. | 33 | <!-- Our activity is the built-in NativeActivity framework class. |
| 18 | This will take care of integrating with our NDK code. --> | 34 | This will take care of integrating with our NDK code. --> |
| 19 | - <activity android:name="com.sec.dalidemo.DaliDemoNativeActivity" | 35 | + <activity android:name="com.sec.dalidemo.DaliDemosNativeActivity" |
| 20 | android:icon="@mipmap/dali_launcher" | 36 | android:icon="@mipmap/dali_launcher" |
| 21 | android:label="@string/demo_name" | 37 | android:label="@string/demo_name" |
| 22 | android:screenOrientation="portrait" | 38 | android:screenOrientation="portrait" |
| 23 | - android:windowSoftInputMode="stateAlwaysVisible"> | 39 | + android:windowSoftInputMode="stateAlwaysVisible" |
| 40 | + android:process=":dalidemos"> | ||
| 24 | <!-- Tell NativeActivity the name of our .so --> | 41 | <!-- Tell NativeActivity the name of our .so --> |
| 25 | <meta-data android:name="android.app.lib_name" | 42 | <meta-data android:name="android.app.lib_name" |
| 26 | android:value="native-activity" /> | 43 | android:value="native-activity" /> |
| @@ -37,7 +54,8 @@ | @@ -37,7 +54,8 @@ | ||
| 37 | android:icon="@mipmap/dali_examples" | 54 | android:icon="@mipmap/dali_examples" |
| 38 | android:label="@string/examples_name" | 55 | android:label="@string/examples_name" |
| 39 | android:screenOrientation="portrait" | 56 | android:screenOrientation="portrait" |
| 40 | - android:windowSoftInputMode="stateAlwaysVisible"> | 57 | + android:windowSoftInputMode="stateAlwaysVisible" |
| 58 | + android:process=":daliexamples"> | ||
| 41 | <!-- Tell NativeActivity the name of our .so --> | 59 | <!-- Tell NativeActivity the name of our .so --> |
| 42 | <meta-data android:name="android.app.lib_name" | 60 | <meta-data android:name="android.app.lib_name" |
| 43 | android:value="native-activity" /> | 61 | android:value="native-activity" /> |
| @@ -54,7 +72,8 @@ | @@ -54,7 +72,8 @@ | ||
| 54 | android:icon="@mipmap/dali_tests" | 72 | android:icon="@mipmap/dali_tests" |
| 55 | android:label="@string/tests_name" | 73 | android:label="@string/tests_name" |
| 56 | android:screenOrientation="portrait" | 74 | android:screenOrientation="portrait" |
| 57 | - android:windowSoftInputMode="stateAlwaysVisible"> | 75 | + android:windowSoftInputMode="stateAlwaysVisible" |
| 76 | + android:process=":dalitests"> | ||
| 58 | <!-- Tell NativeActivity the name of our .so --> | 77 | <!-- Tell NativeActivity the name of our .so --> |
| 59 | <meta-data android:name="android.app.lib_name" | 78 | <meta-data android:name="android.app.lib_name" |
| 60 | android:value="native-activity" /> | 79 | android:value="native-activity" /> |
build/android/app/src/main/cpp/CMakeLists.txt
| @@ -24,6 +24,7 @@ ADD_LIBRARY(native-activity SHARED main.cpp) | @@ -24,6 +24,7 @@ ADD_LIBRARY(native-activity SHARED main.cpp) | ||
| 24 | TARGET_INCLUDE_DIRECTORIES(native-activity PRIVATE | 24 | TARGET_INCLUDE_DIRECTORIES(native-activity PRIVATE |
| 25 | ${ANDROID_NDK}/sources/android/native_app_glue) | 25 | ${ANDROID_NDK}/sources/android/native_app_glue) |
| 26 | 26 | ||
| 27 | +INCLUDE_DIRECTORIES(.) | ||
| 27 | INCLUDE_DIRECTORIES(${DALI_ENV_DIR}/include) | 28 | INCLUDE_DIRECTORIES(${DALI_ENV_DIR}/include) |
| 28 | INCLUDE_DIRECTORIES(${DALI_ENV_DIR}/include/dali) | 29 | INCLUDE_DIRECTORIES(${DALI_ENV_DIR}/include/dali) |
| 29 | 30 |
build/android/app/src/main/cpp/dali-demo-native-activity-jni.h
0 โ 100644
| 1 | +/* | ||
| 2 | + * Copyright (c) 2020 Samsung Electronics Co., Ltd. | ||
| 3 | + * | ||
| 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 | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 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. | ||
| 15 | + */ | ||
| 16 | + | ||
| 17 | +#ifndef ANDROID_DALI_DEMO_NATIVE_ACTIVITY_JNI_H | ||
| 18 | +#define ANDROID_DALI_DEMO_NATIVE_ACTIVITY_JNI_H | ||
| 19 | + | ||
| 20 | +#include <string> | ||
| 21 | +#include <android_native_app_glue.h> | ||
| 22 | + | ||
| 23 | +class DaliDemoNativeActivity | ||
| 24 | +{ | ||
| 25 | +public: | ||
| 26 | + DaliDemoNativeActivity(ANativeActivity* activity) | ||
| 27 | + : activity(activity) | ||
| 28 | + { | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + class JString | ||
| 32 | + { | ||
| 33 | + public: | ||
| 34 | + JString(JNIEnv* env, const std::string& str) | ||
| 35 | + : env(env), | ||
| 36 | + string(env->NewStringUTF(str.c_str())) | ||
| 37 | + { | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + JString(JNIEnv* env, jstring str) | ||
| 41 | + : env(env), | ||
| 42 | + string(str) | ||
| 43 | + { | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + std::string ToString() | ||
| 47 | + { | ||
| 48 | + std::string out; | ||
| 49 | + if (string) | ||
| 50 | + { | ||
| 51 | + const char* utf = env->GetStringUTFChars(string, 0); | ||
| 52 | + out = std::string(utf); | ||
| 53 | + env->ReleaseStringUTFChars(string, utf); | ||
| 54 | + } | ||
| 55 | + return out; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + ~JString() | ||
| 59 | + { | ||
| 60 | + if (string) | ||
| 61 | + { | ||
| 62 | + env->DeleteLocalRef(string); | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + private: | ||
| 67 | + friend class DaliDemoNativeActivity; | ||
| 68 | + JNIEnv* env; | ||
| 69 | + jstring string; | ||
| 70 | + }; | ||
| 71 | + | ||
| 72 | + class NativeActivityJNI | ||
| 73 | + { | ||
| 74 | + public: | ||
| 75 | + NativeActivityJNI(ANativeActivity* activity) | ||
| 76 | + : activity(activity) | ||
| 77 | + { | ||
| 78 | + activity->vm->AttachCurrentThread(&env, nullptr); | ||
| 79 | + clazz = env->GetObjectClass(activity->clazz); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + ~NativeActivityJNI() | ||
| 83 | + { | ||
| 84 | + activity->vm->DetachCurrentThread(); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + std::string CallStringMethod(const std::string& name, const std::string& arg) | ||
| 88 | + { | ||
| 89 | + jmethodID methodID = env->GetMethodID(clazz, name.c_str(), "(Ljava/lang/String;)Ljava/lang/String;"); | ||
| 90 | + JString argument(env, arg); | ||
| 91 | + JString returnValue(env, (jstring)env->CallObjectMethod(activity->clazz, methodID, argument.string)); | ||
| 92 | + return returnValue.ToString(); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + void CallVoidMethod(const std::string& name, const std::string& arg) | ||
| 96 | + { | ||
| 97 | + jmethodID methodID = env->GetMethodID(clazz, name.c_str(), "(Ljava/lang/String;)V"); | ||
| 98 | + JString argument(env, arg); | ||
| 99 | + env->CallVoidMethod(activity->clazz, methodID, argument.string); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + private: | ||
| 103 | + ANativeActivity* activity; | ||
| 104 | + JNIEnv* env; | ||
| 105 | + jclass clazz; | ||
| 106 | + }; | ||
| 107 | + | ||
| 108 | + std::string GetMetaData(const std::string& key) | ||
| 109 | + { | ||
| 110 | + NativeActivityJNI nativeActivityJNI(activity); | ||
| 111 | + return nativeActivityJNI.CallStringMethod("getMetaData", key); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + std::string GetIntentStringExtra(const std::string& key) | ||
| 115 | + { | ||
| 116 | + NativeActivityJNI nativeActivityJNI(activity); | ||
| 117 | + return nativeActivityJNI.CallStringMethod("getIntentStringExtra", key); | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + void LaunchExample(const std::string& exampleName) | ||
| 121 | + { | ||
| 122 | + NativeActivityJNI nativeActivityJNI(activity); | ||
| 123 | + return nativeActivityJNI.CallVoidMethod("launchExample", exampleName); | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | +private: | ||
| 127 | + ANativeActivity* activity; | ||
| 128 | +}; | ||
| 129 | + | ||
| 130 | +#endif //ANDROID_DALI_DEMO_NATIVE_ACTIVITY_JNI_H |
build/android/app/src/main/cpp/main.cpp
| @@ -22,6 +22,7 @@ | @@ -22,6 +22,7 @@ | ||
| 22 | 22 | ||
| 23 | #include <android/log.h> | 23 | #include <android/log.h> |
| 24 | #include <android_native_app_glue.h> | 24 | #include <android_native_app_glue.h> |
| 25 | +#include <dali-demo-native-activity-jni.h> | ||
| 25 | #include <dali/devel-api/adaptor-framework/application-devel.h> | 26 | #include <dali/devel-api/adaptor-framework/application-devel.h> |
| 26 | #include <dali/integration-api/debug.h> | 27 | #include <dali/integration-api/debug.h> |
| 27 | #include <dali/integration-api/adaptor-framework/android/android-framework.h> | 28 | #include <dali/integration-api/adaptor-framework/android/android-framework.h> |
| @@ -39,16 +40,17 @@ namespace | @@ -39,16 +40,17 @@ namespace | ||
| 39 | 40 | ||
| 40 | void free_saved_state(struct android_app *android_app) | 41 | void free_saved_state(struct android_app *android_app) |
| 41 | { | 42 | { |
| 42 | - pthread_mutex_lock(&android_app->mutex); | 43 | + LOGV("free_saved_state"); |
| 44 | + pthread_mutex_lock(&android_app->mutex); | ||
| 43 | 45 | ||
| 44 | - if (android_app->savedState != NULL) | ||
| 45 | - { | ||
| 46 | - free(android_app->savedState); | ||
| 47 | - android_app->savedState = NULL; | ||
| 48 | - android_app->savedStateSize = 0; | ||
| 49 | - } | 46 | + if (android_app->savedState != NULL) |
| 47 | + { | ||
| 48 | + free(android_app->savedState); | ||
| 49 | + android_app->savedState = NULL; | ||
| 50 | + android_app->savedStateSize = 0; | ||
| 51 | + } | ||
| 50 | 52 | ||
| 51 | - pthread_mutex_unlock(&android_app->mutex); | 53 | + pthread_mutex_unlock(&android_app->mutex); |
| 52 | } | 54 | } |
| 53 | 55 | ||
| 54 | void android_app_destroy(struct android_app *android_app) | 56 | void android_app_destroy(struct android_app *android_app) |
| @@ -145,77 +147,12 @@ void ExtractFontConfig(struct android_app* state, std::string assetFontConfig, s | @@ -145,77 +147,12 @@ void ExtractFontConfig(struct android_app* state, std::string assetFontConfig, s | ||
| 145 | } | 147 | } |
| 146 | } | 148 | } |
| 147 | 149 | ||
| 148 | -class DaliDemoNativeActivity | ||
| 149 | -{ | ||
| 150 | -public: | ||
| 151 | - ANativeActivity* activity; | ||
| 152 | - DaliDemoNativeActivity(ANativeActivity* activity) | ||
| 153 | - : activity(activity) | ||
| 154 | - { | ||
| 155 | - } | ||
| 156 | - | ||
| 157 | - class NativeActivityJNI | ||
| 158 | - { | ||
| 159 | - public: | ||
| 160 | - ANativeActivity* activity; | ||
| 161 | - JNIEnv* env; | ||
| 162 | - jclass clazz; | ||
| 163 | - | ||
| 164 | - NativeActivityJNI(ANativeActivity* activity) | ||
| 165 | - : activity(activity) | ||
| 166 | - { | ||
| 167 | - activity->vm->AttachCurrentThread(&env, NULL); | ||
| 168 | - clazz = env->GetObjectClass(activity->clazz); | ||
| 169 | - } | ||
| 170 | - | ||
| 171 | - ~NativeActivityJNI() | ||
| 172 | - { | ||
| 173 | - activity->vm->DetachCurrentThread(); | ||
| 174 | - } | ||
| 175 | - | ||
| 176 | - jstring toJString(const std::string& str) | ||
| 177 | - { | ||
| 178 | - return env->NewStringUTF(str.c_str()); | ||
| 179 | - } | ||
| 180 | - | ||
| 181 | - std::string toString(jstring jstr) | ||
| 182 | - { | ||
| 183 | - std::string out; | ||
| 184 | - if (jstr) | ||
| 185 | - { | ||
| 186 | - const char* utf = env->GetStringUTFChars(jstr, 0); | ||
| 187 | - out = std::string(utf); | ||
| 188 | - env->ReleaseStringUTFChars(jstr, utf); | ||
| 189 | - } | ||
| 190 | - | ||
| 191 | - return out; | ||
| 192 | - } | ||
| 193 | - | ||
| 194 | - std::string callStringMethod(const std::string& name, const std::string& arg) | ||
| 195 | - { | ||
| 196 | - jmethodID methodID = env->GetMethodID(clazz, name.c_str(), "(Ljava/lang/String;)Ljava/lang/String;"); | ||
| 197 | - jstring jstr = (jstring)env->CallObjectMethod(activity->clazz, methodID, toJString(arg)); | ||
| 198 | - return toString(jstr); | ||
| 199 | - } | ||
| 200 | - }; | ||
| 201 | - | ||
| 202 | - std::string getMetaData(const std::string& key) | ||
| 203 | - { | ||
| 204 | - NativeActivityJNI nativeActivityJNI(activity); | ||
| 205 | - return nativeActivityJNI.callStringMethod("getMetaData", key); | ||
| 206 | - } | ||
| 207 | - | ||
| 208 | - std::string getIntentStringExtra(const std::string& key) | ||
| 209 | - { | ||
| 210 | - NativeActivityJNI nativeActivityJNI(activity); | ||
| 211 | - return nativeActivityJNI.callStringMethod("getIntentStringExtra", key); | ||
| 212 | - } | ||
| 213 | -}; | ||
| 214 | - | ||
| 215 | extern "C" void FcConfigPathInit(const char* path, const char* file); | 150 | extern "C" void FcConfigPathInit(const char* path, const char* file); |
| 216 | 151 | ||
| 217 | void android_main( struct android_app* state ) | 152 | void android_main( struct android_app* state ) |
| 218 | { | 153 | { |
| 154 | + LOGV("android_main() >>"); | ||
| 155 | + | ||
| 219 | std::string filesDir = state->activity->internalDataPath; | 156 | std::string filesDir = state->activity->internalDataPath; |
| 220 | 157 | ||
| 221 | std::string fontconfigPath = filesDir + "/fonts"; | 158 | std::string fontconfigPath = filesDir + "/fonts"; |
| @@ -239,19 +176,19 @@ void android_main( struct android_app* state ) | @@ -239,19 +176,19 @@ void android_main( struct android_app* state ) | ||
| 239 | } | 176 | } |
| 240 | 177 | ||
| 241 | Dali::Integration::AndroidFramework::New(); | 178 | Dali::Integration::AndroidFramework::New(); |
| 242 | - Dali::Integration::AndroidFramework::Get().SetNativeApplication( state ); | ||
| 243 | - Dali::Integration::AndroidFramework::Get().SetApplicationConfiguration( state->config ); | ||
| 244 | - Dali::Integration::AndroidFramework::Get().SetApplicationAssets( state->activity->assetManager ); | ||
| 245 | - Dali::Integration::AndroidFramework::Get().SetInternalDataPath( filesDir ); | 179 | + Dali::Integration::AndroidFramework::Get().SetNativeApplication(state); |
| 180 | + Dali::Integration::AndroidFramework::Get().SetApplicationConfiguration(state->config); | ||
| 181 | + Dali::Integration::AndroidFramework::Get().SetApplicationAssets(state->activity->assetManager); | ||
| 182 | + Dali::Integration::AndroidFramework::Get().SetInternalDataPath(filesDir); | ||
| 246 | 183 | ||
| 247 | DaliDemoNativeActivity nativeActivity(state->activity); | 184 | DaliDemoNativeActivity nativeActivity(state->activity); |
| 248 | 185 | ||
| 249 | int status = 0; | 186 | int status = 0; |
| 250 | std::string libpath = "/data/data/com.sec.dalidemo/lib/libdali-demo.so"; | 187 | std::string libpath = "/data/data/com.sec.dalidemo/lib/libdali-demo.so"; |
| 251 | - std::string callParam = nativeActivity.getIntentStringExtra("start"); | 188 | + std::string callParam = nativeActivity.GetIntentStringExtra("start"); |
| 252 | if (callParam.empty()) | 189 | if (callParam.empty()) |
| 253 | { | 190 | { |
| 254 | - callParam = nativeActivity.getMetaData("start"); | 191 | + callParam = nativeActivity.GetMetaData("start"); |
| 255 | } | 192 | } |
| 256 | 193 | ||
| 257 | if (!callParam.empty()) | 194 | if (!callParam.empty()) |
| @@ -259,7 +196,7 @@ void android_main( struct android_app* state ) | @@ -259,7 +196,7 @@ void android_main( struct android_app* state ) | ||
| 259 | libpath = "/data/data/com.sec.dalidemo/lib/lib" + callParam + ".so"; | 196 | libpath = "/data/data/com.sec.dalidemo/lib/lib" + callParam + ".so"; |
| 260 | } | 197 | } |
| 261 | 198 | ||
| 262 | - void* handle = dlopen( libpath.c_str(), RTLD_LAZY ); | 199 | + void* handle = dlopen(libpath.c_str(), RTLD_LAZY); |
| 263 | if (!handle) | 200 | if (!handle) |
| 264 | { | 201 | { |
| 265 | std::exit(status); | 202 | std::exit(status); |
| @@ -286,7 +223,9 @@ void android_main( struct android_app* state ) | @@ -286,7 +223,9 @@ void android_main( struct android_app* state ) | ||
| 286 | Dali::Integration::AndroidFramework::Get().SetApplicationAssets(nullptr); | 223 | Dali::Integration::AndroidFramework::Get().SetApplicationAssets(nullptr); |
| 287 | Dali::Integration::AndroidFramework::Delete(); | 224 | Dali::Integration::AndroidFramework::Delete(); |
| 288 | 225 | ||
| 289 | - // We need to kill the application process manually, DALi cannot restart in the same process due to memory leaks | 226 | + LOGV("android_main() <<"); |
| 227 | + | ||
| 228 | + // We need to kill the application process manually, DALi cannot exit the process properly due to memory leaks | ||
| 290 | std::exit(status); | 229 | std::exit(status); |
| 291 | } | 230 | } |
| 292 | 231 |
build/android/app/src/main/java/com/sec/dalidemo/DaliDemoNativeActivity.java
| @@ -4,6 +4,7 @@ import android.annotation.TargetApi; | @@ -4,6 +4,7 @@ import android.annotation.TargetApi; | ||
| 4 | import android.app.NativeActivity; | 4 | import android.app.NativeActivity; |
| 5 | import android.content.ComponentName; | 5 | import android.content.ComponentName; |
| 6 | import android.content.Context; | 6 | import android.content.Context; |
| 7 | +import android.content.Intent; | ||
| 7 | import android.content.pm.ActivityInfo; | 8 | import android.content.pm.ActivityInfo; |
| 8 | import android.content.pm.ApplicationInfo; | 9 | import android.content.pm.ApplicationInfo; |
| 9 | import android.content.pm.PackageManager; | 10 | import android.content.pm.PackageManager; |
| @@ -94,4 +95,10 @@ public class DaliDemoNativeActivity extends NativeActivity { | @@ -94,4 +95,10 @@ public class DaliDemoNativeActivity extends NativeActivity { | ||
| 94 | public final String getIntentStringExtra(String key) { | 95 | public final String getIntentStringExtra(String key) { |
| 95 | return getIntent().getStringExtra(key); | 96 | return getIntent().getStringExtra(key); |
| 96 | } | 97 | } |
| 98 | + | ||
| 99 | + public final void launchExample(String exampleName) { | ||
| 100 | + Intent intent = new Intent(this, DaliDemoNativeActivity.class); | ||
| 101 | + intent.putExtra("start", exampleName); | ||
| 102 | + startActivity(intent); | ||
| 103 | + } | ||
| 97 | } | 104 | } |
build/android/app/src/main/java/com/sec/dalidemo/DaliDemosNativeActivity.java
0 โ 100644
build/android/build.sh
| @@ -43,6 +43,10 @@ fi | @@ -43,6 +43,10 @@ fi | ||
| 43 | if [ ! -d "$ANDROID_NDK" ]; then | 43 | if [ ! -d "$ANDROID_NDK" ]; then |
| 44 | if [ -d "$ANDROID_SDK" ]; then | 44 | if [ -d "$ANDROID_SDK" ]; then |
| 45 | NDK_DIR=$(find $ANDROID_SDK -maxdepth 2 -name ndk-build | sed 's/\/ndk-build//') | 45 | NDK_DIR=$(find $ANDROID_SDK -maxdepth 2 -name ndk-build | sed 's/\/ndk-build//') |
| 46 | + # Some sdk folder structures have extra <version> dir for ndk folders. | ||
| 47 | + if [ ! -d "$NDK_DIR" ]; then | ||
| 48 | + NDK_DIR=$(find $ANDROID_SDK -maxdepth 3 -name ndk-build | sed 's/\/ndk-build//') | ||
| 49 | + fi | ||
| 46 | if [ -d "$NDK_DIR" ]; then | 50 | if [ -d "$NDK_DIR" ]; then |
| 47 | export ANDROID_NDK=$NDK_DIR | 51 | export ANDROID_NDK=$NDK_DIR |
| 48 | fi | 52 | fi |
build/android/setenv
0 โ 100755
| 1 | +[ -z $ROOT_DIR ] && ROOT_DIR=$HOME | ||
| 2 | +echo "Using ROOT_DIR=\"$ROOT_DIR\"" | ||
| 3 | + | ||
| 4 | +[ -z $DALI_DIR ] && DALI_DIR=$(cd ../../../;pwd) | ||
| 5 | +echo "Using DALI_DIR=\"$DALI_DIR\"" | ||
| 6 | +export DALI_DIR=$DALI_DIR | ||
| 7 | + | ||
| 8 | +[ -z $DALI_ENV_DIR ] && DALI_ENV_DIR=$DALI_DIR/dali-env/android | ||
| 9 | +echo "Using DALI_ENV_DIR=\"$DALI_ENV_DIR\"" | ||
| 10 | +export DALI_ENV_DIR=$DALI_ENV_DIR | ||
| 11 | + | ||
| 12 | +[ -z $TARGET ] && export TARGET=armeabi-v7a | ||
| 13 | +echo "Using TARGET=\"$TARGET\"" | ||
| 14 | + | ||
| 15 | +if [ ! -d "$ANDROID_SDK" ]; then | ||
| 16 | +# try default path | ||
| 17 | + if [ -d "$ROOT_DIR/Android/Sdk" ]; then | ||
| 18 | + export ANDROID_SDK=$ROOT_DIR/Android/Sdk | ||
| 19 | + fi | ||
| 20 | +fi | ||
| 21 | +echo "Using ANDROID_SDK=\"$ANDROID_SDK\"" | ||
| 22 | + | ||
| 23 | +if [ ! -d "$ANDROID_NDK" ]; then | ||
| 24 | + if [ -d "$ANDROID_SDK" ]; then | ||
| 25 | + NDK_DIR=$(find $ANDROID_SDK -maxdepth 2 -name ndk-build | sed 's/\/ndk-build//') | ||
| 26 | + # Some sdk folder structures have extra <version> dir for ndk folders. | ||
| 27 | + if [ ! -d "$NDK_DIR" ]; then | ||
| 28 | + NDK_DIR=$(find $ANDROID_SDK -maxdepth 3 -name ndk-build | sed 's/\/ndk-build//') | ||
| 29 | + fi | ||
| 30 | + if [ -d "$NDK_DIR" ]; then | ||
| 31 | + export ANDROID_NDK=$NDK_DIR | ||
| 32 | + fi | ||
| 33 | + fi | ||
| 34 | +fi | ||
| 35 | +echo "Using ANDROID_NDK=\"$ANDROID_NDK\"" |
build/tizen/CMakeLists.txt
| @@ -207,6 +207,12 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${REQUIRED_CFLAGS} ${DALI_DEMO_CFLAGS} -Werr | @@ -207,6 +207,12 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${REQUIRED_CFLAGS} ${DALI_DEMO_CFLAGS} -Werr | ||
| 207 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}") | 207 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}") |
| 208 | 208 | ||
| 209 | INCLUDE_DIRECTORIES(${ROOT_SRC_DIR}) | 209 | INCLUDE_DIRECTORIES(${ROOT_SRC_DIR}) |
| 210 | +IF(ANDROID) | ||
| 211 | + INCLUDE_DIRECTORIES( ${ANDROID_NDK}/sources/android/native_app_glue ) | ||
| 212 | + INCLUDE_DIRECTORIES( ${ANDROID_NDK}/sysroot/usr ) | ||
| 213 | + INCLUDE_DIRECTORIES( ${ANDROID_NDK}/sysroot/usr/include/android ) | ||
| 214 | + INCLUDE_DIRECTORIES( ${ROOT_SRC_DIR}/build/android/app/src/main/cpp ) | ||
| 215 | +ENDIF() | ||
| 210 | 216 | ||
| 211 | ADD_SUBDIRECTORY(demo) | 217 | ADD_SUBDIRECTORY(demo) |
| 212 | ADD_SUBDIRECTORY(examples) | 218 | ADD_SUBDIRECTORY(examples) |
examples/reflection-demo/gltf-scene.cpp
| @@ -185,7 +185,7 @@ void glTF::LoadFromFile( const std::string& filename ) | @@ -185,7 +185,7 @@ void glTF::LoadFromFile( const std::string& filename ) | ||
| 185 | } | 185 | } |
| 186 | else | 186 | else |
| 187 | { | 187 | { |
| 188 | - GLTF_LOG( "GLTF: %s loaded, size = %d", binFile.c_str(), int(mBuffer.size())); | 188 | + GLTF_LOG( "GLTF: %s loaded, size = %d", binFile.c_str(), int(jsonBuffer.size())); |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | // Abort if errors | 191 | // Abort if errors |
| @@ -412,12 +412,18 @@ glTF_Buffer glTF::LoadFile( const std::string& filename ) | @@ -412,12 +412,18 @@ glTF_Buffer glTF::LoadFile( const std::string& filename ) | ||
| 412 | std::vector<unsigned char> buffer; | 412 | std::vector<unsigned char> buffer; |
| 413 | if( fin ) | 413 | if( fin ) |
| 414 | { | 414 | { |
| 415 | - fseek( fin, 0, SEEK_END ); | 415 | + if( fseek( fin, 0, SEEK_END ) ) |
| 416 | + { | ||
| 417 | + return {}; | ||
| 418 | + } | ||
| 416 | auto size = ftell(fin); | 419 | auto size = ftell(fin); |
| 417 | - fseek( fin, 0, SEEK_SET ); | 420 | + if( fseek( fin, 0, SEEK_SET ) ) |
| 421 | + { | ||
| 422 | + return {}; | ||
| 423 | + } | ||
| 418 | buffer.resize(unsigned(size)); | 424 | buffer.resize(unsigned(size)); |
| 419 | auto result = fread( buffer.data(), 1, size_t(size), fin ); | 425 | auto result = fread( buffer.data(), 1, size_t(size), fin ); |
| 420 | - if( result < 0 ) | 426 | + if( result != size_t(size) ) |
| 421 | { | 427 | { |
| 422 | GLTF_LOG("LoadFile: Result: %d", int(result)); | 428 | GLTF_LOG("LoadFile: Result: %d", int(result)); |
| 423 | // return empty buffer | 429 | // return empty buffer |
examples/reflection-demo/pico-json.h
| @@ -132,8 +132,8 @@ public: | @@ -132,8 +132,8 @@ public: | ||
| 132 | object* object_; | 132 | object* object_; |
| 133 | }; | 133 | }; |
| 134 | protected: | 134 | protected: |
| 135 | - int type_; | ||
| 136 | - _storage u_; | 135 | + int type_{}; |
| 136 | + _storage u_ {}; | ||
| 137 | public: | 137 | public: |
| 138 | value(); | 138 | value(); |
| 139 | value(int type, bool); | 139 | value(int type, bool); |
examples/reflection-demo/reflection-example.cpp
| @@ -639,30 +639,31 @@ private: | @@ -639,30 +639,31 @@ private: | ||
| 639 | } | 639 | } |
| 640 | 640 | ||
| 641 | private: | 641 | private: |
| 642 | + | ||
| 642 | Application& mApplication; | 643 | Application& mApplication; |
| 643 | 644 | ||
| 644 | - Layer mLayer3D; | 645 | + Layer mLayer3D{}; |
| 645 | 646 | ||
| 646 | - std::vector<Actor> mActors; | ||
| 647 | - std::vector<CameraActor> mCameras; | ||
| 648 | - std::vector<std::unique_ptr<Model>> mModels; | ||
| 649 | - std::vector<TextureSet> mTextureSets; | 647 | + std::vector<Actor> mActors {}; |
| 648 | + std::vector<CameraActor> mCameras {}; | ||
| 649 | + std::vector<std::unique_ptr<Model>> mModels {}; | ||
| 650 | + std::vector<TextureSet> mTextureSets {}; | ||
| 650 | 651 | ||
| 651 | - Animation mAnimation; | ||
| 652 | - float mMockTime = 0.0f; | ||
| 653 | - float mKFactor = 0.0f; | ||
| 654 | - Property::Index mSunTimeUniformIndex; | ||
| 655 | - Property::Index mSunKFactorUniformIndex; | ||
| 656 | - PanGestureDetector mPanGestureDetector; | 652 | + Animation mAnimation {}; |
| 653 | + float mMockTime { 0.0f }; | ||
| 654 | + float mKFactor { 0.0f }; | ||
| 655 | + Property::Index mSunTimeUniformIndex {}; | ||
| 656 | + Property::Index mSunKFactorUniformIndex {}; | ||
| 657 | + PanGestureDetector mPanGestureDetector {}; | ||
| 657 | 658 | ||
| 658 | - Vector3 mCameraPos; | ||
| 659 | - Vector3 mLightDir; | ||
| 660 | - Timer mTickTimer; | 659 | + Vector3 mCameraPos { Vector3::ZERO }; |
| 660 | + Vector3 mLightDir { Vector3::ZERO }; | ||
| 661 | + Timer mTickTimer {}; | ||
| 661 | 662 | ||
| 662 | - CameraActor mCamera3D; | ||
| 663 | - CameraActor mReflectionCamera3D; | ||
| 664 | - Actor mCenterActor; | ||
| 665 | - Actor mCenterHorizActor; | 663 | + CameraActor mCamera3D {}; |
| 664 | + CameraActor mReflectionCamera3D {}; | ||
| 665 | + Actor mCenterActor {}; | ||
| 666 | + Actor mCenterHorizActor {}; | ||
| 666 | }; | 667 | }; |
| 667 | 668 | ||
| 668 | int DALI_EXPORT_API main( int argc, char **argv ) | 669 | int DALI_EXPORT_API main( int argc, char **argv ) |
packaging/com.samsung.dali-demo.spec
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | Name: com.samsung.dali-demo | 3 | Name: com.samsung.dali-demo |
| 4 | Summary: The OpenGLES Canvas Core Demo | 4 | Summary: The OpenGLES Canvas Core Demo |
| 5 | -Version: 1.9.5 | 5 | +Version: 1.9.6 |
| 6 | Release: 1 | 6 | Release: 1 |
| 7 | Group: System/Libraries | 7 | Group: System/Libraries |
| 8 | License: Apache-2.0 | 8 | License: Apache-2.0 |
shared/execute-process-android.cpp
| @@ -21,28 +21,23 @@ | @@ -21,28 +21,23 @@ | ||
| 21 | // EXTERNAL INCLUDES | 21 | // EXTERNAL INCLUDES |
| 22 | #include <sstream> | 22 | #include <sstream> |
| 23 | #include <unistd.h> | 23 | #include <unistd.h> |
| 24 | + | ||
| 24 | #include <dali/public-api/common/dali-common.h> | 25 | #include <dali/public-api/common/dali-common.h> |
| 26 | +#include <dali/integration-api/debug.h> | ||
| 27 | +#include <dali/integration-api/adaptor-framework/android/android-framework.h> | ||
| 28 | + | ||
| 29 | +#include <android_native_app_glue.h> | ||
| 30 | +#include <dali-demo-native-activity-jni.h> | ||
| 25 | 31 | ||
| 26 | void ExecuteProcess( const std::string& processName, Dali::Application& application ) | 32 | void ExecuteProcess( const std::string& processName, Dali::Application& application ) |
| 27 | { | 33 | { |
| 28 | - std::stringstream stream; | ||
| 29 | - stream << "am start -a android.intent.action.MAIN -n com.sec.dalidemo/.DaliDemoNativeActivity --user 0 --es start " << processName.c_str(); | ||
| 30 | - pid_t parentPID = getpid(); | ||
| 31 | - | ||
| 32 | - pid_t pid = fork(); | ||
| 33 | - if( pid == 0 ) | 34 | + struct android_app* nativeApp = Dali::Integration::AndroidFramework::Get().GetNativeApplication(); |
| 35 | + if (!nativeApp) | ||
| 34 | { | 36 | { |
| 35 | - do | ||
| 36 | - { | ||
| 37 | - sleep( 1 ); | ||
| 38 | - } | ||
| 39 | - while( kill( parentPID, 0 ) == 0 ); | ||
| 40 | - | ||
| 41 | - system( stream.str().c_str() ); | ||
| 42 | - exit( 0 ); | ||
| 43 | - } | ||
| 44 | - else | ||
| 45 | - { | ||
| 46 | - application.Quit(); | 37 | + DALI_LOG_ERROR("Couldn't get native app."); |
| 38 | + return; | ||
| 47 | } | 39 | } |
| 40 | + | ||
| 41 | + DaliDemoNativeActivity nativeActivity(nativeApp->activity); | ||
| 42 | + nativeActivity.LaunchExample(processName); | ||
| 48 | } | 43 | } |