Commit 0210db302a8f69aa215b2a3015b7b7c4690a2e72

Authored by Cheng-Shiun Tsai
Committed by Adeel Kazmi
1 parent 8fa6f63e

Load libraries directly from apk instead of file path

Android 6 or higher support loading libraies directly from apk
64bit dali demo fail to run due to specifying wrong path
By not specifying path, we can directly dlopen from apk
One less place to have bug

Change-Id: I53619979798ab2d4fbccf25a152d92e52e467d0b
build/android/app/src/main/cpp/main.cpp
... ... @@ -187,7 +187,13 @@ void android_main(struct android_app* state)
187 187 DaliDemoNativeActivity nativeActivity(state->activity);
188 188  
189 189 int status = 0;
190   - std::string libpath = "/data/data/com.sec.dalidemo/lib/libdali-demo.so";
  190 +
  191 + //dali requires Android 8 or higher
  192 + //Android 6+ support loading library directly from apk,
  193 + //therefore no need to extract to filesystem first then open by specifying full path
  194 + //unless there is need to do profiling, or export libraries so that other packages can use
  195 + std::string libpath = "libdali-demo.so";
  196 +
191 197 std::string callParam = nativeActivity.GetIntentStringExtra("start");
192 198 if(callParam.empty())
193 199 {
... ... @@ -196,7 +202,7 @@ void android_main(struct android_app* state)
196 202  
197 203 if(!callParam.empty())
198 204 {
199   - libpath = "/data/data/com.sec.dalidemo/lib/lib" + callParam + ".so";
  205 + libpath = "lib" + callParam + ".so";
200 206 }
201 207  
202 208 void* handle = dlopen(libpath.c_str(), RTLD_LAZY);
... ...