Load libraries directly from apk instead of file path 56/245656/4
authorCheng-Shiun Tsai <cheng.tsai@samsung.com>
Tue, 13 Oct 2020 13:00:35 +0000 (14:00 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 14 Oct 2020 15:17:29 +0000 (15:17 +0000)
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

index 6ae80c1..d02bb12 100644 (file)
@@ -187,7 +187,13 @@ void android_main(struct android_app* state)
   DaliDemoNativeActivity nativeActivity(state->activity);
 
   int         status    = 0;
-  std::string libpath   = "/data/data/com.sec.dalidemo/lib/libdali-demo.so";
+
+  //dali requires Android 8 or higher
+  //Android 6+ support loading library directly from apk,
+  //therefore no need to extract to filesystem first then open by specifying full path
+  //unless there is need to do profiling, or export libraries so that other packages can use
+  std::string libpath   = "libdali-demo.so";
+
   std::string callParam = nativeActivity.GetIntentStringExtra("start");
   if(callParam.empty())
   {
@@ -196,7 +202,7 @@ void android_main(struct android_app* state)
 
   if(!callParam.empty())
   {
-    libpath = "/data/data/com.sec.dalidemo/lib/lib" + callParam + ".so";
+    libpath = "lib" + callParam + ".so";
   }
 
   void* handle = dlopen(libpath.c_str(), RTLD_LAZY);