Android5.0以上编译Root权限

来源:互联网 发布:laravel nginx 502 编辑:程序博客网 时间:2024/06/07 21:51
修改一下几个地方:
//mt6580为当前工程芯片,不同的选择不同目录,如mt6580,mt6735,mt6753
1.  alps\bootable\bootloader\lk\platform\mt6580\rules.mk
# choose one of following value -> 1: disabled/ 2: permissive /3: enforcing
SELINUX_STATUS := 1#此处改为1

2.  \alps\frameworks\base\cmds\app_process\app_main.cpp
int main(int argc, char* const argv[])
{
    //注释下面这个判断
//    if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) < 0) {
//        // Older kernels don't understand PR_SET_NO_NEW_PRIVS and return
//        // EINVAL. Don't die on such kernels.
//        if (errno != EINVAL) {
//            LOG_ALWAYS_FATAL("PR_SET_NO_NEW_PRIVS failed: %s", strerror(errno));
//            return 12;
//        }
//    }
}

3.  \alps\frameworks\base\core\jni\com_android_internal_os_Zygote.cpp
注释以下方法
static void DropCapabilitiesBoundingSet(JNIEnv* env) {
  /*for (int i = 0; prctl(PR_CAPBSET_READ, i, 0, 0, 0) >= 0; i++) {
    int rc = prctl(PR_CAPBSET_DROP, i, 0, 0, 0);
    if (rc == -1) {
      if (errno == EINVAL) {
        ALOGE("prctl(PR_CAPBSET_DROP) failed with EINVAL. Please verify "
              "your kernel is compiled with file capabilities support");
      } else {
        ALOGE("prctl(PR_CAPBSET_DROP) failed");
        RuntimeAbort(env);
      }
    }
  }*/
}

4.  \alps\system\core\init\Android.mk
增加红色代码
ifeq ($(strip $(MTK_BUILD_ROOT)),yes)
LOCAL_CFLAGS += -DALLOW_LOCAL_PROP_OVERRIDE=1 -DALLOW_DISABLE_SELINUX=1
endif

ifeq ($(strip $(TARGET_BUILD_VARIANT)),user)
LOCAL_CFLAGS += -DALLOW_DISABLE_SELINUX=1
endif

# add mtk fstab flags support
LOCAL_CFLAGS += -DMTK_FSTAB_FLAGS
# end


5.  \alps\system\core\adb\adb.c
这个方法直接return 0;
static int should_drop_privileges() {
//add by tomy @20150622 for enable root.
return 0;


改为后执行
make clean
make -j64重新new一遍.


在上面基础上更改root权限:

只需要注释第五步的return 0;就可以关闭adb remount
打开则开启.
只改这个只需要重新编译一遍adb模块及bootimage.
然后只要刷bootimage即可.

0 0