Always allowlist DLC package
Regardless of whether it is from the kiosk app or part of provisioning,
always allowlist the DLC package from lock task mode.
Bug: 306059228
Test: provisioned device
Test: atest DeviceLockControllerRoboTests
Change-Id: Ie052a72466d08056a5f53e966889969051d9a36b
diff --git a/DeviceLockController/src/com/android/devicelockcontroller/policy/LockTaskModePolicyHandler.java b/DeviceLockController/src/com/android/devicelockcontroller/policy/LockTaskModePolicyHandler.java
index 11c19ec..adcd230 100644
--- a/DeviceLockController/src/com/android/devicelockcontroller/policy/LockTaskModePolicyHandler.java
+++ b/DeviceLockController/src/com/android/devicelockcontroller/policy/LockTaskModePolicyHandler.java
@@ -105,8 +105,14 @@
return disableLockTaskMode();
}
- private ListenableFuture<Void> updateAllowlist(boolean includeController) {
- return Futures.transform(composeAllowlist(includeController),
+ /**
+ * Updates the allowlist for lock task mode
+ *
+ * @param includeKiosk true if the kiosk app and the kiosk-specified allowlist should be added
+ * @return future for when the lock task mode allowlist has been updated
+ */
+ private ListenableFuture<Void> updateAllowlist(boolean includeKiosk) {
+ return Futures.transform(composeAllowlist(includeKiosk),
allowlist -> {
TelecomManager telecomManager = mContext.getSystemService(
TelecomManager.class);
@@ -144,7 +150,7 @@
}
private ListenableFuture<Boolean> enableLockTaskModeForController() {
- return Futures.transform(updateAllowlist(/* includeController= */ true),
+ return Futures.transform(updateAllowlist(/* includeKiosk= */ false),
unused -> {
mDpm.setLockTaskFeatures(/* admin= */ null, DEFAULT_LOCK_TASK_FEATURES_FOR_DLC);
return true;
@@ -156,7 +162,7 @@
SetupParametersClient.getInstance().isNotificationsInLockTaskModeEnabled();
return Futures.whenAllSucceed(
notificationsInLockTaskModeEnabled,
- updateAllowlist(/* includeController= */ false))
+ updateAllowlist(/* includeKiosk= */ true))
.call(() -> {
int flags = DEFAULT_LOCK_TASK_FEATURES_FOR_KIOSK;
if (Futures.getDone(notificationsInLockTaskModeEnabled)) {
@@ -199,10 +205,10 @@
* 3. Find the default app used for Settings (should be a System App).
* 4. Find the default app used for permissions (should be a System App).
* 5. Find the default InputMethod.
- * 6. DLC or Kiosk app depending on the input.
- * 7. Append the packages allow-listed through setup parameters if applicable.
+ * 6. Add the DLC app.
+ * 7. Append the kiosk and packages allow-listed through setup parameters if applicable.
*/
- private ListenableFuture<ArraySet<String>> composeAllowlist(boolean includeController) {
+ private ListenableFuture<ArraySet<String>> composeAllowlist(boolean includeKiosk) {
return Futures.submit(() -> {
String[] allowlistArray =
mContext.getResources().getStringArray(R.array.lock_task_allowlist);
@@ -213,10 +219,8 @@
allowlistPackages);
allowlistInputMethod(allowlistPackages);
allowlistCellBroadcastReceiver(allowlistPackages);
- if (includeController) {
- allowlistPackages.add(mContext.getPackageName());
- } else {
- allowlistPackages.remove(mContext.getPackageName());
+ allowlistPackages.add(mContext.getPackageName());
+ if (includeKiosk) {
SetupParametersClient setupParametersClient = SetupParametersClient.getInstance();
allowlistPackages.add(
Futures.getUnchecked(setupParametersClient.getKioskPackage()));
diff --git a/DeviceLockController/tests/robolectric/src/com/android/devicelockcontroller/policy/LockTaskModePolicyHandlerTest.java b/DeviceLockController/tests/robolectric/src/com/android/devicelockcontroller/policy/LockTaskModePolicyHandlerTest.java
index d46c568..3fcd511 100644
--- a/DeviceLockController/tests/robolectric/src/com/android/devicelockcontroller/policy/LockTaskModePolicyHandlerTest.java
+++ b/DeviceLockController/tests/robolectric/src/com/android/devicelockcontroller/policy/LockTaskModePolicyHandlerTest.java
@@ -81,7 +81,8 @@
private static final String DEVICELOCK_CONTROLLER_PACKAGE = "com.android.devicelockcontroller";
private static final String PACKAGE_OVERRIDING_HOME = "com.home.package";
private static final String[] EXPECTED_ALLOWLIST_PACKAGES =
- new String[]{TEST_PACKAGE, SETTINGS_PACKAGE, DIALER_PACKAGE};
+ new String[]{TEST_PACKAGE, SETTINGS_PACKAGE, DIALER_PACKAGE,
+ DEVICELOCK_CONTROLLER_PACKAGE};
private static final String TEST_ACTIVITY = "TestActivity";
private static final String CELL_BROADCAST_RECEIVER_PACKAGE =
"test.cell.broadcast.receiver";
@@ -173,7 +174,8 @@
throws ExecutionException, InterruptedException {
final String[] expectedAllowlistPackages =
new String[]{TEST_PACKAGE, SETTINGS_PACKAGE, DIALER_PACKAGE, IME_PACKAGE,
- PERMISSION_PACKAGE, CELL_BROADCAST_RECEIVER_PACKAGE};
+ PERMISSION_PACKAGE, CELL_BROADCAST_RECEIVER_PACKAGE,
+ DEVICELOCK_CONTROLLER_PACKAGE};
Bundle bundle = new Bundle();
bundle.putString(EXTRA_KIOSK_PACKAGE, TEST_PACKAGE);
SetupParametersClient.getInstance().createPrefs(bundle).get();