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

Unverified Commit f0b33842 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.

For lineage-22.1, includes fixups from:
Michael Bestas <mikeioannina@gmail.com>
someone5678 <someone5678.dev@gmail.com>

Change-Id: I41d5408841593a12443be885e11959bffaebb67b
parent 00779382
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -9734,4 +9734,8 @@ final class ActivityRecord extends WindowToken {
                    mTaskDescription, mCreateTime);
        }
    }

    public boolean shouldForceLongScreen() {
        return mAtmService.shouldForceLongScreen(packageName);
    }
}
+13 −0
Original line number Diff line number Diff line
@@ -284,6 +284,8 @@ import com.android.server.uri.UriGrantsManagerInternal;
import com.android.server.wm.utils.WindowStyleCache;
import com.android.wm.shell.Flags;

import org.lineageos.internal.applications.LineageActivityManager;

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

    private Set<Integer> mProfileOwnerUids = new ArraySet<Integer>();

    // Lineage sdk activity related helper
    private LineageActivityManager mLineageActivityManager;

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

    public void installSystemProviders() {
        mSettingsObserver = new SettingObserver();

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

    public void retrieveSettings(ContentResolver resolver) {
@@ -7610,4 +7619,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        }
        return sIsPip2ExperimentEnabled;
    }

    public boolean shouldForceLongScreen(String packageName) {
        return mLineageActivityManager.shouldForceLongScreen(packageName);
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -324,7 +324,9 @@ class AppCompatAspectRatioPolicy {
        int activityHeight = containingAppHeight;

        if (containingRatio - aspectRatioToApply > ASPECT_RATIO_ROUNDING_TOLERANCE) {
            if (containingAppWidth < containingAppHeight) {
            if (mActivityRecord.shouldForceLongScreen()) {
                // 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 * aspectRatioToApply) + 0.5f);