Since there is no Android level 17 and above on hand, there is a bug in shell command startup script that occurs at SDK level 17 and above
Api>=17 added Interact_across_users_full, which is designed to allow interaction between applications of different users, so that the userserialnumber is verified at interaction, and the user identity mismatch is found. Cause the permission check to fail, it will produce Startinstrumentation asks to run as User-2 but is calling from user 0; This requires Android.permission.INTERACT_ACROSS_USERS_FULL error, causing the script to fail to invoke
Group to try, found in version 17 and above, the command needs to add--user 0 parameters
public static final string[] Exec_device_command = {"/system/bin/am",
"Instrument", "--user", "0", "-w", "-E", "Class",
TestCase
"Packagename/instrumentationtestrunnername"};
Runtime runtime = Runtime.getruntime ();
Process proc = runtime.exec (cmd);
ADB shell AM Instrument--user 0-w packagename/instrumentationtestrunnername
You can use build.version.sdk_int<17 to make decisions about the current version at the time of invocation select the appropriate command line startup method
-------Record of learning
Startinstrumentation asks to run as User-2 are calling from user 0; This requires Android.permission.INTERACT_ACROSS_USERS_FULL