Merge "Revert "Revert "Add setting for touch gesture and long-press hom..."" into sc-dev

This commit is contained in:
Matt Casey
2021-03-30 14:23:10 +00:00
committed by Android (Google) Code Review
5 changed files with 55 additions and 13 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;
}
}
mHomeButtonLongPressDurationMs.ifPresent(longPressDuration -> {
mHandler.postDelayed(mOnVariableDurationHomeLongClick, longPressDuration);
});
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 -----