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

Commit ca7ddbfe authored by Jose Lima's avatar Jose Lima Committed by Android Git Automerger
Browse files

am 00430954: Merge "Only allow 1 Stack on Leanback-only devices" into lmp-preview-dev

* commit '004309546b7efa188df56e58539e4227ed192cf7':
  Only allow 1 Stack on Leanback-only devices
parents f87ec6a6 80962666
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -217,6 +217,8 @@ public final class ActivityStackSupervisor implements DisplayListener {
    /** Set when we have taken too long waiting to go to sleep. */
    boolean mSleepTimeout = false;

    private final boolean mLeanbackOnlyDevice = isLeanbackOnlyDevice();

    /**
     * We don't want to allow the device to go to sleep while in the process
     * of launching an activity.  This is primarily to allow alarm intent
@@ -1412,7 +1414,10 @@ public final class ActivityStackSupervisor implements DisplayListener {

    ActivityStack adjustStackFocus(ActivityRecord r, boolean newTask) {
        final TaskRecord task = r.task;
        if (r.isApplicationActivity() || (task != null && task.isApplicationTask())) {

        // On leanback only devices we should keep all activities in the same stack.
        if (!mLeanbackOnlyDevice &&
                (r.isApplicationActivity() || (task != null && task.isApplicationTask()))) {
            if (task != null) {
                final ActivityStack taskStack = task.stack;
                if (taskStack.isOnHomeDisplay()) {
@@ -3496,4 +3501,16 @@ public final class ActivityStackSupervisor implements DisplayListener {
            return "VirtualActivityDisplay={" + mDisplayId + "}";
        }
    }

    private boolean isLeanbackOnlyDevice() {
        boolean onLeanbackOnly = false;
        try {
            onLeanbackOnly = AppGlobals.getPackageManager().hasSystemFeature(
                    PackageManager.FEATURE_LEANBACK_ONLY);
        } catch (RemoteException e) {
            // noop
        }

        return onLeanbackOnly;
    }
}