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

Commit 50f27c4a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "revert-to-single-threaded-oms-init"

* changes:
  Decouple the display manager from the overlay manager
  Revert: "Init of OverlayManagerService on a parallel thread"
parents bae65201 250cb2b9
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
+22 −59
Original line number Diff line number Diff line
@@ -22,14 +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.MATCH_SYSTEM_ONLY;
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;
@@ -37,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;
@@ -59,11 +55,9 @@ import android.util.AtomicFile;
import android.util.Slog;
import android.util.SparseArray;

import com.android.internal.util.ConcurrentUtils;
import com.android.server.FgThread;
import com.android.server.IoThread;
import com.android.server.LocalServices;
import com.android.server.SystemServerInitThreadPool;
import com.android.server.SystemService;
import com.android.server.pm.Installer;
import com.android.server.pm.UserManagerService;
@@ -84,8 +78,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;

/**
@@ -228,8 +220,6 @@ public final class OverlayManagerService extends SystemService {

    private final AtomicBoolean mPersistSettingsScheduled = new AtomicBoolean(false);

    private Future<?> mInitCompleteSignal;

    public OverlayManagerService(@NonNull final Context context,
            @NonNull final Installer installer) {
        super(context);
@@ -241,7 +231,7 @@ public final class OverlayManagerService extends SystemService {
        mSettings = new OverlayManagerSettings();
        mImpl = new OverlayManagerServiceImpl(mPackageManager, im, mSettings,
                getDefaultOverlayPackages(), new OverlayChangeListener());
        mInitCompleteSignal = SystemServerInitThreadPool.get().submit(() -> {

        final IntentFilter packageFilter = new IntentFilter();
        packageFilter.addAction(ACTION_PACKAGE_ADDED);
        packageFilter.addAction(ACTION_PACKAGE_CHANGED);
@@ -263,7 +253,6 @@ public final class OverlayManagerService extends SystemService {

        publishBinderService(Context.OVERLAY_SERVICE, mService);
        publishLocalService(OverlayManagerService.class, this);
        }, "Init OverlayManagerService");
    }

    @Override
@@ -271,32 +260,6 @@ public final class OverlayManagerService extends SystemService {
        // Intentionally left empty.
    }

    @Override
    public void onBootPhase(int phase) {
        if (phase == PHASE_SYSTEM_SERVICES_READY && mInitCompleteSignal != null) {
            ConcurrentUtils.waitForFutureNoInterrupt(mInitCompleteSignal,
                    "Wait for OverlayManagerService init");
            mInitCompleteSignal = null;
        }
    }

    public void updateSystemUiContext() {
        if (mInitCompleteSignal != null) {
            ConcurrentUtils.waitForFutureNoInterrupt(mInitCompleteSignal,
                    "Wait for OverlayManagerService init");
            mInitCompleteSignal = null;
        }

        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