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

Commit 54f94065 authored by Graciela Wissen Putri's avatar Graciela Wissen Putri
Browse files

Disable user aspect ratio button if app not launchable

Flag: 287943243
Fix: 308391262
Test: atest TaskTests
Change-Id: Ia424737d759593344c87ddb7ff3951eb1557715e
parent 076df248
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -3508,10 +3508,13 @@ class Task extends TaskFragment {
                        top.mLetterboxUiController.getLetterboxPositionForVerticalReachability();
            }
        }
        // User Aspect Ratio Settings is enabled if the app is not in SCM
        // User Aspect Ratio Settings button is enabled if the app is not in SCM and has
        // launchable activities
        info.topActivityEligibleForUserAspectRatioButton = top != null
                && !info.topActivityInSizeCompat
                && top.mLetterboxUiController.shouldEnableUserAspectRatioSettings();
                && top.mLetterboxUiController.shouldEnableUserAspectRatioSettings()
                && mAtmService.mContext.getPackageManager()
                    .getLaunchIntentForPackage(getBasePackageName()) != null;
        info.topActivityBoundsLetterboxed = top != null && top.areBoundsLetterboxed();
    }

+8 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.Rect;
@@ -570,12 +571,15 @@ public class TaskTests extends WindowTestsBase {
                .setWindowingMode(WINDOWING_MODE_FULLSCREEN).setDisplay(display).build();
        final Task task = rootTask.getBottomMostTask();
        final ActivityRecord root = task.getTopNonFinishingActivity();
        final PackageManager pm = mContext.getPackageManager();
        spyOn(pm);
        spyOn(mWm.mLetterboxConfiguration);
        spyOn(root);
        spyOn(root.mLetterboxUiController);

        doReturn(true).when(root.mLetterboxUiController)
                .shouldEnableUserAspectRatioSettings();
        doReturn(new Intent()).when(pm).getLaunchIntentForPackage(anyString());
        doReturn(false).when(root).inSizeCompatMode();
        doReturn(task).when(root).getOrganizedTask();

@@ -593,6 +597,10 @@ public class TaskTests extends WindowTestsBase {
        doReturn(true).when(root).inSizeCompatMode();
        assertFalse(task.getTaskInfo().topActivityEligibleForUserAspectRatioButton);
        doReturn(false).when(root).inSizeCompatMode();

        // When app doesn't have any launchable activities the button is not enabled
        doReturn(null).when(pm).getLaunchIntentForPackage(anyString());
        assertFalse(task.getTaskInfo().topActivityEligibleForUserAspectRatioButton);
    }

    /**