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

Commit 64bf4a87 authored by Dave Mankoff's avatar Dave Mankoff Committed by Android (Google) Code Review
Browse files

Merge "Prevent SystemUISecondaryUserService from screwing up SystemUI." into main

parents 2f2b95a0 014062b3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ import java.io.PrintWriter;
 * If your CoreStartable depends on different CoreStartables starting before it, use a
 * {@link com.android.systemui.startable.Dependencies} annotation to list out those dependencies.
 *
 * @see SystemUIApplication#startServicesIfNeeded()
 * @see SystemUIApplication#startSystemUserServicesIfNeeded()
 */
public interface CoreStartable extends Dumpable {

+12 −2
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.internal.protolog.common.ProtoLog;
import com.android.systemui.dagger.GlobalRootComponent;
import com.android.systemui.dagger.SysUIComponent;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.process.ProcessWrapper;
import com.android.systemui.res.R;
import com.android.systemui.startable.Dependencies;
import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -77,6 +78,7 @@ public class SystemUIApplication extends Application implements
    private SystemUIAppComponentFactoryBase.ContextAvailableCallback mContextAvailableCallback;
    private SysUIComponent mSysUIComponent;
    private SystemUIInitializer mInitializer;
    private ProcessWrapper mProcessWrapper;

    public SystemUIApplication() {
        super();
@@ -115,6 +117,7 @@ public class SystemUIApplication extends Application implements
        // Enable Looper trace points.
        // This allows us to see Handler callbacks on traces.
        rootComponent.getMainLooper().setTraceTag(Trace.TRACE_TAG_APP);
        mProcessWrapper = rootComponent.getProcessWrapper();

        // Set the application theme that is inherited by all services. Note that setting the
        // application theme in the manifest does only work for activities. Keep this in sync with
@@ -132,7 +135,7 @@ public class SystemUIApplication extends Application implements
            View.setTraceLayoutSteps(true);
        }

        if (rootComponent.getProcessWrapper().isSystemUser()) {
        if (mProcessWrapper.isSystemUser()) {
            IntentFilter bootCompletedFilter = new
                    IntentFilter(Intent.ACTION_LOCKED_BOOT_COMPLETED);
            bootCompletedFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
@@ -199,7 +202,11 @@ public class SystemUIApplication extends Application implements
     * <p>This method must only be called from the main thread.</p>
     */

    public void startServicesIfNeeded() {
    public void startSystemUserServicesIfNeeded() {
        if (!mProcessWrapper.isSystemUser()) {
            Log.wtf(TAG, "Tried starting SystemUser services on non-SystemUser");
            return;  // Per-user startables are handled in #startSystemUserServicesIfNeeded.
        }
        final String vendorComponent = mInitializer.getVendorComponent(getResources());

        // Sort the startables so that we get a deterministic ordering.
@@ -219,6 +226,9 @@ public class SystemUIApplication extends Application implements
     * <p>This method must only be called from the main thread.</p>
     */
    void startSecondaryUserServicesIfNeeded() {
        if (mProcessWrapper.isSystemUser()) {
            return;  // Per-user startables are handled in #startSystemUserServicesIfNeeded.
        }
        // Sort the startables so that we get a deterministic ordering.
        Map<Class<?>, Provider<CoreStartable>> sortedStartables = new TreeMap<>(
                Comparator.comparing(Class::getName));
+19 −0
Original line number Diff line number Diff line
@@ -19,12 +19,31 @@ package com.android.systemui;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

import com.android.systemui.process.ProcessWrapper;

import javax.inject.Inject;

public class SystemUISecondaryUserService extends Service {

    private static final String TAG = "SysUISecondaryService";

    private final ProcessWrapper mProcessWrapper;

    @Inject
    SystemUISecondaryUserService(ProcessWrapper processWrapper) {
        mProcessWrapper = processWrapper;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        if (mProcessWrapper.isSystemUser()) {
            Log.w(TAG, "SecondaryServices started for System User. Stopping it.");
            stopSelf();
            return;
        }
        ((SystemUIApplication) getApplication()).startSecondaryUserServicesIfNeeded();
    }

+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ public class SystemUIService extends Service {
        super.onCreate();

        // Start all of SystemUI
        ((SystemUIApplication) getApplication()).startServicesIfNeeded();
        ((SystemUIApplication) getApplication()).startSystemUserServicesIfNeeded();

        // Finish initializing dump logic
        mLogBufferFreezer.attach(mBroadcastDispatcher);
+9 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.dagger;

import android.app.INotificationManager;
import android.app.Service;
import android.content.Context;
import android.service.dreams.IDreamManager;

@@ -28,6 +29,7 @@ import com.android.keyguard.dagger.KeyguardBouncerComponent;
import com.android.systemui.BootCompleteCache;
import com.android.systemui.BootCompleteCacheImpl;
import com.android.systemui.CameraProtectionModule;
import com.android.systemui.SystemUISecondaryUserService;
import com.android.systemui.accessibility.AccessibilityModule;
import com.android.systemui.accessibility.data.repository.AccessibilityRepositoryModule;
import com.android.systemui.appops.dagger.AppOpsModule;
@@ -150,6 +152,8 @@ import dagger.Binds;
import dagger.BindsOptionalOf;
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.ClassKey;
import dagger.multibindings.IntoMap;

import java.util.Collections;
import java.util.Optional;
@@ -384,4 +388,9 @@ public abstract class SystemUIModule {
    @Binds
    abstract LargeScreenShadeInterpolator largeScreensShadeInterpolator(
            LargeScreenShadeInterpolatorImpl impl);

    @Binds
    @IntoMap
    @ClassKey(SystemUISecondaryUserService.class)
    abstract Service bindsSystemUISecondaryUserService(SystemUISecondaryUserService service);
}
Loading