Streamline activity start flow

Refactor activity start logic by moving the similar operations
together and remove code duplications.

The reusable task is selected in earlier stage, so that some
permission and security check could be performed before manipulating
the task (reparenting or finishing activities).

Also fix two activity start cases that didn't work as expected.

Bug: 139449647
Bug: 139390610
Bug: 139333063
Test: atest WmTests CtsWindowManagerDeviceTestCases
Change-Id: Icbaaa29d79fd6cb13a1dff60d45289a6253d20f9
This commit is contained in:
Louis Chang
2019-08-16 17:19:47 +08:00
parent a3662b912d
commit bde91e9441
3 changed files with 408 additions and 556 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -279,6 +279,13 @@ public class LockTaskController {
}
}
/**
* @return true if currently in the lock task mode, otherwise, return false.
*/
boolean isInLockTaskMode() {
return !mLockTaskModeTasks.isEmpty();
}
/**
* @return whether the requested task is disallowed to be launched.
*/

View File

@@ -499,6 +499,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
final ActivityStarter starter = prepareStarter(0);
final LockTaskController lockTaskController = mService.getLockTaskController();
doReturn(true).when(lockTaskController).isInLockTaskMode();
doReturn(true).when(lockTaskController).isLockTaskModeViolation(any());
final int result = starter.setReason("testTaskModeViolation").execute();