summaryrefslogtreecommitdiff
path: root/cmds/dumpstate/DumpstateService.cpp
diff options
context:
space:
mode:
author Abhijeet Kaur <abkaur@google.com> 2020-03-27 12:51:12 +0000
committer Abhijeet Kaur <abkaur@google.com> 2020-04-02 12:56:30 +0100
commita407fb81372c6571c28d603504b23ece2d6bc79e (patch)
tree17d7587ab566c26277e9bd7c14ee3b5d3dd8e2c4 /cmds/dumpstate/DumpstateService.cpp
parenta02bd1948597a829b4c72a1179a0897aa0c633e5 (diff)
Update Last ID early in the bugreport generation
The lifecycle of a bugreport triggered by Shell: 1. Triggers a bugreport using bugreport API. At this point shell does not have any state of the bugreport. mBugreportInfos is the sparse array in Shell that tracks bugreportInfos keyed with the ID. The ID of the bugreport is currently incremented in RunInternal() which is called in a different thread triggered by the DumpstateService (for an API call) 2. dumpstate calls one of the callbacks #onProgress, #onError and #onFinished(), it is then that the corresponding bugreportinfo is tracked in mBugreportInfos keyed with the ID. Problem: Consider a case when 2 bugreports are triggered such that Shell has not received #onProgress for the first one, and received #onError for the second one. This results in a race condition as Shell assumes that the first bugreport has called onError. This race condition occurs due to the fact that Shell depends on the callback to track the bugreports. Solution: Update Id at a definite time (not in some other thread) in Initialize so that the service calling the API can track it right away. Bug: 152292912 Test: Tigger consecutive calls to bugreport from ActivityManager is WAI Test: adb bugreport (open the finished bugreport and check that the correct ID is shown) Test: atest dumpstate_test Change-Id: I63966800725d2aaa1d1d9d6eb997b86d564acf44
Diffstat (limited to 'cmds/dumpstate/DumpstateService.cpp')
-rw-r--r--cmds/dumpstate/DumpstateService.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/cmds/dumpstate/DumpstateService.cpp b/cmds/dumpstate/DumpstateService.cpp
index 1824943eb2..bfcc058c1b 100644
--- a/cmds/dumpstate/DumpstateService.cpp
+++ b/cmds/dumpstate/DumpstateService.cpp
@@ -137,6 +137,8 @@ binder::Status DumpstateService::startBugreport(int32_t calling_uid,
ds_info->calling_package = calling_package;
pthread_t thread;
+ // Initialize dumpstate
+ ds_->Initialize();
status_t err = pthread_create(&thread, nullptr, dumpstate_thread_main, ds_info);
if (err != 0) {
delete ds_info;