Startinstrumentation asks to run as User-2 are calling from user 0; This requires Android.permission.INTERACT_ACROSS_USERS_FULL

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.