Android: Fix use_local_libs when running from launcher

Use persistent data to specify the alternative location
of Qt libraries instead of command line arguments, so that the
application can be run from the launcher and not just from
Qt Creator.

Task-number: QTCREATORBUG-8643
Change-Id: I72df2905f3f35a3b924edd47d3a5387e674c97ac
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2013-03-07 13:30:21 +01:00 committed by The Qt Project
parent b5a388192c
commit 53b32a0b3f
2 changed files with 20 additions and 17 deletions

View File

@ -9,6 +9,12 @@
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<meta-data android:name="android.app.lib_name" android:value=""/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="0"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value=""/>
<meta-data android:name="android.app.load_local_jars" android:value=""/>
<meta-data android:name="android.app.static_init_classes" android:value=""/>
<!-- Messages maps -->
<meta-data android:name="android.app.ministro_not_found_msg" android:value="@string/ministro_not_found_msg"/>
<meta-data android:name="android.app.ministro_needed_msg" android:value="@string/ministro_needed_msg"/>

View File

@ -304,23 +304,22 @@ public class QtActivity extends Activity
m_qtLibs = getResources().getStringArray(resourceId);
}
if (getIntent().getExtras()!= null
&& getIntent().getExtras().containsKey("use_local_qt_libs")
&& getIntent().getExtras().getString("use_local_qt_libs").equals("true")) {
ArrayList<String> libraryList= new ArrayList<String>();
if (ai.metaData.containsKey("android.app.use_local_qt_libs")
&& ai.metaData.getInt("android.app.use_local_qt_libs") == 1) {
ArrayList<String> libraryList = new ArrayList<String>();
String localPrefix="/data/local/tmp/qt/";
if (getIntent().getExtras().containsKey("libs_prefix"))
localPrefix=getIntent().getExtras().getString("libs_prefix");
String localPrefix = "/data/local/tmp/qt/";
if (ai.metaData.containsKey("android.app.libs_prefix"))
localPrefix = ai.metaData.getString("android.app.libs_prefix");
if (m_qtLibs != null) {
for (int i=0;i<m_qtLibs.length;i++)
libraryList.add(localPrefix+"lib/lib"+m_qtLibs[i]+".so");
}
if (getIntent().getExtras().containsKey("load_local_libs")) {
String[] extraLibs=getIntent().getExtras().getString("load_local_libs").split(":");
for (String lib:extraLibs) {
if (ai.metaData.containsKey("android.app.load_local_libs")) {
String[] extraLibs = ai.metaData.getString("android.app.load_local_libs").split(":");
for (String lib : extraLibs) {
if (lib.length() > 0)
libraryList.add(localPrefix + lib);
}
@ -328,8 +327,8 @@ public class QtActivity extends Activity
String dexPaths = new String();
String pathSeparator = System.getProperty("path.separator", ":");
if (getIntent().getExtras().containsKey("load_local_jars")) {
String[] jarFiles = getIntent().getExtras().getString("load_local_jars").split(":");
if (ai.metaData.containsKey("android.app.load_local_jars")) {
String[] jarFiles = ai.metaData.getString("android.app.load_local_jars").split(":");
for (String jar:jarFiles) {
if (jar.length() > 0) {
if (dexPaths.length() > 0)
@ -342,12 +341,10 @@ public class QtActivity extends Activity
Bundle loaderParams = new Bundle();
loaderParams.putInt(ERROR_CODE_KEY, 0);
loaderParams.putString(DEX_PATH_KEY, dexPaths);
loaderParams.putString(LOADER_CLASS_NAME_KEY, getIntent().getExtras().containsKey("loader_class_name")
? getIntent().getExtras().getString("loader_class_name")
: "org.qtproject.qt5.android.QtActivityDelegate");
if (getIntent().getExtras().containsKey("static_init_classes")) {
loaderParams.putString(LOADER_CLASS_NAME_KEY, "org.qtproject.qt5.android.QtActivityDelegate");
if (ai.metaData.containsKey("android.app.static_init_classes")) {
loaderParams.putStringArray(STATIC_INIT_CLASSES_KEY,
getIntent().getExtras().getString("static_init_classes").split(":"));
ai.metaData.getString("android.app.static_init_classes").split(":"));
}
loaderParams.putStringArrayList(NATIVE_LIBRARIES_KEY, libraryList);
loaderParams.putString(ENVIRONMENT_VARIABLES_KEY, ENVIRONMENT_VARIABLES