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

Commit efbdc6b0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixes set lock task (and screen pinning) state with/out quickstep"

parents 6997ad69 6ff33b7f
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.shared.system;

import static android.app.ActivityManager.LOCK_TASK_MODE_NONE;
import static android.app.ActivityManager.LOCK_TASK_MODE_PINNED;
import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
@@ -402,6 +403,25 @@ public class ActivityManagerWrapper {
        }
    }

    /**
     * @return whether screen pinning is active.
     */
    public boolean isScreenPinningActive() {
        try {
            return ActivityManager.getService().getLockTaskModeState() == LOCK_TASK_MODE_PINNED;
        } catch (RemoteException e) {
            return false;
        }
    }

    /**
     * @return whether screen pinning is enabled.
     */
    public boolean isScreenPinningEnabled() {
        final ContentResolver cr = AppGlobals.getInitialApplication().getContentResolver();
        return Settings.System.getInt(cr, Settings.System.LOCK_TO_APP_ENABLED, 0) != 0;
    }

    /**
     * @return whether there is currently a locked task (ie. in screen pinning).
     */
@@ -415,9 +435,9 @@ public class ActivityManagerWrapper {

    /**
     * @return whether screen pinning is enabled.
     * @deprecated See {@link #isScreenPinningEnabled}
     */
    public boolean isLockToAppEnabled() {
        final ContentResolver cr = AppGlobals.getInitialApplication().getContentResolver();
        return Settings.System.getInt(cr, Settings.System.LOCK_TO_APP_ENABLED, 0) != 0;
        return isScreenPinningEnabled();
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -449,7 +449,7 @@ public class Recents extends SystemUI
        final int activityType = runningTask != null
                ? runningTask.configuration.windowConfiguration.getActivityType()
                : ACTIVITY_TYPE_UNDEFINED;
        boolean screenPinningActive = ActivityManagerWrapper.getInstance().isLockToAppActive();
        boolean screenPinningActive = ActivityManagerWrapper.getInstance().isScreenPinningActive();
        boolean isRunningTaskInHomeOrRecentsStack =
                activityType == ACTIVITY_TYPE_HOME || activityType == ACTIVITY_TYPE_RECENTS;
        if (runningTask != null && !isRunningTaskInHomeOrRecentsStack && !screenPinningActive) {
+2 −6
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import static com.android.systemui.statusbar.phone.StatusBar.SYSTEM_DIALOG_REASO

import android.app.ActivityManager;
import android.app.ActivityOptions;
import android.app.KeyguardManager;
import android.app.trust.TrustManager;
import android.content.ActivityNotFoundException;
import android.content.Context;
@@ -34,7 +33,6 @@ import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask.Status;
import android.os.Handler;
import android.os.SystemClock;
import android.util.ArraySet;
@@ -385,8 +383,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
    }

    public void toggleRecents(int growTarget) {
        // Skip preloading if the task is locked
        if (ActivityManagerWrapper.getInstance().isLockToAppActive()) {
        if (ActivityManagerWrapper.getInstance().isScreenPinningActive()) {
            return;
        }

@@ -464,8 +461,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
    }

    public void preloadRecents() {
        // Skip preloading if the task is locked
        if (ActivityManagerWrapper.getInstance().isLockToAppActive()) {
        if (ActivityManagerWrapper.getInstance().isScreenPinningActive()) {
            return;
        }

+2 −1
Original line number Diff line number Diff line
@@ -2188,7 +2188,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
    private void readSystemFlags() {
        SystemServicesProxy ssp = Recents.getSystemServices();
        mTouchExplorationEnabled = ssp.isTouchExplorationEnabled();
        mScreenPinningEnabled = ActivityManagerWrapper.getInstance().isLockToAppEnabled();
        mScreenPinningEnabled = ActivityManagerWrapper.getInstance().isScreenPinningEnabled()
                && !ActivityManagerWrapper.getInstance().isLockToAppActive();
    }

    private void updateStackActionButtonVisibility() {
+2 −1
Original line number Diff line number Diff line
@@ -708,7 +708,8 @@ public class NavigationBarFragment extends Fragment implements Callbacks {

    @VisibleForTesting
    boolean onHomeLongClick(View v) {
        if (!mNavigationBarView.isRecentsButtonVisible() && mNavigationBarView.inScreenPinning()) {
        if (!mNavigationBarView.isRecentsButtonVisible()
                && ActivityManagerWrapper.getInstance().isScreenPinningActive()) {
            return onLongPressBackHome(v);
        }
        if (shouldDisableNavbarGestures()) {
Loading