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

Commit af29800d authored by Matt Casey's avatar Matt Casey Committed by Android (Google) Code Review
Browse files

Merge "Add setting for touch gesture and long-press home assistant invocations" into sc-dev

parents 612a4a78 662f32dd
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -9175,6 +9175,22 @@ public final class Settings {
        @Readable
        public static final String ASSIST_GESTURE_SETUP_COMPLETE = "assist_gesture_setup_complete";
        /**
         * Whether the assistant can be triggered by a touch gesture.
         *
         * @hide
         */
        public static final String ASSIST_TOUCH_GESTURE_ENABLED =
                "assist_touch_gesture_enabled";
        /**
         * Whether the assistant can be triggered by long-pressing the home button
         *
         * @hide
         */
        public static final String ASSIST_LONG_PRESS_HOME_ENABLED =
                "assist_long_press_home_enabled";
        /**
         * Control whether Trust Agents are in active unlock or extend unlock mode.
         * @hide
+2 −0
Original line number Diff line number Diff line
@@ -123,6 +123,8 @@ message SecureSettingsProto {
        optional SettingProto gesture_silence_alerts_enabled = 7 [ (android.privacy).dest = DEST_AUTOMATIC ];
        optional SettingProto gesture_wake_enabled = 8 [ (android.privacy).dest = DEST_AUTOMATIC ];
        optional SettingProto gesture_setup_complete = 9 [ (android.privacy).dest = DEST_AUTOMATIC ];
        optional SettingProto touch_gesture_enabled = 10 [ (android.privacy).dest = DEST_AUTOMATIC ];
        optional SettingProto long_press_home_enabled = 11 [ (android.privacy).dest = DEST_AUTOMATIC ];
    }
    optional Assist assist = 7;

+2 −0
Original line number Diff line number Diff line
@@ -165,6 +165,8 @@ public class SecureSettingsValidators {
        VALIDATORS.put(Secure.ASSIST_GESTURE_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.ASSIST_GESTURE_WAKE_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.ASSIST_TOUCH_GESTURE_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.ASSIST_LONG_PRESS_HOME_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.VR_DISPLAY_MODE, new DiscreteValueValidator(new String[] {"0", "1"}));
        VALIDATORS.put(Secure.NOTIFICATION_BADGING, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.NOTIFICATION_DISMISS_RTL, BOOLEAN_VALIDATOR);
+6 −0
Original line number Diff line number Diff line
@@ -1881,6 +1881,12 @@ class SettingsProtoDumpUtil {
        dumpSetting(s, p,
                Settings.Secure.ASSIST_GESTURE_SETUP_COMPLETE,
                SecureSettingsProto.Assist.GESTURE_SETUP_COMPLETE);
        dumpSetting(s, p,
                Settings.Secure.ASSIST_TOUCH_GESTURE_ENABLED,
                SecureSettingsProto.Assist.TOUCH_GESTURE_ENABLED);
        dumpSetting(s, p,
                Settings.Secure.ASSIST_LONG_PRESS_HOME_ENABLED,
                SecureSettingsProto.Assist.LONG_PRESS_HOME_ENABLED);
        p.end(assistToken);

        final long assistHandlesToken = p.start(SecureSettingsProto.ASSIST_HANDLES);
+29 −13
Original line number Diff line number Diff line
@@ -209,6 +209,8 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
    private @TransitionMode int mNavigationBarMode;
    private ContentResolver mContentResolver;
    private boolean mAssistantAvailable;
    private boolean mLongPressHomeEnabled;
    private boolean mAssistantTouchGestureEnabled;

    private int mDisabledFlags1;
    private int mDisabledFlags2;
@@ -309,7 +311,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener,

            // Send the assistant availability upon connection
            if (isConnected) {
                sendAssistantAvailability(mAssistantAvailable);
                updateAssistantEntrypoints();
            }
        }

@@ -404,12 +406,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
            new Handler(Looper.getMainLooper())) {
        @Override
        public void onChange(boolean selfChange, Uri uri) {
            boolean available = mAssistManagerLazy.get()
                    .getAssistInfoForUser(UserHandle.USER_CURRENT) != null;
            if (mAssistantAvailable != available) {
                sendAssistantAvailability(available);
                mAssistantAvailable = available;
            }
            updateAssistantEntrypoints();
        }
    };

@@ -531,6 +528,13 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
        mContentResolver.registerContentObserver(
                Settings.Secure.getUriFor(Settings.Secure.ASSISTANT),
                false /* notifyForDescendants */, mAssistContentObserver, UserHandle.USER_ALL);
        mContentResolver.registerContentObserver(
                Settings.Secure.getUriFor(Settings.Secure.ASSIST_LONG_PRESS_HOME_ENABLED),
                false, mAssistContentObserver, UserHandle.USER_ALL);
        mContentResolver.registerContentObserver(
                Settings.Secure.getUriFor(Settings.Secure.ASSIST_TOUCH_GESTURE_ENABLED),
                false, mAssistContentObserver, UserHandle.USER_ALL);
        updateAssistantEntrypoints();

        if (savedState != null) {
            mDisabledFlags1 = savedState.getInt(EXTRA_DISABLE_STATE, 0);
@@ -823,7 +827,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
                || mNavigationBarView.getHomeButton().getCurrentView() == null) {
            return;
        }
        if (mHomeButtonLongPressDurationMs.isPresent()) {
        if (mHomeButtonLongPressDurationMs.isPresent() || !mLongPressHomeEnabled) {
            mNavigationBarView.getHomeButton().getCurrentView().setLongClickable(false);
            mNavigationBarView.getHomeButton().getCurrentView().setHapticFeedbackEnabled(false);
            mNavigationBarView.getHomeButton().setOnLongClickListener(null);
@@ -845,6 +849,8 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
        pw.println("  mStartingQuickSwitchRotation=" + mStartingQuickSwitchRotation);
        pw.println("  mCurrentRotation=" + mCurrentRotation);
        pw.println("  mHomeButtonLongPressDurationMs=" + mHomeButtonLongPressDurationMs);
        pw.println("  mLongPressHomeEnabled=" + mLongPressHomeEnabled);
        pw.println("  mAssistantTouchGestureEnabled=" + mAssistantTouchGestureEnabled);

        if (mNavigationBarView != null) {
            pw.println("  mNavigationBarWindowState="
@@ -1206,9 +1212,11 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
                        return true;
                    }
                }
                if (mLongPressHomeEnabled) {
                    mHomeButtonLongPressDurationMs.ifPresent(longPressDuration -> {
                        mHandler.postDelayed(mOnVariableDurationHomeLongClick, longPressDuration);
                    });
                }
                break;
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
@@ -1480,15 +1488,23 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
                | (requestingServices >= 2 ? SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE : 0);
    }

    private void sendAssistantAvailability(boolean available) {
    private void updateAssistantEntrypoints() {
        mAssistantAvailable = mAssistManagerLazy.get()
                .getAssistInfoForUser(UserHandle.USER_CURRENT) != null;
        mLongPressHomeEnabled = Settings.Secure.getInt(mContentResolver,
                Settings.Secure.ASSIST_LONG_PRESS_HOME_ENABLED, 1) != 0;
        mAssistantTouchGestureEnabled = Settings.Secure.getInt(mContentResolver,
                Settings.Secure.ASSIST_TOUCH_GESTURE_ENABLED, 1) != 0;
        if (mOverviewProxyService.getProxy() != null) {
            try {
                mOverviewProxyService.getProxy().onAssistantAvailable(available
                mOverviewProxyService.getProxy().onAssistantAvailable(mAssistantAvailable
                        && mAssistantTouchGestureEnabled
                        && QuickStepContract.isGesturalMode(mNavBarMode));
            } catch (RemoteException e) {
                Log.w(TAG, "Unable to send assistant availability data to launcher");
            }
        }
        reconfigureHomeLongClick();
    }

    // ----- Methods that DisplayNavigationBarController talks to -----