Stub out forceSuspend during fuzzing
Adding macro to stub out force suspend functionality
while fuzzing.
Test: m android.system.suspend-service suspend_service_fuzzer suspend_service_internal_fuzzer
Bug: N/A
Change-Id: I741158c254be5a2e110ef4335052d6f0058e0779
diff --git a/suspend/1.0/default/Android.bp b/suspend/1.0/default/Android.bp
index bb7d91f..b4c1b2a 100644
--- a/suspend/1.0/default/Android.bp
+++ b/suspend/1.0/default/Android.bp
@@ -174,6 +174,9 @@
triage_assignee: "waghpawan@google.com",
},
include_dirs: ["system/hardware/interfaces/suspend/1.0/default/"],
+ cflags: [
+ "-DFUZZ_MODE_SUSPEND_SERVICE=1",
+ ],
}
cc_fuzz {
diff --git a/suspend/1.0/default/SystemSuspend.cpp b/suspend/1.0/default/SystemSuspend.cpp
index 3362fe0..0bc09f8 100644
--- a/suspend/1.0/default/SystemSuspend.cpp
+++ b/suspend/1.0/default/SystemSuspend.cpp
@@ -240,6 +240,7 @@
}
bool SystemSuspend::forceSuspend() {
+#ifndef FUZZ_MODE_SUSPEND_SERVICE
// We are forcing the system to suspend. This particular call ignores all
// existing wakelocks (full or partial). It does not cancel the wakelocks
// or reset mSuspendCounter, it just ignores them. When the system
@@ -253,6 +254,9 @@
PLOG(VERBOSE) << "error writing to /sys/power/state for forceSuspend";
}
return success;
+#else
+ return false;
+#endif // !FUZZ_MODE_SUSPEND_SERVICE
}
void SystemSuspend::incSuspendCounter(const string& name) {