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

Commit 9d698144 authored by Shawn Lee's avatar Shawn Lee Committed by Android (Google) Code Review
Browse files

Merge "Removed Dependency.get from com.android.systemui.statusbar"

parents 3090e6e5 d265a7f5
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ import androidx.annotation.VisibleForTesting;

import com.android.internal.statusbar.NotificationVisibility;
import com.android.internal.widget.LockPatternUtils;
import com.android.systemui.Dependency;
import com.android.systemui.Dumpable;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.SysUISingleton;
@@ -97,6 +96,7 @@ public class NotificationLockscreenUserManagerImpl implements
    private final List<UserChangedListener> mListeners = new ArrayList<>();
    private final BroadcastDispatcher mBroadcastDispatcher;
    private final NotificationClickNotifier mClickNotifier;
    private final Lazy<OverviewProxyService> mOverviewProxyServiceLazy;

    private boolean mShowLockscreenNotifications;
    private boolean mAllowLockscreenRemoteInput;
@@ -157,7 +157,7 @@ public class NotificationLockscreenUserManagerImpl implements
                    break;
                case Intent.ACTION_USER_UNLOCKED:
                    // Start the overview connection to the launcher service
                    Dependency.get(OverviewProxyService.class).startConnectionToCurrentUser();
                    mOverviewProxyServiceLazy.get().startConnectionToCurrentUser();
                    break;
                case NOTIFICATION_UNLOCKED_BY_WORK_CHALLENGE_ACTION:
                    final IntentSender intentSender = intent.getParcelableExtra(
@@ -199,6 +199,7 @@ public class NotificationLockscreenUserManagerImpl implements
            Lazy<NotificationVisibilityProvider> visibilityProviderLazy,
            Lazy<CommonNotifCollection> commonNotifCollectionLazy,
            NotificationClickNotifier clickNotifier,
            Lazy<OverviewProxyService> overviewProxyServiceLazy,
            KeyguardManager keyguardManager,
            StatusBarStateController statusBarStateController,
            @Main Handler mainHandler,
@@ -214,6 +215,7 @@ public class NotificationLockscreenUserManagerImpl implements
        mVisibilityProviderLazy = visibilityProviderLazy;
        mCommonNotifCollectionLazy = commonNotifCollectionLazy;
        mClickNotifier = clickNotifier;
        mOverviewProxyServiceLazy = overviewProxyServiceLazy;
        statusBarStateController.addCallback(this);
        mLockPatternUtils = new LockPatternUtils(context);
        mKeyguardManager = keyguardManager;
+9 −6
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import com.android.systemui.Dependency;
import com.android.systemui.Dumpable;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.colorextraction.SysuiColorExtractor;
@@ -89,11 +88,9 @@ public class NotificationMediaManager implements Dumpable {
    private static final String TAG = "NotificationMediaManager";
    public static final boolean DEBUG_MEDIA = false;

    private final StatusBarStateController mStatusBarStateController
            = Dependency.get(StatusBarStateController.class);
    private final SysuiColorExtractor mColorExtractor = Dependency.get(SysuiColorExtractor.class);
    private final KeyguardStateController mKeyguardStateController = Dependency.get(
            KeyguardStateController.class);
    private final StatusBarStateController mStatusBarStateController;
    private final SysuiColorExtractor mColorExtractor;
    private final KeyguardStateController mKeyguardStateController;
    private final KeyguardBypassController mKeyguardBypassController;
    private static final HashSet<Integer> PAUSED_MEDIA_STATES = new HashSet<>();
    private static final HashSet<Integer> CONNECTING_MEDIA_STATES = new HashSet<>();
@@ -179,6 +176,9 @@ public class NotificationMediaManager implements Dumpable {
            NotifCollection notifCollection,
            @Main DelayableExecutor mainExecutor,
            MediaDataManager mediaDataManager,
            StatusBarStateController statusBarStateController,
            SysuiColorExtractor colorExtractor,
            KeyguardStateController keyguardStateController,
            DumpManager dumpManager) {
        mContext = context;
        mMediaArtworkProcessor = mediaArtworkProcessor;
@@ -192,6 +192,9 @@ public class NotificationMediaManager implements Dumpable {
        mMediaDataManager = mediaDataManager;
        mNotifPipeline = notifPipeline;
        mNotifCollection = notifCollection;
        mStatusBarStateController = statusBarStateController;
        mColorExtractor = colorExtractor;
        mKeyguardStateController = keyguardStateController;

        setupNotifPipeline();

+7 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.statusbar.IStatusBarService;
import com.android.systemui.animation.ActivityLaunchAnimator;
import com.android.systemui.animation.DialogLaunchAnimator;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager;
@@ -130,6 +131,9 @@ public interface CentralSurfacesDependenciesModule {
            NotifCollection notifCollection,
            @Main DelayableExecutor mainExecutor,
            MediaDataManager mediaDataManager,
            StatusBarStateController statusBarStateController,
            SysuiColorExtractor colorExtractor,
            KeyguardStateController keyguardStateController,
            DumpManager dumpManager) {
        return new NotificationMediaManager(
                context,
@@ -142,6 +146,9 @@ public interface CentralSurfacesDependenciesModule {
                notifCollection,
                mainExecutor,
                mediaDataManager,
                statusBarStateController,
                colorExtractor,
                keyguardStateController,
                dumpManager);
    }

+0 −86
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.statusbar;

import static org.junit.Assert.assertFalse;

import android.os.Handler;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;

import androidx.test.filters.SmallTest;

import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.Dependency;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.notification.logging.NotificationLogger;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager.OnSettingsClickListener;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

/**
 * Verifies that particular sets of dependencies don't have dependencies on others. For example,
 * code managing notifications shouldn't directly depend on CentralSurfaces, since there are
 * platforms which want to manage notifications, but don't use CentralSurfaces.
 */
@SmallTest
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
public class NonPhoneDependencyTest extends SysuiTestCase {
    @Mock private NotificationPresenter mPresenter;
    @Mock private NotificationListContainer mListContainer;
    @Mock private RemoteInputController.Delegate mDelegate;
    @Mock private NotificationRemoteInputManager.Callback mRemoteInputManagerCallback;
    @Mock private OnSettingsClickListener mOnSettingsClickListener;

    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);
        mDependency.injectMockDependency(KeyguardUpdateMonitor.class);
        mDependency.injectTestDependency(Dependency.MAIN_HANDLER,
               new Handler(TestableLooper.get(this).getLooper()));
    }

    @Ignore("Causes binder calls which fail")
    @Test
    public void testNotificationManagementCodeHasNoDependencyOnStatusBarWindowManager() {
        NotificationGutsManager gutsManager = Dependency.get(NotificationGutsManager.class);
        NotificationLogger notificationLogger = Dependency.get(NotificationLogger.class);
        NotificationMediaManager mediaManager = Dependency.get(NotificationMediaManager.class);
        NotificationRemoteInputManager remoteInputManager =
                Dependency.get(NotificationRemoteInputManager.class);
        NotificationLockscreenUserManager lockscreenUserManager =
                Dependency.get(NotificationLockscreenUserManager.class);
        gutsManager.setUpWithPresenter(mPresenter, mListContainer,
                mOnSettingsClickListener);
        notificationLogger.setUpWithContainer(mListContainer);
        mediaManager.setUpWithPresenter(mPresenter);
        remoteInputManager.setUpWithCallback(mRemoteInputManagerCallback,
                mDelegate);
        lockscreenUserManager.setUpWithPresenter(mPresenter);

        TestableLooper.get(this).processAllMessages();
        assertFalse(mDependency.hasInstantiatedDependency(NotificationShadeWindowController.class));
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import com.android.systemui.SysuiTestCase;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.statusbar.NotificationLockscreenUserManager.NotificationStateChangedListener;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
@@ -88,6 +89,8 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
    @Mock
    private NotificationClickNotifier mClickNotifier;
    @Mock
    private OverviewProxyService mOverviewProxyService;
    @Mock
    private KeyguardManager mKeyguardManager;
    @Mock
    private DeviceProvisionedController mDeviceProvisionedController;
@@ -344,6 +347,7 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
                    (() -> mVisibilityProvider),
                    (() -> mNotifCollection),
                    mClickNotifier,
                    (() -> mOverviewProxyService),
                    NotificationLockscreenUserManagerTest.this.mKeyguardManager,
                    mStatusBarStateController,
                    Handler.createAsync(Looper.myLooper()),