Merge "Removed Dependency.get from com.android.systemui.statusbar" into tm-qpr-dev am: 02c2b63b73

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19981693

Change-Id: I1d908d3529ee675f40629ae424ed1f138c9214bc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Shawn Lee
2022-10-06 19:55:32 +00:00
committed by Automerger Merge Worker
5 changed files with 24 additions and 96 deletions

View File

@@ -42,7 +42,6 @@ import androidx.annotation.VisibleForTesting;
import com.android.internal.statusbar.NotificationVisibility; import com.android.internal.statusbar.NotificationVisibility;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
import com.android.systemui.Dependency;
import com.android.systemui.Dumpable; import com.android.systemui.Dumpable;
import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.SysUISingleton;
@@ -97,6 +96,7 @@ public class NotificationLockscreenUserManagerImpl implements
private final List<UserChangedListener> mListeners = new ArrayList<>(); private final List<UserChangedListener> mListeners = new ArrayList<>();
private final BroadcastDispatcher mBroadcastDispatcher; private final BroadcastDispatcher mBroadcastDispatcher;
private final NotificationClickNotifier mClickNotifier; private final NotificationClickNotifier mClickNotifier;
private final Lazy<OverviewProxyService> mOverviewProxyServiceLazy;
private boolean mShowLockscreenNotifications; private boolean mShowLockscreenNotifications;
private boolean mAllowLockscreenRemoteInput; private boolean mAllowLockscreenRemoteInput;
@@ -157,7 +157,7 @@ public class NotificationLockscreenUserManagerImpl implements
break; break;
case Intent.ACTION_USER_UNLOCKED: case Intent.ACTION_USER_UNLOCKED:
// Start the overview connection to the launcher service // Start the overview connection to the launcher service
Dependency.get(OverviewProxyService.class).startConnectionToCurrentUser(); mOverviewProxyServiceLazy.get().startConnectionToCurrentUser();
break; break;
case NOTIFICATION_UNLOCKED_BY_WORK_CHALLENGE_ACTION: case NOTIFICATION_UNLOCKED_BY_WORK_CHALLENGE_ACTION:
final IntentSender intentSender = intent.getParcelableExtra( final IntentSender intentSender = intent.getParcelableExtra(
@@ -199,6 +199,7 @@ public class NotificationLockscreenUserManagerImpl implements
Lazy<NotificationVisibilityProvider> visibilityProviderLazy, Lazy<NotificationVisibilityProvider> visibilityProviderLazy,
Lazy<CommonNotifCollection> commonNotifCollectionLazy, Lazy<CommonNotifCollection> commonNotifCollectionLazy,
NotificationClickNotifier clickNotifier, NotificationClickNotifier clickNotifier,
Lazy<OverviewProxyService> overviewProxyServiceLazy,
KeyguardManager keyguardManager, KeyguardManager keyguardManager,
StatusBarStateController statusBarStateController, StatusBarStateController statusBarStateController,
@Main Handler mainHandler, @Main Handler mainHandler,
@@ -214,6 +215,7 @@ public class NotificationLockscreenUserManagerImpl implements
mVisibilityProviderLazy = visibilityProviderLazy; mVisibilityProviderLazy = visibilityProviderLazy;
mCommonNotifCollectionLazy = commonNotifCollectionLazy; mCommonNotifCollectionLazy = commonNotifCollectionLazy;
mClickNotifier = clickNotifier; mClickNotifier = clickNotifier;
mOverviewProxyServiceLazy = overviewProxyServiceLazy;
statusBarStateController.addCallback(this); statusBarStateController.addCallback(this);
mLockPatternUtils = new LockPatternUtils(context); mLockPatternUtils = new LockPatternUtils(context);
mKeyguardManager = keyguardManager; mKeyguardManager = keyguardManager;

View File

@@ -43,7 +43,6 @@ import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import com.android.systemui.Dependency;
import com.android.systemui.Dumpable; import com.android.systemui.Dumpable;
import com.android.systemui.animation.Interpolators; import com.android.systemui.animation.Interpolators;
import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.colorextraction.SysuiColorExtractor;
@@ -89,11 +88,9 @@ public class NotificationMediaManager implements Dumpable {
private static final String TAG = "NotificationMediaManager"; private static final String TAG = "NotificationMediaManager";
public static final boolean DEBUG_MEDIA = false; public static final boolean DEBUG_MEDIA = false;
private final StatusBarStateController mStatusBarStateController private final StatusBarStateController mStatusBarStateController;
= Dependency.get(StatusBarStateController.class); private final SysuiColorExtractor mColorExtractor;
private final SysuiColorExtractor mColorExtractor = Dependency.get(SysuiColorExtractor.class); private final KeyguardStateController mKeyguardStateController;
private final KeyguardStateController mKeyguardStateController = Dependency.get(
KeyguardStateController.class);
private final KeyguardBypassController mKeyguardBypassController; private final KeyguardBypassController mKeyguardBypassController;
private static final HashSet<Integer> PAUSED_MEDIA_STATES = new HashSet<>(); private static final HashSet<Integer> PAUSED_MEDIA_STATES = new HashSet<>();
private static final HashSet<Integer> CONNECTING_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, NotifCollection notifCollection,
@Main DelayableExecutor mainExecutor, @Main DelayableExecutor mainExecutor,
MediaDataManager mediaDataManager, MediaDataManager mediaDataManager,
StatusBarStateController statusBarStateController,
SysuiColorExtractor colorExtractor,
KeyguardStateController keyguardStateController,
DumpManager dumpManager) { DumpManager dumpManager) {
mContext = context; mContext = context;
mMediaArtworkProcessor = mediaArtworkProcessor; mMediaArtworkProcessor = mediaArtworkProcessor;
@@ -192,6 +192,9 @@ public class NotificationMediaManager implements Dumpable {
mMediaDataManager = mediaDataManager; mMediaDataManager = mediaDataManager;
mNotifPipeline = notifPipeline; mNotifPipeline = notifPipeline;
mNotifCollection = notifCollection; mNotifCollection = notifCollection;
mStatusBarStateController = statusBarStateController;
mColorExtractor = colorExtractor;
mKeyguardStateController = keyguardStateController;
setupNotifPipeline(); setupNotifPipeline();

View File

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

View File

@@ -1,88 +0,0 @@
/*
* 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.shade.ShadeController;
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() {
mDependency.injectMockDependency(ShadeController.class);
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));
}
}

View File

@@ -52,6 +52,7 @@ import com.android.systemui.SysuiTestCase;
import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dump.DumpManager; import com.android.systemui.dump.DumpManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController; 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.NotificationLockscreenUserManager.NotificationStateChangedListener;
import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder; import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
@@ -88,6 +89,8 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
@Mock @Mock
private NotificationClickNotifier mClickNotifier; private NotificationClickNotifier mClickNotifier;
@Mock @Mock
private OverviewProxyService mOverviewProxyService;
@Mock
private KeyguardManager mKeyguardManager; private KeyguardManager mKeyguardManager;
@Mock @Mock
private DeviceProvisionedController mDeviceProvisionedController; private DeviceProvisionedController mDeviceProvisionedController;
@@ -344,6 +347,7 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
(() -> mVisibilityProvider), (() -> mVisibilityProvider),
(() -> mNotifCollection), (() -> mNotifCollection),
mClickNotifier, mClickNotifier,
(() -> mOverviewProxyService),
NotificationLockscreenUserManagerTest.this.mKeyguardManager, NotificationLockscreenUserManagerTest.this.mKeyguardManager,
mStatusBarStateController, mStatusBarStateController,
Handler.createAsync(Looper.myLooper()), Handler.createAsync(Looper.myLooper()),