diff options
| author | 2024-07-09 18:48:00 +0000 | |
|---|---|---|
| committer | 2024-07-09 18:48:00 +0000 | |
| commit | 0b6f68a30b9a0d651d488addf647b7002f6ece27 (patch) | |
| tree | b40b59399b10521c76cbb969daec14facdd6fe66 | |
| parent | d4a7ac677111a1fb43bbc553f09e8a264f243c5e (diff) | |
| parent | 39d35099fcffa12b6322e73e0a99ce1ce59b3262 (diff) | |
Merge "Share available TAGs with other processes via IPC." into main
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueDialogDelegate.kt | 5 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/recordissue/TraceurMessageSender.kt | 39 |
2 files changed, 41 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueDialogDelegate.kt index bbf4e51b35e9..8a51ad4cbd71 100644 --- a/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueDialogDelegate.kt +++ b/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueDialogDelegate.kt @@ -87,7 +87,10 @@ constructor( setNegativeButton(R.string.cancel) { _, _ -> } setPositiveButton(R.string.qs_record_issue_start) { _, _ -> onStarted.run() } } - bgExecutor.execute { traceurMessageSender.bindToTraceur(dialog.context) } + bgExecutor.execute { + traceurMessageSender.onBoundToTraceur.add { traceurMessageSender.getTags() } + traceurMessageSender.bindToTraceur(dialog.context) + } } override fun createDialog(): SystemUIDialog = factory.create(this) diff --git a/packages/SystemUI/src/com/android/systemui/recordissue/TraceurMessageSender.kt b/packages/SystemUI/src/com/android/systemui/recordissue/TraceurMessageSender.kt index 903d662c69ff..a31a9ef26b16 100644 --- a/packages/SystemUI/src/com/android/systemui/recordissue/TraceurMessageSender.kt +++ b/packages/SystemUI/src/com/android/systemui/recordissue/TraceurMessageSender.kt @@ -45,11 +45,15 @@ class TraceurMessageSender @Inject constructor(@Background private val backgroun private var binder: Messenger? = null private var isBound: Boolean = false + val onBoundToTraceur = mutableListOf<Runnable>() + private val traceurConnection = object : ServiceConnection { override fun onServiceConnected(className: ComponentName, service: IBinder) { binder = Messenger(service) isBound = true + onBoundToTraceur.forEach(Runnable::run) + onBoundToTraceur.clear() } override fun onServiceDisconnected(className: ComponentName) { @@ -103,11 +107,17 @@ class TraceurMessageSender @Inject constructor(@Background private val backgroun @WorkerThread fun shareTraces(context: Context, screenRecord: Uri?) { - val replyHandler = Messenger(TraceurMessageHandler(context, screenRecord, backgroundLooper)) + val replyHandler = Messenger(ShareFilesHandler(context, screenRecord, backgroundLooper)) notifyTraceur(MessageConstants.SHARE_WHAT, replyTo = replyHandler) } @WorkerThread + fun getTags() { + val replyHandler = Messenger(TagsHandler(backgroundLooper)) + notifyTraceur(MessageConstants.TAGS_WHAT, replyTo = replyHandler) + } + + @WorkerThread private fun notifyTraceur(what: Int, data: Bundle = Bundle(), replyTo: Messenger? = null) { try { binder!!.send( @@ -122,7 +132,7 @@ class TraceurMessageSender @Inject constructor(@Background private val backgroun } } - private class TraceurMessageHandler( + private class ShareFilesHandler( private val context: Context, private val screenRecord: Uri?, looper: Looper, @@ -154,4 +164,29 @@ class TraceurMessageSender @Inject constructor(@Background private val backgroun context.startActivity(fileSharingIntent) } } + + private class TagsHandler(looper: Looper) : Handler(looper) { + + override fun handleMessage(msg: Message) { + if (MessageConstants.TAGS_WHAT == msg.what) { + val keys = msg.data.getStringArrayList(MessageConstants.BUNDLE_KEY_TAGS) + val values = + msg.data.getStringArrayList(MessageConstants.BUNDLE_KEY_TAG_DESCRIPTIONS) + if (keys == null || values == null) { + throw IllegalArgumentException( + "Neither keys: $keys, nor values: $values can " + "be null" + ) + } + + val tags = keys.zip(values).map { "${it.first}: ${it.second}" }.toSet() + Log.e( + TAG, + "These tags: $tags will be saved and used for the Custom Trace" + + " Config dialog in a future CL. This log will be removed." + ) + } else { + throw IllegalArgumentException("received unknown msg.what: " + msg.what) + } + } + } } |