Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b9fc904 authored by Dennis Shen's avatar Dennis Shen
Browse files

aconfig_storage_read_api: allow read api to read from mutable mapping

In aconfigd, we also need to read from mutable storage files (persist
copies of storage files). Current read API only accepts Mmap which is
immutable. We need it to also accept MmapMut. Since both Mmap and
MmapMut deref to &[u8], change the function signature to accept &[u8].

Bug: b/327170179
Test: atest -c
Change-Id: I0a7d99bc38176c2aeae8c20f749419caf1d365fa
parent c923e384
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -115,13 +115,13 @@ pub fn get_flag_read_context(

/// Get the boolean flag value.
///
/// \input file: mapped flag file
/// \input file: a byte slice, can be either &Mmap or &MapMut
/// \input index: boolean flag offset
///
/// \return
/// If the provide offset is valid, it returns the boolean flag value, otherwise it
/// returns the error message.
pub fn get_boolean_flag_value(file: &Mmap, index: u32) -> Result<bool, AconfigStorageError> {
pub fn get_boolean_flag_value(file: &[u8], index: u32) -> Result<bool, AconfigStorageError> {
    find_boolean_flag_value(file, index)
}

@@ -149,7 +149,7 @@ pub fn get_storage_file_version(file_path: &str) -> Result<u32, AconfigStorageEr

/// Get the flag attribute.
///
/// \input file: mapped flag info file
/// \input file: a byte slice, can be either &Mmap or &MapMut
/// \input flag_type: flag value type
/// \input flag_index: flag index
///
@@ -157,7 +157,7 @@ pub fn get_storage_file_version(file_path: &str) -> Result<u32, AconfigStorageEr
/// If the provide offset is valid, it returns the flag attribute bitfiled, otherwise it
/// returns the error message.
pub fn get_flag_attribute(
    file: &Mmap,
    file: &[u8],
    flag_type: FlagValueType,
    flag_index: u32,
) -> Result<u8, AconfigStorageError> {