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

Commit fe54380e authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

Merge changes Ic8951a01,Ia2a577e3,Ibdca61a4

* changes:
  Move QSFragment to be a LifecycleFragment
  Remove usages of Dependency#get from NotificationViewHierarchyManager
  Remove Dependency#get from ExtensionControllerImpl
parents 1048106e 8966d997
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -531,10 +531,18 @@ public class Dependency extends SystemUI {
        sDependency.destroyDependency(cls, destroy);
    }

    /**
     * @deprecated see docs/dagger.md
     */
    @Deprecated
    public static <T> T get(Class<T> cls) {
        return sDependency.getDependency(cls);
    }

    /**
     * @deprecated see docs/dagger.md
     */
    @Deprecated
    public static <T> T get(DependencyKey<T> cls) {
        return sDependency.getDependency(cls);
    }
+7 −10
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ import static android.app.StatusBarManager.DISABLE2_QUICK_SETTINGS;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.Fragment;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.Bundle;
@@ -46,10 +46,11 @@ import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
import com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer;
import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler;
import com.android.systemui.util.InjectionInflationController;
import com.android.systemui.util.LifecycleFragment;

import javax.inject.Inject;

public class QSFragment extends Fragment implements QS, CommandQueue.Callbacks {
public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Callbacks {
    private static final String TAG = "QS";
    private static final boolean DEBUG = false;
    private static final String EXTRA_EXPANDED = "expanded";
@@ -81,9 +82,12 @@ public class QSFragment extends Fragment implements QS, CommandQueue.Callbacks {

    @Inject
    public QSFragment(RemoteInputQuickSettingsDisabler remoteInputQsDisabler,
            InjectionInflationController injectionInflater) {
            InjectionInflationController injectionInflater,
            Context context) {
        mRemoteInputQuickSettingsDisabler = remoteInputQsDisabler;
        mInjectionInflater = injectionInflater;
        SysUiServiceProvider.getComponent(context, CommandQueue.class)
                .observe(getLifecycle(), this);
    }

    @Override
@@ -118,13 +122,6 @@ public class QSFragment extends Fragment implements QS, CommandQueue.Callbacks {
                mQSPanel.getTileLayout().restoreInstanceState(savedInstanceState);
            }
        }
        SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).addCallback(this);
    }

    @Override
    public void onDestroyView() {
        SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).removeCallback(this);
        super.onDestroyView();
    }

    @Override
+26 −23
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.util.Log;
import android.view.View;
import android.view.ViewGroup;

import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.statusbar.notification.NotificationData;
@@ -44,6 +43,8 @@ import java.util.Stack;
import javax.inject.Inject;
import javax.inject.Singleton;

import dagger.Lazy;

/**
 * NotificationViewHierarchyManager manages updating the view hierarchy of notification views based
 * on their group structure. For example, if a notification becomes bundled with another,
@@ -60,20 +61,15 @@ public class NotificationViewHierarchyManager {
            mTmpChildOrderMap = new HashMap<>();

    // Dependencies:
    protected final NotificationLockscreenUserManager mLockscreenUserManager =
            Dependency.get(NotificationLockscreenUserManager.class);
    protected final NotificationGroupManager mGroupManager =
            Dependency.get(NotificationGroupManager.class);
    protected final VisualStabilityManager mVisualStabilityManager =
            Dependency.get(VisualStabilityManager.class);
    private final StatusBarStateController mStatusBarStateController =
            Dependency.get(StatusBarStateController.class);
    private final NotificationEntryManager mEntryManager =
            Dependency.get(NotificationEntryManager.class);
    private final BubbleController mBubbleController = Dependency.get(BubbleController.class);
    protected final NotificationLockscreenUserManager mLockscreenUserManager;
    protected final NotificationGroupManager mGroupManager;
    protected final VisualStabilityManager mVisualStabilityManager;
    private final StatusBarStateController mStatusBarStateController;
    private final NotificationEntryManager mEntryManager;
    private final BubbleController mBubbleController;

    // Lazy
    private ShadeController mShadeController;
    private final Lazy<ShadeController> mShadeController;

    /**
     * {@code true} if notifications not part of a group should by default be rendered in their
@@ -120,20 +116,27 @@ public class NotificationViewHierarchyManager {
        }
    }

    private ShadeController getShadeController() {
        if (mShadeController == null) {
            mShadeController = Dependency.get(ShadeController.class);
        }
        return mShadeController;
    }

    @Inject
    public NotificationViewHierarchyManager(Context context) {
    public NotificationViewHierarchyManager(Context context,
            NotificationLockscreenUserManager notificationLockscreenUserManager,
            NotificationGroupManager groupManager,
            VisualStabilityManager visualStabilityManager,
            StatusBarStateController statusBarStateController,
            NotificationEntryManager notificationEntryManager,
            BubbleController bubbleController,
            Lazy<ShadeController> shadeController) {
        mLockscreenUserManager = notificationLockscreenUserManager;
        mGroupManager = groupManager;
        mVisualStabilityManager = visualStabilityManager;
        mStatusBarStateController = statusBarStateController;
        mEntryManager = notificationEntryManager;
        mBubbleController = bubbleController;
        mShadeController = shadeController;
        Resources res = context.getResources();
        mAlwaysExpandNonGroupedNotification =
                res.getBoolean(R.bool.config_alwaysExpandNonGroupedNotifications);
        mStatusBarStateListener = new StatusBarStateListener(mBubbleController);
        Dependency.get(StatusBarStateController.class).addCallback(mStatusBarStateListener);
        mStatusBarStateController.addCallback(mStatusBarStateListener);
    }

    public void setUpWithPresenter(NotificationPresenter presenter,
@@ -396,7 +399,7 @@ public class NotificationViewHierarchyManager {
                        && !row.isLowPriority()));
            }

            entry.getRow().setOnAmbient(getShadeController().isDozing());
            entry.getRow().setOnAmbient(mShadeController.get().isDozing());
            int userId = entry.notification.getUserId();
            boolean suppressedSummary = mGroupManager.isSummaryOfSuppressedGroup(
                    entry.notification) && !entry.isRowRemoved();
+21 −10
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ import android.content.res.Configuration;
import android.os.Handler;
import android.util.ArrayMap;

import com.android.systemui.Dependency;
import com.android.systemui.plugins.Plugin;
import com.android.systemui.plugins.PluginListener;
import com.android.systemui.shared.plugins.PluginManager;
@@ -49,12 +48,24 @@ public class ExtensionControllerImpl implements ExtensionController {
    public static final int SORT_ORDER_DEFAULT = 4;

    private final Context mDefaultContext;
    private final LeakDetector mLeakDetector;
    private final PluginManager mPluginManager;
    private final TunerService mTunerService;
    private final ConfigurationController mConfigurationController;

    /**
     */
    @Inject
    public ExtensionControllerImpl(Context context) {
    public ExtensionControllerImpl(Context context,
            LeakDetector leakDetector,
            PluginManager pluginManager,
            TunerService tunerService,
            ConfigurationController configurationController) {
        mDefaultContext = context;
        mLeakDetector = leakDetector;
        mPluginManager = pluginManager;
        mTunerService = tunerService;
        mConfigurationController = configurationController;
    }

    @Override
@@ -168,14 +179,14 @@ public class ExtensionControllerImpl implements ExtensionController {
        @Override
        public void clearItem(boolean isDestroyed) {
            if (isDestroyed && mItem != null) {
                Dependency.get(LeakDetector.class).trackGarbage(mItem);
                mLeakDetector.trackGarbage(mItem);
            }
            mItem = null;
        }

        private void notifyChanged() {
            if (mItem != null) {
                Dependency.get(LeakDetector.class).trackGarbage(mItem);
                mLeakDetector.trackGarbage(mItem);
            }
            mItem = null;
            for (int i = 0; i < mProducers.size(); i++) {
@@ -216,7 +227,7 @@ public class ExtensionControllerImpl implements ExtensionController {

            public PluginItem(String action, Class<P> cls, PluginConverter<T, P> converter) {
                mConverter = converter;
                Dependency.get(PluginManager.class).addPluginListener(action, this, cls);
                mPluginManager.addPluginListener(action, this, cls);
            }

            @Override
@@ -244,7 +255,7 @@ public class ExtensionControllerImpl implements ExtensionController {

            @Override
            public void destroy() {
                Dependency.get(PluginManager.class).removePluginListener(this);
                mPluginManager.removePluginListener(this);
            }

            @Override
@@ -260,7 +271,7 @@ public class ExtensionControllerImpl implements ExtensionController {

            public TunerItem(TunerFactory<T> factory, String... setting) {
                mFactory = factory;
                Dependency.get(TunerService.class).addTunable(this, setting);
                mTunerService.addTunable(this, setting);
            }

            @Override
@@ -270,7 +281,7 @@ public class ExtensionControllerImpl implements ExtensionController {

            @Override
            public void destroy() {
                Dependency.get(TunerService.class).removeTunable(this);
                mTunerService.removeTunable(this);
            }

            @Override
@@ -298,7 +309,7 @@ public class ExtensionControllerImpl implements ExtensionController {
                mSupplier = supplier;
                mUiMode = mDefaultContext.getResources().getConfiguration().uiMode
                        & Configuration.UI_MODE_TYPE_MASK;
                Dependency.get(ConfigurationController.class).addCallback(this);
                mConfigurationController.addCallback(this);
            }

            @Override
@@ -318,7 +329,7 @@ public class ExtensionControllerImpl implements ExtensionController {

            @Override
            public void destroy() {
                Dependency.get(ConfigurationController.class).removeCallback(this);
                mConfigurationController.removeCallback(this);
            }

            @Override
+2 −1
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ public class QSFragmentTest extends SysuiBaseFragmentTest {
    @Override
    protected Fragment instantiate(Context context, String className, Bundle arguments) {
        return new QSFragment(new RemoteInputQuickSettingsDisabler(context),
                new InjectionInflationController(SystemUIFactory.getInstance().getRootComponent()));
                new InjectionInflationController(SystemUIFactory.getInstance().getRootComponent()),
                context);
    }
}
Loading