固件UserDebug轉(zhuǎn)User

概述

Android固件在調(diào)試的時候一般會使用userdebug版本,這樣可以直接root,而且有非常多的log信息幫助調(diào)試.但是正式發(fā)布的時候就需要使用User版本.

User版本

關(guān)閉調(diào)試log信息.

User版本除了必要的打印信息和報錯信息外,應該關(guān)掉多余的調(diào)試信息.

  1. menuconfig中關(guān)掉相應的調(diào)試配置.
  2. 驅(qū)動文件中關(guān)閉自定義的調(diào)試宏
  3. 對于使用printk打印的信息根據(jù)實際情況注釋掉.

關(guān)閉adb

adb及root配置的屬性如下表所示:

1.png

當lunch選擇user版本時,ro.secure一般都為0,即關(guān)閉root.adb相關(guān)選項可以根據(jù)自己的需求開關(guān).

adb指紋認證


diff --git a/core/main.mk b/core/main.mk
index b0207be..060b0ec 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -429,7 +429,7 @@ ifeq (true,$(strip $(enable_target_debugging)))
   INCLUDE_TEST_OTA_KEYS := true
 else # !enable_target_debugging
   # Target is less debuggable and adbd is off by default
-  ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
+  ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1
 endif # !enable_target_debugging

ro.adb.secure

#for cts requirement
ifeq ($(TARGET_BUILD_VARIANT),user)
PRODUCT_PROPERTY_OVERRIDES += \
    ro.adb.secure=0 \
    persist.sys.usb.config=mtp
else
PRODUCT_PROPERTY_OVERRIDES += \
    ro.adb.secure=0 \
    persist.sys.usb.config=mtp,adb
endif

RK中還有一個地方影響persist.sys.usb.config參數(shù)

device/rockchip/common

ifeq ($(strip $(BUILD_WITH_UMS)),true)
PRODUCT_PROPERTY_OVERRIDES +=               \
    ro.factory.hasUMS=true                  \
    persist.sys.usb.config=mass_storage,adb

PRODUCT_COPY_FILES += \
    $(LOCAL_PATH)/init.rockchip.hasUMS.true.rc:root/init.$(TARGET_BOARD_HARDWARE).environment.rc
else
ifeq ($(strip $(BUILD_WITH_CDROM)),true)
PRODUCT_PROPERTY_OVERRIDES +=                 \
    ro.factory.hasUMS=cdrom                   \
    ro.factory.cdrom=$(BUILD_WITH_CDROM_PATH) \
    persist.sys.usb.config=mass_storage,adb

PRODUCT_COPY_FILES += \
    $(LOCAL_PATH)/init.rockchip.hasCDROM.true.rc:root/init.$(TARGET_BOARD_HARDWARE).environment.rc
else
PRODUCT_PROPERTY_OVERRIDES +=       \
    ro.factory.hasUMS=false         \
    persist.sys.usb.config=mtp,adb  \
    testing.mediascanner.skiplist = /mnt/shell/emulated/Android/

PRODUCT_COPY_FILES += \
    $(LOCAL_PATH)/init.rockchip.hasUMS.false.rc:root/init.$(TARGET_BOARD_HARDWARE).environment.rc
endif
endif

使用platform key簽名

調(diào)試的時候使用的是testkey,這個是通用的,我們需要生成自己的platform key為固件簽名.

簽名方法請參考:

Android系統(tǒng)制作自定義簽名

對于內(nèi)置apk,如果想要給他們系統(tǒng)權(quán)限,可以使用系統(tǒng)簽名.

方法參考:

Apk 使用系統(tǒng)簽名

編譯時報錯

error: ro.build.fingerprint cannot exceed 91 bytes

需要增大PROP_VALUE_MAX參數(shù)的值

--- a/libc/include/sys/system_properties.h
+++ b/libc/include/sys/system_properties.h
@@ -36,7 +36,8 @@ __BEGIN_DECLS
 typedef struct prop_info prop_info;

 #define PROP_NAME_MAX   32
-#define PROP_VALUE_MAX  92
+//#define PROP_VALUE_MAX  92
+#define PROP_VALUE_MAX  128
--- a/cmds/installd/installd_deps.h
+++ b/cmds/installd/installd_deps.h
@@ -34,7 +34,7 @@ extern int get_property(const char *key,
                         const char *default_value);
 // Size constants. Should be checked to be equal to the cutils requirements.
 constexpr size_t kPropertyKeyMax = 32u;
-constexpr size_t kPropertyValueMax = 92u;
+constexpr size_t kPropertyValueMax = 128u;
--- a/tools/post_process_props.py
+++ b/tools/post_process_props.py
@@ -23,7 +23,8 @@ import sys
 # The constants in system_properties.h includes the termination NUL,
 # so we decrease the values by 1 here.
 PROP_NAME_MAX = 31
-PROP_VALUE_MAX = 91
+#PROP_VALUE_MAX = 91
+PROP_VALUE_MAX = 128
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容