From 2b0ac6a9bd7ea4e69fb28a7fde7df2410c6ef6e0 Mon Sep 17 00:00:00 2001 From: Cristian Luis Duarte Date: Thu, 7 Jun 2018 18:22:58 -0300 Subject: [PATCH 1/2] Android - Make sure we call Interface enterBackground when opening the app --- .../hifiinterface/InterfaceActivity.java | 14 +++++++++++++- interface/src/Application.cpp | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java b/android/app/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java index 28acc77609..20c216d5a9 100644 --- a/android/app/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java +++ b/android/app/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java @@ -56,6 +56,8 @@ public class InterfaceActivity extends QtActivity { private AssetManager assetManager; private static boolean inVrMode; + + private boolean nativeEnterBackgroundCallEnqueued = false; // private GvrApi gvrApi; // Opaque native pointer to the Application C++ object. // This object is owned by the InterfaceActivity instance and passed to the native methods. @@ -121,13 +123,19 @@ public class InterfaceActivity extends QtActivity { @Override protected void onPause() { super.onPause(); - nativeEnterBackground(); + if (super.isLoading) { + nativeEnterBackgroundCallEnqueued = true; + } else { + Log.d("[ENTERBACKGROUND]","onPause calling nativeEnterBackground"); + nativeEnterBackground(); + } //gvrApi.pauseTracking(); } @Override protected void onStart() { super.onStart(); + nativeEnterBackgroundCallEnqueued = false; setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } @@ -256,6 +264,10 @@ public class InterfaceActivity extends QtActivity { public void onAppLoadedComplete() { super.isLoading = false; + if (nativeEnterBackgroundCallEnqueued) { + Log.d("[ENTERBACKGROUND]","onAppLoadedComplete calling nativeEnterBackground"); + nativeEnterBackground(); + } } public void performHapticFeedback(int duration) { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index cbe713127d..6111406291 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -8248,10 +8248,12 @@ void Application::saveNextPhysicsStats(QString filename) { #if defined(Q_OS_ANDROID) void Application::enterBackground() { + qDebug() << "[ENTERBACKGROUND] Application::enterBackground()"; QMetaObject::invokeMethod(DependencyManager::get().data(), "stop", Qt::BlockingQueuedConnection); if (getActiveDisplayPlugin()->isActive()) { getActiveDisplayPlugin()->deactivate(); + qDebug() << "[ENTERBACKGROUND] Application::enterBackground() getActiveDisplayPlugin()->deactivated"; } } From 26a9364efd283ff3778c40f3bb62ec1b2f93aebb Mon Sep 17 00:00:00 2001 From: Cristian Luis Duarte Date: Fri, 8 Jun 2018 20:59:38 -0300 Subject: [PATCH 2/2] Android - Clean up enterBackground logs --- .../java/io/highfidelity/hifiinterface/InterfaceActivity.java | 2 -- interface/src/Application.cpp | 2 -- 2 files changed, 4 deletions(-) diff --git a/android/app/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java b/android/app/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java index 20c216d5a9..84fd2678d8 100644 --- a/android/app/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java +++ b/android/app/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java @@ -126,7 +126,6 @@ public class InterfaceActivity extends QtActivity { if (super.isLoading) { nativeEnterBackgroundCallEnqueued = true; } else { - Log.d("[ENTERBACKGROUND]","onPause calling nativeEnterBackground"); nativeEnterBackground(); } //gvrApi.pauseTracking(); @@ -265,7 +264,6 @@ public class InterfaceActivity extends QtActivity { public void onAppLoadedComplete() { super.isLoading = false; if (nativeEnterBackgroundCallEnqueued) { - Log.d("[ENTERBACKGROUND]","onAppLoadedComplete calling nativeEnterBackground"); nativeEnterBackground(); } } diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6111406291..cbe713127d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -8248,12 +8248,10 @@ void Application::saveNextPhysicsStats(QString filename) { #if defined(Q_OS_ANDROID) void Application::enterBackground() { - qDebug() << "[ENTERBACKGROUND] Application::enterBackground()"; QMetaObject::invokeMethod(DependencyManager::get().data(), "stop", Qt::BlockingQueuedConnection); if (getActiveDisplayPlugin()->isActive()) { getActiveDisplayPlugin()->deactivate(); - qDebug() << "[ENTERBACKGROUND] Application::enterBackground() getActiveDisplayPlugin()->deactivated"; } }