Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf7d9485 authored by Gaurav Bhola's avatar Gaurav Bhola
Browse files

Respect DA policy before trying to start home

- This fixes a system crash when multiple TDAs are set up with
  a few TDAs that cannot host home.
- The system still tries to start home on all the TDAs and
  ActivityStartController fails later as the policy didn't allow.

Test: atest RootWindowContainerTests
Fix: 344010973
Change-Id: Iccf6de6b9b3be6cc4c005dc5047a9f757154aa12
parent 5affad6f
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1693,7 +1693,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
    }

    /**
     * Check if home activity start should be allowed on a display.
     * Check if home activity start should be allowed on a {@link TaskDisplayArea}.
     *
     * @param homeInfo           {@code ActivityInfo} of the home activity that is going to be
     *                           launched.
@@ -1717,6 +1717,10 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            return false;
        }

        if (taskDisplayArea != null && !taskDisplayArea.canHostHomeTask()) {
            return false;
        }

        final int displayId = taskDisplayArea != null ? taskDisplayArea.getDisplayId()
                : INVALID_DISPLAY;
        if (shouldPlacePrimaryHomeOnDisplay(displayId)) {
+18 −0
Original line number Diff line number Diff line
@@ -905,6 +905,24 @@ public class RootWindowContainerTests extends WindowTestsBase {
                true /* allowInstrumenting*/));
    }

    /**
     * Tests whether home can be started if it's not allowed by policy.
     */
    @Test
    public void testCanStartHome_returnsFalse_ifDisallowedByPolicy() {
        final ActivityInfo info = new ActivityInfo();
        info.applicationInfo = new ApplicationInfo();
        final WindowProcessController app = mock(WindowProcessController.class);
        doReturn(app).when(mAtm).getProcessController(any(), anyInt());
        doReturn(false).when(app).isInstrumenting();
        final TaskDisplayArea taskDisplayArea = mRootWindowContainer.getDefaultTaskDisplayArea();
        doReturn(false).when(taskDisplayArea).canHostHomeTask();

        assertFalse(mRootWindowContainer.canStartHomeOnDisplayArea(info, taskDisplayArea,
                false /* allowInstrumenting*/));
    }


    /**
     * Tests that secondary home activity should not be resolved if device is still locked.
     */