Deactivates display plugin when qt app goes to background

This commit is contained in:
Gabriel Calero 2018-05-08 16:55:04 -03:00
parent da69c9d077
commit 5e337e90a3
4 changed files with 8 additions and 29 deletions

View file

@ -27,10 +27,7 @@ public class SplashActivity extends Activity {
}
public void onAppLoadedComplete() {
// Give interface more time so textures don't fail(got deleted) on Adreno (joystick)
new Handler(getMainLooper()).postDelayed(() -> {
startActivity(new Intent(this, HomeActivity.class));
new Handler(getMainLooper()).postDelayed(() -> SplashActivity.this.finish(), 1000);
}, 500);
startActivity(new Intent(this, HomeActivity.class));
finish();
}
}

View file

@ -11,9 +11,7 @@
#include "AndroidHelper.h"
#include <QDebug>
AndroidHelper::AndroidHelper() :
_accountManager ()
{
AndroidHelper::AndroidHelper() {
}
AndroidHelper::~AndroidHelper() {
@ -38,11 +36,3 @@ void AndroidHelper::goBackFromAndroidActivity() {
void AndroidHelper::notifyLoginComplete(bool success) {
emit loginComplete(success);
}
void AndroidHelper::setInBackground(bool background) {
inBackground = background;
}
bool AndroidHelper::isInBackground() {
return inBackground;
}

View file

@ -26,8 +26,6 @@ public:
void requestActivity(const QString &activityName);
void notifyLoadComplete();
void goBackFromAndroidActivity();
void setInBackground(bool background);
bool isInBackground();
void notifyLoginComplete(bool success);
@ -45,8 +43,6 @@ signals:
private:
AndroidHelper();
~AndroidHelper();
QSharedPointer<AccountManager> _accountManager;
bool inBackground;
};
#endif

View file

@ -4330,13 +4330,7 @@ void setupCpuMonitorThread() {
void Application::idle() {
PerformanceTimer perfTimer("idle");
#if defined(Q_OS_ANDROID)
if (AndroidHelper::instance().isInBackground()) {
return;
}
#endif
// Update the deadlock watchdog
updateHeartbeat();
@ -8183,13 +8177,15 @@ void Application::openAndroidActivity(const QString& activityName) {
void Application::enterBackground() {
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
"stop", Qt::BlockingQueuedConnection);
AndroidHelper::instance().setInBackground(true);
getActiveDisplayPlugin()->deactivate();
}
void Application::enterForeground() {
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
"start", Qt::BlockingQueuedConnection);
AndroidHelper::instance().setInBackground(false);
if (!getActiveDisplayPlugin() || !getActiveDisplayPlugin()->activate()) {
qWarning() << "Could not re-activate display plugin";
}
}
#endif