Voice Access Back to main page

Voice Access, modified: technical notes.

What the patch changes, the firmware bug behind it, and how to install it with adb.

voiceaccess-autosave.apk · 5.7 MB · Voice Access 4.0.304676510
sha256 8e9c4731133fa9d36c52f57133ef93513d654855755f173dd9c1c561d2916f5f

PressThe popup records the key.
Let goIt saves and closes by itself.
DoneHold that key to start Voice Access.

The problem

In Voice Access settings, Configure activation key opens a popup. It records every key you press, then waits for you to tap OK. On a keypad-only phone, that fails two separate ways.

You can't reach OK

Keypad phones move popup buttons to the soft-key bar. Pressing "OK" sends a key press, and the popup records it as your new key. Every attempt to save overwrites your choice.

OK wouldn't save anyway

On the Sonim XP3900 we tested, a firmware bug makes the OK button on this kind of settings popup quietly throw your choice away. More on that below.

A USB mouse doesn't help either. The phone turns clicks into key presses too.

What the patch changes

One small part of the app, the key popup. Nothing else.

The key that opens the popup can't save itself by accident. The popup only saves on a release when the press also started inside it.

The bug hiding in the firmware

The first version of this patch was correct and still didn't save. Logging showed the key was captured and the save ran every time. The phone threw the value away at the last step.

Android settings popups remember which button you clicked, then check it when the popup closes. OK sets the value to -1. Stock Android checks for -1. This phone's firmware checks for -3, the "neutral" button:

# android.preference.DialogPreference.onDismiss, pulled from the phone
iget p1, p0, ...DialogPreference;->mWhichButtonClicked:I
const/4 v0, -0x3        # stock Android uses -0x1 here
if-ne p1, v0, :cancelled

So OK sets -1, the check looks for -3, and every save gets treated as a cancel. The popup closes and looks like it worked. This hits every settings popup of this type on the phone, not only Voice Access.

Why the patch works either wayThe patch skips the button check and calls the app's save step directly. It works on this firmware, on stock Android, and on any update that fixes the bug.

Install

You need a computer with Android platform-tools (adb) and USB debugging turned on in the phone's developer options.

1. Remove the original Voice Access

The modified app is signed with a different key than the original, so the original has to come off first. Its settings go with it.

adb uninstall com.android.cts.apps.accessibility.voiceaccess

2. Install the modified app

adb install voiceaccess-autosave.apk

3. Set it up on the phone

  1. Settings, Accessibility, Voice Access: turn it on.
  2. Allow the microphone and finish setup.
  3. In Voice Access settings: Configure activation key, then Activation key.
  4. Press and release the key you want. The popup closes by itself.

Turn Voice Access on from the phone itself. Don't flip accessibility settings over adb.

Check that it saved

The line under "Activation key" should now show your key, for example KEYCODE_SPEAKER. "No key assigned" means nothing saved.

If the key saves but holding it doesn't start Voice Access, the phone is using that key for something else first. Pick a different key. That's not a problem with the patch.

Will it work on my phone?

Check the app, not the phone model.

Tested onSonim XP3900 (TMO_XP3900), Android 11, 32-bit
Packagecom.android.cts.apps.accessibility.voiceaccess
Version4.0.304676510 (unchanged)
ChangedKeyComboPreference only. No resources, manifest, or other classes.
Original sha25691c07fd24999f1ca12f6cc24715451d5bf451370c7151ff08d84915651e51f71
Modified sha2568e9c4731133fa9d36c52f57133ef93513d654855755f173dd9c1c561d2916f5f

Going back

Keep your original APK. To undo, uninstall the modified app and install the original. The two are signed with different keys, so one can't install over the other. You'll set up Voice Access again either way.