简体   繁体   English

如何冻结root用户的Android设备上的应用程序

[英]How to freeze applications on rooted android device

How can I Freeze/Unfreeze applications on the rooted device like Titanium Backup app so that i make my app non-accessable from a rooted device. 我如何冻结/取消冻结 root用户设备(如Titanium Backup应用程序)上的应用程序,以便无法从root用户设备访问我的应用程序。 Any method to trace whether the device is rooted or not? 有什么方法可以跟踪设备是否已植根?

i am using RootTools library to do disable/enable command 我正在使用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();

You could actually try to run a root command and catch the response and determine if the device is rooted. 您实际上可以尝试运行root命令并捕获响应并确定设备是否已root。

Taking code from here and modifying it a little to suit your needs, I think it could go like this: 这里获取代码并对其进行一些修改以满足您的需求,我认为它可能像这样:

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;
       }

I have not tested this but I'm sure it will help you. 我尚未对此进行测试,但是我相信它将为您提供帮助。 Or at least it will point you in the right way. 或至少它将以正确的方式指出您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM