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

Commit 52fc18ad authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Move setHasTopUi to the background

This call was responsible for 0.8% of all SysUI ANRs in the field.
It should happen asynchronously in the background.

Fixes: 297216344
Test: atest BubblesTest NotificationShadeWindowControllerImpl
KeyguardViewMediatorTest
Change-Id: Ib29c49e5dca9f33e755be4f2a38deacaa1d344e3
parent ef87d087
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_M
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_BEHAVIOR_CONTROLLED;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_OPTIMIZE_MEASURE;

import static com.android.systemui.DejankUtils.whitelistIpcs;
import static com.android.systemui.statusbar.NotificationRemoteInputManager.ENABLE_REMOTE_INPUT;

import android.app.IActivityManager;
@@ -52,6 +51,7 @@ import com.android.systemui.R;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.dump.DumpsysTableLogger;
import com.android.systemui.keyguard.KeyguardViewMediator;
@@ -76,6 +76,7 @@ import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import java.util.stream.Collectors;

@@ -104,6 +105,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
    private final float mKeyguardMaxRefreshRate;
    private final KeyguardViewMediator mKeyguardViewMediator;
    private final KeyguardBypassController mKeyguardBypassController;
    private final Executor mBackgroundExecutor;
    private final AuthController mAuthController;
    private ViewGroup mWindowRootView;
    private LayoutParams mLp;
@@ -141,6 +143,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
            ConfigurationController configurationController,
            KeyguardViewMediator keyguardViewMediator,
            KeyguardBypassController keyguardBypassController,
            @Background Executor backgroundExecutor,
            SysuiColorExtractor colorExtractor,
            DumpManager dumpManager,
            KeyguardStateController keyguardStateController,
@@ -159,6 +162,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
        mLpChanged = new LayoutParams();
        mKeyguardViewMediator = keyguardViewMediator;
        mKeyguardBypassController = keyguardBypassController;
        mBackgroundExecutor = backgroundExecutor;
        mColorExtractor = colorExtractor;
        mScreenOffAnimationController = screenOffAnimationController;
        dumpManager.registerDumpable(this);
@@ -520,13 +524,14 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
        applyWindowLayoutParams();

        if (mHasTopUi != mHasTopUiChanged) {
            whitelistIpcs(() -> {
            mHasTopUi = mHasTopUiChanged;
            mBackgroundExecutor.execute(() -> {
                try {
                    mActivityManager.setHasTopUi(mHasTopUiChanged);
                } catch (RemoteException e) {
                    Log.e(TAG, "Failed to call setHasTopUi", e);
                }
                mHasTopUi = mHasTopUiChanged;

            });
        }
        notifyStateChangedCallbacks();
+1 −0
Original line number Diff line number Diff line
@@ -241,6 +241,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
                mConfigurationController,
                mViewMediator,
                mKeyguardBypassController,
                mUiBgExecutor,
                mColorExtractor,
                mDumpManager,
                mKeyguardStateController,
+5 −0
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;

import com.google.common.util.concurrent.MoreExecutors;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -73,6 +75,7 @@ import org.mockito.MockitoAnnotations;
import org.mockito.Spy;

import java.util.List;
import java.util.concurrent.Executor;

@RunWith(AndroidTestingRunner.class)
@RunWithLooper
@@ -98,6 +101,7 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
    @Mock private ShadeWindowLogger mShadeWindowLogger;
    @Captor private ArgumentCaptor<WindowManager.LayoutParams> mLayoutParameters;
    @Captor private ArgumentCaptor<StatusBarStateController.StateListener> mStateListener;
    private final Executor mBackgroundExecutor = MoreExecutors.directExecutor();

    private NotificationShadeWindowControllerImpl mNotificationShadeWindowController;
    private float mPreferredRefreshRate = -1;
@@ -125,6 +129,7 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
                mConfigurationController,
                mKeyguardViewMediator,
                mKeyguardBypassController,
                mBackgroundExecutor,
                mColorExtractor,
                mDumpManager,
                mKeyguardStateController,
+1 −0
Original line number Diff line number Diff line
@@ -341,6 +341,7 @@ public class BubblesTest extends SysuiTestCase {
                mConfigurationController,
                mKeyguardViewMediator,
                mKeyguardBypassController,
                syncExecutor,
                mColorExtractor,
                mDumpManager,
                mKeyguardStateController,