diff --git a/include/android_avb/avb_ops_user.h b/include/android_avb/avb_ops_user.h index a51a8c2715..c232ee8320 100644 --- a/include/android_avb/avb_ops_user.h +++ b/include/android_avb/avb_ops_user.h @@ -28,6 +28,9 @@ #include #include +#define PERM_ATTR_DIGEST_SIZE 32 +#define PERM_ATTR_TOTAL_SIZE 1084 + /* Allocates an AvbOps instance suitable for use in Android userspace * on the device. Returns NULL on OOM. * @@ -162,4 +165,27 @@ int avb_read_lock_state(uint8_t *lock_state); */ int avb_write_lock_state(uint8_t lock_state); +/** + * The android things uses fastboot to flash the permanent attributes. + * And if them were written, there must have a flag to indicate. + * + * @param flag indicate the permanent attributes have been written + * or not. + * + * @return 0 if the command succeeded, -1 if it failed + */ +int avb_read_perm_attr_flag(uint8_t *flag); + +/** + * The android things uses fastboot to flash the permanent attributes. + * And if them were written, there must have a flag to indicate. + * + * @param flag We can call this function to write the flag '1' + * to indicate the permanent attributes has been + * written. + * + * @return 0 if the command succeeded, -1 if it failed + */ +int avb_write_perm_attr_flag(uint8_t flag); + #endif diff --git a/lib/avb/rk_libavb_user/avb_ops_user.c b/lib/avb/rk_libavb_user/avb_ops_user.c index cc93eb4b76..5152de7a11 100644 --- a/lib/avb/rk_libavb_user/avb_ops_user.c +++ b/lib/avb/rk_libavb_user/avb_ops_user.c @@ -429,3 +429,17 @@ int avb_write_lock_state(uint8_t lock_state) return -1; return 0; } + +int avb_read_perm_attr_flag(uint8_t *flag) +{ + if (trusty_read_permanent_attributes_flag(flag)) + return -1; + return 0; +} + +int avb_write_perm_attr_flag(uint8_t flag) +{ + if (trusty_write_permanent_attributes_flag(flag)) + return -1; + return 0; +}