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

Commit 250cb2b9 authored by Mårten Kongstad's avatar Mårten Kongstad Committed by Todd Kennedy
Browse files

Decouple the display manager from the overlay manager

The display manager relies on resources that may or may not have been
modified via runtime resource overlay. Because the overlay manager is
initialized in parallel with the display manager, the two need to
synchronize their work so the display manager knows when it can rely on
its resources.

An upcoming change will hold off on threading the system until after the
initialization of the overlay manager. This means all overlays should be
setup before other services start, which in turn means no additional
synchronization is required. As a first step towards this, remove the
synchronization between the display manager and the overlay manager.

Also remove unused variable LogicalDisplay#PROP_MASKING_INSET_TOP.

Bug: 80150169
Test: builds, boots
Change-Id: I844de9e09eb1464ae112e1b480d21cf662a026e0
parent cd78e0f2
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -157,7 +157,6 @@ import com.android.internal.os.RuntimeInit;
import com.android.internal.os.SomeArgs;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.FastPrintWriter;
import com.android.internal.util.Preconditions;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.org.conscrypt.OpenSSLSocketImpl;
import com.android.org.conscrypt.TrustedCertificateStore;
@@ -5324,16 +5323,6 @@ public final class ActivityThread extends ClientTransactionHandler {
        }
    }

    /**
     * Updates the application info.
     *
     * This only works in the system process. Must be called on the main thread.
     */
    public void handleSystemApplicationInfoChanged(@NonNull ApplicationInfo ai) {
        Preconditions.checkState(mSystemThread, "Must only be called in the system process");
        handleApplicationInfoChanged(ai);
    }

    void handleApplicationInfoChanged(@NonNull final ApplicationInfo ai) {
        // Updates triggered by package installation go through a package update
        // receiver. Here we try to capture ApplicationInfo changes that are
+1 −13
Original line number Diff line number Diff line
@@ -247,9 +247,6 @@ public final class DisplayManagerService extends SystemService {
    // device).
    private Point mStableDisplaySize = new Point();

    // Whether the system has finished booting or not.
    private boolean mSystemReady;

    // The top inset of the default display.
    // This gets persisted so that the boot animation knows how to transition from the display's
    // full size to the size configured by the user. Right now we only persist and animate the top
@@ -322,8 +319,6 @@ public final class DisplayManagerService extends SystemService {
        PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
        mGlobalDisplayBrightness = pm.getDefaultScreenBrightnessSetting();
        mCurrentUserId = UserHandle.USER_SYSTEM;

        mSystemReady = false;
    }

    public void setupSchedulerPolicies() {
@@ -413,10 +408,6 @@ public final class DisplayManagerService extends SystemService {
        synchronized (mSyncRoot) {
            mSafeMode = safeMode;
            mOnlyCore = onlyCore;
            mSystemReady = true;
            // Just in case the top inset changed before the system was ready. At this point, any
            // relevant configuration should be in place.
            recordTopInsetLocked(mLogicalDisplays.get(Display.DEFAULT_DISPLAY));
        }

        mHandler.sendEmptyMessage(MSG_REGISTER_ADDITIONAL_DISPLAY_ADAPTERS);
@@ -1065,10 +1056,7 @@ public final class DisplayManagerService extends SystemService {
    }

    private void recordTopInsetLocked(@Nullable LogicalDisplay d) {
        // We must only persist the inset after boot has completed, otherwise we will end up
        // overwriting the persisted value before the masking flag has been loaded from the
        // resource overlay.
        if (!mSystemReady || d == null) {
        if (d == null) {
            return;
        }
        int topInset = d.getInsets().top;
+0 −2
Original line number Diff line number Diff line
@@ -57,8 +57,6 @@ import java.util.Objects;
 * </p>
 */
final class LogicalDisplay {
    private static final String PROP_MASKING_INSET_TOP = "persist.sys.displayinset.top";

    private final DisplayInfo mBaseDisplayInfo = new DisplayInfo();

    // The layer stack we use when the display has been blanked to prevent any
+0 −14
Original line number Diff line number Diff line
@@ -22,13 +22,11 @@ import static android.content.Intent.ACTION_PACKAGE_CHANGED;
import static android.content.Intent.ACTION_PACKAGE_REMOVED;
import static android.content.Intent.ACTION_USER_ADDED;
import static android.content.Intent.ACTION_USER_REMOVED;
import static android.content.pm.PackageManager.GET_SHARED_LIBRARY_FILES;
import static android.content.pm.PackageManager.SIGNATURE_MATCH;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityThread;
import android.app.IActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -36,7 +34,6 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.om.IOverlayManager;
import android.content.om.OverlayInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManagerInternal;
@@ -263,17 +260,6 @@ public final class OverlayManagerService extends SystemService {
        // Intentionally left empty.
    }

    public void updateSystemUiContext() {
        final ApplicationInfo ai;
        try {
            ai = mPackageManager.mPackageManager.getApplicationInfo("android",
                    GET_SHARED_LIBRARY_FILES, UserHandle.USER_SYSTEM);
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
        ActivityThread.currentActivityThread().handleSystemApplicationInfoChanged(ai);
    }

    private void initIfNeeded() {
        final UserManager um = getContext().getSystemService(UserManager.class);
        final List<UserInfo> users = um.getUsers(true /*excludeDying*/);
+1 −10
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import android.content.res.Resources.Theme;
import android.database.sqlite.SQLiteCompatibilityWalFlags;
import android.database.sqlite.SQLiteGlobal;
import android.hardware.display.ColorDisplayManager;
import android.hardware.display.DisplayManagerInternal;
import android.os.BaseBundle;
import android.os.Binder;
import android.os.Build;
@@ -717,17 +716,9 @@ public final class SystemServer {

        // Manages Overlay packages
        traceBeginAndSlog("StartOverlayManagerService");
        OverlayManagerService overlayManagerService = new OverlayManagerService(
                mSystemContext, installer);
        mSystemServiceManager.startService(overlayManagerService);
        mSystemServiceManager.startService(new OverlayManagerService(mSystemContext, installer));
        traceEnd();

        if (SystemProperties.getInt("persist.sys.displayinset.top", 0) > 0) {
            // DisplayManager needs the overlay immediately.
            overlayManagerService.updateSystemUiContext();
            LocalServices.getService(DisplayManagerInternal.class).onOverlayChanged();
        }

        // The sensor service needs access to package manager service, app ops
        // service, and permissions service, therefore we start it after them.
        // Start sensor service in a separate thread. Completion should be checked