delete custom panic hooks

For non-test binaries, the default hook calls android_set_abort_message,
which causes the panic message to be included in the crashdump output,
so these hooks were redundant.

For test binaries, the story is more complicated. Android uses `-Z
panic-abort-tests`, which installs a panic hook to detect if the test
panic'd and communicates the reason to the test framework. If a test
binary installs its own custom panic hook, it breaks that setup and so
the test framework will think the test crashed in an unknown manner. It
is possible to use a custom hook without breaking it, but probably not
worth the complexity. Panic messages from tests will no longer go to
logcat, but they will now  be reported as part of the test results, e.g.
in `atest`'s stderr and in the test results web UI.

Test: atest rialto_test
Change-Id: Ib53248c054f8d358835501814568cec8bedf5f03
diff --git a/android/VmAttestationDemoApp/src/main.rs b/android/VmAttestationDemoApp/src/main.rs
index 26df52c..bcc056d 100644
--- a/android/VmAttestationDemoApp/src/main.rs
+++ b/android/VmAttestationDemoApp/src/main.rs
@@ -16,7 +16,6 @@
 
 use anyhow::{ensure, Context, Result};
 use log::{error, info};
-use std::panic;
 use vm_payload::AttestationError;
 
 vm_payload::main!(main);
@@ -28,10 +27,6 @@
             .with_tag("service_vm_client")
             .with_max_level(log::LevelFilter::Debug),
     );
-    // Redirect panic messages to logcat.
-    panic::set_hook(Box::new(|panic_info| {
-        error!("{}", panic_info);
-    }));
     if let Err(e) = try_main() {
         error!("failed with {:?}", e);
         std::process::exit(1);
diff --git a/android/compos_verify/verify.rs b/android/compos_verify/verify.rs
index b94ebbc..a88d00c 100644
--- a/android/compos_verify/verify.rs
+++ b/android/compos_verify/verify.rs
@@ -34,7 +34,6 @@
 use std::fs;
 use std::fs::File;
 use std::io::Read;
-use std::panic;
 use std::path::Path;
 
 const MAX_FILE_SIZE_BYTES: u64 = 100 * 1024;
@@ -65,11 +64,6 @@
             .with_log_buffer(LogId::System), // Needed to log successfully early in boot
     );
 
-    // Redirect panic messages to logcat.
-    panic::set_hook(Box::new(|panic_info| {
-        error!("{}", panic_info);
-    }));
-
     if let Err(e) = try_main() {
         error!("{:?}", e);
         std::process::exit(1)
diff --git a/android/composd/src/composd_main.rs b/android/composd/src/composd_main.rs
index e5d6c75..0b142f2 100644
--- a/android/composd/src/composd_main.rs
+++ b/android/composd/src/composd_main.rs
@@ -28,7 +28,6 @@
 use anyhow::{Context, Result};
 use binder::{register_lazy_service, ProcessState};
 use log::{error, info};
-use std::panic;
 use std::sync::Arc;
 
 #[allow(clippy::eq_op)]
@@ -39,11 +38,6 @@
         android_logger::Config::default().with_tag("composd").with_max_level(log_level),
     );
 
-    // Redirect panic messages to logcat.
-    panic::set_hook(Box::new(|panic_info| {
-        log::error!("{}", panic_info);
-    }));
-
     ProcessState::start_thread_pool();
 
     let virtmgr =
diff --git a/guest/compsvc/src/compsvc_main.rs b/guest/compsvc/src/compsvc_main.rs
index 9bc522c..a8202e1 100644
--- a/guest/compsvc/src/compsvc_main.rs
+++ b/guest/compsvc/src/compsvc_main.rs
@@ -25,7 +25,6 @@
 use anyhow::Result;
 use compos_common::COMPOS_VSOCK_PORT;
 use log::{debug, error};
-use std::panic;
 
 fn main() {
     if let Err(e) = try_main() {
@@ -40,10 +39,6 @@
             .with_tag("compsvc")
             .with_max_level(log::LevelFilter::Debug),
     );
-    // Redirect panic messages to logcat.
-    panic::set_hook(Box::new(|panic_info| {
-        error!("{}", panic_info);
-    }));
 
     debug!("compsvc is starting as a rpc service.");
     vm_payload::run_single_vsock_service(compsvc::new_binder()?, COMPOS_VSOCK_PORT)
diff --git a/guest/rialto/tests/test.rs b/guest/rialto/tests/test.rs
index 09f9cc3..c94a0e3 100644
--- a/guest/rialto/tests/test.rs
+++ b/guest/rialto/tests/test.rs
@@ -40,7 +40,6 @@
 use service_vm_manager::{ServiceVm, VM_MEMORY_MB};
 use std::fs;
 use std::fs::File;
-use std::panic;
 use std::path::PathBuf;
 use std::str::FromStr;
 use vmclient::VmInstance;
@@ -300,10 +299,6 @@
             .with_tag("rialto")
             .with_max_level(log::LevelFilter::Debug),
     );
-    // Redirect panic messages to logcat.
-    panic::set_hook(Box::new(|panic_info| {
-        log::error!("{}", panic_info);
-    }));
     // We need to start the thread pool for Binder to work properly, especially link_to_death.
     ProcessState::start_thread_pool();
     ServiceVm::start_vm(vm_instance(vm_type, vm_memory_mb)?, vm_type)
diff --git a/tests/testapk/src/native/testbinary.rs b/tests/testapk/src/native/testbinary.rs
index e479342..2502113 100644
--- a/tests/testapk/src/native/testbinary.rs
+++ b/tests/testapk/src/native/testbinary.rs
@@ -26,7 +26,6 @@
 };
 use cstr::cstr;
 use log::{error, info};
-use std::panic;
 use std::process::exit;
 use std::string::String;
 use std::vec::Vec;
@@ -40,10 +39,6 @@
             .with_tag("microdroid_testlib_rust")
             .with_max_level(log::LevelFilter::Debug),
     );
-    // Redirect panic messages to logcat.
-    panic::set_hook(Box::new(|panic_info| {
-        error!("{panic_info}");
-    }));
     if let Err(e) = try_main() {
         error!("failed with {:?}", e);
         exit(1);
diff --git a/tests/vm_attestation/src/native/main.rs b/tests/vm_attestation/src/native/main.rs
index 52635ad..e8038b5 100644
--- a/tests/vm_attestation/src/native/main.rs
+++ b/tests/vm_attestation/src/native/main.rs
@@ -24,10 +24,7 @@
     binder::{self, BinderFeatures, Interface, IntoBinderResult, Strong},
 };
 use log::{error, info};
-use std::{
-    panic,
-    sync::{Arc, Mutex},
-};
+use std::sync::{Arc, Mutex};
 use vm_payload::{AttestationError, AttestationResult};
 
 vm_payload::main!(main);
@@ -39,10 +36,6 @@
             .with_tag("service_vm_client")
             .with_max_level(log::LevelFilter::Debug),
     );
-    // Redirect panic messages to logcat.
-    panic::set_hook(Box::new(|panic_info| {
-        error!("{}", panic_info);
-    }));
     if let Err(e) = try_main() {
         error!("failed with {:?}", e);
         std::process::exit(1);
diff --git a/tests/vmbase_example/src/main.rs b/tests/vmbase_example/src/main.rs
index 34a2b0b..cbe90d8 100644
--- a/tests/vmbase_example/src/main.rs
+++ b/tests/vmbase_example/src/main.rs
@@ -27,7 +27,7 @@
     collections::{HashSet, VecDeque},
     fs::File,
     io::{self, BufRead, BufReader, Read, Write},
-    panic, thread,
+    thread,
 };
 use vmclient::{DeathReason, VmInstance};
 
@@ -58,11 +58,6 @@
             .with_max_level(log::LevelFilter::Debug),
     );
 
-    // Redirect panic messages to logcat.
-    panic::set_hook(Box::new(|panic_info| {
-        log::error!("{}", panic_info);
-    }));
-
     // We need to start the thread pool for Binder to work properly, especially link_to_death.
     ProcessState::start_thread_pool();