android靜默root
⑴ 檢測Android手機是否具有root許可權和靜默安裝
樓主想檢測手機有沒有root的話可以下載一個電腦版的應用寶,用數據線連接手機和電腦,打開手機系統設置-開發人員選項-USB調試,連接成功之後再我的手機工具箱裡面點擊一鍵root。如果手機已經獲取成功,會顯示手機已處於root狀態,繼續的話就可以解除了,如果手機沒有獲取成功,會顯示獲取許可權的過程,至於靜默安裝一般是在手機的市場裡面進行設置的,希望幫到你
⑵ Android 靜默安裝和自啟動(1、Root環境下)
各種以android硬體平台為基礎的【公示屏】、【廣告屏】等等,雖然很少有升級,但是不可避免的會遇到,而此類APP的使用場景,一般沒人會去幫助你版本更新,點擊安裝,故而需要:靜默安裝。
1、確認安裝包是否存在,並可讀寫
2、隱示啟動:action和data的schema來控制彈出安裝工具類APP,然後點擊安裝...
3、升級完:BootReceiver 監聽到Intent.ACTION_PACKAGE_REPLACED,然後自啟動
靜默安裝apk介面,無需開放root,也無需system許可權。
⑶ android在root許可權下實現apk的靜默卸載,靜默安裝,重啟
1.靜默卸載實現:
/**
* 靜默卸載app
*
* @param context
* @param packageName app的包名
* @throws IOException
* @throws InterruptedException
*/
public static void uninstallApp(Context context, String packageName) throws IOException, InterruptedException {
List<PackageInfo> packageInfos = context.getPackageManager().getInstalledPackages(PackageManager.GET_ACTIVITIES);
for (PackageInfo packageInfo1 : packageInfos) {
if (packageName.equals(packageInfo1.packageName)) {
String suPath = "/system/xbin/su";
File file = new File(suPath);
if (!file.exists()) {
suPath = "/system/bin/su";
}
Process process = Runtime.getRuntime().exec(suPath);
String cmd = "pm uninstall " + packageName + "\n" + "exit\n";
process.getOutputStream().write(cmd.getBytes());
process.waitFor();
break;
}
}
}
2.靜默安裝實現:
/**
* 靜默安裝app
*
* @param filePath
* @throws IOException
* @throws InterruptedException
*/
public static void installApp(String filePath) throws IOException, InterruptedException {
String suPath = "/system/xbin/su";
File file = new File(suPath);
if (!file.exists()) {
suPath = "/system/bin/su";
}
Process process = Runtime.getRuntime().exec(suPath);
String cmd = "pm install -r " + filePath + "\n" + "exit\n";
process.getOutputStream().write(cmd.getBytes());
process.waitFor();
}
最後加上重啟命令:
/**
* 重啟系統
*
* @return
*/
public static boolean reboot() {
try {
String suPath = "/system/xbin/su";
File file = new File(suPath);
if (!file.exists()) {
suPath = "/system/bin/su";
}
Process process = Runtime.getRuntime().exec(suPath);
String cmd = "reboot\nexit\n";
process.getOutputStream().write(cmd.getBytes());
return true;
} catch (IOException error) {
return false;
}
}
注意卸載和安裝需要在子線程中執行;如果單純關機則用「reboot -p」命令。
⑷ android如何實現靜默安裝哦
原理
靜默安裝、卸載的原理就是利用pm install命令來安裝apk,pm uninstall 來卸載apk.
智能安裝是利用android系統提供的無障礙服務AccessibilityService,來模擬用戶點擊,從而自動安裝.
java">//靜默安裝
privatevoidinstallSlient(){
Stringcmd="pminstall-r/mnt/sdcard/test.apk";
Processprocess=null;
DataOutputStreamos=null;
BufferedReadersuccessResult=null;
BufferedReadererrorResult=null;
StringBuildersuccessMsg=null;
StringBuildererrorMsg=null;
try{
//靜默安裝需要root許可權
process=Runtime.getRuntime().exec("su");
os=newDataOutputStream(process.getOutputStream());
os.write(cmd.getBytes());
os.writeBytes(" ");
os.writeBytes("exit ");
os.flush();
//執行命令
process.waitFor();
//獲取返回結果
successMsg=newStringBuilder();
errorMsg=newStringBuilder();
successResult=newBufferedReader(newInputStreamReader(process.getInputStream()));
errorResult=newBufferedReader(newInputStreamReader(process.getErrorStream()));
Strings;
while((s=successResult.readLine())!=null){
successMsg.append(s);
}
while((s=errorResult.readLine())!=null){
errorMsg.append(s);
}
}catch(Exceptione){
e.printStackTrace();
}finally{
try{
if(os!=null){
os.close();
}
if(process!=null){
process.destroy();
}
if(successResult!=null){
successResult.close();
}
if(errorResult!=null){
errorResult.close();
}
}catch(Exceptione){
e.printStackTrace();
}
}
//顯示結果
tvTest.setText("成功消息:"+successMsg.toString()+" "+"錯誤消息:"+errorMsg.toString());
}
⑸ android沒有root的情況下怎麼實現靜默安裝
手機ROOT方法:x0dx0a1、下載安裝KingRoot 電腦版x0dx0a2、用USB數據線連接手機Root過程中,保持手機連接PCx0dx0a3、按提示開始Root操作整個過程需要5-10分鍾x0dx0a4、Root成功!x0dx0ax0dx0a註:手機ROOT之後是不在保修條約裡面的,需要解除ROOT許可權即可。