Merge changes Iadce8bd7,I4ee818dd into main am: 92a97843c4
Original change: https://android-review.googlesource.com/c/platform/system/core/+/3531411
Change-Id: I0dfa2aa94a2b2015ed15e4fb7622edf078629dc3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/init/libprefetch/prefetch/prefetch.rc b/init/libprefetch/prefetch/prefetch.rc
index bdcbbc6..56fb827 100644
--- a/init/libprefetch/prefetch/prefetch.rc
+++ b/init/libprefetch/prefetch/prefetch.rc
@@ -30,7 +30,7 @@
disabled
oneshot
-service prefetch_replay /system/bin/prefetch replay --io-depth ${ro.prefetch_boot.io_depth:-2} --max-fds ${ro.prefetch_boot.max_fds:-128}
+service prefetch_replay /system/bin/prefetch replay --io-depth ${ro.prefetch_boot.io_depth:-2} --max-fds ${ro.prefetch_boot.max_fds:-1024}
user root
group root system
disabled
diff --git a/init/libprefetch/prefetch/src/arch/android.rs b/init/libprefetch/prefetch/src/arch/android.rs
index a87502d..7d446ba 100644
--- a/init/libprefetch/prefetch/src/arch/android.rs
+++ b/init/libprefetch/prefetch/src/arch/android.rs
@@ -12,6 +12,12 @@
const PREFETCH_RECORD_PROPERTY_STOP: &str = "prefetch_boot.record_stop";
+fn is_prefetch_enabled() -> Result<bool, Error> {
+ rustutils::system_properties::read_bool("ro.prefetch_boot.enabled", false).map_err(|e| {
+ Error::Custom { error: format!("Failed to read ro.prefetch_boot.enabled: {}", e) }
+ })
+}
+
fn wait_for_property_true(
property_name: &str,
timeout: Option<Duration>,
@@ -31,6 +37,10 @@
/// Checks if we can perform replay phase.
/// Ensure that the pack file exists and is up-to-date, returns false otherwise.
pub fn can_perform_replay(pack_path: &Path, fingerprint_path: &Path) -> Result<bool, Error> {
+ if !is_prefetch_enabled()? {
+ return Ok(false);
+ }
+
if !pack_path.exists() || !fingerprint_path.exists() {
return Ok(false);
}
@@ -54,6 +64,10 @@
pack_path: &Path,
fingerprint_path: &Path,
) -> Result<bool, Error> {
+ if !is_prefetch_enabled()? {
+ return Ok(false);
+ }
+
if !ready_path.exists() {
File::create(ready_path)
.map_err(|_| Error::Custom { error: "File Creation failed".to_string() })?;