Register OverlayPlugins in StatusBar directly.
This removes the last call to getComponent(StatusBar.class). Prior to this change, we would register a listener for OverlayPlugins inside the SystemUIApp. Because they are directly related to the StatusBar, it is safe and appropriate to have the StatusBar register with the PluginManager itself. Bug: 143224715 Test: atest SystemUITests Change-Id: I5ecdf6a4dae05ba674bcbcd940b9f2655d2b1cbb
This commit is contained in:
@@ -42,6 +42,7 @@ import com.android.systemui.plugins.FalsingManager;
|
||||
import com.android.systemui.power.PowerUI;
|
||||
import com.android.systemui.recents.Recents;
|
||||
import com.android.systemui.recents.RecentsModule;
|
||||
import com.android.systemui.shared.plugins.PluginManager;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
import com.android.systemui.statusbar.FeatureFlags;
|
||||
import com.android.systemui.statusbar.NavigationBarController;
|
||||
@@ -275,6 +276,7 @@ public abstract class CarSystemUIBinder {
|
||||
PowerManager powerManager,
|
||||
DozeScrimController dozeScrimController,
|
||||
CommandQueue commandQueue,
|
||||
PluginManager pluginManager,
|
||||
CarNavigationBarController carNavigationBarController) {
|
||||
return new CarStatusBar(
|
||||
context,
|
||||
@@ -341,6 +343,7 @@ public abstract class CarSystemUIBinder {
|
||||
powerManager,
|
||||
dozeScrimController,
|
||||
commandQueue,
|
||||
pluginManager,
|
||||
carNavigationBarController);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ import com.android.systemui.navigationbar.car.CarNavigationBarView;
|
||||
import com.android.systemui.plugins.FalsingManager;
|
||||
import com.android.systemui.plugins.qs.QS;
|
||||
import com.android.systemui.qs.car.CarQSFragment;
|
||||
import com.android.systemui.shared.plugins.PluginManager;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
import com.android.systemui.statusbar.FeatureFlags;
|
||||
import com.android.systemui.statusbar.FlingAnimationUtils;
|
||||
@@ -299,6 +300,8 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
||||
PowerManager powerManager,
|
||||
DozeScrimController dozeScrimController,
|
||||
CommandQueue commandQueue,
|
||||
PluginManager pluginManager,
|
||||
|
||||
/* Car Settings injected components. */
|
||||
CarNavigationBarController carNavigationBarController) {
|
||||
super(
|
||||
@@ -366,7 +369,8 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
||||
dozeServiceHost,
|
||||
powerManager,
|
||||
dozeScrimController,
|
||||
commandQueue);
|
||||
commandQueue,
|
||||
pluginManager);
|
||||
mScrimController = scrimController;
|
||||
mCarNavigationBarController = carNavigationBarController;
|
||||
}
|
||||
|
||||
@@ -24,23 +24,14 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Process;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.Trace;
|
||||
import android.os.UserHandle;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
import android.util.TimingsTraceLog;
|
||||
|
||||
import com.android.systemui.dagger.ContextComponentHelper;
|
||||
import com.android.systemui.plugins.OverlayPlugin;
|
||||
import com.android.systemui.plugins.PluginListener;
|
||||
import com.android.systemui.shared.plugins.PluginManager;
|
||||
import com.android.systemui.statusbar.phone.DozeParameters;
|
||||
import com.android.systemui.statusbar.phone.StatusBar;
|
||||
import com.android.systemui.statusbar.phone.StatusBarWindowController;
|
||||
import com.android.systemui.util.NotificationChannels;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
@@ -224,65 +215,6 @@ public class SystemUIApplication extends Application implements SysUiServiceProv
|
||||
}
|
||||
Dependency.get(InitController.class).executePostInitTasks();
|
||||
log.traceEnd();
|
||||
final Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Dependency.get(PluginManager.class).addPluginListener(
|
||||
new PluginListener<OverlayPlugin>() {
|
||||
private ArraySet<OverlayPlugin> mOverlays = new ArraySet<>();
|
||||
|
||||
@Override
|
||||
public void onPluginConnected(OverlayPlugin plugin, Context pluginContext) {
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
StatusBar statusBar = getComponent(StatusBar.class);
|
||||
if (statusBar != null) {
|
||||
plugin.setup(statusBar.getStatusBarWindow(),
|
||||
statusBar.getNavigationBarView(), new Callback(plugin),
|
||||
Dependency.get(DozeParameters.class));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginDisconnected(OverlayPlugin plugin) {
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mOverlays.remove(plugin);
|
||||
Dependency.get(StatusBarWindowController.class).setForcePluginOpen(
|
||||
mOverlays.size() != 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
class Callback implements OverlayPlugin.Callback {
|
||||
private final OverlayPlugin mPlugin;
|
||||
|
||||
Callback(OverlayPlugin plugin) {
|
||||
mPlugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHoldStatusBarOpenChange() {
|
||||
if (mPlugin.holdStatusBarOpen()) {
|
||||
mOverlays.add(mPlugin);
|
||||
} else {
|
||||
mOverlays.remove(mPlugin);
|
||||
}
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Dependency.get(StatusBarWindowController.class)
|
||||
.setStateListener(b -> mOverlays.forEach(
|
||||
o -> o.setCollapseDesired(b)));
|
||||
Dependency.get(StatusBarWindowController.class)
|
||||
.setForcePluginOpen(mOverlays.size() != 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, OverlayPlugin.class, true /* Allow multiple plugins */);
|
||||
|
||||
mServicesStarted = true;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ import com.android.systemui.plugins.FalsingManager;
|
||||
import com.android.systemui.power.PowerUI;
|
||||
import com.android.systemui.recents.Recents;
|
||||
import com.android.systemui.recents.RecentsModule;
|
||||
import com.android.systemui.shared.plugins.PluginManager;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
import com.android.systemui.statusbar.FeatureFlags;
|
||||
import com.android.systemui.statusbar.NavigationBarController;
|
||||
@@ -271,7 +272,8 @@ public abstract class SystemUIBinder {
|
||||
DozeServiceHost dozeServiceHost,
|
||||
PowerManager powerManager,
|
||||
DozeScrimController dozeScrimController,
|
||||
CommandQueue commandQueue) {
|
||||
CommandQueue commandQueue,
|
||||
PluginManager pluginManager) {
|
||||
return new StatusBar(
|
||||
context,
|
||||
featureFlags,
|
||||
@@ -337,7 +339,8 @@ public abstract class SystemUIBinder {
|
||||
dozeServiceHost,
|
||||
powerManager,
|
||||
dozeScrimController,
|
||||
commandQueue);
|
||||
commandQueue,
|
||||
pluginManager);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ import android.provider.Settings;
|
||||
import android.service.dreams.DreamService;
|
||||
import android.service.dreams.IDreamManager;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.util.ArraySet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.EventLog;
|
||||
import android.util.Log;
|
||||
@@ -168,7 +169,9 @@ import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||
import com.android.systemui.plugins.ActivityStarter;
|
||||
import com.android.systemui.plugins.DarkIconDispatcher;
|
||||
import com.android.systemui.plugins.FalsingManager;
|
||||
import com.android.systemui.plugins.OverlayPlugin;
|
||||
import com.android.systemui.plugins.PluginDependencyProvider;
|
||||
import com.android.systemui.plugins.PluginListener;
|
||||
import com.android.systemui.plugins.qs.QS;
|
||||
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper.SnoozeOption;
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
@@ -176,6 +179,7 @@ import com.android.systemui.qs.QSFragment;
|
||||
import com.android.systemui.qs.QSPanel;
|
||||
import com.android.systemui.recents.Recents;
|
||||
import com.android.systemui.recents.ScreenPinningRequest;
|
||||
import com.android.systemui.shared.plugins.PluginManager;
|
||||
import com.android.systemui.shared.system.WindowManagerWrapper;
|
||||
import com.android.systemui.stackdivider.Divider;
|
||||
import com.android.systemui.stackdivider.WindowManagerProxy;
|
||||
@@ -396,6 +400,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
private final NotifLog mNotifLog;
|
||||
private final DozeParameters mDozeParameters;
|
||||
private final Lazy<BiometricUnlockController> mBiometricUnlockControllerLazy;
|
||||
private final PluginManager mPluginManager;
|
||||
|
||||
// expanded notifications
|
||||
protected NotificationPanelView mNotificationPanel; // the sliding/resizing panel within the notification window
|
||||
@@ -697,7 +702,8 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
DozeServiceHost dozeServiceHost,
|
||||
PowerManager powerManager,
|
||||
DozeScrimController dozeScrimController,
|
||||
CommandQueue commandQueue) {
|
||||
CommandQueue commandQueue,
|
||||
PluginManager pluginManager) {
|
||||
super(context);
|
||||
mFeatureFlags = featureFlags;
|
||||
mLightBarController = lightBarController;
|
||||
@@ -763,6 +769,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
mDozeScrimController = dozeScrimController;
|
||||
mBiometricUnlockControllerLazy = biometricUnlockControllerLazy;
|
||||
mCommandQueue = commandQueue;
|
||||
mPluginManager = pluginManager;
|
||||
|
||||
mBubbleExpandListener =
|
||||
(isExpanding, key) -> {
|
||||
@@ -929,6 +936,50 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
int disabledFlags2 = result.mDisabledFlags2;
|
||||
Dependency.get(InitController.class).addPostInitTask(
|
||||
() -> setUpDisableFlags(disabledFlags1, disabledFlags2));
|
||||
|
||||
mPluginManager.addPluginListener(
|
||||
new PluginListener<OverlayPlugin>() {
|
||||
private ArraySet<OverlayPlugin> mOverlays = new ArraySet<>();
|
||||
|
||||
@Override
|
||||
public void onPluginConnected(OverlayPlugin plugin, Context pluginContext) {
|
||||
mMainThreadHandler.post(
|
||||
() -> plugin.setup(getStatusBarWindow(), getNavigationBarView(),
|
||||
new Callback(plugin), mDozeParameters));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginDisconnected(OverlayPlugin plugin) {
|
||||
mMainThreadHandler.post(() -> {
|
||||
mOverlays.remove(plugin);
|
||||
mStatusBarWindowController.setForcePluginOpen(mOverlays.size() != 0);
|
||||
});
|
||||
}
|
||||
|
||||
class Callback implements OverlayPlugin.Callback {
|
||||
private final OverlayPlugin mPlugin;
|
||||
|
||||
Callback(OverlayPlugin plugin) {
|
||||
mPlugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHoldStatusBarOpenChange() {
|
||||
if (mPlugin.holdStatusBarOpen()) {
|
||||
mOverlays.add(mPlugin);
|
||||
} else {
|
||||
mOverlays.remove(mPlugin);
|
||||
}
|
||||
mMainThreadHandler.post(() -> {
|
||||
mStatusBarWindowController
|
||||
.setStateListener(b -> mOverlays.forEach(
|
||||
o -> o.setCollapseDesired(b)));
|
||||
mStatusBarWindowController
|
||||
.setForcePluginOpen(mOverlays.size() != 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
}, OverlayPlugin.class, true /* Allow multiple plugins */);
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
|
||||
@@ -91,6 +91,7 @@ import com.android.systemui.keyguard.ScreenLifecycle;
|
||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||
import com.android.systemui.plugins.ActivityStarter.OnDismissAction;
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
import com.android.systemui.shared.plugins.PluginManager;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
import com.android.systemui.statusbar.FeatureFlags;
|
||||
import com.android.systemui.statusbar.KeyguardIndicationController;
|
||||
@@ -230,6 +231,7 @@ public class StatusBarTest extends SysuiTestCase {
|
||||
@Mock private ViewMediatorCallback mKeyguardVieMediatorCallback;
|
||||
@Mock private KeyguardLiftController mKeyguardLiftController;
|
||||
@Mock private CommandQueue mCommandQueue;
|
||||
@Mock private PluginManager mPluginManager;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
@@ -366,7 +368,8 @@ public class StatusBarTest extends SysuiTestCase {
|
||||
mDozeServiceHost,
|
||||
mPowerManager,
|
||||
mDozeScrimController,
|
||||
mCommandQueue);
|
||||
mCommandQueue,
|
||||
mPluginManager);
|
||||
|
||||
when(mStatusBarWindowView.findViewById(R.id.lock_icon_container)).thenReturn(
|
||||
mLockIconContainer);
|
||||
@@ -392,7 +395,6 @@ public class StatusBarTest extends SysuiTestCase {
|
||||
mStatusBar.mStackScroller = mStackScroller;
|
||||
mStatusBar.mStatusBarWindowViewController = mStatusBarWindowViewController;
|
||||
mStatusBar.startKeyguard();
|
||||
mStatusBar.putComponent(StatusBar.class, mStatusBar);
|
||||
Dependency.get(InitController.class).executePostInitTasks();
|
||||
entryManager.setUpForTest(mock(NotificationPresenter.class), mStackScroller,
|
||||
mHeadsUpManager);
|
||||
|
||||
Reference in New Issue
Block a user