Ignore "use pre-dump" flag if no data is available

In some cases dumpstate might be requested to create a bugreport with "use pre-dump" flag,
even if no pre-dumped data is available on disk.

In such cases dumpstate should ignore the "use pre-dump" flag.

Example scenario where the pre-dumped data would not be available:
1. Pre-dump data
2. Start bugreport + "use pre-dump" flag (USE AND REMOVE THE PRE-DUMP FROM DISK)
3. Start bugreport + "use pre-dump" flag (NO PRE-DUMP AVAILABLE ON DISK)

Bug: 327322141
Test: atest com.android.os.bugreports.tests.BugreportManagerTest
Change-Id: Ice75f18437064daad98857c8de8a07c7e2994e0c
Ignore-AOSP-First: depends on changes not available in AOSP
   (e.g. I343813929a537c601132dd15db5e2c4d3fbbdcb1)
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 8d37aac..826a8db 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -3280,6 +3280,12 @@
     // duration is logged into MYLOG instead.
     PrintHeader();
 
+    bool system_trace_exists = access(SYSTEM_TRACE_SNAPSHOT, F_OK) == 0;
+    if (options_->use_predumped_ui_data && !system_trace_exists) {
+        MYLOGW("Ignoring 'use predumped data' flag because no predumped data is available");
+        options_->use_predumped_ui_data = false;
+    }
+
     std::future<std::string> snapshot_system_trace;
 
     bool is_dumpstate_restricted =