Tooth uncle tutorial is easy to understand

Concept of accessibility

Accessibility services are applications that provide better accessibility to users who have disabilities or who are temporarily unable to fully interact with their devices, such as driving, taking care of a child, or who may need additional or alternative interactive feedback at a noisy party.

Android offers standard accessibility services, including TalkBack, where developers can create and distribute their own services.

The environment

Autojs version: 9.0.8 Android version: 11 Mobile phone: Mi 11 Pro

Detection barrier-free mode

1. Ordinary barrier-free detection
let am = context.getSystemService(android.content.Context.ACCESSIBILITY_SERVICE);
let isAccessibilityEnabled_flag = am.isEnabled();
log(isAccessibilityEnabled_flag);
Copy the code
2. Check TalkBack. 0 disables TalkBack and 1 enables TalkBack
// Check whether the barrier-free service is enabled in TalkBack mode let isExploreByTouchEnabled_flag = isScreenReaderActive(context); log(isExploreByTouchEnabled_flag); Function isScreenReaderActive(context) {function isScreenReaderActive(context) {function isScreenReaderActive(context) { Let SCREEN_READER_INTENT_ACTION ="android.accessibilityservice.AccessibilityService";
  let SCREEN_READER_INTENT_CATEGORY = "android.accessibilityservice.category.FEEDBACK_SPOKEN";
  let screenReaderIntent = new Intent(SCREEN_READER_INTENT_ACTION);
  screenReaderIntent.addCategory(SCREEN_READER_INTENT_CATEGORY);
  let screenReaders = context.getPackageManager().queryIntentServices(screenReaderIntent, 0);
  if (screenReaders == null || screenReaders.size() <= 0) {
    log("No service of TalkBack type");
    return false;
  }

  let hasActiveScreenReader = false;
  if (Build.VERSION.SDK_INT >= 26) {// The higher version can directly determine whether the service is enabledlen = screenReaders.size();
    for (var i = 0; i < len; i++) {
      screenReader = screenReaders.get(i);
      log(screenReader);
      hasActiveScreenReader |= isAccessibilitySettingsOn(
        context,
        screenReader.serviceInfo.packageName + "/"+ screenReader.serviceInfo.name ); }}else{Service let runningServices = new ArrayList(); let manager = context.getSystemService(Context.ACTIVITY_SERVICE); let services = manager.getRunningServices(java.lang.Integer.MAX_VALUE); varlen = services.size();
    for (var i = 0; i < len; i++) {
      service = runningServices.get(i);
      runningServices.add(service.service.getPackageName());
    }

    len = screenReaders.size();
    for (var i = 0; i < len; i++) {
      screenReader = screenReaders.get(i);
      if(runningServices.contains(screenReader.serviceInfo.packageName)) { hasActiveScreenReader |= true; }}}return hasActiveScreenReader;
}

// To check service is enabled
function isAccessibilitySettingsOn(context, service) {
  let mStringColonSplitter = new TextUtils.SimpleStringSplitter(":");
  let settingValue = Settings.Secure.getString(
    context.getApplicationContext().getContentResolver(),
    Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES
  );
  if(settingValue ! = null) { mStringColonSplitter.setString(settingValue);while (mStringColonSplitter.hasNext()) {
      let accessibilityService = mStringColonSplitter.next(a);if (accessibilityService.equalsIgnoreCase(service)) {
        returntrue; }}}return false;
}
Copy the code

TalkBack uses tread pits

Click once = select, click twice after select = select, slide with two fingers

TalkBack concept

TalkBack is a screen reader built into Android devices. TalkBack will provide you with voice feedback to ensure you can use your mobile device even if your vision is impaired.

When you click the button or switch, you will be informed of the name of the button/switch in the form of voice, double-click the screen twice on the selected basis to open it.

You can also hold down the screen and drag to see what buttons/switches and other clickable controls the current page has.

TalkBack class name
com.google.android.marvin.talkback/com.google.android.marvin.talkback.TalkBackService 
Copy the code
The corresponding app

Testing way

Either blacklist or whitelist

  • Blacklist, is to block autoJS, easyclick, CTRLJS, Android development toolbox, and so on package names or other features
  • Whitelist, only allow xiaomi, Huawei, OnePlus, OpPO and other mobile phones built-in barrier-free services

Quotes.

Thinking is the most important, other Baidu, Bing, StackOverflow, Android documents, autoJS documents, and finally in the group to ask — fang Shu tutorial

The statement

This tutorial is intended for learning purposes only and is not intended for any other use