diff options
author | Sarah Chin <sarahchin@google.com> | 2020-06-13 03:57:10 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-06-13 03:57:10 +0000 |
commit | 77cc0f74c754170819647d9a4ff13a9b10f67783 (patch) | |
tree | 667bc951305dc310c10f5ceac4545061186ca87d | |
parent | d319203513aeab336001b25e680b660b6e1e7f53 (diff) | |
parent | 1ff31a39063dbf7c9f17849decff1461bc697543 (diff) | |
download | CellBroadcastReceiver-77cc0f74c754170819647d9a4ff13a9b10f67783.tar.gz |
Merge "Home key does not cancel dialog if mute_by_physical_button is false" into rvc-dev
-rw-r--r-- | src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java index fd24887c7..ec860856b 100644 --- a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java +++ b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java @@ -293,6 +293,14 @@ public class CellBroadcastAlertDialog extends Activity { | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); + // Disable home button when alert dialog is showing if mute_by_physical_button is false. + if (!CellBroadcastSettings.getResources(getApplicationContext(), + SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) + .getBoolean(R.bool.mute_by_physical_button)) { + final View decorView = win.getDecorView(); + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); + } + setFinishOnTouchOutside(false); // Initialize the view. @@ -389,7 +397,7 @@ public class CellBroadcastAlertDialog extends Activity { @Override protected void onStop() { - super.onStop(); + Log.d(TAG, "onStop called"); // When the activity goes in background eg. clicking Home button, send notification. // Avoid doing this when activity will be recreated because of orientation change or if // screen goes off @@ -400,6 +408,7 @@ public class CellBroadcastAlertDialog extends Activity { } // Stop playing alert sound/vibration/speech (if started) stopService(new Intent(this, CellBroadcastAlertAudio.class)); + super.onStop(); } @Override @@ -751,7 +760,8 @@ public class CellBroadcastAlertDialog extends Activity { } @Override - public boolean dispatchKeyEvent(KeyEvent event) { + public boolean onKeyDown(int keyCode, KeyEvent event) { + Log.d(TAG, "onKeyDown: " + event); SmsCbMessage message = getLatestMessage(); if (CellBroadcastSettings.getResources(getApplicationContext(), message.getSubscriptionId()) .getBoolean(R.bool.mute_by_physical_button)) { @@ -769,8 +779,14 @@ public class CellBroadcastAlertDialog extends Activity { default: break; } + return super.onKeyDown(keyCode, event); + } else { + if (event.getKeyCode() == KeyEvent.KEYCODE_POWER) { + // TODO: do something to prevent screen off + } + // Disable all physical keys if mute_by_physical_button is false + return true; } - return super.dispatchKeyEvent(event); } @Override |