diff options
| author | 2021-01-06 11:23:40 +0000 | |
|---|---|---|
| committer | 2021-01-06 11:23:40 +0000 | |
| commit | 3adb225c8bedfff4e7bfa57903af3ffcf7d44167 (patch) | |
| tree | 52356a01eb597ee0cf84ceef348dd05c0ccd7f3d | |
| parent | abe52a0718a7526ec4a118462070420a5a6d184b (diff) | |
| parent | 918cc97a126b36b5e1a2e62cbf305aee24c9e20c (diff) | |
Merge changes I5e1802c5,I4542568f,I99a052d7,Iae89206d,Ie955266a am: 9ca3672319 am: 918cc97a12
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1532905
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: Ic99132f50babb1d890f737dc3a54e5b381f3c890
| -rw-r--r-- | packages/Shell/src/com/android/shell/BugreportProgressService.java | 15 | ||||
| -rw-r--r-- | packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java | 13 |
2 files changed, 24 insertions, 4 deletions
diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java index 2b71892ee8a5..8b73c5ed552e 100644 --- a/packages/Shell/src/com/android/shell/BugreportProgressService.java +++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java @@ -618,12 +618,21 @@ public class BugreportProgressService extends Service { BugreportInfo info = new BugreportInfo(mContext, baseName, name, shareTitle, shareDescription, bugreportType, mBugreportsDir); + synchronized (mLock) { + if (info.bugreportFile.exists()) { + Log.e(TAG, "Failed to start bugreport generation, the requested bugreport file " + + info.bugreportFile + " already exists"); + return; + } + info.createBugreportFile(); + } ParcelFileDescriptor bugreportFd = info.getBugreportFd(); if (bugreportFd == null) { Log.e(TAG, "Failed to start bugreport generation as " + " bugreport parcel file descriptor is null."); return; } + info.createScreenshotFile(mBugreportsDir); ParcelFileDescriptor screenshotFd = null; if (isDefaultScreenshotRequired(bugreportType, /* hasScreenshotButton= */ !mIsTv)) { screenshotFd = info.getDefaultScreenshotFd(); @@ -1918,12 +1927,10 @@ public class BugreportProgressService extends Service { this.shareDescription = shareDescription == null ? "" : shareDescription; this.type = type; this.baseName = baseName; - createBugreportFile(bugreportsDir); - createScreenshotFile(bugreportsDir); + this.bugreportFile = new File(bugreportsDir, getFileName(this, ".zip")); } - void createBugreportFile(File bugreportsDir) { - bugreportFile = new File(bugreportsDir, getFileName(this, ".zip")); + void createBugreportFile() { createReadWriteFile(bugreportFile); } 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. |