Added rest of file modifications. (oops)
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.2.5" android:installLocation="auto" package="com.github.codestation.qcma" android:versionCode="1">
|
||||
<application android:label="qcma" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:icon="@drawable/icon">
|
||||
<activity android:screenOrientation="unspecified" android:label="@string/app_name" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
<meta-data android:value="qcma" android:name="android.app.lib_name"/>
|
||||
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
|
||||
<meta-data android:value="default" android:name="android.app.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"/>
|
||||
<!-- Deploy Qt libs as part of package -->
|
||||
<meta-data android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --" android:name="android.app.bundle_local_qt_libs"/>
|
||||
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
|
||||
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
|
||||
<!-- Run with local libs -->
|
||||
<meta-data android:value="-- %%USE_LOCAL_QT_LIBS%% --" android:name="android.app.use_local_qt_libs"/>
|
||||
<meta-data android:value="/data/local/tmp/qt/" android:name="android.app.libs_prefix"/>
|
||||
<meta-data android:value="-- %%INSERT_LOCAL_LIBS%% --" android:name="android.app.load_local_libs"/>
|
||||
<meta-data android:value="-- %%INSERT_LOCAL_JARS%% --" android:name="android.app.load_local_jars"/>
|
||||
<meta-data android:value="-- %%INSERT_INIT_CLASSES%% --" android:name="android.app.static_init_classes"/>
|
||||
<!-- Messages maps -->
|
||||
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
|
||||
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
|
||||
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
|
||||
<!-- Messages maps -->
|
||||
<!-- Splash screen -->
|
||||
<meta-data android:name="android.app.splash_screen" android:resource="@layout/splash"/>
|
||||
<!-- Splash screen -->
|
||||
</activity>
|
||||
</application>
|
||||
<uses-sdk android:targetSdkVersion="19" android:minSdkVersion="10"/>
|
||||
<supports-screens android:normalScreens="true" android:smallScreens="true" android:largeScreens="true" android:anyDensity="true"/>
|
||||
<!-- %%INSERT_PERMISSIONS -->
|
||||
<!-- %%INSERT_FEATURES -->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
</manifest>
|
||||
@@ -10,20 +10,14 @@ QMAKE_CXXFLAGS += $$system(pkg-config --static --cflags libvitamtp libavformat l
|
||||
LIBS += $$system(pkg-config --static --libs libvitamtp libavformat libavcodec libavutil libswscale)
|
||||
|
||||
SOURCES += \
|
||||
main_android.cpp
|
||||
main_android.cpp \
|
||||
qtandroidservice.cpp
|
||||
# headlessmanager.cpp
|
||||
|
||||
#HEADERS += \
|
||||
# headlessmanager.h
|
||||
|
||||
DISTFILES += \
|
||||
../android-src/gradle/wrapper/gradle-wrapper.jar \
|
||||
../android-src/AndroidManifest.xml \
|
||||
../android-src/gradlew.bat \
|
||||
../android-src/res/values/libs.xml \
|
||||
../android-src/build.gradle \
|
||||
../android-src/gradle/wrapper/gradle-wrapper.properties \
|
||||
../android-src/gradlew \
|
||||
android-src/gradle/wrapper/gradle-wrapper.jar \
|
||||
android-src/AndroidManifest.xml \
|
||||
android-src/gradlew.bat \
|
||||
|
||||
@@ -1 +1,194 @@
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <jni.h>
|
||||
#include <android/log.h>
|
||||
#include <android/api-level.h>
|
||||
|
||||
// Global variables
|
||||
|
||||
static jclass m_applicationClass = NULL;
|
||||
static jobject m_classLoaderObject = NULL;
|
||||
static jmethodID m_loadClassMethodID = NULL;
|
||||
static jobject m_resourcesObj;
|
||||
static jobject m_activityObject = NULL;
|
||||
|
||||
extern "C" typedef int (*Main)(int, char **); //use the standard main method to start the application
|
||||
static JavaVM *m_javaVM = NULL;
|
||||
static Main m_main = NULL;
|
||||
static void *m_mainLibraryHnd = NULL;
|
||||
|
||||
static const char m_classErrorMsg[] = "Can't find class \"%s\"";
|
||||
static const char m_methodErrorMsg[] = "Can't find method \"%s%s\"";
|
||||
|
||||
// Methods definition
|
||||
|
||||
static jboolean startQtAndroidPlugin(JNIEnv* env, jobject object /*, jobject applicationAssetManager*/)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/,
|
||||
jint /*widthPixels*/, jint /*heightPixels*/,
|
||||
jint desktopWidthPixels, jint desktopHeightPixels,
|
||||
jdouble xdpi, jdouble ydpi, jdouble scaledDensity)
|
||||
{}
|
||||
|
||||
// Methods definition
|
||||
|
||||
static void *startMainMethod(void *ar)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "Qt", "Calling main method");
|
||||
|
||||
char *argv[] = { "qcma", "--verbose", "--set-locale", "en"};
|
||||
int argc = sizeof(argv) / sizeof(char*);
|
||||
|
||||
int ret = m_main(argc, argv);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static jboolean startQtApplication(JNIEnv *env, jobject object, jstring paramsString, jstring environmentString)
|
||||
{
|
||||
// Get native
|
||||
|
||||
const char *nativeEnvironmentString = (env)->GetStringUTFChars(environmentString, NULL); // C++
|
||||
const char *nativeParamsString = (env)->GetStringUTFChars(paramsString, NULL); // C++
|
||||
|
||||
// Print info
|
||||
|
||||
__android_log_print(ANDROID_LOG_FATAL, "Qt", "Starting the Qt service");
|
||||
|
||||
char cwd[1024];
|
||||
if (getcwd(cwd, sizeof(cwd)) != NULL)
|
||||
__android_log_print(ANDROID_LOG_INFO, "Qt", "Current working dir : %s", cwd);
|
||||
|
||||
__android_log_print(ANDROID_LOG_FATAL, "Qt", "Param : %s", nativeParamsString );
|
||||
__android_log_print(ANDROID_LOG_FATAL, "Qt", "Env : %s", nativeEnvironmentString );
|
||||
|
||||
// Start
|
||||
|
||||
m_mainLibraryHnd = NULL;
|
||||
|
||||
// Obtain a handle to the main library (the library that contains the main() function).
|
||||
// This library should already be loaded, and calling dlopen() will just return a reference to it.
|
||||
__android_log_print(ANDROID_LOG_INFO, "Qt", "Trying to open %s", nativeParamsString);
|
||||
m_mainLibraryHnd = dlopen(nativeParamsString, 0);
|
||||
|
||||
if (m_mainLibraryHnd == NULL) {
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, "Qt", "No main library was specified; searching entire process (this is slow!)");
|
||||
m_main = (Main)dlsym(RTLD_DEFAULT, "main");
|
||||
}
|
||||
else {
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, "Qt", "Getting the main method from handler");
|
||||
m_main = (Main)dlsym(m_mainLibraryHnd, "main");
|
||||
}
|
||||
|
||||
|
||||
if (!m_main) {
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, "Qt", "Could not find main method");
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, "Qt", "Main method found, starting");
|
||||
}
|
||||
|
||||
|
||||
pthread_t appThread;
|
||||
return pthread_create(&appThread, NULL, startMainMethod, NULL) == 0;
|
||||
|
||||
//env->ReleaseStringUTFChars(environmentString, nativeString);
|
||||
}
|
||||
|
||||
static void quitQtAndroidPlugin(JNIEnv *env, jclass clazz)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void terminateQt(JNIEnv *env, jclass clazz)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Native methods
|
||||
|
||||
static JNINativeMethod methods[] = {
|
||||
{"startQtAndroidPlugin", "()Z", (void *)startQtAndroidPlugin},
|
||||
{"setDisplayMetrics", "(IIIIDDD)V", (void *)setDisplayMetrics},
|
||||
{"startQtApplication", "(Ljava/lang/String;Ljava/lang/String;)V", (void *)startQtApplication},
|
||||
{"quitQtAndroidPlugin", "()V", (void *)quitQtAndroidPlugin},
|
||||
{"terminateQt", "()V", (void *)terminateQt}
|
||||
};
|
||||
|
||||
|
||||
// Helpers functions
|
||||
|
||||
#define FIND_AND_CHECK_CLASS(CLASS_NAME) \
|
||||
clazz = env->FindClass(CLASS_NAME); \
|
||||
if (!clazz) { \
|
||||
__android_log_print(ANDROID_LOG_FATAL, "Qt", m_classErrorMsg, CLASS_NAME); \
|
||||
return JNI_FALSE; \
|
||||
}
|
||||
|
||||
#define GET_AND_CHECK_METHOD(VAR, CLASS, METHOD_NAME, METHOD_SIGNATURE) \
|
||||
VAR = env->GetMethodID(CLASS, METHOD_NAME, METHOD_SIGNATURE); \
|
||||
if (!VAR) { \
|
||||
__android_log_print(ANDROID_LOG_FATAL, "Qt", m_methodErrorMsg, METHOD_NAME, METHOD_SIGNATURE); \
|
||||
return JNI_FALSE; \
|
||||
}
|
||||
|
||||
#define GET_AND_CHECK_STATIC_METHOD(VAR, CLASS, METHOD_NAME, METHOD_SIGNATURE) \
|
||||
VAR = env->GetStaticMethodID(CLASS, METHOD_NAME, METHOD_SIGNATURE); \
|
||||
if (!VAR) { \
|
||||
__android_log_print(ANDROID_LOG_FATAL, "Qt", m_methodErrorMsg, METHOD_NAME, METHOD_SIGNATURE); \
|
||||
return JNI_FALSE; \
|
||||
}
|
||||
|
||||
#define GET_AND_CHECK_FIELD(VAR, CLASS, FIELD_NAME, FIELD_SIGNATURE) \
|
||||
VAR = env->GetFieldID(CLASS, FIELD_NAME, FIELD_SIGNATURE); \
|
||||
if (!VAR) { \
|
||||
__android_log_print(ANDROID_LOG_FATAL, "Qt", m_methodErrorMsg, FIELD_NAME, FIELD_SIGNATURE); \
|
||||
return JNI_FALSE; \
|
||||
}
|
||||
|
||||
#define GET_AND_CHECK_STATIC_FIELD(VAR, CLASS, FIELD_NAME, FIELD_SIGNATURE) \
|
||||
VAR = env->GetStaticFieldID(CLASS, FIELD_NAME, FIELD_SIGNATURE); \
|
||||
if (!VAR) { \
|
||||
__android_log_print(ANDROID_LOG_FATAL, "Qt", m_methodErrorMsg, FIELD_NAME, FIELD_SIGNATURE); \
|
||||
return JNI_FALSE; \
|
||||
}
|
||||
|
||||
// On load
|
||||
|
||||
jint JNICALL JNI_OnLoad(JavaVM *vm, void *ld)
|
||||
{
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, "Qt", "Qt Android service wrapper start");
|
||||
|
||||
JNIEnv* env;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
|
||||
__android_log_print(ANDROID_LOG_FATAL, "Qt", "Can't get env in wrapper start"); \
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_javaVM = vm;
|
||||
|
||||
jclass clazz;
|
||||
FIND_AND_CHECK_CLASS("org/qtproject/qt5/android/QtNative");
|
||||
m_applicationClass = static_cast<jclass>(env->NewGlobalRef(clazz));
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, "Qt", "Registering native classes for service wrapper");
|
||||
|
||||
if (env->RegisterNatives(m_applicationClass, methods, sizeof(methods) / sizeof(methods[0])) < 0) {
|
||||
__android_log_print(ANDROID_LOG_FATAL,"Qt", "RegisterNatives failed for service wrapper");
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
return JNI_VERSION_1_4;
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 555 B |
Binary file not shown.
|
Before Width: | Height: | Size: 755 B |
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,34 +0,0 @@
|
||||
package com.github.codestation.qcma;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.widget.Toast;
|
||||
import android.app.AlertDialog;
|
||||
|
||||
public class QcmaNotification extends org.qtproject.qt5.android.bindings.QtActivity
|
||||
{
|
||||
private static QcmaNotification m_instance;
|
||||
|
||||
public QcmaNotification()
|
||||
{
|
||||
m_instance = this;
|
||||
}
|
||||
|
||||
public static void showToast(String message)
|
||||
{
|
||||
Context context = m_instance.getApplicationContext();
|
||||
Toast toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
|
||||
public static void showDialog(String message)
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(m_instance);
|
||||
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
}
|
||||
});
|
||||
builder.setMessage(message).setTitle("QCMA message");
|
||||
AlertDialog dialog = builder.create();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user