From ad5948a81070df52aad6e90abc4aafa527e71a31 Mon Sep 17 00:00:00 2001 From: Shengsong Tan Date: Fri, 20 Sep 2024 04:49:35 +0000 Subject: [PATCH] Replace base::RandInt with std::uniform_int_distribution As part of the effort to uprev libchrome in Android, we are removing Android dependencies to libchrome utility functions that are not strictly required. This CL remove the usage of base::RandInt and replace by std cpp Bug: 360917504 Change-Id: I83ea0f00ca07074f8c6c9a69db343a65cc8deb27 Test: atest libfs_avb_internal_test --- fs_mgr/libfs_avb/tests/avb_util_test.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs_mgr/libfs_avb/tests/avb_util_test.cpp b/fs_mgr/libfs_avb/tests/avb_util_test.cpp index 5dc26ac25..85eeeb075 100644 --- a/fs_mgr/libfs_avb/tests/avb_util_test.cpp +++ b/fs_mgr/libfs_avb/tests/avb_util_test.cpp @@ -16,10 +16,11 @@ #include +#include + #include #include #include -#include #include #include "avb_util.h" @@ -727,7 +728,10 @@ void AvbUtilTest::ModifyFile(const base::FilePath& file_path, size_t offset, ssi // Introduces a new modification. if (length > 0) { - int modify_location = base::RandInt(offset, offset + length - 1); + // mersenne_twister_engine seeded with the default seed source. + static std::mt19937 gen(std::random_device{}()); + std::uniform_int_distribution<> rand_distribution(offset, offset + length - 1); + int modify_location = rand_distribution(gen); file_content[modify_location] ^= 0x80; last_file_path = file_path.value(); last_modified_location = modify_location;