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

Commit 92d5d4be authored by Winson Chung's avatar Winson Chung
Browse files

Fetch top task on background thread when handling rotation request

Fixes: 299350378
Test: atest RotationButtonControllerTest
Change-Id: If2583094ba51796a549dd39277d2b21428304d83
parent 52d4cfa2
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -702,12 +702,17 @@ public class RotationButtonController {

        @Override
        public void onActivityRequestedOrientationChanged(int taskId, int requestedOrientation) {
            // Only hide the icon if the top task changes its requestedOrientation
            // Launcher can alter its requestedOrientation while it's not on top, don't hide on this
            mBgExecutor.execute(() -> {
                // Only hide the icon if the top task changes its requestedOrientation Launcher can
                // alter its requestedOrientation while it's not on top, don't hide on this
                Optional.ofNullable(ActivityManagerWrapper.getInstance())
                        .map(ActivityManagerWrapper::getRunningTask)
                        .ifPresent(a -> {
                        if (a.id == taskId) setRotateSuggestionButtonState(false /* visible */);
                            if (a.id == taskId) {
                                mMainThreadHandler.post(() ->
                                        setRotateSuggestionButtonState(false /* visible */));
                            }
                        });
            });
        }
    }