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

Commit 733c2d46 authored by ezio84's avatar ezio84 Committed by Łukasz Patron
Browse files

SystemUI: block gestural navigation when using partial screenshot

Change-Id: I68d25a6eab9ea16707e8736b9e56055532bcdf87
parent 3aa78af0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -165,6 +165,8 @@ oneway interface IStatusBar
    // Used to show or hide in display fingerprint view
    void showInDisplayFingerprintView();
    void hideInDisplayFingerprintView();
    // Used to block or unblock usage of gestural navigation
    void setBlockedGesturalNavigation(boolean blocked);

    /**
     * Notifies System UI that the display is ready to show system decorations.
+2 −0
Original line number Diff line number Diff line
@@ -113,4 +113,6 @@ interface IStatusBarService
    // Used to show or hide in display fingerprint view
    void showInDisplayFingerprintView();
    void hideInDisplayFingerprintView();
    // Used to block or unblock usage of gestural navigation
    void setBlockedGesturalNavigation(boolean blocked);
}
+19 −0
Original line number Diff line number Diff line
@@ -67,6 +67,8 @@ import android.os.AsyncTask;
import android.os.Environment;
import android.os.PowerManager;
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.provider.MediaStore;
import android.text.TextUtils;
@@ -86,6 +88,7 @@ import android.widget.LinearLayout;
import android.widget.Toast;

import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.statusbar.IStatusBarService;
import com.android.systemui.R;
import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.SystemUI;
@@ -667,11 +670,24 @@ class GlobalScreenshot {
                new Rect(0, 0, mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels));
    }

    void setBlockedGesturalNavigation(boolean blocked) {
        IStatusBarService service = IStatusBarService.Stub.asInterface(
                ServiceManager.getService(Context.STATUS_BAR_SERVICE));
        if (service != null) {
            try {
                service.setBlockedGesturalNavigation(blocked);
            } catch (RemoteException e) {
                // end of the world
            }
        }
    }

    /**
     * Displays a screenshot selector
     */
    void takeScreenshotPartial(final Runnable finisher, final boolean statusBarVisible,
            final boolean navBarVisible) {
        setBlockedGesturalNavigation(true);
        mWindowManager.addView(mScreenshotLayout, mWindowLayoutParams);
        mScreenshotSelectorView.setSelectionListener(
                new ScreenshotSelectorView.OnSelectionListener() {
@@ -725,6 +741,7 @@ class GlobalScreenshot {
        mScreenshotSelectorView.stopSelection();
        mScreenshotSelectorView.setVisibility(View.GONE);
        mCaptureButton.setVisibility(View.GONE);
        setBlockedGesturalNavigation(false);
    }

    /**
@@ -736,6 +753,8 @@ class GlobalScreenshot {
            mWindowManager.removeView(mScreenshotLayout);
            mScreenshotSelectorView.stopSelection();
        }

        setBlockedGesturalNavigation(false);
    }

    /**
+15 −0
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ public class CommandQueue extends IStatusBar.Stub implements CallbackController<
    private static final int MSG_RECENTS_ANIMATION_STATE_CHANGED = 47 << MSG_SHIFT;
    private static final int MSG_SHOW_IN_DISPLAY_FINGERPRINT_VIEW = 48 << MSG_SHIFT;
    private static final int MSG_HIDE_IN_DISPLAY_FINGERPRINT_VIEW = 49 << MSG_SHIFT;
    private static final int MSG_SET_BLOCKED_GESTURAL_NAVIGATION = 50 << MSG_SHIFT;

    public static final int FLAG_EXCLUDE_NONE = 0;
    public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
@@ -281,6 +282,7 @@ public class CommandQueue extends IStatusBar.Stub implements CallbackController<
        default void hideBiometricDialog() { }
        default void showInDisplayFingerprintView() { }
        default void hideInDisplayFingerprintView() { }
        default void setBlockedGesturalNavigation(boolean blocked) {}

        /**
         * @see IStatusBar#onDisplayReady(int)
@@ -803,6 +805,14 @@ public class CommandQueue extends IStatusBar.Stub implements CallbackController<
        }
    }

    @Override
    public void setBlockedGesturalNavigation(boolean blocked) {
        synchronized (mLock) {
            mHandler.removeMessages(MSG_SET_BLOCKED_GESTURAL_NAVIGATION);
            mHandler.obtainMessage(MSG_SET_BLOCKED_GESTURAL_NAVIGATION, blocked).sendToTarget();
        }
    }

    @Override
    public void onDisplayReady(int displayId) {
        synchronized (mLock) {
@@ -1119,6 +1129,11 @@ public class CommandQueue extends IStatusBar.Stub implements CallbackController<
                        mCallbacks.get(i).hideInDisplayFingerprintView();
                    }
                    break;
                case MSG_SET_BLOCKED_GESTURAL_NAVIGATION:
                    for (int i = 0; i < mCallbacks.size(); i++) {
                        mCallbacks.get(i).setBlockedGesturalNavigation((Boolean) msg.obj);
                    }
                    break;
            }
        }
    }
+12 −1
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@ public class NavigationBarView extends FrameLayout implements
    private boolean mDeadZoneConsuming = false;
    private final NavigationBarTransitions mBarTransitions;
    private final OverviewProxyService mOverviewProxyService;
    private boolean mBlockedGesturalNavigation;

    // performs manual animation in sync with layout transitions
    private final NavTransitionListener mTransitionListener = new NavTransitionListener();
@@ -767,10 +768,13 @@ public class NavigationBarView extends FrameLayout implements
        mOverviewProxyService.setSystemUiStateFlag(SYSUI_STATE_SCREEN_PINNING,
                ActivityManagerWrapper.getInstance().isScreenPinningActive(), displayId);
        mOverviewProxyService.setSystemUiStateFlag(SYSUI_STATE_OVERVIEW_DISABLED,
                mBlockedGesturalNavigation ||
                (mDisabledFlags & View.STATUS_BAR_DISABLE_RECENT) != 0, displayId);
        mOverviewProxyService.setSystemUiStateFlag(SYSUI_STATE_HOME_DISABLED,
                mBlockedGesturalNavigation ||
                (mDisabledFlags & View.STATUS_BAR_DISABLE_HOME) != 0, displayId);
        mOverviewProxyService.setSystemUiStateFlag(SYSUI_STATE_SEARCH_DISABLED,
                mBlockedGesturalNavigation ||
                (mDisabledFlags & View.STATUS_BAR_DISABLE_SEARCH) != 0, displayId);
    }

@@ -778,7 +782,8 @@ public class NavigationBarView extends FrameLayout implements
        int displayId = mContext.getDisplayId();
        if (mPanelView != null) {
            mOverviewProxyService.setSystemUiStateFlag(SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED,
                    mPanelView.isFullyExpanded() && !mPanelView.isInSettings(), displayId);
                    mBlockedGesturalNavigation ||
                    (mPanelView.isFullyExpanded() && !mPanelView.isInSettings()), displayId);
            mOverviewProxyService.setSystemUiStateFlag(SYSUI_STATE_QUICK_SETTINGS_EXPANDED,
                    mPanelView.isInSettings(), displayId);
        }
@@ -801,6 +806,12 @@ public class NavigationBarView extends FrameLayout implements
                showSwipeUpUI ? mQuickStepAccessibilityDelegate : null);
    }

    public void setBlockedGesturalNavigation(boolean blocked) {
        mBlockedGesturalNavigation = blocked;
        updateDisabledSystemUiStateFlags();
        updatePanelSystemUiStateFlags();
    }

    /**
     * Updates the {@link WindowManager.LayoutParams.FLAG_SLIPPERY} state dependent on if swipe up
     * is enabled, or the notifications is fully opened without being in an animated state. If
Loading