[英]How to freeze applications on rooted android device
我如何凍結/取消凍結 root用戶設備(如Titanium Backup應用程序)上的應用程序,以便無法從root用戶設備訪問我的應用程序。 有什么方法可以跟蹤設備是否已植根?
我正在使用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命令並捕獲響應並確定設備是否已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;
}
我尚未對此進行測試,但是我相信它將為您提供幫助。 或至少它將以正確的方式指出您。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.