Application porting on Android devices is an important part of system development. Especially on embedded platforms like RK3568, pre-installing APK, system compilation, and permission management all require specific configurations and optimizations. This guide will provide a detailed introduction on how to complete Android application porting on the RK3568 platform, including key steps such as pre-installing and uninstalling APK and obtaining Root privileges, to help developers quickly adapt and customize the Android system.
Pre-installing Apps on the Android System
- Adding an APK file: Take dogdog.apk as an example:
Add an Android.mk file under the "dogdog" folder and write the relevant content for the dogdog.apk file.
Pre-installing Apps on the Android System
Add the Android. mk under the dogdog folder and write the dogdog. apk films.
Pre-installing Apps on the Android System
Android.mk writing method:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := dogdog
LOCAL_SRC_FILES := dogdog.apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := .apk
LOCAL_BUILT_MODULE_STEM := package.apk
LOCAL_CERTIFICATE := platform
LOCAL_DEX_PREOPT := false
LOCAL_PRIVILEGED_MODULE := ture
include $(BUILD_PREBUILT)
Guide to RK3568 Android Application Porting and System Customization
- Adding an installation configuration
Modify/OK3568-android11-source/device/rockchip/rk356x/ok3568_r/ok3568_r.mk
Add dogdog \
Guide to RK3568 Android Application Porting and System Customization
Compile again to generate update. img files, which can be flahsed and pre-installed apk normally.
Pre-installing Apps on the Android System
- Delete the apk file
Delete the doggo file under/OK3568-android11-source/packages/apps/
Guide to RK3568 Android Application Porting and System Customization
2.Delete installation configuration
Mod/OK3568-android11-source/device/rockchip/rk356x/ok3568_r/ok3568_r.mk file
Delete dogdog \
Guide to RK3568 Android Application Porting and System Customization
3.Delete the intermediate files generated by compilation
Delete /Ok3568-android11-source/out/target/product/ok3568_r/system/priv-app/ corresponding files
Guide to RK3568 Android Application Porting and System Customization
Compile again to generate the update. img file.
Android Getting Root Privileges
Location of references and test procedures:
Guide to RK3568 Android Application Porting and System Customization
1.The user debug version needs to be compiled.
2.Close selinux
Modify the configuration according to the red prompt:
Source code/device/rockchip/common/BoardConfig.mk
BOARD_MKBOOTIMG_ARGS :=
BOARD_PREBUILT_DTBOIMAGE ?= $(TARGET_DEVICE_DIR)/dtbo.img
BOARD_ROCKCHIP_VIRTUAL_AB_ENABLE ?= false
BOARD_SELINUX_ENFORCING ?= false
false is Close, true is Open.
- Annotation User Group Permission Detection
Comment the following two lines.
Source code/system/extras/su/su.cpp
int main(int argc, char** argv) {
//uid_t current_uid = getuid();
//if (current_uid != AID_ROOT && current_uid != AID_SHELL) error(1, 0, "not allowed");
// Handle -h and --help.
++argv;
- Grant root privileges to su files by default
(1)Source code/system/core/libcutils/fs_config.cpp
static const struct fs_path_config android_files[] = {
……
// the following two files are INTENTIONALLY set-uid, but they
// are NOT included on user builds.
{ 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procmem" },
{ 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procmem" },
// the following files have enhanced capabilities and ARE included
// in user builds.
(2)Source code/frameworks/base/core/jni/com_android_internal_os_Zygote.cpp
static void DropCapabilitiesBoundingSet(fail_fn_t fail_fn) {
/*
for (int i = 0; prctl(PR_CAPBSET_READ, i, 0, 0, 0) >= 0; i++) {;
if (prctl(PR_CAPBSET_DROP, i, 0, 0, 0) == -1) {
if (errno == EINVAL) {
ALOGE("prctl(PR_CAPBSET_DROP) failed with EINVAL. Please verify "
''your kernel is compiled with file capabilities support");
} else {
fail_fn(CREATE_ERROR("prctl(PR_CAPBSET_DROP, %d) failed: %s", i, strerror(errno)));
}
}
}
*/
}
(3)Source code/kernel/security/commoncap.c
static int cap_prctl_drop(unsigned long cap)
{
struct cred new;
/
if (!ns_capable(current_user_ns(), CAP_SETPCAP))
return -EPERM;
if (!cap_valid(cap))
return -EINVAL;
*/
new = prepare_creds();
if (!new)
return -ENOMEM;
cap_lower(new->cap_bset, cap);
return commit_creds(new);
}
5.Complete compilation and flashing.
After compiling and flashing, you can install the RootChecker. apk to detect whether android has obtained root permission. If the prompt is "Root check pass", it indicates that root privileges have been obtained.
Top comments (0)