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

Commit 4a380003 authored by Jesse Chan's avatar Jesse Chan Committed by Michael Bestas
Browse files

Add an option to force pre-O apps to use full screen aspect ratio

When an app target pre-O releases, the default max aspect ratio
is 1.86:1 which leads to ugly black areas on devices that have
screens with higher aspect ratio (for example Galaxy S8/S9).

This change adds an option to allow users to change aspect ratio
for pre-O apps to full screen aspect ratio.

Change-Id: I41d5408841593a12443be885e11959bffaebb67b
parent deed70c1
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -3095,7 +3095,9 @@ final class ActivityRecord extends ConfigurationContainer {
        int activityHeight = containingAppHeight;

        if (containingRatio > maxAspectRatio && maxAspectRatio != 0) {
            if (containingAppWidth < containingAppHeight) {
            if (mAtmService.shouldForceLongScreen(packageName)) {
                 // Use containingAppWidth/Height for maxActivityWidth/Height when force long screen
            } else if (containingAppWidth < containingAppHeight) {
                // Width is the shorter side, so we use that to figure-out what the max. height
                // should be given the aspect ratio.
                activityHeight = (int) ((activityWidth * maxAspectRatio) + 0.5f);
+13 −0
Original line number Diff line number Diff line
@@ -271,6 +271,8 @@ import com.android.server.policy.PermissionPolicyInternal;
import com.android.server.uri.UriGrantsManagerInternal;
import com.android.server.vr.VrManagerInternal;

import org.lineageos.internal.applications.LineageActivityManager;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileDescriptor;
@@ -650,6 +652,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {

    private int mDeviceOwnerUid = Process.INVALID_UID;

    // Lineage sdk activity related helper
    private LineageActivityManager mLineageActivityManager;

    private final class FontScaleSettingObserver extends ContentObserver {
        private final Uri mFontScaleUri = Settings.System.getUriFor(FONT_SCALE);
        private final Uri mHideErrorDialogsUri = Settings.Global.getUriFor(HIDE_ERROR_DIALOGS);
@@ -719,6 +724,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {

    public void installSystemProviders() {
        mFontScaleSettingObserver = new FontScaleSettingObserver();

        // LineageActivityManager depends on settings so we can initialize only
        // after providers are available.
        mLineageActivityManager = new LineageActivityManager(mContext);
    }

    public void retrieveSettings(ContentResolver resolver) {
@@ -7484,4 +7493,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            }
        }
    }

    public boolean shouldForceLongScreen(String packageName) {
        return mLineageActivityManager.shouldForceLongScreen(packageName);
    }
}