Update java part for Ministro 9.x

Add default source and repository.

Change-Id: Idfa7936e8a2879fad9944702c2aa5c6d4638185a
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
This commit is contained in:
BogDan Vatra 2013-03-25 20:23:07 +02:00 committed by The Qt Project
parent 12f7596cf6
commit f5ba2b8a91
7 changed files with 63 additions and 36 deletions

View File

@ -6,6 +6,8 @@
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="@string/repository"/>
<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=""/>

View File

@ -1,8 +1,11 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<array name="qt_sources">
<item>https://files.kde.org/necessitas/ministro/android/necessitas/qt5/latest</item>
</array>
<string name="repository">default</string>
<array name="qt_libs">
<item>QtCore</item>
<item>QtGui</item>
<item>Qt5Core</item>
</array>
<array name="bundled_libs"/>
</resources>

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2012, BogDan Vatra <bogdan@kde.org>
Copyright (c) 2011-2013, BogDan Vatra <bogdan@kde.org>
Contact: http://www.qt-project.org/legal
Redistribution and use in source and binary forms, with or without
@ -24,6 +24,7 @@
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.kde.necessitas.ministro;
import org.kde.necessitas.ministro.IMinistroCallback;
@ -37,13 +38,13 @@ interface IMinistro
* param parameters
* parameters fields:
* * Key Name Key type Explanations
* "sources" StringArray Sources list from where Ministro will download the libs. Make sure you are using ONLY secure locations.
* "repository" String Overwrites the default Ministro repository. Possible values: default, stable, testing and unstable
* "required.modules" StringArray Required modules by your application
* "application.title" String Application name, used to show more informations to user
* "qt.provider" String Qt libs provider, currently only "necessitas" is supported.
* "minimum.ministro.api" Integer Minimum Ministro API level, used to check if Ministro service compatible with your application. Current API Level is 1 !
* "minimum.qt.version" Integer Minimim Qt version (e.g. 0x040800, which means Qt 4.8.0, check http://doc.trolltech.com/4.8/qtglobal.html#QT_VERSION)!
* "3rd.party.repositories" StringArray 3rd party repositories, which should be downloaded by ministro, needs minimum.ministro.api >= 2
* Check http://community.kde.org/Necessitas/Ministro for more details.
* "minimum.ministro.api" Integer Minimum Ministro API level, used to check if Ministro service compatible with your application. Current API Level is 3 !
* "minimum.qt.version" Integer Minimim Qt version (e.g. 0x040800, which means Qt 4.8.0, check http://qt-project.org/doc/qt-4.8/qtglobal.html#QT_VERSION)!
*/
void requestLoader(in IMinistroCallback callback, in Bundle parameters);
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2012, BogDan Vatra <bogdan@kde.org>
Copyright (c) 2011-2013, BogDan Vatra <bogdan@kde.org>
Contact: http://www.qt-project.org/legal
Redistribution and use in source and binary forms, with or without
@ -45,8 +45,10 @@ oneway interface IMinistroCallback {
* - 1 incompatible Ministro version. Ministro needs to be upgraded.
* - 2 not all modules could be satisfy.
* - 3 invalid parameters
* - 4 invalid qt version
* - 5 download canceled
*
* This parameter will contain additional fields which are used by the loader to start your application, so it must be passed to loader.
* The parameter contains additional fields which are used by the loader to start your application, so it must be passed to the loader.
*/
void loaderReady(in Bundle loaderParams);

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2012, BogDan Vatra <bogdan@kde.org>
Copyright (c) 2012-2013, BogDan Vatra <bogdan@kde.org>
Contact: http://www.qt-project.org/legal
Redistribution and use in source and binary forms, with or without
@ -76,9 +76,8 @@ import android.view.ActionMode.Callback;
public class QtActivity extends Activity
{
private final static int MINISTRO_INSTALL_REQUEST_CODE = 0xf3ee; // request code used to know when Ministro instalation is finished
private static final int MINISTRO_API_LEVEL = 2; // Ministro api level (check IMinistro.aidl file)
private static final int MINISTRO_API_LEVEL = 3; // Ministro api level (check IMinistro.aidl file)
private static final int NECESSITAS_API_LEVEL = 2; // Necessitas api level used by platform plugin
private static final String QT_PROVIDER = "necessitas";
private static final int QT_VERSION = 0x050100; // This app requires at least Qt version 5.1.0
private static final String ERROR_CODE_KEY = "error.code";
@ -97,15 +96,16 @@ public class QtActivity extends Activity
/// Ministro server parameter keys
private static final String REQUIRED_MODULES_KEY = "required.modules";
private static final String APPLICATION_TITLE_KEY = "application.title";
private static final String QT_PROVIDER_KEY = "qt.provider";
private static final String MINIMUM_MINISTRO_API_KEY = "minimum.ministro.api";
private static final String MINIMUM_QT_VERSION_KEY = "minimum.qt.version";
// private static final String REPOSITORIES="3rd.party.repositories"; // needs MINISTRO_API_LEVEL >=2 !!!
// Use this key to specify any 3rd party repositories urls
// Ministro will download these repositories into thier
private static final String SOURCES_KEY = "sources"; // needs MINISTRO_API_LEVEL >=3 !!!
// Use this key to specify any 3rd party sources urls
// Ministro will download these repositories into their
// own folders, check http://community.kde.org/Necessitas/Ministro
// for more details.
private static final String REPOSITORY_KEY = "repository"; // use this key to overwrite the default ministro repsitory
private static final String APPLICATION_PARAMETERS = null; // use this variable to pass any parameters to your application,
// the parameters must not contain any white spaces
// and must be separated with "\t"
@ -122,6 +122,18 @@ public class QtActivity extends Activity
private static final int INCOMPATIBLE_MINISTRO_VERSION = 1; // Incompatible Ministro version. Ministro needs to be upgraded.
private ActivityInfo m_activityInfo = null; // activity info object, used to access the libs and the strings
private DexClassLoader m_classLoader = null; // loader object
private String[] m_sources = {"https://files.kde.org/necessitas/ministro/android/necessitas/qt5/latest"}; // Make sure you are using ONLY secure locations
private String m_repository = "default"; // Overwrites the default Ministro repository
// Possible values:
// * default - Ministro default repository set with "Ministro configuration tool".
// By default the stable version is used. Only this or stable repositories should
// be used in production.
// * stable - stable repository, only this and default repositories should be used
// in production.
// * testing - testing repository, DO NOT use this repository in production,
// this repository is used to push a new release, and should be used to test your application.
// * unstable - unstable repository, DO NOT use this repository in production,
// this repository is used to push Qt snapshots.
private String[] m_qtLibs = null; // required qt libs
// this function is used to load and start the loader
@ -191,7 +203,7 @@ public class QtActivity extends Activity
} catch (Exception e) {
e.printStackTrace();
AlertDialog errorDialog = new AlertDialog.Builder(QtActivity.this).create();
if (m_activityInfo != null && m_activityInfo.metaData.containsKey("android.app.fatal_error_msg"))
if (m_activityInfo.metaData.containsKey("android.app.fatal_error_msg"))
errorDialog.setMessage(m_activityInfo.metaData.getString("android.app.fatal_error_msg"));
else
errorDialog.setMessage("Fatal error, your application can't be started.");
@ -218,12 +230,12 @@ public class QtActivity extends Activity
parameters.putStringArray(REQUIRED_MODULES_KEY, m_qtLibs);
parameters.putString(APPLICATION_TITLE_KEY, (String)QtActivity.this.getTitle());
parameters.putInt(MINIMUM_MINISTRO_API_KEY, MINISTRO_API_LEVEL);
parameters.putString(QT_PROVIDER_KEY, QT_PROVIDER);
parameters.putInt(MINIMUM_QT_VERSION_KEY, QT_VERSION);
parameters.putString(ENVIRONMENT_VARIABLES_KEY, ENVIRONMENT_VARIABLES);
if (null!=APPLICATION_PARAMETERS)
parameters.putString(APPLICATION_PARAMETERS_KEY, APPLICATION_PARAMETERS);
// parameters.putStringArray(REPOSITORIES, null);
parameters.putStringArray(SOURCES_KEY, m_sources);
parameters.putString(REPOSITORY_KEY, m_repository);
m_service.requestLoader(m_ministroCallback, parameters);
}
} catch (RemoteException e) {
@ -282,7 +294,7 @@ public class QtActivity extends Activity
{
AlertDialog errorDialog = new AlertDialog.Builder(QtActivity.this).create();
if (m_activityInfo != null && m_activityInfo.metaData.containsKey("android.app.ministro_not_found_msg"))
if (m_activityInfo.metaData.containsKey("android.app.ministro_not_found_msg"))
errorDialog.setMessage(m_activityInfo.metaData.getString("android.app.ministro_not_found_msg"));
else
errorDialog.setMessage("Can't find Ministro service.\nThe application can't start.");
@ -299,27 +311,34 @@ public class QtActivity extends Activity
private void startApp(final boolean firstStart)
{
try {
ActivityInfo ai=getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA);
if (ai.metaData.containsKey("android.app.qt_libs_resource_id")) {
int resourceId = ai.metaData.getInt("android.app.qt_libs_resource_id");
if (m_activityInfo.metaData.containsKey("android.app.qt_sources_resource_id")) {
int resourceId = m_activityInfo.metaData.getInt("android.app.qt_sources_resource_id");
m_sources = getResources().getStringArray(resourceId);
}
if (m_activityInfo.metaData.containsKey("android.app.repository"))
m_repository = m_activityInfo.metaData.getString("android.app.repository");
if (m_activityInfo.metaData.containsKey("android.app.qt_libs_resource_id")) {
int resourceId = m_activityInfo.metaData.getInt("android.app.qt_libs_resource_id");
m_qtLibs = getResources().getStringArray(resourceId);
}
if (ai.metaData.containsKey("android.app.use_local_qt_libs")
&& ai.metaData.getInt("android.app.use_local_qt_libs") == 1) {
if (m_activityInfo.metaData.containsKey("android.app.use_local_qt_libs")
&& m_activityInfo.metaData.getInt("android.app.use_local_qt_libs") == 1) {
ArrayList<String> libraryList = new ArrayList<String>();
String localPrefix = "/data/local/tmp/qt/";
if (ai.metaData.containsKey("android.app.libs_prefix"))
localPrefix = ai.metaData.getString("android.app.libs_prefix");
if (m_activityInfo.metaData.containsKey("android.app.libs_prefix"))
localPrefix = m_activityInfo.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 (ai.metaData.containsKey("android.app.load_local_libs")) {
String[] extraLibs = ai.metaData.getString("android.app.load_local_libs").split(":");
if (m_activityInfo.metaData.containsKey("android.app.load_local_libs")) {
String[] extraLibs = m_activityInfo.metaData.getString("android.app.load_local_libs").split(":");
for (String lib : extraLibs) {
if (lib.length() > 0)
libraryList.add(localPrefix + lib);
@ -328,8 +347,8 @@ public class QtActivity extends Activity
String dexPaths = new String();
String pathSeparator = System.getProperty("path.separator", ":");
if (ai.metaData.containsKey("android.app.load_local_jars")) {
String[] jarFiles = ai.metaData.getString("android.app.load_local_jars").split(":");
if (m_activityInfo.metaData.containsKey("android.app.load_local_jars")) {
String[] jarFiles = m_activityInfo.metaData.getString("android.app.load_local_jars").split(":");
for (String jar:jarFiles) {
if (jar.length() > 0) {
if (dexPaths.length() > 0)
@ -343,9 +362,9 @@ public class QtActivity extends Activity
loaderParams.putInt(ERROR_CODE_KEY, 0);
loaderParams.putString(DEX_PATH_KEY, dexPaths);
loaderParams.putString(LOADER_CLASS_NAME_KEY, "org.qtproject.qt5.android.QtActivityDelegate");
if (ai.metaData.containsKey("android.app.static_init_classes")) {
if (m_activityInfo.metaData.containsKey("android.app.static_init_classes")) {
loaderParams.putStringArray(STATIC_INIT_CLASSES_KEY,
ai.metaData.getString("android.app.static_init_classes").split(":"));
m_activityInfo.metaData.getString("android.app.static_init_classes").split(":"));
}
loaderParams.putStringArrayList(NATIVE_LIBRARIES_KEY, libraryList);
loaderParams.putString(ENVIRONMENT_VARIABLES_KEY, ENVIRONMENT_VARIABLES
@ -366,7 +385,7 @@ public class QtActivity extends Activity
} catch (Exception e) {
if (firstStart) {
String msg = "This application requires Ministro service. Would you like to install it?";
if (m_activityInfo != null && m_activityInfo.metaData.containsKey("android.app.ministro_needed_msg"))
if (m_activityInfo.metaData.containsKey("android.app.ministro_needed_msg"))
msg = m_activityInfo.metaData.getString("android.app.ministro_needed_msg");
downloadUpgradeMinistro(msg);
} else {

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2012, BogDan Vatra <bogdan@kde.org>
Copyright (c) 2012-2013, BogDan Vatra <bogdan@kde.org>
Contact: http://www.qt-project.org/legal
Redistribution and use in source and binary forms, with or without

View File

@ -1,4 +1,4 @@
<version value="3">
<version value="5">
<ignore>
<file>AndroidManifest.xml</file>
<file>libs.xml</file>