@@ -33,6 +33,9 @@ Runtime *runtime = nullptr;
3333// Pipe file descriptors: g_backPipe[0] is read-end, g_backPipe[1] is write-end
3434static int g_backPipe[2 ] = {-1 , -1 };
3535
36+ // whether native back key handling is active
37+ static bool g_predictiveBack = false ;
38+
3639// the sensorTypes corresponding to _sensors[] positions
3740constexpr int SENSOR_TYPES[MAX_SENSORS] = {
3841 ASENSOR_TYPE_ACCELEROMETER,
@@ -159,7 +162,7 @@ static void process_input(android_app *app, android_poll_source *source) {
159162 AKeyEvent_getKeyCode (event) == AKEYCODE_BACK) {
160163 // prevent AInputQueue_preDispatchEvent from attempting to close
161164 // the keypad here to avoid a crash in android 4.2 + 4.3.
162- if (AKeyEvent_getAction (event) == AKEY_EVENT_ACTION_DOWN && runtime->isActive ()) {
165+ if (AKeyEvent_getAction (event) == AKEY_EVENT_ACTION_DOWN && runtime->isActive () && !g_predictiveBack ) {
163166 pushBackEvent ();
164167 }
165168 AInputQueue_finishEvent (app->inputQueue , event, true );
@@ -287,7 +290,10 @@ Runtime::Runtime(android_app *app) :
287290 _looper = ALooper_forThread ();
288291 _sensorManager = ASensorManager_getInstance ();
289292 memset (&_sensors, 0 , sizeof (_sensors));
290- setupBackWakePipe (_looper);
293+ g_predictiveBack = getBoolean (" isPredictiveBack" );
294+ if (g_predictiveBack) {
295+ setupBackWakePipe (_looper);
296+ }
291297}
292298
293299Runtime::~Runtime () {
0 commit comments