Improvements to ActivityManagerService stack dumping

- Deduplicate code in DumpStackFileObserver, ensure consistent behavior at addition use site
- Fix bug in DumpStackFileObserver where closed state was not reset
- Align TRACE_DUMP_TIMEOUT_MS with frameworks/native/cmds/dumpstate/utils.cpp
- Fallback to Debug.dumpNativeBacktraceToFileTimeout on timeout
- Share timeout constant with other Debug.dumpNativeBacktraceToFileTimeout caller

Test: Insert 1s sleep in system/bt/btif/src/bluetooth.cc is_profile to trigger ANR
Test: Insert hang into art/runtime/signal_catcher.cc after "reacting to signal"
Bug: 35962833

(cherry picked from commit beed965c25d6996ed0f7947bf8a569ca4489f79e)

Merged-In: I6b5cc3f106f1e2b49400e382b8ad71ddbd4685f3
Change-Id: Ia2024bfa54a15a57821958d69b442d0bc9985eb6
1 file changed