Loading aconfig/systemui.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -69,3 +69,10 @@ flag { description: "Enables the BC25 design of the customization picker UI." bug: "339081035" } flag { name: "ambient_aod" namespace: "systemui" description: "Enables ambient wallpaper and AOD enhancements" bug: "372655702" } No newline at end of file viewcapturelib/src/com/android/app/viewcapture/ViewCaptureFactory.kt +53 −52 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.app.viewcapture import android.content.Context import android.os.Looper import android.os.Process import android.tracing.Flags import android.util.Log Loading @@ -27,21 +26,12 @@ import android.view.WindowManager * Factory to create polymorphic instances of ViewCapture according to build configurations and * flags. */ class ViewCaptureFactory { companion object { object ViewCaptureFactory { private val TAG = ViewCaptureFactory::class.java.simpleName private var instance: ViewCapture? = null @JvmStatic fun getInstance(context: Context): ViewCapture { if (Looper.myLooper() != Looper.getMainLooper()) { return ViewCapture.MAIN_EXECUTOR.submit { getInstance(context) }.get() } if (instance != null) { return instance!! } private val instance: ViewCapture by lazy { createInstance() } private lateinit var appContext: Context private fun createInstance(): ViewCapture { return when { !android.os.Build.IS_DEBUGGABLE -> { Log.i(TAG, "instantiating ${NoOpViewCapture::class.java.simpleName}") Loading @@ -50,39 +40,50 @@ class ViewCaptureFactory { !Flags.perfettoViewCaptureTracing() -> { Log.i(TAG, "instantiating ${SettingsAwareViewCapture::class.java.simpleName}") SettingsAwareViewCapture( context.applicationContext, appContext, ViewCapture.createAndStartNewLooperExecutor( "SAViewCapture", Process.THREAD_PRIORITY_FOREGROUND ) Process.THREAD_PRIORITY_FOREGROUND, ), ) } else -> { Log.i(TAG, "instantiating ${PerfettoViewCapture::class.java.simpleName}") PerfettoViewCapture( context.applicationContext, appContext, ViewCapture.createAndStartNewLooperExecutor( "PerfettoViewCapture", Process.THREAD_PRIORITY_FOREGROUND ) Process.THREAD_PRIORITY_FOREGROUND, ), ) } }.also { instance = it } } } /** Returns an instance of [ViewCapture]. */ @JvmStatic fun getInstance(context: Context): ViewCapture { synchronized(this) { if (this::appContext.isInitialized && appContext != context.applicationContext) { throw IllegalStateException("appContext is already set to a different value") } appContext = context.applicationContext } return instance } /** Returns an instance of [ViewCaptureAwareWindowManager]. */ @JvmStatic fun getViewCaptureAwareWindowManagerInstance( context: Context, isViewCaptureTracingEnabled: Boolean isViewCaptureTracingEnabled: Boolean, ): ViewCaptureAwareWindowManager { val windowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager val lazyViewCapture = lazy { getInstance(context) } return ViewCaptureAwareWindowManager( windowManager, lazyViewCapture, isViewCaptureTracingEnabled isViewCaptureTracingEnabled, ) } } } Loading
aconfig/systemui.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -69,3 +69,10 @@ flag { description: "Enables the BC25 design of the customization picker UI." bug: "339081035" } flag { name: "ambient_aod" namespace: "systemui" description: "Enables ambient wallpaper and AOD enhancements" bug: "372655702" } No newline at end of file
viewcapturelib/src/com/android/app/viewcapture/ViewCaptureFactory.kt +53 −52 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.app.viewcapture import android.content.Context import android.os.Looper import android.os.Process import android.tracing.Flags import android.util.Log Loading @@ -27,21 +26,12 @@ import android.view.WindowManager * Factory to create polymorphic instances of ViewCapture according to build configurations and * flags. */ class ViewCaptureFactory { companion object { object ViewCaptureFactory { private val TAG = ViewCaptureFactory::class.java.simpleName private var instance: ViewCapture? = null @JvmStatic fun getInstance(context: Context): ViewCapture { if (Looper.myLooper() != Looper.getMainLooper()) { return ViewCapture.MAIN_EXECUTOR.submit { getInstance(context) }.get() } if (instance != null) { return instance!! } private val instance: ViewCapture by lazy { createInstance() } private lateinit var appContext: Context private fun createInstance(): ViewCapture { return when { !android.os.Build.IS_DEBUGGABLE -> { Log.i(TAG, "instantiating ${NoOpViewCapture::class.java.simpleName}") Loading @@ -50,39 +40,50 @@ class ViewCaptureFactory { !Flags.perfettoViewCaptureTracing() -> { Log.i(TAG, "instantiating ${SettingsAwareViewCapture::class.java.simpleName}") SettingsAwareViewCapture( context.applicationContext, appContext, ViewCapture.createAndStartNewLooperExecutor( "SAViewCapture", Process.THREAD_PRIORITY_FOREGROUND ) Process.THREAD_PRIORITY_FOREGROUND, ), ) } else -> { Log.i(TAG, "instantiating ${PerfettoViewCapture::class.java.simpleName}") PerfettoViewCapture( context.applicationContext, appContext, ViewCapture.createAndStartNewLooperExecutor( "PerfettoViewCapture", Process.THREAD_PRIORITY_FOREGROUND ) Process.THREAD_PRIORITY_FOREGROUND, ), ) } }.also { instance = it } } } /** Returns an instance of [ViewCapture]. */ @JvmStatic fun getInstance(context: Context): ViewCapture { synchronized(this) { if (this::appContext.isInitialized && appContext != context.applicationContext) { throw IllegalStateException("appContext is already set to a different value") } appContext = context.applicationContext } return instance } /** Returns an instance of [ViewCaptureAwareWindowManager]. */ @JvmStatic fun getViewCaptureAwareWindowManagerInstance( context: Context, isViewCaptureTracingEnabled: Boolean isViewCaptureTracingEnabled: Boolean, ): ViewCaptureAwareWindowManager { val windowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager val lazyViewCapture = lazy { getInstance(context) } return ViewCaptureAwareWindowManager( windowManager, lazyViewCapture, isViewCaptureTracingEnabled isViewCaptureTracingEnabled, ) } } }