diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-12-21 07:38:37 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-12-21 07:38:37 +0000 |
commit | 04fa560fc9059564b94cad0121daf9443bc2532d (patch) | |
tree | ab5e0d06beea4bcb3ac075530e12ff722ea5a4c4 | |
parent | f3954d3cec1886ba5ac706386d0f2765e0b9b925 (diff) | |
parent | a39a1f2ecde29ac073ffe61efc632aa8365fefb0 (diff) | |
download | CellBroadcastReceiver-04fa560fc9059564b94cad0121daf9443bc2532d.tar.gz |
Merge "remove turn_screen_on flag after screen off" into mainline-prod
-rw-r--r-- | src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java index b2874f250..5664e5736 100644 --- a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java +++ b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java @@ -25,10 +25,12 @@ import android.app.NotificationManager; import android.app.StatusBarManager; import android.app.PendingIntent; import android.app.RemoteAction; +import android.content.BroadcastReceiver; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; @@ -161,6 +163,18 @@ public class CellBroadcastAlertDialog extends Activity { // Show the opt-out dialog private AlertDialog mOptOutDialog; + /** BroadcastReceiver for screen off events. When screen was off, remove FLAG_TURN_SCREEN_ON to + * start from a clean state. Otherwise, the window flags from the first alert will be + * automatically applied to the following alerts handled at onNewIntent. + */ + private BroadcastReceiver mScreenOffReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent){ + Log.d(TAG, "onSreenOff: remove FLAG_TURN_SCREEN_ON flag"); + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); + } + }; + /** * Animation handler for the flashing warning icon (emergency alerts only). */ @@ -360,6 +374,8 @@ public class CellBroadcastAlertDialog extends Activity { clearNotification(intent); } + registerReceiver(mScreenOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF)); + if (mMessageList == null || mMessageList.size() == 0) { Log.e(TAG, "onCreate failed as message list is null or empty"); finish(); @@ -976,6 +992,7 @@ public class CellBroadcastAlertDialog extends Activity { @Override public void onDestroy() { + unregisterReceiver(mScreenOffReceiver); super.onDestroy(); } |