一、整个过程需要修改的内容,不多解释,直接看源码吧 read the fuck code。
diff --git a/bootable/recovery/install/include/install/wipe_data.h b/bootable/recovery/install/include/install/wipe_data.h
old mode 100644
new mode 100755
index c177f59274..6e1987d990
--- a/bootable/recovery/install/include/install/wipe_data.h
+++ b/bootable/recovery/install/include/install/wipe_data.h
@@ -30,5 +30,7 @@ bool WipeCache(RecoveryUI* ui, const std::function& confirm);
bool WipeData(Device* device, bool convert_fbe);
void SureMetadataMount();
+void SurePrivateMount();
+
void WipeFrp();
int ResizeData(Device* device);
diff --git a/bootable/recovery/install/wipe_data.cpp b/bootable/recovery/install/wipe_data.cpp
old mode 100644
new mode 100755
index a16e62c1d7..6017f807e1
--- a/bootable/recovery/install/wipe_data.cpp
+++ b/bootable/recovery/install/wipe_data.cpp
@@ -36,6 +36,7 @@
constexpr const char* CACHE_ROOT = "/cache";
constexpr const char* DATA_ROOT = "/data";
constexpr const char* METADATA_ROOT = "/metadata";
+constexpr const char* PRIVATE_ROOT = "/cameradata";
/**
* reset hdmi after restore factory.
@@ -152,6 +153,11 @@ bool WipeData(Device* device, bool convert_fbe) {
if (has_cache) {
success &= EraseVolume(CACHE_ROOT, ui, false);
}
+/*
+ if (volume_for_mount_point(PRIVATE_ROOT) != nullptr) {
+ success &= EraseVolume(PRIVATE_ROOT, ui, false);
+ }
+*/
if (volume_for_mount_point(METADATA_ROOT) != nullptr) {
success &= EraseVolume(METADATA_ROOT, ui, false);
}
@@ -172,6 +178,16 @@ void SureMetadataMount() {
ensure_path_mounted(METADATA_ROOT);
}
}
+
+void SurePrivateMount() {
+ if (ensure_path_mounted(PRIVATE_ROOT)) {
+ printf("mount private fail,so formate...\n");
+ reset_tmplog_offset();
+ format_volume(PRIVATE_ROOT);
+ ensure_path_mounted(PRIVATE_ROOT);
+ }
+}
+
void WipeFrp() {
printf("begin to wipe frp partion!\n");
int ret = format_volume("/frp");
diff --git a/bootable/recovery/recovery.cpp b/bootable/recovery/recovery.cpp
old mode 100644
new mode 100755
index eda573bc87..a61936cba3
--- a/bootable/recovery/recovery.cpp
+++ b/bootable/recovery/recovery.cpp
@@ -1170,6 +1170,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vectorStartRecovery();
SureMetadataMount();
+ SurePrivateMount();
printf("Command:");
for (const auto& arg : args) {
diff --git a/device/rockchip/common/build/rockchip/RebuildParameter.mk b/device/rockchip/common/build/rockchip/RebuildParameter.mk
old mode 100644
new mode 100755
index e1ccb55748..d1ea556eae
--- a/device/rockchip/common/build/rockchip/RebuildParameter.mk
+++ b/device/rockchip/common/build/rockchip/RebuildParameter.mk
@@ -23,7 +23,7 @@ partition_list := $(partition_list),dtbo:$(BOARD_DTBOIMG_PARTITION_SIZE),vbmeta:
endif # BOARD_USES_AB_IMAGE
partition_list := $(partition_list),backup:384M,cache:$(BOARD_CACHEIMAGE_PARTITION_SIZE),metadata:16M
-
+partition_list := $(partition_list),camera_data:64M
ifeq ($(strip $(BUILD_WITH_GOOGLE_FRP)), true)
partition_list := $(partition_list),frp:512K
endif
diff --git a/device/rockchip/common/scripts/fstab_tools/fstab.in b/device/rockchip/common/scripts/fstab_tools/fstab.in
index 10c3d2ee85..25ea9f0ccf 100755
--- a/device/rockchip/common/scripts/fstab_tools/fstab.in
+++ b/device/rockchip/common/scripts/fstab_tools/fstab.in
@@ -10,7 +10,8 @@ ${_block_prefix}system_ext /system_ext ext4 ro,barrier=1 ${_flags},first_stage_
/dev/block/by-name/metadata /metadata ext4 nodev,noatime,nosuid,discard,sync wait,formattable,first_stage_mount,check
/dev/block/by-name/misc /misc emmc defaults defaults
/dev/block/by-name/cache /cache ext4 noatime,nodiratime,nosuid,nodev,noauto_da_alloc,discard wait,check
-
+/dev/block/by-name/camera_data /cameradata ext4 noatime,nodiratime,nosuid,nodev,noauto_da_alloc,discard wait,check
+
/devices/platform/*usb* auto vfat defaults voldmanaged=usb:auto
# For sata
diff --git a/device/rockchip/rk356x/rk3568_r/recovery.fstab b/device/rockchip/rk356x/rk3568_r/recovery.fstab
old mode 100644
new mode 100755
index 08567914fd..fbf817b11f
--- a/device/rockchip/rk356x/rk3568_r/recovery.fstab
+++ b/device/rockchip/rk356x/rk3568_r/recovery.fstab
@@ -9,6 +9,7 @@
/dev/block/by-name/system_ext /system_ext ext4 defaults defaults
/dev/block/by-name/cache /cache ext4 defaults defaults
/dev/block/by-name/metadata /metadata ext4 defaults defaults
+/dev/block/by-name/camera_data /cameradata ext4 defaults defaults
/dev/block/by-name/userdata /data f2fs defaults defaults
/dev/block/by-name/cust /cust ext4 defaults defaults
/dev/block/by-name/custom /custom ext4 defaults defaults
diff --git a/device/rockchip/rk356x/upgrade.tar.gz b/device/rockchip/rk356x/upgrade.tar.gz
index 36676b575a..81e765db21 100755
Binary files a/device/rockchip/rk356x/upgrade.tar.gz and b/device/rockchip/rk356x/upgrade.tar.gz differ
diff --git a/system/core/rootdir/Android.mk b/system/core/rootdir/Android.mk
index 4188aba0bd..dc3e1975eb 100755
--- a/system/core/rootdir/Android.mk
+++ b/system/core/rootdir/Android.mk
@@ -77,7 +77,7 @@ endif
#
# create some directories (some are mount points) and symlinks
LOCAL_POST_INSTALL_CMD := mkdir -p $(addprefix $(TARGET_ROOT_OUT)/, \
- dev proc sys system data data_mirror odm oem acct config storage mnt apex debug_ramdisk \
+ dev proc sys system data data_mirror odm oem acct config storage mnt apex debug_ramdisk cameradata \
linkerconfig $(BOARD_ROOT_EXTRA_FOLDERS)); \
ln -sf /system/bin $(TARGET_ROOT_OUT)/bin; \
ln -sf /system/etc $(TARGET_ROOT_OUT)/etc; \
diff --git a/system/core/rootdir/init.rc b/system/core/rootdir/init.rc
index beae221c24..de65c6e597 100755
--- a/system/core/rootdir/init.rc
+++ b/system/core/rootdir/init.rc
@@ -539,7 +539,8 @@ on post-fs-data
# Make sure we have the device encryption key.
installkey /data
-
+ chown system system /cameradata
+ chmod 0771 /cameradata
# Start bootcharting as soon as possible after the data partition is
# mounted to collect more data.
mkdir /data/bootchart 0755 shell shell encryption=Require
diff --git a/system/sepolicy/prebuilts/api/30.0/private/file_contexts b/system/sepolicy/prebuilts/api/30.0/private/file_contexts
index f19e99d0d2..dd55d3d20b 100755
--- a/system/sepolicy/prebuilts/api/30.0/private/file_contexts
+++ b/system/sepolicy/prebuilts/api/30.0/private/file_contexts
@@ -27,6 +27,7 @@
/data_mirror u:object_r:mirror_data_file:s0
/debug_ramdisk u:object_r:tmpfs:s0
/mnt u:object_r:tmpfs:s0
+/cameradata u:object_r:tmpfs:s0
/postinstall u:object_r:postinstall_mnt_dir:s0
/postinstall/apex u:object_r:postinstall_apex_mnt_dir:s0
/proc u:object_r:rootfs:s0
diff --git a/system/sepolicy/private/file_contexts b/system/sepolicy/private/file_contexts
index f19e99d0d2..dd55d3d20b 100755
--- a/system/sepolicy/private/file_contexts
+++ b/system/sepolicy/private/file_contexts
@@ -27,6 +27,7 @@
/data_mirror u:object_r:mirror_data_file:s0
/debug_ramdisk u:object_r:tmpfs:s0
/mnt u:object_r:tmpfs:s0
+/cameradata u:object_r:tmpfs:s0
/postinstall u:object_r:postinstall_mnt_dir:s0
/postinstall/apex u:object_r:postinstall_apex_mnt_dir:s0
/proc u:object_r:rootfs:s0
二、实际测试,根目录下面生成cameradata文件夹,大小是64M这样,恢复出厂设置也会保留原数据。
2.1 查看分区挂载情况
df -h
2.2 查看分区数,64M等于1024X64等于65536(KB) 。
2.3 查看分区挂载点:
# cat /proc/mounts
2.4 查看分区名字:
# ls -l /dev/block/by-name
三、恢复出厂设置,可以看到cameradata下面的内容依然存在,data下面的内容已经被清除。
四、参考文章
linux安卓挂载分区,Android分区查看-CSDN博客
rk3566-11.0新增device分区_rk3566修改分区大小-CSDN博客
AOSP ~ RK3568 ANDROID11 增加分区_rk3568创建新分区-CSDN博客