From a39a1f2ecde29ac073ffe61efc632aa8365fefb0 Mon Sep 17 00:00:00 2001 From: Chen Xu Date: Mon, 14 Dec 2020 22:32:51 +0800 Subject: remove turn_screen_on flag after screen off per KR gov requirement, the receival of alerts on channel 4372 should not turn screen on while 4370/4371 should. If devices received 4370/4371 followed by 4372, turn_on_screen window flags which is added onCreate will be automatically applied to the next alert handled by onNewIntent. Instead, we should remove the window flag whenever the screen is off as turn_screen_on flag is no longer needed. Bug: 175267124 Test: Manual Change-Id: I32f446559b86e95ce5d944f853abb9e0e4cb77db Merged-in: I4b15e783cc0dec33a47a26cfe3d4256593bbc33e --- .../cellbroadcastreceiver/CellBroadcastAlertDialog.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertDialog.java index e80fbddbd..00a7b386c 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). */ @@ -363,6 +377,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(); @@ -966,6 +982,7 @@ public class CellBroadcastAlertDialog extends Activity { @Override public void onDestroy() { + unregisterReceiver(mScreenOffReceiver); super.onDestroy(); } -- cgit v1.2.3