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

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

Merge changes from topics "b142537875-remove-get-component",...

Merge changes from topics "b142537875-remove-get-component", "b144284870-get-component-heads-up-manager"

* changes:
  Remove SysUiServiceProvider and mComponents.
  Remove calls to getComponent(HeadsUpManager.class)
parents 018bd027 95754e70
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.systemui.car.CarNotificationInterruptionStateProvider;
import com.android.systemui.dagger.SystemUIRootComponent;
import com.android.systemui.dock.DockManager;
import com.android.systemui.dock.DockManagerImpl;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.power.EnhancedEstimates;
import com.android.systemui.power.EnhancedEstimatesImpl;
import com.android.systemui.recents.Recents;
@@ -38,10 +39,13 @@ import com.android.systemui.statusbar.car.CarStatusBar;
import com.android.systemui.statusbar.car.CarStatusBarKeyguardViewManager;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.KeyguardEnvironmentImpl;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.volume.CarVolumeDialogComponent;
import com.android.systemui.volume.VolumeDialogComponent;

@@ -82,6 +86,17 @@ abstract class CarSystemUIModule {
        return new Divider(context, recentsOptionalLazy);
    }

    @Singleton
    @Provides
    static HeadsUpManagerPhone provideHeadsUpManagerPhone(Context context,
            StatusBarStateController statusBarStateController,
            KeyguardBypassController bypassController) {
        return new HeadsUpManagerPhone(context, statusBarStateController, bypassController);
    }

    @Binds
    abstract HeadsUpManager bindHeadsUpManagerPhone(HeadsUpManagerPhone headsUpManagerPhone);

    @Singleton
    @Provides
    @Named(LEAK_REPORT_EMAIL_NAME)
+0 −6
Original line number Diff line number Diff line
@@ -24,12 +24,6 @@ the main path for onConfigurationChanged, now also happens through
ConfigurationController). They also receive a callback for onBootCompleted
since these objects may be started before the device has finished booting.

SystemUI and SystemUIApplication also have methods for putComponent and
getComponent which were existing systems to get a hold of other parts of
sysui before Dependency existed. Generally new things should not be added
to putComponent, instead Dependency and other refactoring is preferred to
make sysui structure cleaner.

Each SystemUI service is expected to be a major part of system ui and the
goal is to minimize communication between them. So in general they should be
relatively silo'd.
+0 −29
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the
 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

package com.android.systemui;

import android.content.Context;

/**
 * The interface for getting core components of SysUI. Exists for Testability
 * since tests don't have SystemUIApplication as their ApplicationContext.
 */
public interface SysUiServiceProvider {
    <T> T getComponent(Class<T> interfaceType);

    public static <T> T getComponent(Context context, Class<T> interfaceType) {
        return ((SysUiServiceProvider) context.getApplicationContext()).getComponent(interfaceType);
    }
}
+1 −14
Original line number Diff line number Diff line
@@ -23,11 +23,9 @@ import android.os.Bundle;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.Map;

public abstract class SystemUI implements SysUiServiceProvider {
public abstract class SystemUI {
    protected final Context mContext;
    public Map<Class<?>, Object> mComponents;

    public SystemUI(Context context) {
        mContext = context;
@@ -44,17 +42,6 @@ public abstract class SystemUI implements SysUiServiceProvider {
    protected void onBootCompleted() {
    }

    @SuppressWarnings("unchecked")
    public <T> T getComponent(Class<T> interfaceType) {
        return (T) (mComponents != null ? mComponents.get(interfaceType) : null);
    }

    public <T, C extends T> void putComponent(Class<T> interfaceType, C component) {
        if (mComponents != null) {
            mComponents.put(interfaceType, component);
        }
    }

    public static void overrideNotificationAppName(Context context, Notification.Builder n,
            boolean system) {
        final Bundle extras = new Bundle();
+1 −10
Original line number Diff line number Diff line
@@ -36,13 +36,11 @@ import com.android.systemui.util.NotificationChannels;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;

/**
 * Application class for SystemUI.
 */
public class SystemUIApplication extends Application implements SysUiServiceProvider,
public class SystemUIApplication extends Application implements
        SystemUIAppComponentFactory.ContextInitializer {

    public static final String TAG = "SystemUIService";
@@ -56,7 +54,6 @@ public class SystemUIApplication extends Application implements SysUiServiceProv
    private SystemUI[] mServices;
    private boolean mServicesStarted;
    private boolean mBootCompleted;
    private final Map<Class<?>, Object> mComponents = new HashMap<>();
    private SystemUIAppComponentFactory.ContextAvailableCallback mContextAvailableCallback;

    public SystemUIApplication() {
@@ -199,7 +196,6 @@ public class SystemUIApplication extends Application implements SysUiServiceProv
                throw new RuntimeException(ex);
            }

            mServices[i].mComponents = mComponents;
            if (DEBUG) Log.d(TAG, "running: " + mServices[i]);
            mServices[i].start();
            log.traceEnd();
@@ -232,11 +228,6 @@ public class SystemUIApplication extends Application implements SysUiServiceProv
        }
    }

    @SuppressWarnings("unchecked")
    public <T> T getComponent(Class<T> interfaceType) {
        return (T) mComponents.get(interfaceType);
    }

    public SystemUI[] getServices() {
        return mServices;
    }
Loading