Skip to content

Instantly share code, notes, and snippets.

@mrk-han
Last active May 18, 2024 03:51
Show Gist options
  • Save mrk-han/67a98616e43f86f8482c5ee6dd3faabe to your computer and use it in GitHub Desktop.
Save mrk-han/67a98616e43f86f8482c5ee6dd3faabe to your computer and use it in GitHub Desktop.
Enable and Disable Android Accessibility Settings from the Command Line using ADB (Font scale, talkback, color blind)

Using ADB to control Accessbility settings for easier testing with Android Emulators + Real Devices

It's a lot easier to test accessibility on the fly using ADB. This gist attempts to make the days of navigating through the Android device settings UI to change Accessibility settings obsolete.

These ADB commands will hopefully encourage Android developers to test and use their apps with common Accessiblility settings enabled.

Credit to James Nitsch for inspiring this, and for figuring out the put commands to enable these settings.

Font Scale (Font Size -- Testing Dynamic Text)

adb shell settings put system font_scale 0.85 (small)

adb shell settings put system font_scale 1.0 (default)

adb shell settings put system font_scale 1.15 (large)

adb shell settings put system font_scale 1.30 (largest)

adb shell settings put system font_scale 2.0 (sizes like this can only be achieved with custom adb setting, not from ui)

Talkback

disable talkback

adb shell settings put secure enabled_accessibility_services com.android.talkback/com.google.android.marvin.talkback.TalkBackService

enable talkback

adb shell settings put secure enabled_accessibility_services com.google.android.marvin.talkback/com.google.android.marvin.talkback.TalkBackService

Color

Properties:

accessibility_display_daltonizer_enabled=1
accessibility_display_daltonizer=11
accessibility_display_daltonizer=12
accessibility_display_daltonizer=13

Examples:

adb shell settings put secure accessibility_display_daltonizer_enabled 1

adb shell settings put secure accessibility_display_daltonizer 0

adb shell settings put secure accessibility_display_daltonizer 11

adb shell settings put secure accessibility_display_daltonizer 12

adb shell settings put secure accessibility_display_daltonizer 13

0 == Monochromatic
11 is for Deuteranomaly (red-green)
12 is for Protanomaly (red-green)
13 is for Tritanomaly (blue-yellow)

Color Inversion

Property: accessibility_display_inversion_enabled=1

ADB Command: adb shell settings put secure accessibility_display_inversion_enabled 1

High Contrast Text

Property: high_text_contrast_enabled=1

ADB Command: adb shell settings put secure high_text_contrast_enabled 1

Magnification

Set: adb shell settings put secure accessibility_display_magnification_scale 5.0

Enable: adb shell settings put secure accessibility_display_magnification_enabled 1

Disable: adb shell settings put secure accessibility_display_magnification_enabled 0

List Existing Properties

adb shell settings list system
adb shell settings list global
adb shell settings list secure

Also, adb shell getprop is a great way to expose a lot of other properties you can change with the adb shell setprop functionality

Show Touches

adb shell settings put system show_touches 1

Pointer Location

adb shell settings put system pointer_location 1

https://developer.android.com/reference/android/provider/Settings

@msenyer
Copy link

msenyer commented Jul 11, 2023

Hi everyone! I just wanted to pass by to let you know I found what I was looking for, hope this may help someone in the future.
This was my problem:

Hi, maybe this is not exactly related with what you posted but I thought you might be able to help me. How would you disable the "TalkBack shortcut", on the TalkBack accessibility menu? Thank you in advance @mrk-han

And I wanted it to be solved with and adb command.

Screenshot_2023-07-11-16-35-46-072

I needed this "talkback shortcut" to be programmatically turned off.

The command adb shell settings put secure accessibility_shortcut_target_service null does the job :)

Thank you all for your help in this process, I finally found it.

@mrk-han
Copy link
Author

mrk-han commented Jul 12, 2023

@msenyer Thank you for the update! This is great info. Maybe when I find time I'll revise this document. Much appreciated.

@artmrch
Copy link

artmrch commented Aug 23, 2023

adb shell settings list secure

give me nothing

@qbalsdon
Copy link

@artmrch does the device appear when you use adb devices?

List of devices attached
[DEVICE_SERIAL_NUMBER]	device

Note it must have 'device' next to it, if it says anything else (for example, 'unauthorized') then there are other steps you need to take

I'm not sure of your experience level, so I apologize if you have done these, but it's good to check:

  1. Have you installed adb
  2. Put adb on the path
  3. Turned on developer mode on the phone and after plugging it in with a cable, opt in to trust the computer

@artmrch
Copy link

artmrch commented Aug 23, 2023

yes it shows

i did daltonizer color already
and its great
couldnt find any app to do it

but i cant check if there are more settings with

settings list

@qbalsdon
Copy link

Another thing you can try is:

  1. adb shell [press enter to enter the phone shell]
  2. settings list secure [while in the shell]
    2.1 settings list global [to see if you can get the global settings]
  3. exit [when you're done]

If there is an error getting the secure settings, try getting the global settings. Also if there is another profile (for work or whatever) that may be preventing you from getting access

@artmrch
Copy link

artmrch commented Aug 24, 2023

no error, just nothing

how do i check that something preventing it
daltonizer, zoom, contrast work like a charm
i just got interested what else i can do

like remove all the shadows from layers and pop-up massages

@mrk-han
Copy link
Author

mrk-han commented Aug 25, 2023

@artmrch Some of the settings are dependent on which device/emulator you are using.

@artmrch
Copy link

artmrch commented Sep 17, 2023

@artmrch Some of the settings are dependent on which device/emulator you are using.

flymeos 5.1.5.3G

it seems that settings command have no
'list' option :/

anyway, i have found some other great accessabillity commands

-- accelerometer_rotation --

adb shell settings put system accelerometer_rotation 0

adb shell settings put system user_rotation 0,1,2,3

0 - portaite
1 - 90' (landscape)
2 - 180' (reverse portait)
3 - 270' (reverse landscape)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment