libprefetch: check `ro.prefetch_boot.enabled` internally

Checking this value on the prefetch internally prevents
it from starting unless you explicitly enable the feature.

Bug: 380766679
Test: Builds
Test: Build emulator image with `ro.prefetch_boot.enabled 0`.
observe prefetch record exiting even when other condition meets.

Change-Id: Iadce8bd77a6b5299f33efdf5e195e715798f5104
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() })?;