force ok google when screen off

Voice commands and digital assistants are the new faces of the smartness in smartphones. Operating your smartphone with voice commands is quite useful, and it’s also pretty cool. You can just say a magic word, and it opens Google Maps on your docked phone in the car or play songs while you’re in the shower. “OK Google” is one such great voice assistant (Google Assistant in Pixel devices) from Google which delivers excellent voice interface with your smartphone. Unfortunately, not all devices support “OK Google” detection while the screen if OFF due to lack of supported hardware. Luckily, you can now force “OK Google” detection on any device while the screen is OFF.

Folks over at XDA developers have come up with this beautiful theory on how to make “OK Google” available all the time. Well, the theory actually works in real time and we’ve tried it on our devices. Before we force “OK Google” detection on your device, let’s just see how it works.

How “OK Google” Works?

You need a special hardware on your device to make “OK Google” work all the time. If you do not have such hardware, there are only two options for this to work – either your device should be plugged into a power source, or the screen should be ON. Well, both the options are pretty useless as plugging your device into a power source all the time beats the purpose of the mobile device. Moreover, you don’t want to leave your screen ON all the time resulting in battery drain. But if you can make your device think it’s either charging, you can force “OK Google” to work even when the screen is OFF.

Here comes the Android debug commands into the show. There is a debug command called “dumpsys battery” which can be used to make your device think it’s charging even though it’s not. You can do this by giving a shell command “dumpsys battery set ac 1” but there are drawbacks with this method. Firstly, the battery icon in the status bar will be frozen, and the data will not be refreshed for other apps. You can easily overcome this with another command “dumpsys battery reset” when the screen is ON. The other drawback is an increase in battery drain even though it’s not much. On my OnePlus 3, it’s just a few minutes difference in battery life which is not much for me.

How to Force “OK Google” detection on All devices

Well, so you need to run two commands to get this working, but it would be stupid to enter them manually every time you turn ON/OFF your device. So, we’ll use an automation app like Tasker to get this working. Also, you’ll need root on your device for these commands to work. So, make sure to root your device before following the below steps.

  1. Install the Tasker app from the Google Play Store link below. You can also use any other automation app for Android.
    Tasker Price: $2.99
  2. Open Tasker app, click on “Plus (+)” button at the bottom. Then, click on Event » Display » Display OFF and then hit back.
    create profile tasker
  3. Now, it’ll ask for creating a new task. Click on New Task » Code » Run Shell. Enter the command “dumpsys battery set ac 1” and tick the checkbox next to “Use root.”
    force ok google tasker profile
  4. Similarly, you need to create a profile for Display ON. Click on Event » Display » Display ON and then hit back. Click on New Task » Code » Run Shell. Enter the command “dumpsys battery reset” and tick the checkbox next to “Use root.”
    disable ok google
  5. Finally, you’ll see something like the below screenshot with two profiles.
    enable tasker
  6. Enable Tasker from its menu. That’s it you’re done.
    enable tasker
  7. Turn off your screen and say “OK Google” and the voice assistant should pop up. If it didn’t, make sure “From any screen” and “Trusted voice” are enabled in “OK Google” settings.

That’s it, folks. You can now open up maps or play music on any device even with the screen is OFF.