Merge changes I5e1802c5,I4542568f,I99a052d7,Iae89206d,Ie955266a am: 9ca3672319
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1532905 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I151bb11d0b36dae2ac6d67c9a57e1619543bd136
This commit is contained in:
@@ -618,12 +618,21 @@ public class BugreportProgressService extends Service {
|
|||||||
|
|
||||||
BugreportInfo info = new BugreportInfo(mContext, baseName, name,
|
BugreportInfo info = new BugreportInfo(mContext, baseName, name,
|
||||||
shareTitle, shareDescription, bugreportType, mBugreportsDir);
|
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();
|
ParcelFileDescriptor bugreportFd = info.getBugreportFd();
|
||||||
if (bugreportFd == null) {
|
if (bugreportFd == null) {
|
||||||
Log.e(TAG, "Failed to start bugreport generation as "
|
Log.e(TAG, "Failed to start bugreport generation as "
|
||||||
+ " bugreport parcel file descriptor is null.");
|
+ " bugreport parcel file descriptor is null.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
info.createScreenshotFile(mBugreportsDir);
|
||||||
ParcelFileDescriptor screenshotFd = null;
|
ParcelFileDescriptor screenshotFd = null;
|
||||||
if (isDefaultScreenshotRequired(bugreportType, /* hasScreenshotButton= */ !mIsTv)) {
|
if (isDefaultScreenshotRequired(bugreportType, /* hasScreenshotButton= */ !mIsTv)) {
|
||||||
screenshotFd = info.getDefaultScreenshotFd();
|
screenshotFd = info.getDefaultScreenshotFd();
|
||||||
@@ -1918,12 +1927,10 @@ public class BugreportProgressService extends Service {
|
|||||||
this.shareDescription = shareDescription == null ? "" : shareDescription;
|
this.shareDescription = shareDescription == null ? "" : shareDescription;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.baseName = baseName;
|
this.baseName = baseName;
|
||||||
createBugreportFile(bugreportsDir);
|
this.bugreportFile = new File(bugreportsDir, getFileName(this, ".zip"));
|
||||||
createScreenshotFile(bugreportsDir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void createBugreportFile(File bugreportsDir) {
|
void createBugreportFile() {
|
||||||
bugreportFile = new File(bugreportsDir, getFileName(this, ".zip"));
|
|
||||||
createReadWriteFile(bugreportFile);
|
createReadWriteFile(bugreportFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import static org.mockito.ArgumentMatchers.any;
|
|||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.Mockito.timeout;
|
import static org.mockito.Mockito.timeout;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
@@ -534,6 +535,18 @@ public class BugreportReceiverTest {
|
|||||||
assertActionSendMultiple(extras);
|
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() {
|
private void cancelExistingNotifications() {
|
||||||
// Must kill service first, because notifications from a foreground service cannot be
|
// Must kill service first, because notifications from a foreground service cannot be
|
||||||
// canceled.
|
// canceled.
|
||||||
|
|||||||
Reference in New Issue
Block a user