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权限即可。