0
我如何才能冻结/解冻根植设备上的应用程序,如钛备份应用程序,以便使我的应用程序无法从根设备访问。任何方法追踪设备是否植根?如何冻结扎根Android设备上的应用程序
我如何才能冻结/解冻根植设备上的应用程序,如钛备份应用程序,以便使我的应用程序无法从根设备访问。任何方法追踪设备是否植根?如何冻结扎根Android设备上的应用程序
我使用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();
您实际上可以尝试运行root命令并捕获响应并确定该设备是否已生根。
从here以代码并修改它一点点地满足您的需求,我认为这可能是这样的:
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;
}
我没有测试过这一点,但我敢肯定,它会帮助你。或者至少它会以正确的方式指出你。
你知道,如果还有检查它是否是“冻结”的方法吗? – NoBugs 2013-06-28 03:11:50
为什么使用'CommandCapture'时,它是'Command'的扩展名,用于保存输出? http://code.google.com/p/roottools/source/browse/trunk/Developmental/RootTools_sdk3_generic/src/com/stericson/RootTools/Command.java?r=208 – NoBugs 2013-06-28 03:16:38