5

I have this adb shell command for android and tried with the terminal and it's working perfectly.

But not sure how to use this in a framework using appium command.

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

// enable
adb shell settings put secure enabled_accessibility_services com.google.android.marvin.talkback/com.google.android.marvin.talkback.TalkBackService
J.Adhikari
  • 125
  • 1
  • 13

3 Answers3

1

I am able to use abd command in java in the following way. Hope its helps you too.

String disable= "adb shell settings put secure enabled_accessibility_services com.android.talkback/com.google.android.marvin.talkback.TalkBackService"
String enable = "adb shell settings put secure enabled_accessibility_services com.google.android.marvin.talkback/com.google.android.marvin.talkback.TalkBackService"
try{
       Runtime.getRuntime().exec(disable); //to disable
   //    Runtime.getRuntime().exec(enable);  //to enable
}catch(Exception e){
      e.printStackTrace();
}
Suban Dhyako
  • 2,436
  • 4
  • 16
  • 38
0

You can use mobile:shell in Appium to execute ADB commands:

You must start Appium server with security key: appium --relaxed-security

Then you do it like:

List<String> args = Arrays.asList(
   arg1,
   arg2,
   ...
   argN
);
Map<String, Object> yourCmd = ImmutableMap.of(
    "command", <adbCommand>,
    "args", args
);
driver.executeScript("mobile: shell", yourCmd);

I'm not sure about settings put operation, but pull/push/rm works perfectly.

Wasiq Bhamla
  • 949
  • 1
  • 7
  • 12
dmle
  • 3,498
  • 1
  • 14
  • 22
0

this works for me.

const { exec } = require('child_process');

exec('adb shell settings put secure enabled_accessibility_services com.google.android.marvin.talkback/com.google.android.marvin.talkback.TalkBackService', (err, stdout, stderr) => {
        if (err) {
          return;
        }
});
J.Adhikari
  • 125
  • 1
  • 13