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

Commit d2598d34 authored by Adrian Roos's avatar Adrian Roos Committed by android-build-merger
Browse files

Add setting for allowing remote input from keyguard am: 3aec638a

am: f86c39d1

* commit 'f86c39d1':
  Add setting for allowing remote input from keyguard
parents f4e5e773 f86c39d1
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -4659,6 +4659,14 @@ public final class Settings {
        public static final String LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS =
                "lock_screen_allow_private_notifications";

        /**
         * When set by a user, allows notification remote input atop a securely locked screen
         * without having to unlock
         * @hide
         */
        public static final String LOCK_SCREEN_ALLOW_REMOTE_INPUT =
                "lock_screen_allow_remote_input";

        /**
         * Set by the system to track if the user needs to see the call to action for
         * the lockscreen notification policy.
+34 −1
Original line number Diff line number Diff line
@@ -229,6 +229,7 @@ public abstract class BaseStatusBar extends SystemUI implements
    protected int mState;
    protected boolean mBouncerShowing;
    protected boolean mShowLockscreenNotifications;
    protected boolean mAllowLockscreenRemoteInput;

    protected NotificationOverflowContainer mKeyguardIconOverflowContainer;
    protected DismissView mDismissView;
@@ -400,11 +401,26 @@ public abstract class BaseStatusBar extends SystemUI implements
                }
                p = p.getParent();
            }
            ExpandableNotificationRow row = null;
            while (p != null) {
                if (p instanceof ExpandableNotificationRow) {
                    row = (ExpandableNotificationRow) p;
                    break;
                }
                p = p.getParent();
            }

            if (riv == null) {
            if (riv == null || row == null) {
                return false;
            }

            row.setUserExpanded(true);

            if (isLockscreenPublicMode() && !mAllowLockscreenRemoteInput) {
                onLockedRemoteInput(row, view);
                return true;
            }

            riv.setVisibility(View.VISIBLE);
            int cx = view.getLeft() + view.getWidth() / 2;
            int cy = view.getTop() + view.getHeight() / 2;
@@ -619,6 +635,10 @@ public abstract class BaseStatusBar extends SystemUI implements
                Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS), false,
                mSettingsObserver,
                UserHandle.USER_ALL);
        mContext.getContentResolver().registerContentObserver(
                Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT), false,
                mSettingsObserver,
                UserHandle.USER_ALL);

        mContext.getContentResolver().registerContentObserver(
                Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS),
@@ -1300,6 +1320,8 @@ public abstract class BaseStatusBar extends SystemUI implements
        }
    }

    protected void onLockedRemoteInput(ExpandableNotificationRow row, View clickedView) {}

    @Override
    public void onExpandClicked(Entry clickedEntry, boolean nowExpanded) {
    }
@@ -1936,6 +1958,10 @@ public abstract class BaseStatusBar extends SystemUI implements
        mShowLockscreenNotifications = show;
    }

    protected void setLockScreenAllowRemoteInput(boolean allowLockscreenRemoteInput) {
        mAllowLockscreenRemoteInput = allowLockscreenRemoteInput;
    }

    private void updateLockscreenNotificationSetting() {
        final boolean show = Settings.Secure.getIntForUser(mContext.getContentResolver(),
                Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
@@ -1945,7 +1971,14 @@ public abstract class BaseStatusBar extends SystemUI implements
                null /* admin */, mCurrentUserId);
        final boolean allowedByDpm = (dpmFlags
                & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS) == 0;

        final boolean remoteInput = Settings.Secure.getIntForUser(mContext.getContentResolver(),
                Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT,
                0,
                mCurrentUserId) != 0;

        setShowLockscreenNotifications(show && allowedByDpm);
        setLockScreenAllowRemoteInput(remoteInput);
    }

    protected abstract void setAreThereNotifications();
+20 −0
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ import android.view.ThreadedRenderer;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewParent;
import android.view.ViewStub;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
@@ -342,6 +343,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    private long mKeyguardFadingAwayDelay;
    private long mKeyguardFadingAwayDuration;

    // RemoteInputView to be activated after unlock
    private View mPendingRemoteInputView;

    int mMaxAllowedKeyguardNotifications;

    boolean mExpandedVisible;
@@ -3567,6 +3571,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            mDraggedDownRow.notifyHeightChanged(false  /* needsAnimation */);
            mDraggedDownRow = null;
        }
        mPendingRemoteInputView = null;
        mAssistManager.onLockscreenShown();
    }

@@ -3683,6 +3688,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    public boolean hideKeyguard() {
        boolean staying = mLeaveOpenOnKeyguardHide;
        setBarState(StatusBarState.SHADE);
        View viewToClick = null;
        if (mLeaveOpenOnKeyguardHide) {
            mLeaveOpenOnKeyguardHide = false;
            long delay = calculateGoingToFullShadeDelay();
@@ -3691,6 +3697,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                mDraggedDownRow.setUserLocked(false);
                mDraggedDownRow = null;
            }
            viewToClick = mPendingRemoteInputView;
            mPendingRemoteInputView = null;

            // Disable layout transitions in navbar for this transition because the load is just
            // too heavy for the CPU and GPU on any device.
@@ -3708,6 +3716,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        }
        updateKeyguardState(staying, false /* fromShadeLocked */);

        if (viewToClick != null) {
            viewToClick.callOnClick();
        }

        // Keyguard state has changed, but QS is not listening anymore. Make sure to update the tile
        // visibilities so next time we open the panel we know the correct height already.
        if (mQSPanel != null) {
@@ -4071,6 +4083,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            mLeaveOpenOnKeyguardHide = true;
            showBouncer();
            mDraggedDownRow = row;
            mPendingRemoteInputView = null;
        } else {
            mNotificationPanel.animateToFullShade(0 /* delay */);
            setBarState(StatusBarState.SHADE_LOCKED);
@@ -4078,6 +4091,13 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        }
    }

    @Override
    protected void onLockedRemoteInput(ExpandableNotificationRow row, View clicked) {
        mLeaveOpenOnKeyguardHide = true;
        showBouncer();
        mPendingRemoteInputView = clicked;
    }

    @Override
    public void onExpandClicked(Entry clickedEntry, boolean nowExpanded) {
        mHeadsUpManager.setExpanded(clickedEntry, nowExpanded);