summaryrefslogtreecommitdiff
path: root/packages/Shell/tests
diff options
context:
space:
mode:
authorRhed Jao <rhedjao@google.com>2020-12-07 19:44:13 +0800
committerRhed Jao <rhedjao@google.com>2020-12-21 04:20:03 +0000
commit7cb78fdf34e84e1ee58c4ad939ba5060688caff2 (patch)
tree07a65b108b828632e98a507da97084928b26d1bc /packages/Shell/tests
parent39b6acbb55b037ba6dbeb092eb93caddd277a2cd (diff)
Returns immediately if the bugreport file already exists
There's a case that BugreportProgressService is invoked twice quickly, and both services create the same bugreport file name. The later one may delete current running bugreport file in its clean function, when it detects another bugreport is running. Bug: 174314124 Bug: 175287931 Test: atest BugreportReceiverTest Change-Id: I5e1802c5912f4414f1ad3b8bdaf7c7420332b9d6 Merged-In: I5e1802c5912f4414f1ad3b8bdaf7c7420332b9d6
Diffstat (limited to 'packages/Shell/tests')
-rw-r--r--packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
index 89cdeaea199c..947691206741 100644
--- a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
+++ b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
@@ -40,6 +40,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.timeout;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import android.app.ActivityManager;
@@ -534,6 +535,18 @@ public class BugreportReceiverTest {
assertActionSendMultiple(extras);
}
+ @Test
+ public void testBugreportRequestTwice_oneStartBugreportInvoked() throws Exception {
+ sendBugreportStarted();
+ new BugreportRequestedReceiver().onReceive(mContext,
+ new Intent(INTENT_BUGREPORT_REQUESTED));
+ getInstrumentation().waitForIdleSync();
+
+ verify(mMockIDumpstate, times(1)).startBugreport(anyInt(), any(), any(), any(),
+ anyInt(), any(), anyBoolean());
+ sendBugreportFinished();
+ }
+
private void cancelExistingNotifications() {
// Must kill service first, because notifications from a foreground service cannot be
// canceled.