mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Restore background tracing touch target (#53753)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53753 Changelog: [Internal] Reviewed By: rubennorte Differential Revision: D82302063 fbshipit-source-id: 25c99c2449fd72b81ce3ac25473c41304993cbc1
This commit is contained in:
committed by
Facebook GitHub Bot
parent
136d795c22
commit
d28ee162e3
+1
@@ -229,6 +229,7 @@ public abstract class DevSupportManagerBase(
|
||||
}
|
||||
context
|
||||
},
|
||||
{ openDebugger(DebuggerFrontendPanelName.PERFORMANCE.toString()) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+17
-1
@@ -15,10 +15,12 @@ import javax.inject.Provider
|
||||
internal class PerfMonitorOverlayManager(
|
||||
private val devHelper: PerfMonitorDevHelper,
|
||||
private val contextProvider: Provider<Context?>,
|
||||
private val onRequestOpenDevTools: () -> Unit,
|
||||
) : PerfMonitorUpdateListener {
|
||||
private var enabled: Boolean = false
|
||||
private var initialized: Boolean = false
|
||||
private var view: PerfMonitorOverlayView? = null
|
||||
private var tracingState: TracingState = TracingState.ENABLEDINCDPMODE
|
||||
|
||||
private fun init() {
|
||||
if (initialized || !enabled) {
|
||||
@@ -27,7 +29,7 @@ internal class PerfMonitorOverlayManager(
|
||||
|
||||
UiThreadUtil.runOnUiThread {
|
||||
val context = contextProvider.get() ?: return@runOnUiThread
|
||||
view = PerfMonitorOverlayView(context)
|
||||
view = PerfMonitorOverlayView(context, ::handleRecordingButtonPress)
|
||||
|
||||
// Start background tracing
|
||||
devHelper.inspectorTarget?.resumeBackgroundTrace()
|
||||
@@ -59,6 +61,20 @@ internal class PerfMonitorOverlayManager(
|
||||
}
|
||||
|
||||
override fun onRecordingStateChanged(state: TracingState) {
|
||||
tracingState = state
|
||||
view?.updateRecordingState(state)
|
||||
}
|
||||
|
||||
private fun handleRecordingButtonPress() {
|
||||
when (tracingState) {
|
||||
TracingState.ENABLEDINBACKGROUNDMODE -> {
|
||||
devHelper.inspectorTarget?.pauseAndAnalyzeBackgroundTrace()
|
||||
onRequestOpenDevTools()
|
||||
}
|
||||
TracingState.DISABLED -> {
|
||||
devHelper.inspectorTarget?.resumeBackgroundTrace()
|
||||
}
|
||||
TracingState.ENABLEDINCDPMODE -> Unit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-13
@@ -27,6 +27,7 @@ import com.facebook.react.uimanager.PixelUtil
|
||||
|
||||
internal class PerfMonitorOverlayView(
|
||||
private val context: Context,
|
||||
private val onButtonPress: () -> Unit,
|
||||
) {
|
||||
private val dialog: Dialog
|
||||
private lateinit var statusLabel: TextView
|
||||
@@ -101,22 +102,11 @@ internal class PerfMonitorOverlayView(
|
||||
textContainer.addView(tooltipLabel)
|
||||
|
||||
val containerLayout = createInnerLayout()
|
||||
containerLayout.setOnClickListener { onButtonPress() }
|
||||
containerLayout.addView(statusIndicator)
|
||||
containerLayout.addView(textContainer)
|
||||
|
||||
val dialog =
|
||||
createAnchoredDialog(dpToPx(12f), dpToPx(12f)).apply { setContentView(containerLayout) }
|
||||
dialog.window?.apply {
|
||||
attributes =
|
||||
attributes?.apply {
|
||||
flags =
|
||||
flags or
|
||||
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE or
|
||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
||||
}
|
||||
}
|
||||
|
||||
return dialog
|
||||
return createAnchoredDialog(dpToPx(12f), dpToPx(12f)).apply { setContentView(containerLayout) }
|
||||
}
|
||||
|
||||
private fun createAnchoredDialog(offsetX: Float, offsetY: Float): Dialog {
|
||||
|
||||
Reference in New Issue
Block a user