Skip to content

Commit

Permalink
Fixed issue where back button would not exit the activity if bootstra…
Browse files Browse the repository at this point in the history
…p installation failed and users dismissed the error dialog,
  • Loading branch information
agnostic-apollo committed Jun 28, 2021
1 parent e408fdc commit 9c92251
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ public boolean onKeyDown(int keyCode, KeyEvent e, TerminalSession currentSession

@Override
public boolean onKeyUp(int keyCode, KeyEvent e) {
// If emulator is not set, like if bootstrap installation failed and user dismissed the error
// dialog, then just exit the activity, otherwise they will be stuck in a broken state.
if (keyCode == KeyEvent.KEYCODE_BACK && mActivity.getTerminalView().mEmulator == null) {
mActivity.finishActivityIfNotFinishing();
return true;
}

return handleVirtualKeys(keyCode, e, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,10 @@ public boolean handleKeyCode(int keyCode, int keyMod) {
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (TERMINAL_VIEW_KEY_LOGGING_ENABLED)
mClient.logInfo(LOG_TAG, "onKeyUp(keyCode=" + keyCode + ", event=" + event + ")");
if (mEmulator == null) return true;

// Do not return for KEYCODE_BACK and send it to the client since user may be trying
// to exit the activity.
if (mEmulator == null && keyCode != KeyEvent.KEYCODE_BACK) return true;

if (mClient.onKeyUp(keyCode, event)) {
invalidate();
Expand Down

0 comments on commit 9c92251

Please sign in to comment.