summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Stefan Andonian <andonian@google.com> 2024-04-09 23:43:54 +0000
committer Stefan Andonian <andonian@google.com> 2024-04-16 21:52:36 +0000
commitdd80507ca5246eee9fc92673379ae3ae4c91fef3 (patch)
treed2d4c8666d98605d75f8b2ce606fac2a2d89cace
parent771a4e9bb1e6abb0097d6cc56ff3978099c0ec27 (diff)
Upload Perfetto Trace and Screen Recording as Unique Files when
recording an issue. This is part of the RecordIssueTile. These files are not all openable within solely the winscope web ui. Particularly, the perfetto file is not useful in winscope, but has it's own ui. The screen recording likewise can individually be opened in buganizer without the need to pull all traces into winscope. Also fixed issue where crash would happen if traces.get was null (which happens if share notification is clicked more than once). Bug: 305049544 Test: Tested this locally on device. Flag: ACONFIG record_issue_qs_tile STAGING Change-Id: Ib45005c1755e6bccd26d34eee29b72685cda3b50
-rw-r--r--packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt39
1 files changed, 21 insertions, 18 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt b/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt
index 4d34a869002a..4e290e699ac4 100644
--- a/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt
+++ b/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt
@@ -47,6 +47,7 @@ import java.util.concurrent.Executor
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
import javax.inject.Inject
+import kotlin.jvm.optionals.getOrElse
class IssueRecordingService
@Inject
@@ -140,15 +141,25 @@ constructor(
}
private fun shareRecording(screenRecording: Uri?) {
- val sharableUri: Uri =
- zipAndPackageRecordings(
- TraceUtils.traceDump(contentResolver, TRACE_FILE_NAME).get(),
- screenRecording
- )
- ?: return
+ val traces =
+ TraceUtils.traceDump(contentResolver, TRACE_FILE_NAME).getOrElse {
+ Log.v(
+ TAG,
+ "Traces were not present. This can happen if users double" +
+ "click on share notification. Traces are cleaned up after sharing" +
+ "so they won't be present for the 2nd share attempt."
+ )
+ return
+ }
+ val perfetto = FileProvider.getUriForFile(this, AUTHORITY, traces.first())
+ val urisToShare = mutableListOf(perfetto)
+ traces.removeFirst()
+
+ getZipWinscopeFileUri(traces)?.let { urisToShare.add(it) }
+ screenRecording?.let { urisToShare.add(it) }
+
val sendIntent =
- FileSender.buildSendIntent(this, listOf(sharableUri))
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ FileSender.buildSendIntent(this, urisToShare).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
// TODO: Debug why the notification shade isn't closing upon starting the BetterBug activity
mKeyguardDismissUtil.executeWhenUnlocked(
@@ -161,7 +172,7 @@ constructor(
)
}
- private fun zipAndPackageRecordings(traceFiles: List<File>, screenRecording: Uri?): Uri? {
+ private fun getZipWinscopeFileUri(traceFiles: List<File>): Uri? {
try {
externalCacheDir?.mkdirs()
val outZip: File = File.createTempFile(TEMP_FILE_PREFIX, ZIP_SUFFIX, externalCacheDir)
@@ -171,13 +182,6 @@ constructor(
Files.copy(file.toPath(), os)
os.closeEntry()
}
- if (screenRecording != null) {
- contentResolver.openInputStream(screenRecording)?.use {
- os.putNextEntry(ZipEntry(SCREEN_RECORDING_ZIP_LABEL))
- it.transferTo(os)
- os.closeEntry()
- }
- }
}
return FileProvider.getUriForFile(this, AUTHORITY, outZip)
} catch (e: Exception) {
@@ -192,8 +196,7 @@ constructor(
private const val EXTRA_SCREEN_RECORD = "extra_screenRecord"
private const val EXTRA_WINSCOPE_TRACING = "extra_winscopeTracing"
private const val ZIP_SUFFIX = ".zip"
- private const val TEMP_FILE_PREFIX = "issue_recording"
- private const val SCREEN_RECORDING_ZIP_LABEL = "screen-recording.mp4"
+ private const val TEMP_FILE_PREFIX = "winscope_recordings"
private val DEFAULT_TRACE_TAGS = listOf<String>()
private const val DEFAULT_BUFFER_SIZE = 16384