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

Commit 95881937 authored by Winson Chung's avatar Winson Chung Committed by Automerger Merge Worker
Browse files

Merge "[sysui] Use weak reference for the listener in...

Merge "[sysui] Use weak reference for the listener in NavigationBarTransitions" into tm-qpr-dev am: 5af264c1

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21931839



Change-Id: I4f4d3a57878ac5913775463404db88faf8569620
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents b6857ad6 5af264c1
Loading
Loading
Loading
Loading
+21 −6
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.systemui.statusbar.phone.BarTransitions;
import com.android.systemui.statusbar.phone.LightBarTransitionsController;

import java.io.PrintWriter;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;

@@ -76,15 +77,27 @@ public final class NavigationBarTransitions extends BarTransitions implements
    private List<DarkIntensityListener> mDarkIntensityListeners;

    private final Handler mHandler = Handler.getMain();
    private final IWallpaperVisibilityListener mWallpaperVisibilityListener =
            new IWallpaperVisibilityListener.Stub() {

    static final class WallpaperVisibilityListener extends IWallpaperVisibilityListener.Stub {
        private final WeakReference<NavigationBarTransitions> mSelf;

        WallpaperVisibilityListener(NavigationBarTransitions self) {
            mSelf = new WeakReference<>(self);
        }

        @Override
        public void onWallpaperVisibilityChanged(boolean newVisibility,
                int displayId) throws RemoteException {
            mWallpaperVisible = newVisibility;
            mHandler.post(() -> applyLightsOut(true, false));
            NavigationBarTransitions self = mSelf.get();
            if (self == null) {
                return;
            }
            self.mWallpaperVisible = newVisibility;
            self.mHandler.post(() -> self.applyLightsOut(true, false));
        }
    }
    };

    private final IWallpaperVisibilityListener mWallpaperVisibilityListener;

    @Inject
    public NavigationBarTransitions(
@@ -93,6 +106,7 @@ public final class NavigationBarTransitions extends BarTransitions implements
            LightBarTransitionsController.Factory lightBarTransitionsControllerFactory,
            DisplayTracker displayTracker) {
        super(view, R.drawable.nav_background);

        mView = view;
        mWindowManagerService = windowManagerService;
        mLightTransitionsController = lightBarTransitionsControllerFactory.create(this);
@@ -101,6 +115,7 @@ public final class NavigationBarTransitions extends BarTransitions implements
                .getBoolean(R.bool.config_navigation_bar_enable_auto_dim_no_visible_wallpaper);
        mDarkIntensityListeners = new ArrayList();

        mWallpaperVisibilityListener = new WallpaperVisibilityListener(this);
        try {
            mWallpaperVisible = mWindowManagerService.registerWallpaperVisibilityListener(
                    mWallpaperVisibilityListener, mDisplayTracker.getDefaultDisplayId());