一、概述:
1、iphone越狱,android root都是根据系统漏洞才能获取
2、其实是根据 su 获得系统的手机的超级权限
二、步骤:
1、进入E:\android-sdk\platforms\android-10\images,找到system.img镜像文件
2、打开yaffs2img浏览器.exe
3、选取镜像文件
4、把su文件拷贝到bin目录下
5、修改权限0755为4755,其他用户拥有root权限
6、使用superuser.apk,导入到app文件夹(superuser.apk获取root的最后防线)
修改权限0755为4755
7、整理导出
8、拷贝到原来的目录下E:\android-sdk\platforms\android-10\images,覆盖原来的system.img文件
9、以 arm 方式 重启2.3模拟器
10、打开superuser.apk
11、进入cmd窗口,输入
>adb -s emulator-5554 shell
>su
12、创建页面
//变成超级用户,获得root权限
Runtime.getRuntime().exec(“su”);
/**
* @描述 获取root
* @项目名称 App_imooc
* @包名 com.android.imooc.async
* @类名 RootActivity
* @author chenlin
* @date 2012年6月11日 上午10:26:12
* @version 1.0
*/
public class RootActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_root);
}
public void getRoot(View view){
try {
//变成超级用户
Runtime.getRuntime().exec("su");
} catch (IOException e) {
e.printStackTrace();
}
}
}
布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="getRoot"
android:text="获取root" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="disable"
android:text="冻结程序" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="enable"
android:text="解冻程序" />
</LinearLayout>
13、冻结程序,解冻程序
拷贝roottools.jar到项目的libs目录
在主页写入下面代码:
public void enable(View view){
try {
RootTools.sendShell("pm enable com.android.game", 3000);
} catch (Exception e) {
e.printStackTrace();
}
}
public void disable(View view){
try {
RootTools.sendShell("pm disable com.android.game", 3000);
} catch (Exception e) {
e.printStackTrace();
}
}
14、工具类下载:
链接:http://pan.baidu.com/s/1i5lmb33 密码:s40n