Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何冻结根安卓设备上的应用程序_Android_Root_Android Package Managers - Fatal编程技术网

Android 如何冻结根安卓设备上的应用程序

Android 如何冻结根安卓设备上的应用程序,android,root,android-package-managers,Android,Root,Android Package Managers,如何冻结/解冻根设备上的应用程序(如Tianium Backup应用程序),使我的应用程序无法从根设备访问。有没有跟踪设备是否为根目录的方法?您实际上可以尝试运行root命令并捕获响应并确定设备是否为根目录 从中提取代码并稍作修改以满足您的需要,我认为可以如下所示: public static boolean canRunRootCommands() { boolean retval = false; Process suProcess;

如何冻结/解冻根设备上的应用程序(如Tianium Backup应用程序),使我的应用程序无法从根设备访问。有没有跟踪设备是否为根目录的方法?

您实际上可以尝试运行root命令并捕获响应并确定设备是否为根目录

从中提取代码并稍作修改以满足您的需要,我认为可以如下所示:

public static boolean canRunRootCommands()
       {
          boolean retval = false;
          Process suProcess;

          try
          {
             suProcess = Runtime.getRuntime().exec("su");

             DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());
             DataInputStream osRes = new DataInputStream(suProcess.getInputStream());

             if (null != os && null != osRes)
             {
                retval = true;

                /*
                 *if got to this point, its safe to assume the 
                 *device is rooted and here you can do something 
                 *to tell your app that su is present. Or you could 
                 *use the bool return of this function to know that the 
                 *device is rooted and make the app act different.
                 */

             }
          }
          catch (Exception e)
          {
             // Can't get root !
             // [...] meaning that the device is not rooted

             retval = false;
          }

          return retval;
       }

我还没有测试过这个,但我相信它会帮助你。或者至少它会为您指明正确的方向。

您实际上可以尝试运行root命令并捕获响应并确定设备是否为root

从中提取代码并稍作修改以满足您的需要,我认为可以如下所示:

public static boolean canRunRootCommands()
       {
          boolean retval = false;
          Process suProcess;

          try
          {
             suProcess = Runtime.getRuntime().exec("su");

             DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());
             DataInputStream osRes = new DataInputStream(suProcess.getInputStream());

             if (null != os && null != osRes)
             {
                retval = true;

                /*
                 *if got to this point, its safe to assume the 
                 *device is rooted and here you can do something 
                 *to tell your app that su is present. Or you could 
                 *use the bool return of this function to know that the 
                 *device is rooted and make the app act different.
                 */

             }
          }
          catch (Exception e)
          {
             // Can't get root !
             // [...] meaning that the device is not rooted

             retval = false;
          }

          return retval;
       }
我还没有测试过这个,但我相信它会帮助你。或者至少它会为您指明正确的方向。

我正在使用RootTools库执行禁用/启用命令

CommandCapture command_enable = new CommandCapture(0,"pm enable "+ Package_Name);                           
RootTools.getShell(true).add(command_enable).waitForFinish();

CommandCapture command_disable = new CommandCapture(0,"pm disable "+ Package_Name);
RootTools.getShell(true).add(command_disable).waitForFinish();
我正在使用RootTools库执行禁用/启用命令

CommandCapture command_enable = new CommandCapture(0,"pm enable "+ Package_Name);                           
RootTools.getShell(true).add(command_enable).waitForFinish();

CommandCapture command_disable = new CommandCapture(0,"pm disable "+ Package_Name);
RootTools.getShell(true).add(command_disable).waitForFinish();

你知道有没有办法检查它是否“冻结”了吗?为什么要使用
CommandCapture
,而它是
Command
的扩展,用来保存输出?你知道有没有办法检查它是否“冻结”了吗?为什么要使用
CommandCapture
,而它是
Command
的扩展,用来保存输出?