Top Ad unit 728 × 90

How to enable “Hold for Assistant” gesture from Android 12 on older versions

Google’s big (virtual) I/O developer conference was held last week, and at the show, we were given teasers for all the new services and features that the Mountain View company is working on. The most exciting announcement for us was the big reveal of Android 12, and while the first beta release was missing a lot of promised features, it still had a lot for us to pore over. One of the new features that landed in Beta 1 is a gesture called “Hold for Assistant”, but as it turns out, the gesture itself isn’t actually new to Android. In fact, a method to enable it has been available in Android’s codebase as far back as Android 10, and we’re going to show you how to enable it.

You’ll find the new “Hold for Assistant” gesture tucked away under Settings > System > Gestures > Power menu in Android 12 Beta 1. When enabled, the feature lets the user “trigger the Assistant by holding the power button.” Depending on your device, a similar gesture may already exist, but a setting to enable this feature is at least new to Pixel phones.

the "hold for assistant' option in Android 12

Left: Press and Hold the Power Button settings in OxygenOS 11 on the OnePlus 9. Right: Power menu settings in Android 12 Beta 1 on the Google Pixel 5.

Using a simple ADB shell command, it’s possible to change the behavior of the long-press power button gesture on Android 10 and Android 11 to mimic Android 12’s “Hold for Assistant” gesture. The reason this is possible is because Google added code to Android that allows the long-press power button function to be tweaked at runtime. This code change was merged to Android in 2019 and is present in Android 10, as I’ve confirmed on my dedicated Google Photos upload machine Google Pixel XL. All you need to do is modify the value of Settings.Global.power_button_long_press and Settings.Global.power_button_very_long_press, two settings values that override the framework-defined values of config_longPressOnPowerBehavior and config_veryLongPressOnPowerBehavior respectively. The possible values for “power_button_long_press” and “power_button_very_long_press” are defined in AOSP under the PhoneWindowManager class. You don’t need to read up on any of these pages, though, as I’ll demonstrate how to change these values and what you can change them to.

Enable Android 12’s “Hold for Assistant” gesture on Android 10-11

This method may not work on all devices running Android 10 or Android 11. While we do know it works on Pixel phones, we don’t know if the changes that OEMs made to Android have blocked this method. Your mileage may vary!

  1. Install and set up ADB on your PC or LADB on your phone (Android 11 only). Either way works since all we need is access to Android’s shell interface with sufficient privileges to modify the Settings tables. (That means apps like “Material Terminal” off the Play Store won’t work unless you’ve got root access.)
  2. Run the following command in shell to change the behavior of long-pressing the power button:
    adb shell settings put global power_button_long_press X

    where “X” is one of the following:

    • “0” for “do nothing” (ie. long-pressing the power button does nothing)
    • “1” for “global actions” (ie. show the normal power menu)
    • “2” for “shut off” (ie. power down the phone)
    • “3” for “shut off no confirm” (ie. power down the phone immediately)
    • “4” for “go to voice assist” (launches the old Assistant UI with a top-down dialog and “search a song” button)
    • “5” for “assistant” (ie. launches the default Assistant service as defined in “Default Apps” under Settings)
  3. Run the following command in shell to change the behavior of very (3.5s) long-pressing the power button:
    adb shell settings put global power_button_very_long_press X

    where “X” is one of the following:

    • “0” for “do nothing” (ie. very long-pressing the power button does nothing)
    • “1” for “global actions” (ie. show the normal power menu)
  4. In order to not lock yourself out from accessing the power menu (as is currently the case when you enable “Hold for Assistant” in Android 12 Beta 1, interestingly!), I recommend running the above two commands with the following values:
    adb shell settings put global power_button_long_press 5
    adb shell settings put global power_button_long_press 1

    this will let you launch the Google Assistant (or whatever other Assistant app you’ve set as default) with a long-press of the power button for 0.5s while also letting you access the power menu with a very long-press of the power button for 3.5s.

  5. To revert back to the default behavior, simply change “power_button_long_press” to 1 and “power_button_very_long_press” to 0 or run the following commands:
    adb shell settings delete global power_button_long_press
    adb shell settings delete global power_button_long_press

In case you’re wondering, changing these values won’t affect the behavior of very, very, very long-pressing the power button (ie. force reboot the phone) which is a safety feature that can’t be disabled by the user.


As we recently spotted, the Google App is preparing to add its own support for the “Hold for Assistant” gesture. The feature is currently not available, but the latest version of the Google App has added a “talk to Google with the Power button” screen that informs the user that they’ll be able to long press the power button to access the Google Assistant. Interestingly, this screen also tells the user they’ll be able to power off the phone by telling Assistant to “power off”, a function that currently isn’t supported by Assistant.

Google App talk to Google Assistant with power button

We don’t know exactly how the Google App will implement this feature — whether it’s limited to Android 12 or if Google will use the built-in functionality mentioned above to enable it on Android 10 and Android 11. The Google App is currently missing the requisite permissions needed to do the above, and it’s also missing the permission needed for it to trigger a shutdown or reboot on the device. We’ll likely have to wait for newer versions of the Google App to come out, but rather than wait, you can run the ADB commands in this article to get Android 12’s “Hold for Assistant” gesture right now!

The post How to enable “Hold for Assistant” gesture from Android 12 on older versions appeared first on xda-developers.



from xda-developers https://ift.tt/3uiNpde
via IFTTT
How to enable “Hold for Assistant” gesture from Android 12 on older versions Reviewed by site on 15:06 Rating: 5

Aucun commentaire:

All Rights Reserved by xda © 2014 - 2015
Powered By Blogger, Designed by Sweetheme

Formulaire de contact

Nom

E-mail *

Message *

Fourni par Blogger.