diff options
5 files changed, 37 insertions, 22 deletions
diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl index ffb920b907ab..f880901429f7 100644 --- a/core/java/android/app/IActivityManager.aidl +++ b/core/java/android/app/IActivityManager.aidl @@ -501,7 +501,7 @@ interface IActivityManager { in String shareDescription); void requestInteractiveBugReport(); - void requestBugReportWithExtraAttachment(in Uri extraAttachment); + void requestBugReportWithExtraAttachments(in List<Uri> extraAttachment); void requestFullBugReport(); void requestRemoteBugReport(long nonce); boolean launchBugReportHandlerApp(); diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java index bcfd8f620f9c..0a68e6791df5 100644 --- a/packages/Shell/src/com/android/shell/BugreportProgressService.java +++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java @@ -90,10 +90,10 @@ import com.android.internal.app.ChooserActivity; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; -import libcore.io.Streams; - import com.google.android.collect.Lists; +import libcore.io.Streams; + import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.File; @@ -171,8 +171,8 @@ public class BugreportProgressService extends Service { static final String EXTRA_DESCRIPTION = "android.intent.extra.DESCRIPTION"; static final String EXTRA_ORIGINAL_INTENT = "android.intent.extra.ORIGINAL_INTENT"; static final String EXTRA_INFO = "android.intent.extra.INFO"; - static final String EXTRA_EXTRA_ATTACHMENT_URI = - "android.intent.extra.EXTRA_ATTACHMENT_URI"; + static final String EXTRA_EXTRA_ATTACHMENT_URIS = + "android.intent.extra.EXTRA_ATTACHMENT_URIS"; private static final int MSG_SERVICE_COMMAND = 1; private static final int MSG_DELAYED_SCREENSHOT = 2; @@ -682,10 +682,11 @@ public class BugreportProgressService extends Service { long nonce = intent.getLongExtra(EXTRA_BUGREPORT_NONCE, 0); String baseName = getBugreportBaseName(bugreportType); String name = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date()); - Uri extraAttachment = intent.getParcelableExtra(EXTRA_EXTRA_ATTACHMENT_URI, Uri.class); + List<Uri> extraAttachments = + intent.getParcelableArrayListExtra(EXTRA_EXTRA_ATTACHMENT_URIS, Uri.class); BugreportInfo info = new BugreportInfo(mContext, baseName, name, shareTitle, - shareDescription, bugreportType, mBugreportsDir, nonce, extraAttachment); + shareDescription, bugreportType, mBugreportsDir, nonce, extraAttachments); synchronized (mLock) { if (info.bugreportFile.exists()) { Log.e(TAG, "Failed to start bugreport generation, the requested bugreport file " @@ -1233,9 +1234,13 @@ public class BugreportProgressService extends Service { clipData.addItem(new ClipData.Item(null, null, null, screenshotUri)); attachments.add(screenshotUri); } - if (info.extraAttachment != null) { - clipData.addItem(new ClipData.Item(null, null, null, info.extraAttachment)); - attachments.add(info.extraAttachment); + if (info.extraAttachments != null) { + info.extraAttachments.forEach(it -> { + if (it != null) { + clipData.addItem(new ClipData.Item(null, null, null, it)); + attachments.add(it); + } + }); } intent.setClipData(clipData); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments); @@ -2096,7 +2101,7 @@ public class BugreportProgressService extends Service { final long nonce; @Nullable - public Uri extraAttachment = null; + public List<Uri> extraAttachments = null; private final Object mLock = new Object(); @@ -2106,7 +2111,7 @@ public class BugreportProgressService extends Service { BugreportInfo(Context context, String baseName, String name, @Nullable String shareTitle, @Nullable String shareDescription, @BugreportParams.BugreportMode int type, File bugreportsDir, long nonce, - @Nullable Uri extraAttachment) { + @Nullable List<Uri> extraAttachments) { this.context = context; this.name = this.initialName = name; this.shareTitle = shareTitle == null ? "" : shareTitle; @@ -2115,7 +2120,7 @@ public class BugreportProgressService extends Service { this.nonce = nonce; this.baseName = baseName; this.bugreportFile = new File(bugreportsDir, getFileName(this, ".zip")); - this.extraAttachment = extraAttachment; + this.extraAttachments = extraAttachments; } void createBugreportFile() { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceSessionTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceSessionTest.kt index 9dbcf18b2416..aceaab8206a2 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceSessionTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceSessionTest.kt @@ -115,7 +115,7 @@ class IssueRecordingServiceSessionTest : SysuiTestCase() { underTest.share(0, uri) bgExecutor.runAllReady() - verify(iActivityManager).requestBugReportWithExtraAttachment(uri) + verify(iActivityManager).requestBugReportWithExtraAttachments(any()) } @Test diff --git a/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingServiceSession.kt b/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingServiceSession.kt index 06407acb62d0..43539335d8e4 100644 --- a/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingServiceSession.kt +++ b/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingServiceSession.kt @@ -18,6 +18,7 @@ package com.android.systemui.recordissue import android.app.IActivityManager import android.app.NotificationManager +import android.content.Intent import android.net.Uri import android.os.UserHandle import android.provider.Settings @@ -27,6 +28,7 @@ import com.android.systemui.settings.UserContextProvider import com.android.traceur.PresetTraceConfigs import java.util.concurrent.Executor +private const val SHELL_PACKAGE = "com.android.shell" private const val NOTIFY_SESSION_ENDED_SETTING = "should_notify_trace_session_ended" private const val DISABLED = 0 @@ -86,7 +88,14 @@ class IssueRecordingServiceSession( } } if (takeBugReport) { - iActivityManager.requestBugReportWithExtraAttachment(screenRecording) + screenRecordingUris.forEach { + userContextProvider.userContext.grantUriPermission( + SHELL_PACKAGE, + it, + Intent.FLAG_GRANT_READ_URI_PERMISSION, + ) + } + iActivityManager.requestBugReportWithExtraAttachments(screenRecordingUris) } else { traceurConnection.shareTraces(screenRecordingUris) } diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 6ba851423219..a6189d2148fa 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -632,8 +632,8 @@ public class ActivityManagerService extends IActivityManager.Stub static final String EXTRA_DESCRIPTION = "android.intent.extra.DESCRIPTION"; static final String EXTRA_BUGREPORT_TYPE = "android.intent.extra.BUGREPORT_TYPE"; static final String EXTRA_BUGREPORT_NONCE = "android.intent.extra.BUGREPORT_NONCE"; - static final String EXTRA_EXTRA_ATTACHMENT_URI = - "android.intent.extra.EXTRA_ATTACHMENT_URI"; + static final String EXTRA_EXTRA_ATTACHMENT_URIS = + "android.intent.extra.EXTRA_ATTACHMENT_URIS"; /** * The maximum number of bytes that {@link #setProcessStateSummary} accepts. @@ -7660,7 +7660,7 @@ public class ActivityManagerService extends IActivityManager.Stub */ public void requestBugReportWithDescription(@Nullable String shareTitle, @Nullable String shareDescription, int bugreportType, long nonce, - @Nullable Uri extraAttachment) { + @Nullable List<Uri> extraAttachments) { String type = null; switch (bugreportType) { case BugreportParams.BUGREPORT_MODE_FULL: @@ -7715,8 +7715,9 @@ public class ActivityManagerService extends IActivityManager.Stub triggerShellBugreport.setPackage(SHELL_APP_PACKAGE); triggerShellBugreport.putExtra(EXTRA_BUGREPORT_TYPE, bugreportType); triggerShellBugreport.putExtra(EXTRA_BUGREPORT_NONCE, nonce); - if (extraAttachment != null) { - triggerShellBugreport.putExtra(EXTRA_EXTRA_ATTACHMENT_URI, extraAttachment); + if (extraAttachments != null && !extraAttachments.isEmpty()) { + triggerShellBugreport.putParcelableArrayListExtra(EXTRA_EXTRA_ATTACHMENT_URIS, + new ArrayList(extraAttachments)); triggerShellBugreport.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } triggerShellBugreport.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); @@ -7775,9 +7776,9 @@ public class ActivityManagerService extends IActivityManager.Stub * Takes an interactive bugreport with a progress notification. Also attaches given file uri. */ @Override - public void requestBugReportWithExtraAttachment(@NonNull Uri extraAttachment) { + public void requestBugReportWithExtraAttachments(@NonNull List<Uri> extraAttachments) { requestBugReportWithDescription(null, null, BugreportParams.BUGREPORT_MODE_INTERACTIVE, 0L, - extraAttachment); + extraAttachments); } /** |