diff options
author | BogDan Vatra <bogdan@kdab.com> | 2016-11-08 17:12:05 +0200 |
---|---|---|
committer | BogDan Vatra <bogdan@kdab.com> | 2017-07-04 18:38:19 +0000 |
commit | 4f7507c52390cd19d76e0f36744f21fbc3e14674 (patch) | |
tree | c5ee6bf83ea7c0a58d75101ddc03db105d32c2a9 /src/plugins/platforms/android/androidjnimain.cpp | |
parent | cfbe03a6e035ab3cce5f04962cddd06bd414dcea (diff) |
Forward Service.onBind notification to Qt
It is needed to implement Android Binder in Qt.
Change-Id: I8f6f8ef778f97a444a1b16d6f62e211e188b65cc
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/plugins/platforms/android/androidjnimain.cpp')
-rw-r--r-- | src/plugins/platforms/android/androidjnimain.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 06bca0354d..4a24f3fb47 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -542,7 +542,14 @@ static jboolean startQtApplication(JNIEnv *env, jobject /*object*/, jstring para if (sem_init(&m_terminateSemaphore, 0, 0) == -1) return false; - return pthread_create(&m_qtAppThread, nullptr, startMainMethod, nullptr) == 0; + jboolean res = pthread_create(&m_qtAppThread, nullptr, startMainMethod, nullptr) == 0; + + // The service must wait until the QCoreApplication starts otherwise onBind will be + // called too early + if (m_serviceObject) + QtAndroidPrivate::waitForServiceSetup(); + + return res; } static void quitQtCoreApplication(JNIEnv *env, jclass /*clazz*/) @@ -742,6 +749,11 @@ static void onNewIntent(JNIEnv *env, jclass /*cls*/, jobject data) QtAndroidPrivate::handleNewIntent(env, data); } +static jobject onBind(JNIEnv */*env*/, jclass /*cls*/, jobject intent) +{ + return QtAndroidPrivate::callOnBindListener(intent); +} + static JNINativeMethod methods[] = { {"startQtAndroidPlugin", "()Z", (void *)startQtAndroidPlugin}, {"startQtApplication", "(Ljava/lang/String;Ljava/lang/String;)V", (void *)startQtApplication}, @@ -754,7 +766,8 @@ static JNINativeMethod methods[] = { {"updateApplicationState", "(I)V", (void *)updateApplicationState}, {"handleOrientationChanged", "(II)V", (void *)handleOrientationChanged}, {"onActivityResult", "(IILandroid/content/Intent;)V", (void *)onActivityResult}, - {"onNewIntent", "(Landroid/content/Intent;)V", (void *)onNewIntent} + {"onNewIntent", "(Landroid/content/Intent;)V", (void *)onNewIntent}, + {"onBind", "(Landroid/content/Intent;)Landroid/os/IBinder;", (void *)onBind} }; #define FIND_AND_CHECK_CLASS(CLASS_NAME) \ |