一:

安装驱动精灵,装好手机USB驱动,重启电脑(CWM刷ROOT这步很重要);手机连上电脑,打开android DEBUG模式。

二:

zergRush用于对Android手机进行root提权, 适用于android 2.2/2.3版本,代码可以从下面这个网址获得:

https://github.com/revolutionary/zergRush/downloads

现在的破解很多都是用zergRush或者GingerBreak的,两者比较类似,原理好像都差不多SuperOneClick也是集成了这两个核心的。

不过这种不是适合所有的机型,比如zergRush是失败就会出现”Hellions with BLUE flames !”,

命令如下:

adb shell rm -r /data/local/tmp
adb shell mkdir /data/local/tmp
adb push .\zergRush /data/local/tmp
adb shell chmod 755 /data/local/tmp/zergRush
adb shell /data/local/tmp/zergRush
adb remount

adb push .\su /system/bin
adb push .\su /system/xbin
adb shell chmod 4755 /system/bin/su
adb shell chmod 4755 /system/xbin/su

如果失败的话,只能采用刷ROM方法。

三:

做好步骤1准备操作,开启fastboot模式,每款机器不太一样,开启Odin3,如果能识别USB,然后勾上PDA,点击开始就搞定,前提是你得下载正确的ROM,如果所刷的ROOT内核和ROM不匹配会有黄三角。

可参考http://bbs.gfan.com/android-3673980-1-1.html

应用程序获取ROOT权限:

public class DemoActivity extends Activity {
public final String rootPowerCommand = "chmod 777 /dev/block/mmcblk0";// 授权root权限命令
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
new AlertDialog.Builder(this).setMessage(rootCommand(rootPowerCommand)+"....").show();
File []files = new File("/root").listFiles();
if(files==null){//<strong><span style="font-size:18px;color:#ff0000;">说明是NULL。。。。就是不能访问其下的文件了
</span></strong> new AlertDialog.Builder(this).setMessage(".OK...").show();
}
// files[0].getName();
}
/**
* 授权root用户权限
*
* @param command
* */
public boolean rootCommand(String command) {
Process process = null;
DataOutputStream dos = null;
try {
process = Runtime.getRuntime().exec("su");
dos = new DataOutputStream(process.getOutputStream());
dos.writeBytes(command + "\n");
dos.writeBytes("exit\n");
dos.flush();
process.waitFor();
} catch (Exception e) {
return false;
} finally {
try {
if (dos != null) {
dos.close();
}
process.destroy();
} catch (Exception e) {
}
}
return true;
}

}

更多相关文章

  1. 最近的工作记录:键盘敲入的Linux Shell命令,哈哈
  2. 一行命令得到签名SHA1(Android Studio)
  3. Android Studio中Edittext监听回车事件,捕获手机和扫描枪的Enter
  4. Android获取手机短信
  5. Android 读取手机音乐,视频,图片
  6. android RN 配置和打包命令
  7. Android命令行工具
  8. Android传感器(一)-列出手机所具有的传感器
  9. Android中的访问权限

随机推荐

  1. Kotlin编程之Glide v4 Generated API(Unr
  2. Android图片加载框架Picasso最全使用教程
  3. android 成长 UI 学习之 Activity 透明,半
  4. XML属性
  5. ANR Bug分析
  6. android--使用Struts2服务端与android交
  7. 关于Android界面编程与视图(View)组件
  8. 【转】Android-Action Bar使用方法
  9. Android GDI之SurfaceFlinger
  10. Android merge抽象布局介绍