Android system customization

Scope of application

  • RK3368 Android10

  • RK3399Pro Android9

  • RK3399 Android7.1/Android10

  • RK356X Android11

  • RK3588 Android12 For other Android versions, it is available for reference.

Explanation of terms

  • CPU_TYPE:Indicates the main control chip, for examplerk3368,rk3399,rk3399pro, rk356x, rk3588

  • PRODUCT_TYPE:Indicates the type of product, for example LKD3588

Boot logo animation modification

Phase 1

Methods of code modification

  • Prepare your logo

    • Make new logo.bmp

      • The image properties are the same as the default logo.bmp, otherwise an inversion exception will occur

      • Both width and height are even numbers

  • Replace the logo

    • Replace the kernel/logo.bmp

Phase 2s

Temporary Modification Method

  • Prepare bootanimation.zip

    • Prepare png files

      • Width and height must be even numbers Prepare desc.txt file, for example:

800 1280 30
p 0 0 part0
    * `800 1280 30`meaning:The first two numbers represent the pixel width and height of the image, 30 represents the frame rate, which is the number of images played per second.
    * `p 0 0 part0`meaning: p stands for flag, 0 means infinite loop, the second 0 means the interval time between stages is 0, part0 represents the corresponding folder.
    * desc.txt text format:Unix+UTF-8
* Make bootanimation.zip
    * Compress into a zip file using storage mode

Push bootanimation.zip push bootanimation.zip

adb shell setprop persist.sys.root_access 3
adb root
adb remount
adb push bootanimation.zip system/media/bootanimation.zip
adb shell reboot

Code Modification Method

  • Prepare bootanimation.zip

    • Place the prepared bootanimation.zip into the device/rockchip/CPU_TYPE/ directory In the device/rockchip/CPU_TYPE/device.mk file, add the following content:

PRODUCT_COPY_FILES += \
       device/rockchip/CPU_TYPE/bootanimation.zip:/system/media/bootanimation.zip

Default Screen Orientation Modification

Temporary Modification Method

System is read-write enabled

adb shell setprop persist.sys.root_access 3
adb root
adb remount
  • Modify or add property values

    • Android7.1

      • In the /system/build.prop file, modify or add the value of ro.sf.hwrotation

        • 0:Landscape

        • 90:Portrait

        • 180:Reverse landscape

        • 270:Reverse portrait

    • Android10 and above

      • In the vendor/build.prop file, modify or add the value of ro.surface_flinger.primary_display_orientation

        • ORIENTATION_0:Landscape

        • ORIENTATION_90:Portrait

        • ORIENTATION_180:Reverse landscape

        • ORIENTATION_270:Reverse portrait

System restart

adb shell reboot

Code Modification Method

Android 7.1:

  • In the device/rockchip/CPU_TYPE/PRODUCT_TYPE/system.prop file, modify the value of ro.sf.hwrotation Android 10 and above:

  • In the device/rockchip/CPU_TYPE/BoardConfig.mk file, modify the value of SF_PRIMARY_DISPLAY_ORIENTATION

    • 0:Landscape

    • 90:Portrait

    • 180:Reverse landscape

    • 270:Reverse portrait Delete build.prop in the out directory

rm out/target/product/PRODUCT_TYPE/obj/ETC/system_build_prop_intermediates/build.prop

Default Hide Status Bar

Temporary Modification Method

Execute in adb shell mode

settings put global policy_control immersive.status=*

Code Modification Method

Modify as follows

diff --git a/device/rockchip/common/overlay/frameworks/base/core/res/res/values/config.xml b/device/rockchip/common/overlay/frameworks/base/core/res/res/values/config.xml
index 2092e98d16..59c3ba0321 100644
--- a/device/rockchip/common/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/device/rockchip/common/overlay/frameworks/base/core/res/res/values/config.xml
@@ -30,7 +30,10 @@

     <!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
          autodetected from the Configuration. -->
     <bool name="config_showNavigationBar">true</bool>
+
+    <!-- Height of the status bar -->
+    <dimen name="status_bar_height">0dp</dimen>

     <!--  Maximum number of supported users -->
     <integer name="config_multiuserMaximumUsers">8</integer>

Default Hide Navigation Bar

Code Modification Method

Modify as follows

diff --git a/device/rockchip/common/overlay/frameworks/base/core/res/res/values/config.xml b/device/rockchip/common/overlay/frameworks/base/core/res/res/values/config.xml
index 2092e98d16..59c3ba0321 100644
--- a/device/rockchip/common/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/device/rockchip/common/overlay/frameworks/base/core/res/res/values/config.xml
@@ -30,7 +30,10 @@
 
     <!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
          autodetected from the Configuration. -->
-    <bool name="config_showNavigationBar">true</bool>
+    <bool name="config_showNavigationBar">false</bool>
+
     <!-- Height of the status bar -->
     <dimen name="status_bar_height">0dp</dimen>

Built-in APP Methods

Code Modification Method

You can add a new APP folder in the vendor directory

Non-removable

Refer to vendor/rockchip/app

Contents of Android.mk

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := neardi_sdkapi_demo
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_TAGS := optional
LOCAL_BUILT_MODULE_STEM := package.apk
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
#LOCAL_PRIVILEGED_MODULE :=
LOCAL_CERTIFICATE := platform
#LOCAL_OVERRIDES_PACKAGES := 
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
#LOCAL_REQUIRED_MODULES :=
#LOCAL_PREBUILT_JNI_LIBS :=
include $(BUILD_PREBUILT)
* LOCAL_CERTIFICATE := platform meaning: APK is signed with the system signature
* If LOCAL_PRIVILEGED_MODULE is not set or set to false, the installation location is /system/app
#### Removable

* Create a preinstall_del directory under device/rockchip/CPU_TYPE/PRODUCT_TYPE
* Copy the APK to the device/rockchip/CPU_TYPE/PRODUCT_TYPE/preinstall_del directory
* Compile Android

Delete Built-in Application

Temporary Modification Method

adb shell setprop persist.sys.root_access 3
adb root
adb remount
adb shell rm -r system/app/APK_NAME/
adb shell reboot

or

adb shell setprop persist.sys.root_access 3
adb root
adb remount
adb shell rm -r system/priv-app/APK_NAME/
adb shell reboot

Code Modification Method

  • If the application has source code, comment out include $(BUILD_PACKAGE) in the application’s Android.mk file

  • If the application is an APK file and has Android.mk, then comment out include $(BUILD_PREBUILT) in the Android.mk file

Boot Start Application

Code Modification Method

Non-Launcher

Add the following content in the AndroidManifest.xml of the application source code

package="com.example.testfile"
android:sharedUserId="android.uid.system">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<receiver android:name="com.example.testfile.BootBroadcastReceiver" >
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
        <category android:name="android.intent.category.LAUNCHER" />
   </intent-filter>
</receiver>

Add the broadcast receiver code BootBroadcastReceiver.java, for example

package com.example.testfile;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

public class BootBroadcastReceiver extends BroadcastReceiver {
    private static final String TAG = "sjft";

    public static final String EXTRA_VOLUME_STATE = "android.os.storage.extra.VOLUME_STATE";

    public static final int STATE_UNMOUNTED = 0;
    public static final int STATE_CHECKING = 1;
    public static final int STATE_MOUNTED = 2;
    public static final int STATE_MOUNTED_READ_ONLY = 3;
    public static final int STATE_FORMATTING = 4;
    public static final int STATE_EJECTING = 5;
    public static final int STATE_UNMOUNTABLE = 6;
    public static final int STATE_REMOVED = 7;
    public static final int STATE_BAD_REMOVAL = 8;

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        String action = intent.getAction();
        if (action.equals("android.intent.action.PACKAGE_REPLACED")){
            String packageName = intent.getData().getSchemeSpecificPart();
            Log.v(TAG,"BootBroadcastReceiver packageName:"+packageName);
            if(context.getPackageName().equals(packageName)){
                Intent launchIntent = new Intent(context, MainActivity.class);//Restart the application
                //If you don't want to hardcode the startup Activity, you can also get the default startup Activity through the following method
                //Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(packageName);
                launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(launchIntent);
            }
        } else if (action.equals("android.intent.action.BOOT_COMPLETED")) {
            Intent launchIntent = new Intent(context, MainActivity.class);//Restart the application
            //If you don't want to hardcode the startup Activity, you can also get the default startup Activity through the following method
            //Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(packageName);
            launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(launchIntent);
        }
    }
}
  • An APK that starts automatically upon boot requires a system signature

  • The APK must be launched at least once before it can receive the broadcast after boot completion.

Launcher

  • Remove or do not compile the Launcher application in the SDK In the AndroidManifest.xml of the application source code, add the following content to the Activity that starts first:

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

Default Language Modification

The list of supported languages can be viewed in build/target/product/languages_full.mk

Temporary Modification Method

The system is read-write enabled

adb shell setprop persist.sys.root_access 3
adb root
adb remount
  • Modify the value of ro.product.locale in the /system/build.prop file (for Android 10 and above: /vendor/build.prop)

    • en-US:English

    • zh-CN:Chinese System restart

adb shell reboot

Code Modification Method

  • Modify the value of PRODUCT_LOCALES in build/target/product/full_base.mk Chinese

PRODUCT_LOCALES := zh_CN

Delete build.prop in the out directory

rm out/target/product/PRODUCT_TYPE/obj/ETC/system_build_prop_intermediates/build.prop

Default Time Zone Modification

The list of supported time zones can be viewed in frameworks/base/packages/SettingsLib/res/xml/timezones.xml

Temporary Modification Method

The system is read-write enabled

adb shell setprop persist.sys.root_access 3
adb root
adb remount
  • Modify the value of persist.sys.timezone in the /system/build.prop file (for Android 10 and above: /vendor/build.prop)

    • Asia/Shanghai:UTC+8 System restart

adb shell reboot

Code Modification Method

  • Android7.1/Android10

    • In the device/rockchip/CPU_TYPE/PRODUCT_TYPE/system.prop file, modify the value of persist.sys.timezon

    • Asia/Shanghai:UTC+8 Android11

    • In the device/rockchip/CPU_TYPE/PRODUCT_TYPE/PRODUCT_TYPE.mk file, add the following content:

PRODUCT_PROPERTY_OVERRIDES += persist.sys.timezone=Asia/Shanghai

Delete build.prop in the out directory

rm out/target/product/PRODUCT_TYPE/obj/ETC/system_build_prop_intermediates/build.prop

Default ROOT

Temporary Modification Method

adb shell setprop persist.sys.root_access 3

Code Modification Method

Android7.1/Android10.0

* In the device/rockchip/CPU_TYPE/PRODUCT_TYPE/system.prop file, add the following content:
persist.sys.root_access=3

Android11 * In the device/rockchip/CPU_TYPE/PRODUCT_TYPE/PRODUCT_TYPE.mk file, add the following content:

PRODUCT_PROPERTY_OVERRIDES += persist.sys.root_access=3

Delete build.prop in the out directory

rm out/target/product/PRODUCT_TYPE/obj/ETC/system_build_prop_intermediates/build.prop

Default System Time 24-Hour Format

Code Modification Method

diff --git a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
index f95ecc6535..06055dba7b 100644
--- a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
+++ b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
@@ -244,4 +244,6 @@
 
     <!-- should show the screenshot button default -->
     <integer name="def_screenshot_button_show">0</integer>
+<!-- value 12/24/null corresponds to setting 12/24/auto-->
+    <string name="def_time_12_24" translatable="false">24</string>
 </resources>
diff --git a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index b3ff9d08a8..ebdd5d3637 100644
--- a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2261,6 +2261,9 @@ class DatabaseHelper extends SQLiteOpenHelper {
    private void loadSystemSettings(SQLiteDatabase db) {
                                     ......
+            
+            loadStringSetting(stmt, Settings.System.TIME_12_24,
+                    R.string.def_time_12_24);

Default Never Sleep

Code Modification Method

diff --git a/device/rockchip/common/overlay_screenoff/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/device/rockchip/common/overlay_screenoff/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
index 77499e6356..2573ace4c5 100644
--- a/device/rockchip/common/overlay_screenoff/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
+++ b/device/rockchip/common/overlay_screenoff/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
@@ -17,7 +17,8 @@
  */
 -->
 <resources>
-    <integer name="def_screen_off_timeout">0x7fffffff</integer>
+    <integer name="def_screen_off_timeout">2147483647</integer>
+    <bool name="def_lockscreen_disabled">true</bool>

Setting Time Invalid

The system time set is earlier than the build time; upon restart, the default is set to the build time.

Code Modification Method

diff --git a/frameworks/base/services/core/java/com/android/server/AlarmManagerService.java b/frameworks/base/services/core/java/com/android/server/AlarmManagerService.java
index 7cdcc01bc0..10f4808ecb 100644
--- a/frameworks/base/services/core/java/com/android/server/AlarmManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/AlarmManagerService.java
@@ -1510,11 +1510,11 @@ class AlarmManagerService extends SystemService {
             final long systemBuildTime =  Long.max(
                     1000L * SystemProperties.getLong("ro.build.date.utc", -1L),
                     Long.max(Environment.getRootDirectory().lastModified(), Build.TIME));
-            if (mInjector.getCurrentTimeMillis() < systemBuildTime) {
+            /*if (mInjector.getCurrentTimeMillis() < systemBuildTime) {
                 Slog.i(TAG, "Current time only " + mInjector.getCurrentTimeMillis()
                         + ", advancing to build time " + systemBuildTime);
                 mInjector.setKernelTime(systemBuildTime);
-            }
+            }*/

             // Determine SysUI's uid
             mSystemUiUid = mInjector.getSystemUiUid();

Default Open Network ADB

Temporary Modification Method

Method One

adb shell setprop persist.internet_adb_enable 1

Method Two

  • Open “Developer Options” Enable ADB over network

  • Settings–>Developeroptions–>ADB network

Code Modification Method

Android7.1/Android10

* In the device/rockchip/CPU_TYPE/PRODUCT_TYPE/system.prop file, add the following content:
persist.internet.adb.enable=1

Android11 * In the device/rockchip/CPU_TYPE/PRODUCT_TYPE/PRODUCT_TYPE.mk file, add the following content:

PRODUCT_PROPERTY_OVERRIDES += persist.internet.adb.enable=1

Delete build.prop in the out directory

rm out/target/product/PRODUCT_TYPE/obj/ETC/system_build_prop_intermediates/build.prop

Default Setting OTG USB3.0 as Device Mode

Temporary Modification Method

adb shell setprop persist.usb.mode 2

Code Modification Method

Android7.1/Android10

* In the device/rockchip/CPU_TYPE/PRODUCT_TYPE/system.prop file, add the following content:
persist.usb.mode=2

Android11 * In the device/rockchip/CPU_TYPE/PRODUCT_TYPE/PRODUCT_TYPE.mk file, add the following content:

PRODUCT_PROPERTY_OVERRIDES += persist.usb.mode=otg

Delete build.prop in the out directory

rm out/target/product/PRODUCT_TYPE/obj/ETC/system_build_prop_intermediates/build.prop

Enable or Disable Installation of Unknown Apps

Code Modification Method

Android 7.1

In the frameworks/base/packages/SettingsProvider/res/values/defaults.xml file, modify the value of def_install_non_market_apps.

  • false : Disable

  • true : Enable

Android 10 and above

In Android 10, the permanent authorization option for “Allow installation from unknown sources” has been removed. This switch is no longer found in the system settings. Google has changed the permanent authorization to individual authorization each time, requiring users to manually confirm software permissions each time they install Android software from third-party sources.

Enable or Disable Touch Sounds

Code Modification Method

Modify the value of def_sound_effects_enabled in the frameworks/base/packages/SettingsProvider/res/values/defaults.xml file.

  • false : Disable

  • true : Enable

Configure USB Camera as Front or Rear

By default, it is set to front-facing.(Android7.1 and Android10)

Temporary Modification Method

For front-facing:

adb shell setprop persist.sys.uvc.facing front

For rear-facing:

adb shell setprop persist.sys.uvc.facing back

Code Modification Method

  • Android7.1/Android10 In the device/rockchip/CPU_TYPE/PRODUCT_TYPE/system.prop file, add the following content:

      * For front-facing
    
persist.sys.uvc.facing=front
    * For rear-facing:
persist.sys.uvc.facing=back
  • Android11 In the device/rockchip/CPU_TYPE/PRODUCT_TYPE/PRODUCT_TYPE.mk file, add the following content:

      * For front-facing
    
PRODUCT_PROPERTY_OVERRIDES += persist.sys.uvc.facing=front
    * For rear-facing:
PRODUCT_PROPERTY_OVERRIDES += persist.sys.uvc.facing=back

Delete build.prop in the out directory

rm out/target/product/PRODUCT_TYPE/obj/ETC/system_build_prop_intermediates/build.prop