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

Commit 652d33bd authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use ShadeWindowGoesAround helper class instead of just reading the flag" into main

parents e3648b59 599b7208
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import com.android.app.viewcapture.ViewCaptureFactory;
import com.android.internal.view.FloatingActionMode;
import com.android.internal.widget.floatingtoolbar.FloatingToolbar;
import com.android.systemui.scene.ui.view.WindowRootView;
import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround;
import com.android.systemui.statusbar.phone.ConfigurationForwarder;

/**
@@ -168,11 +169,13 @@ public class NotificationShadeWindowView extends WindowRootView {
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        if (mConfigurationForwarder != null) {
            ShadeWindowGoesAround.isUnexpectedlyInLegacyMode();
            mConfigurationForwarder.onConfigurationChanged(newConfig);
        }
    }

    public void setConfigurationForwarder(ConfigurationForwarder configurationForwarder) {
        ShadeWindowGoesAround.isUnexpectedlyInLegacyMode();
        mConfigurationForwarder = configurationForwarder;
    }

+2 −1
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ import com.android.systemui.keyguard.shared.model.TransitionStep;
import com.android.systemui.res.R;
import com.android.systemui.scene.shared.flag.SceneContainerFlag;
import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor;
import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround;
import com.android.systemui.shared.animation.DisableSubpixelTextTransitionListener;
import com.android.systemui.statusbar.DragDownHelper;
import com.android.systemui.statusbar.LockscreenShadeTransitionController;
@@ -247,7 +248,7 @@ public class NotificationShadeWindowViewController implements Dumpable {
                            mDisableSubpixelTextTransitionListener));
        }

        if (com.android.systemui.Flags.shadeWindowGoesAround()) {
        if (ShadeWindowGoesAround.isEnabled()) {
            mView.setConfigurationForwarder(configurationForwarder);
        }
        dumpManager.registerDumpable(this);
+4 −4
Original line number Diff line number Diff line
@@ -20,10 +20,10 @@ import android.content.Context
import android.content.res.Resources
import android.view.LayoutInflater
import android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
import com.android.systemui.Flags
import com.android.systemui.common.ui.GlobalConfig
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.res.R
import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround
import com.android.systemui.statusbar.phone.ConfigurationControllerImpl
import com.android.systemui.statusbar.phone.ConfigurationForwarder
import com.android.systemui.statusbar.policy.ConfigurationController
@@ -50,7 +50,7 @@ object ShadeDisplayAwareModule {
    @ShadeDisplayAware
    @SysUISingleton
    fun provideShadeDisplayAwareContext(context: Context): Context {
        return if (Flags.shadeWindowGoesAround()) {
        return if (ShadeWindowGoesAround.isEnabled) {
            context
                .createWindowContext(context.display, TYPE_APPLICATION_OVERLAY, /* options= */ null)
                .apply { setTheme(R.style.Theme_SystemUI) }
@@ -81,7 +81,7 @@ object ShadeDisplayAwareModule {
        factory: ConfigurationControllerImpl.Factory,
        @GlobalConfig globalConfigConfigController: ConfigurationController,
    ): ConfigurationController {
        return if (Flags.shadeWindowGoesAround()) {
        return if (ShadeWindowGoesAround.isEnabled) {
            factory.create(shadeContext)
        } else {
            globalConfigConfigController
@@ -95,7 +95,7 @@ object ShadeDisplayAwareModule {
        @ShadeDisplayAware shadeConfigurationController: ConfigurationController,
        @GlobalConfig globalConfigController: ConfigurationController,
    ): ConfigurationForwarder {
        return if (Flags.shadeWindowGoesAround()) {
        return if (ShadeWindowGoesAround.isEnabled) {
            shadeConfigurationController
        } else {
            globalConfigController
+61 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.shade.shared.flag

import com.android.systemui.Flags
import com.android.systemui.flags.FlagToken
import com.android.systemui.flags.RefactorFlagUtils

/** Helper for reading or using the shade window goes around flag state. */
@Suppress("NOTHING_TO_INLINE")
object ShadeWindowGoesAround {
    /** The aconfig flag name */
    const val FLAG_NAME = Flags.FLAG_SHADE_WINDOW_GOES_AROUND

    /** A token used for dependency declaration */
    val token: FlagToken
        get() = FlagToken(FLAG_NAME, isEnabled)

    /** Is the refactor enabled */
    @JvmStatic
    inline val isEnabled
        get() = Flags.shadeWindowGoesAround()

    /**
     * Called to ensure code is only run when the flag is enabled. This protects users from the
     * unintended behaviors caused by accidentally running new logic, while also crashing on an eng
     * build to ensure that the refactor author catches issues in testing.
     */
    @JvmStatic
    inline fun isUnexpectedlyInLegacyMode() =
        RefactorFlagUtils.isUnexpectedlyInLegacyMode(isEnabled, FLAG_NAME)

    /**
     * Called to ensure code is only run when the flag is enabled. This will throw an exception if
     * the flag is not enabled to ensure that the refactor author catches issues in testing.
     * Caution!! Using this check incorrectly will cause crashes in nextfood builds!
     */
    @JvmStatic
    inline fun assertInNewMode() = RefactorFlagUtils.assertInNewMode(isEnabled, FLAG_NAME)

    /**
     * Called to ensure code is only run when the flag is disabled. This will throw an exception if
     * the flag is enabled to ensure that the refactor author catches issues in testing.
     */
    @JvmStatic
    inline fun assertInLegacyMode() = RefactorFlagUtils.assertInLegacyMode(isEnabled, FLAG_NAME)
}