Merge "Make CommandQueue implement CallbackController"
This commit is contained in:
@@ -140,7 +140,7 @@ public class BiometricDialogImpl extends SystemUI implements CommandQueue.Callba
|
||||
createDialogs();
|
||||
|
||||
if (!mDialogs.isEmpty()) {
|
||||
getComponent(CommandQueue.class).addCallbacks(this);
|
||||
getComponent(CommandQueue.class).addCallback(this);
|
||||
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class GlobalActionsComponent extends SystemUI implements Callbacks, Globa
|
||||
.withCallback(this::onExtensionCallback)
|
||||
.build();
|
||||
mPlugin = mExtension.get();
|
||||
SysUiServiceProvider.getComponent(mContext, CommandQueue.class).addCallbacks(this);
|
||||
SysUiServiceProvider.getComponent(mContext, CommandQueue.class).addCallback(this);
|
||||
}
|
||||
|
||||
private void onExtensionCallback(GlobalActions newPlugin) {
|
||||
|
||||
@@ -55,12 +55,12 @@ public class GlobalActionsImpl implements GlobalActions, CommandQueue.Callbacks
|
||||
mContext = context;
|
||||
mKeyguardMonitor = Dependency.get(KeyguardMonitor.class);
|
||||
mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class);
|
||||
SysUiServiceProvider.getComponent(context, CommandQueue.class).addCallbacks(this);
|
||||
SysUiServiceProvider.getComponent(context, CommandQueue.class).addCallback(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
SysUiServiceProvider.getComponent(mContext, CommandQueue.class).removeCallbacks(this);
|
||||
SysUiServiceProvider.getComponent(mContext, CommandQueue.class).removeCallback(this);
|
||||
if (mGlobalActions != null) {
|
||||
mGlobalActions.destroy();
|
||||
mGlobalActions = null;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class PipUI extends SystemUI implements CommandQueue.Callbacks {
|
||||
: com.android.systemui.pip.phone.PipManager.getInstance();
|
||||
mPipManager.initialize(mContext);
|
||||
|
||||
getComponent(CommandQueue.class).addCallbacks(this);
|
||||
getComponent(CommandQueue.class).addCallback(this);
|
||||
putComponent(PipUI.class, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,12 +108,12 @@ public class QSFragment extends Fragment implements QS, CommandQueue.Callbacks {
|
||||
mQSPanel.getTileLayout().restoreInstanceState(savedInstanceState);
|
||||
}
|
||||
}
|
||||
SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).addCallbacks(this);
|
||||
SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).addCallback(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).removeCallbacks(this);
|
||||
SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).removeCallback(this);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Recents extends SystemUI implements CommandQueue.Callbacks {
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
getComponent(CommandQueue.class).addCallbacks(this);
|
||||
getComponent(CommandQueue.class).addCallback(this);
|
||||
putComponent(Recents.class, this);
|
||||
mImpl = createRecentsImplementationFromConfig();
|
||||
mImpl.onStart(mContext, this);
|
||||
|
||||
@@ -35,6 +35,8 @@ import com.android.internal.os.SomeArgs;
|
||||
import com.android.internal.statusbar.IStatusBar;
|
||||
import com.android.internal.statusbar.StatusBarIcon;
|
||||
import com.android.systemui.SystemUI;
|
||||
import com.android.systemui.statusbar.CommandQueue.Callbacks;
|
||||
import com.android.systemui.statusbar.policy.CallbackController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -45,7 +47,7 @@ import java.util.ArrayList;
|
||||
* coalescing these calls so they don't stack up. For the calls
|
||||
* are coalesced, note that they are all idempotent.
|
||||
*/
|
||||
public class CommandQueue extends IStatusBar.Stub {
|
||||
public class CommandQueue extends IStatusBar.Stub implements CallbackController<Callbacks> {
|
||||
private static final int INDEX_MASK = 0xffff;
|
||||
private static final int MSG_SHIFT = 16;
|
||||
private static final int MSG_MASK = 0xffff << MSG_SHIFT;
|
||||
@@ -183,12 +185,12 @@ public class CommandQueue extends IStatusBar.Stub {
|
||||
&& !ONLY_CORE_APPS;
|
||||
}
|
||||
|
||||
public void addCallbacks(Callbacks callbacks) {
|
||||
public void addCallback(Callbacks callbacks) {
|
||||
mCallbacks.add(callbacks);
|
||||
callbacks.disable(mDisable1, mDisable2, false /* animate */);
|
||||
}
|
||||
|
||||
public void removeCallbacks(Callbacks callbacks) {
|
||||
public void removeCallback(Callbacks callbacks) {
|
||||
mCallbacks.remove(callbacks);
|
||||
}
|
||||
|
||||
|
||||
@@ -120,14 +120,14 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mCommandQueue.addCallbacks(this);
|
||||
mCommandQueue.addCallback(this);
|
||||
mStatusBarStateController.addCallback(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mCommandQueue.removeCallbacks(this);
|
||||
mCommandQueue.removeCallback(this);
|
||||
mStatusBarStateController.removeCallback(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,14 +73,14 @@ public class LightBarTransitionsController implements Dumpable, Callbacks,
|
||||
mKeyguardMonitor = Dependency.get(KeyguardMonitor.class);
|
||||
mStatusBarStateController = Dependency.get(StatusBarStateController.class);
|
||||
SysUiServiceProvider.getComponent(context, CommandQueue.class)
|
||||
.addCallbacks(this);
|
||||
.addCallback(this);
|
||||
mStatusBarStateController.addCallback(this);
|
||||
mDozeAmount = mStatusBarStateController.getDozeAmount();
|
||||
}
|
||||
|
||||
public void destroy(Context context) {
|
||||
SysUiServiceProvider.getComponent(context, CommandQueue.class)
|
||||
.removeCallbacks(this);
|
||||
.removeCallback(this);
|
||||
mStatusBarStateController.removeCallback(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ public class NavigationBarFragment extends Fragment implements Callbacks {
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mCommandQueue = SysUiServiceProvider.getComponent(getContext(), CommandQueue.class);
|
||||
mCommandQueue.addCallbacks(this);
|
||||
mCommandQueue.addCallback(this);
|
||||
mStatusBar = SysUiServiceProvider.getComponent(getContext(), StatusBar.class);
|
||||
mRecents = SysUiServiceProvider.getComponent(getContext(), Recents.class);
|
||||
mDivider = SysUiServiceProvider.getComponent(getContext(), Divider.class);
|
||||
@@ -225,7 +225,7 @@ public class NavigationBarFragment extends Fragment implements Callbacks {
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
mCommandQueue.removeCallbacks(this);
|
||||
mCommandQueue.removeCallback(this);
|
||||
Dependency.get(AccessibilityManagerWrapper.class).removeCallback(
|
||||
mAccessibilityListener);
|
||||
mContentResolver.unregisterContentObserver(mMagnificationObserver);
|
||||
|
||||
@@ -268,7 +268,7 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks,
|
||||
mLocationController.addCallback(this);
|
||||
mPrivacyItemController.setListening(true);
|
||||
|
||||
SysUiServiceProvider.getComponent(mContext, CommandQueue.class).addCallbacks(this);
|
||||
SysUiServiceProvider.getComponent(mContext, CommandQueue.class).addCallback(this);
|
||||
ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskListener);
|
||||
|
||||
// Clear out all old notifications on startup (only present in the case where sysui dies)
|
||||
@@ -296,7 +296,7 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks,
|
||||
mKeyguardMonitor.removeCallback(this);
|
||||
mLocationController.removeCallback(this);
|
||||
mPrivacyItemController.setListening(false);
|
||||
SysUiServiceProvider.getComponent(mContext, CommandQueue.class).removeCallbacks(this);
|
||||
SysUiServiceProvider.getComponent(mContext, CommandQueue.class).removeCallback(this);
|
||||
mContext.unregisterReceiver(mIntentReceiver);
|
||||
|
||||
NotificationManager noMan = mContext.getSystemService(NotificationManager.class);
|
||||
|
||||
@@ -663,7 +663,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
|
||||
// Connect in to the status bar manager service
|
||||
mCommandQueue = getComponent(CommandQueue.class);
|
||||
mCommandQueue.addCallbacks(this);
|
||||
mCommandQueue.addCallback(this);
|
||||
|
||||
int[] switches = new int[9];
|
||||
ArrayList<IBinder> binders = new ArrayList<>();
|
||||
|
||||
@@ -76,7 +76,7 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu
|
||||
loadDimens();
|
||||
|
||||
SysUiServiceProvider.getComponent(context, CommandQueue.class)
|
||||
.addCallbacks(this);
|
||||
.addCallback(this);
|
||||
Dependency.get(TunerService.class).addTunable(this, ICON_BLACKLIST);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public class StatusBarRemoteInputCallback implements Callback, Callbacks {
|
||||
mStatusBarStateController.addCallback(mStateListener);
|
||||
mKeyguardManager = context.getSystemService(KeyguardManager.class);
|
||||
mCommandQueue = getComponent(context, CommandQueue.class);
|
||||
mCommandQueue.addCallbacks(this);
|
||||
mCommandQueue.addCallback(this);
|
||||
}
|
||||
|
||||
private void setStatusBarState(int state) {
|
||||
|
||||
@@ -187,7 +187,7 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
|
||||
null, Dependency.get(Dependency.TIME_TICK_HANDLER));
|
||||
Dependency.get(TunerService.class).addTunable(this, CLOCK_SECONDS,
|
||||
StatusBarIconController.ICON_BLACKLIST);
|
||||
SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).addCallbacks(this);
|
||||
SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).addCallback(this);
|
||||
if (mShowDark) {
|
||||
Dependency.get(DarkIconDispatcher.class).addDarkReceiver(this);
|
||||
}
|
||||
@@ -215,7 +215,7 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
|
||||
mAttached = false;
|
||||
Dependency.get(TunerService.class).removeTunable(this);
|
||||
SysUiServiceProvider.getComponent(getContext(), CommandQueue.class)
|
||||
.removeCallbacks(this);
|
||||
.removeCallback(this);
|
||||
if (mShowDark) {
|
||||
Dependency.get(DarkIconDispatcher.class).removeDarkReceiver(this);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class TvStatusBar extends SystemUI implements Callbacks {
|
||||
public void start() {
|
||||
putComponent(TvStatusBar.class, this);
|
||||
CommandQueue commandQueue = getComponent(CommandQueue.class);
|
||||
commandQueue.addCallbacks(this);
|
||||
commandQueue.addCallback(this);
|
||||
int[] switches = new int[9];
|
||||
ArrayList<IBinder> binders = new ArrayList<>();
|
||||
ArrayList<String> iconSlots = new ArrayList<>();
|
||||
|
||||
@@ -57,13 +57,13 @@ public class Utils {
|
||||
public void onViewAttachedToWindow(View v) {
|
||||
mView = v;
|
||||
SysUiServiceProvider.getComponent(v.getContext(), CommandQueue.class)
|
||||
.addCallbacks(this);
|
||||
.addCallback(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewDetachedFromWindow(View v) {
|
||||
SysUiServiceProvider.getComponent(mView.getContext(), CommandQueue.class)
|
||||
.removeCallbacks(this);
|
||||
.removeCallback(this);
|
||||
mView = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class CommandQueueTest extends SysuiTestCase {
|
||||
public void setup() {
|
||||
mCommandQueue = new CommandQueue();
|
||||
mCallbacks = mock(Callbacks.class);
|
||||
mCommandQueue.addCallbacks(mCallbacks);
|
||||
mCommandQueue.addCallback(mCallbacks);
|
||||
verify(mCallbacks).disable(eq(0), eq(0), eq(false));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user