Make qt application not stop in background and remove separete thread

This commit is contained in:
Gabriel Calero 2018-05-08 15:45:33 -03:00
parent 03ca427234
commit da69c9d077
5 changed files with 26 additions and 25 deletions

View file

@ -130,15 +130,13 @@ public class InterfaceActivity extends QtActivity {
if (!isLoading) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
// TODO Fix displayPlugin deactivate so it doesn't leave us with a black screen Interface
//nativeEnterForeground();
nativeEnterForeground();
}
@Override
protected void onStop() {
super.onStop();
// TODO Fix displayPlugin deactivate so it doesn't leave us with a black screen Interface
//nativeEnterBackground();
nativeEnterBackground();
}
@Override

View file

@ -504,7 +504,7 @@ public class QtActivity extends Activity {
// GC: this trick allow us to show a splash activity until Qt app finishes
// loading
if (!isLoading) {
QtApplication.invokeDelegate();
//QtApplication.invokeDelegate();
}
}
//---------------------------------------------------------------------------
@ -644,7 +644,7 @@ public class QtActivity extends Activity {
@Override
protected void onStop() {
super.onStop();
QtApplication.invokeDelegate();
//QtApplication.invokeDelegate();
}
//---------------------------------------------------------------------------

View file

@ -14,22 +14,13 @@
AndroidHelper::AndroidHelper() :
_accountManager ()
{
workerThread.start();
}
AndroidHelper::~AndroidHelper() {
workerThread.quit();
workerThread.wait();
}
QSharedPointer<AccountManager> AndroidHelper::getAccountManager() {
_accountManager = QSharedPointer<AccountManager>(new AccountManager, &QObject::deleteLater);
_accountManager->setIsAgent(true);
_accountManager->setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL());
_accountManager->moveToThread(&workerThread);
return _accountManager;
return DependencyManager::get<AccountManager>();
}
void AndroidHelper::requestActivity(const QString &activityName) {
@ -46,4 +37,12 @@ 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,6 +26,8 @@ public:
void requestActivity(const QString &activityName);
void notifyLoadComplete();
void goBackFromAndroidActivity();
void setInBackground(bool background);
bool isInBackground();
void notifyLoginComplete(bool success);
@ -44,7 +46,7 @@ private:
AndroidHelper();
~AndroidHelper();
QSharedPointer<AccountManager> _accountManager;
QThread workerThread;
bool inBackground;
};
#endif

View file

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