Loading services/core/java/com/android/server/wm/LockTaskController.java +24 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.policy.IKeyguardDismissCallback; import com.android.internal.protolog.common.ProtoLog; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.telephony.CellBroadcastUtils; import com.android.internal.widget.LockPatternUtils; import com.android.server.LocalServices; import com.android.server.am.ActivityManagerService; Loading Loading @@ -392,6 +393,10 @@ public class LockTaskController { return false; } if (isWirelessEmergencyAlert(intent)) { return false; } return !(isTaskAuthAllowlisted(taskAuth) || mLockTaskModeTasks.isEmpty()); } Loading Loading @@ -424,6 +429,25 @@ public class LockTaskController { return isPackageAllowlisted(userId, packageName); } private boolean isWirelessEmergencyAlert(Intent intent) { if (intent == null) { return false; } final ComponentName cellBroadcastAlertDialogComponentName = CellBroadcastUtils.getDefaultCellBroadcastAlertDialogComponent(mContext); if (cellBroadcastAlertDialogComponentName == null) { return false; } if (cellBroadcastAlertDialogComponentName.equals(intent.getComponent())) { return true; } return false; } private boolean isEmergencyCallIntent(Intent intent) { if (intent == null) { return false; Loading services/tests/wmtests/src/com/android/server/wm/LockTaskControllerTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,7 @@ import android.util.Pair; import androidx.test.filters.SmallTest; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.telephony.CellBroadcastUtils; import com.android.internal.widget.LockPatternUtils; import com.android.server.LocalServices; import com.android.server.statusbar.StatusBarManagerInternal; Loading Loading @@ -296,6 +297,22 @@ public class LockTaskControllerTest { assertTrue(mLockTaskController.isLockTaskModeViolation(dialer)); } @Test public void testLockTaskViolation_wirelessEmergencyAlerts() { // GIVEN one task record with allowlisted auth that is in lock task mode Task tr = getTask(LOCK_TASK_AUTH_ALLOWLISTED); mLockTaskController.startLockTaskMode(tr, false, TEST_UID); // GIVEN cellbroadcast task necessary for emergency warning alerts Task cellbroadcastreceiver = getTask( new Intent().setComponent( CellBroadcastUtils.getDefaultCellBroadcastAlertDialogComponent(mContext)), LOCK_TASK_AUTH_PINNABLE); // THEN the cellbroadcast task should all be allowed assertFalse(mLockTaskController.isLockTaskModeViolation(cellbroadcastreceiver)); } @Test public void testStopLockTaskMode() throws Exception { // GIVEN one task record with allowlisted auth that is in lock task mode Loading telephony/common/com/android/internal/telephony/CellBroadcastUtils.java +14 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.telephony; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; Loading Loading @@ -62,4 +63,17 @@ public class CellBroadcastUtils { return packageName; } /** * Utility method to get cellbroadcast alert dialog component name */ public static ComponentName getDefaultCellBroadcastAlertDialogComponent(Context context) { String cellBroadcastReceiverPackageName = getDefaultCellBroadcastReceiverPackageName(context); if (TextUtils.isEmpty(cellBroadcastReceiverPackageName)) { return null; } return ComponentName.createRelative(cellBroadcastReceiverPackageName, "com.android.cellbroadcastreceiver.CellBroadcastAlertDialog"); } } Loading
services/core/java/com/android/server/wm/LockTaskController.java +24 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.policy.IKeyguardDismissCallback; import com.android.internal.protolog.common.ProtoLog; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.telephony.CellBroadcastUtils; import com.android.internal.widget.LockPatternUtils; import com.android.server.LocalServices; import com.android.server.am.ActivityManagerService; Loading Loading @@ -392,6 +393,10 @@ public class LockTaskController { return false; } if (isWirelessEmergencyAlert(intent)) { return false; } return !(isTaskAuthAllowlisted(taskAuth) || mLockTaskModeTasks.isEmpty()); } Loading Loading @@ -424,6 +429,25 @@ public class LockTaskController { return isPackageAllowlisted(userId, packageName); } private boolean isWirelessEmergencyAlert(Intent intent) { if (intent == null) { return false; } final ComponentName cellBroadcastAlertDialogComponentName = CellBroadcastUtils.getDefaultCellBroadcastAlertDialogComponent(mContext); if (cellBroadcastAlertDialogComponentName == null) { return false; } if (cellBroadcastAlertDialogComponentName.equals(intent.getComponent())) { return true; } return false; } private boolean isEmergencyCallIntent(Intent intent) { if (intent == null) { return false; Loading
services/tests/wmtests/src/com/android/server/wm/LockTaskControllerTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,7 @@ import android.util.Pair; import androidx.test.filters.SmallTest; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.telephony.CellBroadcastUtils; import com.android.internal.widget.LockPatternUtils; import com.android.server.LocalServices; import com.android.server.statusbar.StatusBarManagerInternal; Loading Loading @@ -296,6 +297,22 @@ public class LockTaskControllerTest { assertTrue(mLockTaskController.isLockTaskModeViolation(dialer)); } @Test public void testLockTaskViolation_wirelessEmergencyAlerts() { // GIVEN one task record with allowlisted auth that is in lock task mode Task tr = getTask(LOCK_TASK_AUTH_ALLOWLISTED); mLockTaskController.startLockTaskMode(tr, false, TEST_UID); // GIVEN cellbroadcast task necessary for emergency warning alerts Task cellbroadcastreceiver = getTask( new Intent().setComponent( CellBroadcastUtils.getDefaultCellBroadcastAlertDialogComponent(mContext)), LOCK_TASK_AUTH_PINNABLE); // THEN the cellbroadcast task should all be allowed assertFalse(mLockTaskController.isLockTaskModeViolation(cellbroadcastreceiver)); } @Test public void testStopLockTaskMode() throws Exception { // GIVEN one task record with allowlisted auth that is in lock task mode Loading
telephony/common/com/android/internal/telephony/CellBroadcastUtils.java +14 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.telephony; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; Loading Loading @@ -62,4 +63,17 @@ public class CellBroadcastUtils { return packageName; } /** * Utility method to get cellbroadcast alert dialog component name */ public static ComponentName getDefaultCellBroadcastAlertDialogComponent(Context context) { String cellBroadcastReceiverPackageName = getDefaultCellBroadcastReceiverPackageName(context); if (TextUtils.isEmpty(cellBroadcastReceiverPackageName)) { return null; } return ComponentName.createRelative(cellBroadcastReceiverPackageName, "com.android.cellbroadcastreceiver.CellBroadcastAlertDialog"); } }