用超级用户构建Android

前端之家收集整理的这篇文章主要介绍了用超级用户构建Android前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
有没有人知道如何从源代码(AOSP)构建 android时包含超级用户权限?

解决方法

获取root(编辑)shell,请在android源代码中编辑system / core / rootdir或与您的设备相关联的init.rc(例如,pandaboard的device / ti / panda / init.rc),然后更改这些行:
service console /system/bin/sh
    class core
    console
    disabled
    user shell
    group log

成:

service console /system/bin/sh
    class core
    console
    disabled
    user root 
    group root

要在AOSP中嵌入Superuser.apk,您必须获取并构建:

> su-binary(例如在外部/)和存根/删除系统/ extras / su包中.
> Superuser(例如在包/应用程序/)

您还可能必须在su-binary / Android.mk中设置/ system / xbin / su的粘性位.例如,我使用以下makefile:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE := su
LOCAL_SRC_FILES := su.c db.c activity.cpp

SU_SHARED_LIBRARIES := liblog libsqlite
ifeq ($(PLATFORM_SDK_VERSION),4)
    LOCAL_CFLAGS += -DSU_LEGACY_BUILD
    SU_SHARED_LIBRARIES += libandroid_runtime
else
    SU_SHARED_LIBRARIES += libcutils libbinder libutils
    LOCAL_MODULE_TAGS := eng
endif

LOCAL_C_INCLUDES += external/sqlite/dist

LOCAL_SHARED_LIBRARIES := $(SU_SHARED_LIBRARIES)

LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)


SU_INSTALL_DIR := $(TARGET_OUT)/xbin
SU_BINARY := $(SU_INSTALL_DIR)/su
# taken from busyBox-android
$(SU_BINARY)-post: su
    @echo "Setting SUID/GUID to su-binary..."
    chmod ug+s $(TARGET_OUT_OPTIONAL_EXECUTABLES)/su

SU_CMD := su
SYMLINKS := $(addprefix $(TARGET_OUT_EXECUTABLES)/,$(SU_CMD))
$(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(SU_BINARY)-post $(LOCAL_PATH)/Android.mk
    @echo "Symlink: $@ -> /system/xbin/$(SU_CMD)"
    @mkdir -p $(dir $@)
    @rm -rf $@
    @ln -sf /system/xbin/$(SU_CMD) $@

ALL_DEFAULT_INSTALLED_MODULES += $(SU_BINARY)-post $(SYMLINKS)

include $(BUILD_EXECUTABLE)

猜你在找的Android相关文章