Skip to content

Commit

Permalink
Workaround for AGDK issue 398193010
Browse files Browse the repository at this point in the history
  • Loading branch information
znakeeye committed Feb 21, 2025
1 parent f949482 commit 632194f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.orx.lib;

import androidx.core.view.ViewCompat;
import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;
Expand All @@ -12,6 +13,16 @@ protected void onResume() {
hideSystemBars();
}

@Override
protected void onDestroy() {
// See https://issuetracker.google.com/issues/398193010
if (mSurfaceView != null) {
ViewCompat.setOnApplyWindowInsetsListener(mSurfaceView, null);
}

super.onDestroy();
}

protected void hideSystemBars() {
WindowInsetsControllerCompat windowInsetsController = WindowCompat.getInsetsController(getWindow(), getWindow().getDecorView());
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars());
Expand Down
37 changes: 21 additions & 16 deletions code/src/main/android/orxAndroidSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,20 +746,19 @@ void android_main(android_app *_pstState)
{
char *argv[orxANDROID_KU32_MAX_ARGUMENT_COUNT];

_pstState->onAppCmd = orxAndroid_handleCmd;
/* Inits Java VM */
jVM = _pstState->activity->vm;

android_app_set_motion_event_filter(_pstState, NULL);
JNIEnv *pstEnv = orxAndroid_JNI_GetEnv();
if (pstEnv == NULL)
{
/* Exits gracefully */
return;
}

/* Cleans static controller */
orxMemory_Zero(&sstAndroid, sizeof(orxANDROID_STATIC));

sstAndroid.app = _pstState;
sstAndroid.bPaused = orxTRUE;
sstAndroid.bHasFocus = orxFALSE;
sstAndroid.fSurfaceScale = orxFLOAT_0;

jVM = _pstState->activity->vm;

/*
* Create sThreadKey so we can keep track of the JNIEnv assigned to each thread
* Refer to http://developer.android.com/guide/practices/design/jni.html for the rationale behind this
Expand All @@ -774,11 +773,17 @@ void android_main(android_app *_pstState)
orxAndroid_JNI_SetupThread(orxNULL);
}

/* Initializes joystick support */
JNIEnv *pstEnv = orxAndroid_JNI_GetEnv();
/* Inits structure */
sstAndroid.app = _pstState;
sstAndroid.bPaused = orxTRUE;

_pstState->onAppCmd = orxAndroid_handleCmd;

/* Inits joystick support */
Paddleboat_init(pstEnv, _pstState->activity->javaGameActivity);
android_app_set_motion_event_filter(_pstState, NULL);

/* Initializes SwappyGL */
/* Inits SwappyGL */
SwappyGL_init(pstEnv, _pstState->activity->javaGameActivity);
SwappyGL_setAutoSwapInterval(false);
SwappyGL_setAutoPipelineMode(false);
Expand All @@ -797,28 +802,28 @@ void android_main(android_app *_pstState)
}
argv[argc] = NULL;

/* Run the application code! */
/* Runs the application code */
main(argc, argv);

if(_pstState->destroyRequested == 0)
{
GameActivity_finish(_pstState->activity);

/* pumps final events */
/* Pumps final events */
int id;
android_poll_source *source;

_pstState->onAppCmd = NULL;

while((id = ALooper_pollOnce(-1, NULL, NULL, (void **)&source)) >= 0)
{
/* Process this event. */
/* Process this event */
if(source != NULL)
{
source->process(_pstState, source);
}

/* Check if we are exiting. */
/* Check if we are exiting */
if(_pstState->destroyRequested != 0)
{
break;
Expand Down

0 comments on commit 632194f

Please sign in to comment.