Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78f595c8 authored by Graciela Putri's avatar Graciela Putri Committed by Android (Google) Code Review
Browse files

Merge "Run ktfmt on shell/compatui" into main

parents 236f3901 931a2eb1
Loading
Loading
Loading
Loading
+31 −38
Original line number Diff line number Diff line
@@ -30,9 +30,7 @@ import android.view.WindowlessWindowManager
import com.android.wm.shell.common.DisplayLayout
import com.android.wm.shell.common.SyncTransactionQueue

/**
 * The component created after a {@link CompatUISpec} definition
 */
/** The component created after a {@link CompatUISpec} definition */
class CompatUIComponent(
    private val spec: CompatUISpec,
    private val id: String,
@@ -40,13 +38,14 @@ class CompatUIComponent(
    private val state: CompatUIState,
    private var compatUIInfo: CompatUIInfo,
    private val syncQueue: SyncTransactionQueue,
    private var displayLayout: DisplayLayout?
) : WindowlessWindowManager(
    private var displayLayout: DisplayLayout?,
) :
    WindowlessWindowManager(
        compatUIInfo.taskInfo.configuration,
        /* rootSurface */
        null,
        /* hostInputToken */
    null
        null,
    ) {

    private val tag
@@ -56,20 +55,17 @@ class CompatUIComponent(

    private var layout: View? = null

    /**
     * Utility class for adding and releasing a View hierarchy for this [ ] to `mLeash`.
     */
    /** Utility class for adding and releasing a View hierarchy for this [ ] to `mLeash`. */
    protected var viewHost: SurfaceControlViewHost? = null

    override fun setConfiguration(configuration: Configuration?) {
        super.setConfiguration(configuration)
        configuration?.let {
            context = context.createConfigurationContext(it)
        }
        configuration?.let { context = context.createConfigurationContext(it) }
    }

    /**
     * Invoked every time a new CompatUIInfo comes from core
     *
     * @param newInfo The new CompatUIInfo object
     */
    fun update(newInfo: CompatUIInfo) {
@@ -89,11 +85,7 @@ class CompatUIComponent(
        viewHost = null
        leash?.run {
            val localLeash: SurfaceControl = this
            syncQueue.runInSync { t: SurfaceControl.Transaction ->
                t.remove(
                    localLeash
                )
            }
            syncQueue.runInSync { t: SurfaceControl.Transaction -> t.remove(localLeash) }
            leash = null
            spec.log("$tag leash removed")
        }
@@ -102,10 +94,11 @@ class CompatUIComponent(

    override fun getParentSurface(
        window: IWindow,
        attrs: WindowManager.LayoutParams
        attrs: WindowManager.LayoutParams,
    ): SurfaceControl? {
        val className = javaClass.simpleName
        val builder = SurfaceControl.Builder()
        val builder =
            SurfaceControl.Builder()
                .setContainerLayer()
                .setName(className + "Leash")
                .setHidden(false)
@@ -129,7 +122,8 @@ class CompatUIComponent(
        // We inflate the layout
        layout = spec.layout.viewBuilder(context, compatUIInfo, componentState)
        spec.log("$tag layout: $layout")
        viewHost = createSurfaceViewHost().apply {
        viewHost =
            createSurfaceViewHost().apply {
                spec.log("$tag adding view $layout to host $this")
                setView(layout!!, getWindowLayoutParams())
            }
@@ -156,7 +150,7 @@ class CompatUIComponent(
                    it,
                    compatUIInfo,
                    state.sharedState,
                    state.stateForComponent(id)
                    state.stateForComponent(id),
                )
            )
        }
@@ -170,13 +164,14 @@ class CompatUIComponent(
                height,
                WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
                spec.layout.layoutParamFlags,
                PixelFormat.TRANSLUCENT
                PixelFormat.TRANSLUCENT,
            )
        winParams.token = Binder()
        winParams.title = javaClass.simpleName + compatUIInfo.taskInfo.taskId
        winParams.privateFlags =
            winParams.privateFlags or (WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION
                    or WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY)
            winParams.privateFlags or
                (WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION or
                    WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY)
        spec.log("$tag getWindowLayoutParams $winParams")
        return winParams
    }
@@ -185,9 +180,7 @@ class CompatUIComponent(
    protected fun getWindowLayoutParams(): WindowManager.LayoutParams =
        layout?.run {
            measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
            spec.log(
                "$tag getWindowLayoutParams size: ${measuredWidth}x$measuredHeight"
            )
            spec.log("$tag getWindowLayoutParams size: ${measuredWidth}x$measuredHeight")
            return getWindowLayoutParams(measuredWidth, measuredHeight)
        } ?: WindowManager.LayoutParams()

@@ -207,7 +200,7 @@ class CompatUIComponent(

    private fun updateComponentState(
        newInfo: CompatUIInfo,
        componentState: CompatUIComponentState?
        componentState: CompatUIComponentState?,
    ) {
        spec.log("$tag component state updating.... $componentState")
        compatUIInfo = newInfo
+1 −3
Original line number Diff line number Diff line
@@ -16,9 +16,7 @@

package com.android.wm.shell.compatui.api

/**
 * Abstracts the component responsible for the creation of a component
 */
/** Abstracts the component responsible for the creation of a component */
interface CompatUIComponentFactory {

    fun create(
+6 −7
Original line number Diff line number Diff line
@@ -16,14 +16,13 @@

package com.android.wm.shell.compatui.api

/**
 * Any object responsible to generate an id for a component.
 */
/** Any object responsible to generate an id for a component. */
interface CompatUIComponentIdGenerator {

    /**
     * Generates the unique id for a component given a {@link CompatUIInfo} and component
     * {@link CompatUISpec}.
     * Generates the unique id for a component given a {@link CompatUIInfo} and component {@link
     * CompatUISpec}.
     *
     * @param compatUIInfo The object encapsulating information about the current Task.
     * @param spec The {@link CompatUISpec} for the component.
     */
+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
package com.android.wm.shell.compatui.api

/**
 * Abstraction of all the component specific state. Each
 * component can create its own state implementing this interface.
 * Abstraction of all the component specific state. Each component can create its own state
 * implementing this interface.
 */
interface CompatUIComponentState
+4 −9
Original line number Diff line number Diff line
@@ -16,17 +16,12 @@

package com.android.wm.shell.compatui.api

/**
 * Abstraction for all the possible Compat UI Component events.
 */
/** Abstraction for all the possible Compat UI Component events. */
interface CompatUIEvent {
    /**
     * Unique event identifier
     */
    /** Unique event identifier */
    val eventId: Int

    @Suppress("UNCHECKED_CAST")
    fun <T : CompatUIEvent> asType(): T? = this as? T
    @Suppress("UNCHECKED_CAST") fun <T : CompatUIEvent> asType(): T? = this as? T

    fun <T : CompatUIEvent> asType(clazz: Class<T>): T? {
        return if (clazz.isInstance(this)) clazz.cast(this) else null
Loading