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

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

Merge changes I1ef8b41a,I348bdb1c

* changes:
  Remove Dependency.get usages from QSFooterImpl
  Remove Dependency.get usages from QSTileHost.
parents 65e0a89f 7a56b838
Loading
Loading
Loading
Loading
+26 −14
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.systemui.qs;

import static android.app.StatusBarManager.DISABLE2_QUICK_SETTINGS;

import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEXT;

import android.content.Context;
import android.content.Intent;
import android.content.pm.UserInfo;
@@ -48,7 +50,6 @@ import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.settingslib.Utils;
import com.android.settingslib.drawable.UserIconDrawable;
import com.android.settingslib.graph.SignalDrawable;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.R.dimen;
import com.android.systemui.plugins.ActivityStarter;
@@ -63,11 +64,16 @@ import com.android.systemui.statusbar.policy.UserInfoController;
import com.android.systemui.statusbar.policy.UserInfoController.OnUserInfoChangedListener;
import com.android.systemui.tuner.TunerService;

import javax.inject.Inject;
import javax.inject.Named;

public class QSFooterImpl extends FrameLayout implements QSFooter,
        OnClickListener, OnUserInfoChangedListener, EmergencyListener, SignalCallback {

    private ActivityStarter mActivityStarter;
    private UserInfoController mUserInfoController;
    private final ActivityStarter mActivityStarter;
    private final UserInfoController mUserInfoController;
    private final NetworkController mNetworkController;
    private final DeviceProvisionedController mDeviceProvisionedController;
    private SettingsButton mSettingsButton;
    protected View mSettingsContainer;
    private PageIndicator mPageIndicator;
@@ -100,9 +106,17 @@ public class QSFooterImpl extends FrameLayout implements QSFooter,
    private final CellSignalState mInfo = new CellSignalState();
    private OnClickListener mExpandClickListener;

    public QSFooterImpl(Context context, AttributeSet attrs) {
    @Inject
    public QSFooterImpl(@Named(VIEW_CONTEXT) Context context, AttributeSet attrs,
            ActivityStarter activityStarter, UserInfoController userInfoController,
            NetworkController networkController,
            DeviceProvisionedController deviceProvisionedController) {
        super(context, attrs);
        mColorForeground = Utils.getColorAttrDefaultColor(context, android.R.attr.colorForeground);
        mActivityStarter = activityStarter;
        mUserInfoController = userInfoController;
        mNetworkController = networkController;
        mDeviceProvisionedController = deviceProvisionedController;
    }

    @Override
@@ -111,7 +125,7 @@ public class QSFooterImpl extends FrameLayout implements QSFooter,
        mDivider = findViewById(R.id.qs_footer_divider);
        mEdit = findViewById(android.R.id.edit);
        mEdit.setOnClickListener(view ->
                Dependency.get(ActivityStarter.class).postQSRunnableDismissingKeyguard(() ->
                mActivityStarter.postQSRunnableDismissingKeyguard(() ->
                        mQsPanel.showEdit(view)));

        mPageIndicator = findViewById(R.id.footer_page_indicator);
@@ -137,8 +151,6 @@ public class QSFooterImpl extends FrameLayout implements QSFooter,

        updateResources();

        mUserInfoController = Dependency.get(UserInfoController.class);
        mActivityStarter = Dependency.get(ActivityStarter.class);
        addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight,
                oldBottom) -> updateAnimator(right - left));
        setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
@@ -316,14 +328,14 @@ public class QSFooterImpl extends FrameLayout implements QSFooter,
    private void updateListeners() {
        if (mListening) {
            mUserInfoController.addCallback(this);
            if (Dependency.get(NetworkController.class).hasVoiceCallingFeature()) {
                Dependency.get(NetworkController.class).addEmergencyListener(this);
                Dependency.get(NetworkController.class).addCallback(this);
            if (mNetworkController.hasVoiceCallingFeature()) {
                mNetworkController.addEmergencyListener(this);
                mNetworkController.addCallback(this);
            }
        } else {
            mUserInfoController.removeCallback(this);
            Dependency.get(NetworkController.class).removeEmergencyListener(this);
            Dependency.get(NetworkController.class).removeCallback(this);
            mNetworkController.removeEmergencyListener(this);
            mNetworkController.removeCallback(this);
        }
    }

@@ -344,7 +356,7 @@ public class QSFooterImpl extends FrameLayout implements QSFooter,
        }

        if (v == mSettingsButton) {
            if (!Dependency.get(DeviceProvisionedController.class).isCurrentUserSetup()) {
            if (!mDeviceProvisionedController.isCurrentUserSetup()) {
                // If user isn't setup just unlock the device and dump them back at SUW.
                mActivityStarter.postQSRunnableDismissingKeyguard(() -> { });
                return;
@@ -353,7 +365,7 @@ public class QSFooterImpl extends FrameLayout implements QSFooter,
                    mExpanded ? MetricsProto.MetricsEvent.ACTION_QS_EXPANDED_SETTINGS_LAUNCH
                            : MetricsProto.MetricsEvent.ACTION_QS_COLLAPSED_SETTINGS_LAUNCH);
            if (mSettingsButton.isTunerClick()) {
                Dependency.get(ActivityStarter.class).postQSRunnableDismissingKeyguard(() -> {
                mActivityStarter.postQSRunnableDismissingKeyguard(() -> {
                    if (TunerService.isTunerEnabled(mContext)) {
                        TunerService.showResetRequest(mContext, () -> {
                            // Relaunch settings so that the tuner disappears.
+16 −8
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
@@ -69,6 +70,8 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory> {
    private final LinkedHashMap<String, QSTile> mTiles = new LinkedHashMap<>();
    protected final ArrayList<String> mTileSpecs = new ArrayList<>();
    private final TileServices mServices;
    private final TunerService mTunerService;
    private final PluginManager mPluginManager;

    private final List<Callback> mCallbacks = new ArrayList<>();
    private final AutoTileManager mAutoTiles;
@@ -81,21 +84,26 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory> {
    public QSTileHost(Context context,
            StatusBarIconController iconController,
            QSFactoryImpl defaultFactory,
            @Named(Dependency.MAIN_HANDLER_NAME) Handler mainHandler) {
            @Named(Dependency.MAIN_HANDLER_NAME) Handler mainHandler,
            @Named(Dependency.BG_LOOPER_NAME) Looper bgLooper,
            PluginManager pluginManager,
            TunerService tunerService) {
        mIconController = iconController;
        mContext = context;
        mTunerService = tunerService;
        mPluginManager = pluginManager;

        mServices = new TileServices(this, Dependency.get(Dependency.BG_LOOPER));
        mServices = new TileServices(this, bgLooper);

        defaultFactory.setHost(this);
        mQsFactories.add(defaultFactory);
        Dependency.get(PluginManager.class).addPluginListener(this, QSFactory.class, true);
        pluginManager.addPluginListener(this, QSFactory.class, true);

        mainHandler.post(() -> {
            // This is technically a hack to avoid circular dependency of
            // QSTileHost -> XXXTile -> QSTileHost. Posting ensures creation
            // finishes before creating any tiles.
            Dependency.get(TunerService.class).addTunable(this, TILES_SETTING);
            tunerService.addTunable(this, TILES_SETTING);
        });
        // AutoTileManager can modify mTiles so make sure mTiles has already been initialized.
        mAutoTiles = new AutoTileManager(context, this);
@@ -108,16 +116,16 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory> {
    public void destroy() {
        mTiles.values().forEach(tile -> tile.destroy());
        mAutoTiles.destroy();
        Dependency.get(TunerService.class).removeTunable(this);
        mTunerService.removeTunable(this);
        mServices.destroy();
        Dependency.get(PluginManager.class).removePluginListener(this);
        mPluginManager.removePluginListener(this);
    }

    @Override
    public void onPluginConnected(QSFactory plugin, Context pluginContext) {
        // Give plugins priority over creation so they can override if they wish.
        mQsFactories.add(0, plugin);
        String value = Dependency.get(TunerService.class).getValue(TILES_SETTING);
        String value = mTunerService.getValue(TILES_SETTING);
        // Force remove and recreate of all tiles.
        onTuningChanged(TILES_SETTING, "");
        onTuningChanged(TILES_SETTING, value);
@@ -127,7 +135,7 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory> {
    public void onPluginDisconnected(QSFactory plugin) {
        mQsFactories.remove(plugin);
        // Force remove and recreate of all tiles.
        String value = Dependency.get(TunerService.class).getValue(TILES_SETTING);
        String value = mTunerService.getValue(TILES_SETTING);
        onTuningChanged(TILES_SETTING, "");
        onTuningChanged(TILES_SETTING, value);
    }
+5 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.view.LayoutInflater;
import android.view.View;

import com.android.systemui.SystemUIFactory;
import com.android.systemui.qs.QSFooterImpl;
import com.android.systemui.qs.QuickStatusBarHeader;

import java.lang.reflect.InvocationTargetException;
@@ -107,6 +108,10 @@ public class InjectionInflationController {
         * Creates the QuickStatusBarHeader.
         */
        QuickStatusBarHeader createQsHeader();
        /**
         * Creates the QSFooterImpl.
         */
        QSFooterImpl createQsFooter();
    }

    /**
+4 −1
Original line number Diff line number Diff line
@@ -38,11 +38,13 @@ import com.android.systemui.R;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.SysuiBaseFragmentTest;
import com.android.systemui.qs.tileimpl.QSFactoryImpl;
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.policy.Clock;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.util.InjectionInflationController;

import org.junit.Before;
@@ -89,7 +91,8 @@ public class QSFragmentTest extends SysuiBaseFragmentTest {
        mFragments.dispatchResume();
        processAllMessages();
        QSTileHost host = new QSTileHost(mContext, mock(StatusBarIconController.class),
                mock(QSFactoryImpl.class), new Handler());
                mock(QSFactoryImpl.class), new Handler(), Looper.myLooper(),
                mock(PluginManager.class), mock(TunerService.class));
        qs.setHost(host);

        qs.setListening(true);
+6 −1
Original line number Diff line number Diff line
@@ -32,8 +32,10 @@ import android.testing.TestableLooper.RunWithLooper;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.qs.QSTileHost;
import com.android.systemui.qs.tileimpl.QSFactoryImpl;
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.policy.BluetoothController;
import com.android.systemui.tuner.TunerService;

import org.junit.After;
import org.junit.Before;
@@ -60,7 +62,10 @@ public class TileServicesTest extends SysuiTestCase {
        QSTileHost host = new QSTileHost(mContext,
                mock(StatusBarIconController.class),
                mock(QSFactoryImpl.class),
                new Handler());
                new Handler(),
                Looper.myLooper(),
                mock(PluginManager.class),
                mock(TunerService.class));
        mTileService = new TestTileServices(host, Looper.getMainLooper());
    }