Guide to RK3568 Android Application Porting and System Customization

Forlinx

Apr 23, 2023
107
Joined
Apr 23, 2023
Messages
107
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


1. 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.

file.php


Add the Android. mk under the dogdog folder and write the dogdog. apk films.

file.php


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)


file.php


2. Adding an installation configuration

Modify/OK3568-android11-source/device/rockchip/rk356x/ok3568_r/ok3568_r.mk
Add dogdog \

file.php


Compile again to generate update. img files, which can be flahsed and pre-installed apk normally.


Pre-installing Apps on the Android System


1. Delete the apk file

Delete the doggo file under/OK3568-android11-source/packages/apps/

file.php


2.Delete installation configuration

Mod/OK3568-android11-source/device/rockchip/rk356x/ok3568_r/ok3568_r.mk file
Delete dogdog \

file.php


3.Delete the intermediate files generated by compilation

Delete /Ok3568-android11-source/out/target/product/ok3568_r/system/priv-app/ corresponding files

file.php


Compile again to generate the update. img file.


Android Getting Root Privileges


Location of references and test procedures:

file.php


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.

3. 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;


4. 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.

 

Arish12

May 9, 2025
1
Joined
May 9, 2025
Messages
1
This guide offers a clear and practical approach to Android application porting and system customization for the RK3568 platform. It’s especially helpful for developers working with embedded systems or custom Android ROMs. The step-by-step instructions and technical depth make it accessible yet comprehensive. A valuable resource for both beginners and experienced engineers aiming to tailor Android OS behavior to specific hardware or application needs.

 
Top