From f5ba2b8a91b3af74470776fabdbd170383e91f57 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Mon, 25 Mar 2013 20:23:07 +0200 Subject: [PATCH] Update java part for Ministro 9.x Add default source and repository. Change-Id: Idfa7936e8a2879fad9944702c2aa5c6d4638185a Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/android/java/AndroidManifest.xml | 2 + src/android/java/res/values/libs.xml | 7 +- .../kde/necessitas/ministro/IMinistro.aidl | 11 +-- .../ministro/IMinistroCallback.aidl | 6 +- .../qt5/android/bindings/QtActivity.java | 69 ++++++++++++------- .../qt5/android/bindings/QtApplication.java | 2 +- src/android/java/version.xml | 2 +- 7 files changed, 63 insertions(+), 36 deletions(-) diff --git a/src/android/java/AndroidManifest.xml b/src/android/java/AndroidManifest.xml index 1161b15e8d..6a407dcb6e 100644 --- a/src/android/java/AndroidManifest.xml +++ b/src/android/java/AndroidManifest.xml @@ -6,6 +6,8 @@ + + diff --git a/src/android/java/res/values/libs.xml b/src/android/java/res/values/libs.xml index 92ce09b7c0..f47174e3d3 100644 --- a/src/android/java/res/values/libs.xml +++ b/src/android/java/res/values/libs.xml @@ -1,8 +1,11 @@ + + https://files.kde.org/necessitas/ministro/android/necessitas/qt5/latest + + default - QtCore - QtGui + Qt5Core diff --git a/src/android/java/src/org/kde/necessitas/ministro/IMinistro.aidl b/src/android/java/src/org/kde/necessitas/ministro/IMinistro.aidl index 1c33a77fdb..236a62f63e 100644 --- a/src/android/java/src/org/kde/necessitas/ministro/IMinistro.aidl +++ b/src/android/java/src/org/kde/necessitas/ministro/IMinistro.aidl @@ -1,5 +1,5 @@ /* - Copyright (c) 2012, BogDan Vatra + Copyright (c) 2011-2013, BogDan Vatra 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); } diff --git a/src/android/java/src/org/kde/necessitas/ministro/IMinistroCallback.aidl b/src/android/java/src/org/kde/necessitas/ministro/IMinistroCallback.aidl index eec270aec1..0bcb5285b8 100644 --- a/src/android/java/src/org/kde/necessitas/ministro/IMinistroCallback.aidl +++ b/src/android/java/src/org/kde/necessitas/ministro/IMinistroCallback.aidl @@ -1,5 +1,5 @@ /* - Copyright (c) 2012, BogDan Vatra + Copyright (c) 2011-2013, BogDan Vatra 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); diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java index 1e24db7bee..dfb638fbb0 100644 --- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java +++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java @@ -1,5 +1,5 @@ /* - Copyright (c) 2012, BogDan Vatra + Copyright (c) 2012-2013, BogDan Vatra 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 libraryList = new ArrayList(); 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 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 { diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtApplication.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtApplication.java index a23c3afb4d..4de1c833f5 100644 --- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtApplication.java +++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtApplication.java @@ -1,5 +1,5 @@ /* - Copyright (c) 2012, BogDan Vatra + Copyright (c) 2012-2013, BogDan Vatra Contact: http://www.qt-project.org/legal Redistribution and use in source and binary forms, with or without diff --git a/src/android/java/version.xml b/src/android/java/version.xml index 1cd8eb31fe..e709357ba6 100644 --- a/src/android/java/version.xml +++ b/src/android/java/version.xml @@ -1,4 +1,4 @@ - + AndroidManifest.xml libs.xml