How to Force ‘OK Google’ Hotword Detection to work when the Screen is Off on any Device [Root]: Hotword Detection is a wonderful feature that was first introduced by Moto X in 2013. Soon, many more brands offered this feature into the upcoming models. Hotword Detection is an exciting feature that allows you control Google with your voice commands. This is especially useful when your hands are engaged such as when you are driving. You can also access Google Maps while driving by just a simple voice command.
Hotword Detection requires a special piece of hardware to come with your device. It is a voice recognition chip that allows your device to respond to voice commands. Unfortunately, it is still not available on all the devices. However, you can still avail this feature via ‘OK Google’. But, it works only when the device is connected to a charger or when the screen in on. Let us learn a simple trick to enable ‘OK Google’ even when the screen is off.
How to Force ‘OK Google’ Hotword Detection to work when the Screen is Off on any Device [Root]
When the hardware that supports ‘hotword recognition’ is absent on a device, the only solution is to trick the device. “Ok Google” can work on all the devices under two conditions irrespective of the presence of the desired hardware. The first condition is when the screen is one and second condition is when the device is plugged in for charging. Thus, we need to find a trick that can fool a device into believing that it is in either of two states all the time.
One of the best possible tricks to make your device think that it is charging is to use debug shell command. This command is meant to be used for testing a device but it can be safely used as part of the trick. The command that will be used in the trick is “dumpsys battery”. The use of this command conveys a wrong message to the applications in your device that are monitoring the status or charging. There are three different versions of the command with a minor difference. If you want to make your device think that it is being charged via AC power, you need to use the following command:
su dumpsys battery set ac 1
Similarly, there are two more versions of this command to make your device think that it is being charged via USB or a wireless charger. It does not make any difference, which of the three commands you use. All of them serve the purpose equally well. This is one of the ways make Google’s hotword work even when the screen is off, on a device that lacks the supporting hardware.
Here, it is important to understand that using this command is not normal for any device. This command is meant to be used by the developers to check the response of the device under different charging inputs. Thus, it can result in a couple of drawbacks.
Drawback #1 – Frozen Battery Indicator
Every Android device comes with a BatteryManager Service. This service collects and reports the status of the battery in terms of the health, voltage, current, temperature and battery level. When you run the above command on your device the BatteryManager Service stops working. The services enter into a ‘frozen mode’ where the applications stop to collect any data regarding the status of the battery.
The problem with this mode is that you will not receive any notification regarding the problems in the status of the battery. The good thing about the problems is that it can be rectified easily. Even when you do not receive any notification, the data regarding the status of the battery is still being collected all the time. You just need to find a way to get access to this information. This can be done with the help of an automation application such as Tasker. It can be enabled to receive notifications for any text stored in /sys/class/power_supply/battery/capacity.
Another important thing that you need to consider here is that you do not need to use the trick when the screen is in on state. Thus, you can be smart and disable this command when the screen is turned on. This will allow you to stay away from all the drawbacks that were occurring due to activating the command. Most importantly, “OK Google” will still be working perfectly.
The above command can be most easily disabled by using the automation app such as Tasker. You will need to run the following command:
dumpsys battery reset
You can set up the Tasker profile to enable command when the screen is off and disable it when the screen is turned on.
You will need to create two “Event” contexts. One for the ‘Display Unlocked” Event and other for the “Display Off” Event. With the “Display Off” event, you need to go to “Run Shell” in the Code (Code-> Run Shell) and enter the following command:
dumpsys battery set ac 1
In the same way, you will need to enter a command in “Run Shell” (Code–>Run Shell) for the “Display Unlocked” Event. The command is as follows:
dumpsys battery reset
This will automatically enable and disable the command when the screen of your device is switched between ‘On’ and ‘Off’ mode.
Drawback #2 – Increased Battery Drain
The second drawback of running this trick is that it leads to draining of your battery. This happens because the Hotword Detection requires some additional apps to run all the time in the background. These additional applications draw extra power from the battery assuming that it is being plugged into an external power supply or charger. The performance of your battery can reduce by 15 to 20% when the command is enabled for a duration of 12 hours.
Unlike the first drawback, there is no way you can avoid this drawback. You will have to deal with the reduced battery life. The problem can be reduced to some extent by disabling the command while the screen is on. However, mostly the screen of your device is off. Thus, the power saving achieved through this method is very less.