执行;APOPS集合“;来自Android应用程序的命令失败

执行;APOPS集合“;来自Android应用程序的命令失败,android,Android,我想测试一个应用程序是否可以忽略其他应用程序的阅读短信权限,主要活动的源代码是 ... ShellExecuter se = new ShellExecuter(); ... protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_applist); ignPermission("co

我想测试一个应用程序是否可以
忽略
其他应用程序的
阅读短信
权限,主要活动的源代码是

...
ShellExecuter se = new ShellExecuter();
...
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_applist);

    ignPermission("com.vrs.smsapp", "READ_SMS");
}

private void ignPermission(String pkg, String perm) {
    String cmd = "appops set " + pkg + " " + perm + " ignore";
    String res = se.Execute(cmd);
    Log.d(LOGTAG, "cmd: " + cmd + ", res: " + res);
}
类的代码
ShellExecuter

public class ShellExecuter {

    public String Execute(String cmd) {
        StringBuffer output = new StringBuffer();

        Process p;
        try {
            p = Runtime.getRuntime().exec(cmd);
            p.waitFor();
            BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));

            String line = "";
            while ((line = reader.readLine()) != null) {
                output.append(line + "\n");
            }
        } catch (Exception e){
            e.printStackTrace();
        }
        String response = output.toString();
        return response;
    }
}
日志文件将是

cmd:appops set com.vrs.smsapp READ_SMS ignore,res:

但是,运行此应用后,权限仍然存在:

$ adb shell appops get com.vrs.smsapp
READ_SMS: allow; time=+30s557ms ago
READ_ICC_SMS: allow; time=+30s557ms ago
READ_EXTERNAL_STORAGE: allow; time=+1m9s309ms ago
WRITE_EXTERNAL_STORAGE: allow; time=+1m9s309ms ago
如果我在macbook的终端上运行该命令,它将成功:

$ adb shell appops set com.vrs.smsapp READ_SMS ignore
$ adb shell appops get com.vrs.smsapp
READ_SMS: ignore; time=+20m38s355ms ago
READ_ICC_SMS: allow; time=+20m38s355ms ago; rejectTime=+13m11s708ms ago
READ_EXTERNAL_STORAGE: allow; time=+13m14s688ms ago
WRITE_EXTERNAL_STORAGE: allow; time=+13m14s688ms ago
我想知道如何更改我的程序以控制其他应用程序的权限