Work on sysui dependencies
One of the many problems with PhoneStatusBar is that it holds
dependencies for many other parts of SysUI. Fix this by creating
a static method of grabbing dependencies that are global to sysui
this cleans up a lot of chains of interdependence.
Also add easy way to inject mocks of these dependencies for the
purpose of testing.
Test: runtest systemui
Change-Id: Ia0e947faea62d15b665facada47ac9916c99f895
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index faf143e..6ac5cb8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -71,7 +71,6 @@
import android.view.Display;
import android.view.IWindowManager;
import android.view.LayoutInflater;
-import android.view.MotionEvent;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewGroup;
@@ -92,6 +91,7 @@
import com.android.keyguard.KeyguardHostView.OnDismissAction;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.DejankUtils;
+import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.RecentsComponent;
@@ -100,11 +100,11 @@
import com.android.systemui.assist.AssistManager;
import com.android.systemui.recents.Recents;
import com.android.systemui.statusbar.NotificationData.Entry;
-import com.android.systemui.statusbar.NotificationGuts.OnGutsClosedListener;
import com.android.systemui.statusbar.notification.VisualStabilityManager;
-import com.android.systemui.statusbar.phone.NavigationBarView;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
+import com.android.systemui.statusbar.policy.DeviceProvisionedController;
+import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.policy.PreviewInflater;
import com.android.systemui.statusbar.policy.RemoteInputView;
@@ -223,6 +223,7 @@
protected KeyguardManager mKeyguardManager;
private LockPatternUtils mLockPatternUtils;
+ private DeviceProvisionedController mDeviceProvisionedController;
// UI-specific methods
@@ -237,8 +238,6 @@
protected Display mDisplay;
- private boolean mDeviceProvisioned = false;
-
protected RecentsComponent mRecents;
protected int mZenMode;
@@ -270,7 +269,7 @@
@Override // NotificationData.Environment
public boolean isDeviceProvisioned() {
- return mDeviceProvisioned;
+ return mDeviceProvisionedController.isDeviceProvisioned();
}
private final IVrStateCallbacks mVrStateCallbacks = new IVrStateCallbacks.Stub() {
@@ -284,15 +283,17 @@
return mVrMode;
}
+ private final DeviceProvisionedListener mDeviceProvisionedListener =
+ new DeviceProvisionedListener() {
+ @Override
+ public void onDeviceProvisionedChanged() {
+ updateNotifications();
+ }
+ };
+
protected final ContentObserver mSettingsObserver = new ContentObserver(mHandler) {
@Override
public void onChange(boolean selfChange) {
- final boolean provisioned = 0 != Settings.Global.getInt(
- mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0);
- if (provisioned != mDeviceProvisioned) {
- mDeviceProvisioned = provisioned;
- updateNotifications();
- }
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.ZEN_MODE, Settings.Global.ZEN_MODE_OFF);
setZenMode(mode);
@@ -707,9 +708,8 @@
ServiceManager.checkService(DreamService.DREAM_SERVICE));
mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
- mContext.getContentResolver().registerContentObserver(
- Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), true,
- mSettingsObserver);
+ mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class);
+ mDeviceProvisionedController.addCallback(mDeviceProvisionedListener);
mContext.getContentResolver().registerContentObserver(
Settings.Global.getUriFor(Settings.Global.ZEN_MODE), false,
mSettingsObserver);
@@ -2470,6 +2470,7 @@
} catch (RemoteException e) {
// Ignore.
}
+ mDeviceProvisionedController.removeCallback(mDeviceProvisionedListener);
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
index fed28e3..477701c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
@@ -185,7 +185,14 @@
public void animateCollapsePanels() {
synchronized (mLock) {
mHandler.removeMessages(MSG_COLLAPSE_PANELS);
- mHandler.sendEmptyMessage(MSG_COLLAPSE_PANELS);
+ mHandler.obtainMessage(MSG_COLLAPSE_PANELS, 0, 0).sendToTarget();
+ }
+ }
+
+ public void animateCollapsePanels(int flags) {
+ synchronized (mLock) {
+ mHandler.removeMessages(MSG_COLLAPSE_PANELS);
+ mHandler.obtainMessage(MSG_COLLAPSE_PANELS, flags, 0).sendToTarget();
}
}
@@ -450,7 +457,7 @@
break;
case MSG_COLLAPSE_PANELS:
for (int i = 0; i < mCallbacks.size(); i++) {
- mCallbacks.get(i).animateCollapsePanels(0);
+ mCallbacks.get(i).animateCollapsePanels(msg.arg1);
}
break;
case MSG_EXPAND_SETTINGS:
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
index f451aef..08fd93d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
@@ -42,10 +42,10 @@
import com.android.internal.app.IBatteryStats;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.statusbar.phone.KeyguardIndicationTextView;
import com.android.systemui.statusbar.phone.LockIcon;
-import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
/**
@@ -109,7 +109,7 @@
KeyguardUpdateMonitor.getInstance(context).registerCallback(mUpdateMonitor);
context.registerReceiverAsUser(mTickReceiver, UserHandle.SYSTEM,
new IntentFilter(Intent.ACTION_TIME_TICK), null,
- PhoneStatusBar.getTimeTickHandler(mContext));
+ Dependency.get(Dependency.TIME_TICK_HANDLER));
updateDisclosure();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
index d77e9ed..1128101 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
@@ -37,8 +37,10 @@
import android.widget.ImageView;
import android.widget.LinearLayout;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.statusbar.phone.StatusBarIconController;
+import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NetworkController.IconState;
import com.android.systemui.statusbar.policy.NetworkControllerImpl;
import com.android.systemui.statusbar.policy.SecurityController;
@@ -62,8 +64,8 @@
private static final String SLOT_WIFI = "wifi";
private static final String SLOT_ETHERNET = "ethernet";
- NetworkControllerImpl mNC;
- SecurityController mSC;
+ private final NetworkController mNetworkController;
+ private final SecurityController mSecurityController;
private boolean mNoSimsVisible = false;
private boolean mVpnVisible = false;
@@ -131,6 +133,8 @@
TypedValue typedValue = new TypedValue();
res.getValue(R.dimen.status_bar_icon_scale_factor, typedValue, true);
mIconScaleFactor = typedValue.getFloat();
+ mNetworkController = Dependency.get(NetworkController.class);
+ mSecurityController = Dependency.get(SecurityController.class);
}
@Override
@@ -151,25 +155,11 @@
mBlockEthernet = blockEthernet;
mBlockWifi = blockWifi;
// Re-register to get new callbacks.
- mNC.removeCallback(this);
- mNC.addCallback(this);
+ mNetworkController.removeCallback(this);
+ mNetworkController.addCallback(this);
}
}
- public void setNetworkController(NetworkControllerImpl nc) {
- if (DEBUG) Log.d(TAG, "NetworkController=" + nc);
- mNC = nc;
- mNC.addCallback(this);
- }
-
- public void setSecurityController(SecurityController sc) {
- if (DEBUG) Log.d(TAG, "SecurityController=" + sc);
- mSC = sc;
- mSC.addCallback(this);
- mVpnVisible = mSC.isVpnEnabled();
- mVpnIconId = currentVpnIconId(mSC.isVpnBranded());
- }
-
@Override
protected void onFinishInflate() {
super.onFinishInflate();
@@ -213,6 +203,8 @@
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
+ mVpnVisible = mSecurityController.isVpnEnabled();
+ mVpnIconId = currentVpnIconId(mSecurityController.isVpnBranded());
for (PhoneState state : mPhoneStates) {
if (state.mMobileGroup.getParent() == null) {
@@ -227,14 +219,16 @@
apply();
applyIconTint();
+ mNetworkController.addCallback(this);
+ mSecurityController.addCallback(this);
}
@Override
protected void onDetachedFromWindow() {
mMobileSignalGroup.removeAllViews();
TunerService.get(mContext).removeTunable(this);
- mSC.removeCallback(this);
- mNC.removeCallback(this);
+ mSecurityController.removeCallback(this);
+ mNetworkController.removeCallback(this);
super.onDetachedFromWindow();
}
@@ -253,8 +247,8 @@
post(new Runnable() {
@Override
public void run() {
- mVpnVisible = mSC.isVpnEnabled();
- mVpnIconId = currentVpnIconId(mSC.isVpnBranded());
+ mVpnVisible = mSecurityController.isVpnEnabled();
+ mVpnIconId = currentVpnIconId(mSecurityController.isVpnBranded());
apply();
}
});
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarController.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarController.java
index 1c8c317..3bbda4b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarController.java
@@ -30,7 +30,7 @@
import android.widget.LinearLayout;
import com.android.systemui.R;
-import com.android.systemui.plugins.qs.QS.ActivityStarter;
+import com.android.systemui.ActivityStarter;
import java.net.URISyntaxException;
import java.util.ArrayList;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
index 7adb36d..93f72a8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
@@ -24,8 +24,6 @@
import android.content.IntentFilter;
import android.graphics.PixelFormat;
import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.Log;
@@ -35,15 +33,16 @@
import android.view.WindowManager;
import android.widget.LinearLayout;
import com.android.systemui.BatteryMeterView;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.misc.SystemServicesProxy.TaskStackListener;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
-import com.android.systemui.statusbar.phone.NavigationBarGestureHelper;
import com.android.systemui.statusbar.phone.PhoneStatusBarView;
import com.android.systemui.statusbar.policy.BatteryController;
+import com.android.systemui.statusbar.policy.UserSwitcherController;
/**
* A status bar (and navigation bar) tailored for the automotive use case.
@@ -105,7 +104,7 @@
R.dimen.status_bar_connected_device_signal_margin_end));
mConnectedDeviceSignalController = new ConnectedDeviceSignalController(mContext,
- mSignalsView, mBluetoothController);
+ mSignalsView);
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "makeStatusBarView(). mBatteryMeterView: " + mBatteryMeterView);
@@ -211,8 +210,11 @@
@Override
protected void createUserSwitcher() {
- if (mUserSwitcherController.useFullscreenUserSwitcher()) {
- mFullscreenUserSwitcher = new FullscreenUserSwitcher(this, mUserSwitcherController,
+ UserSwitcherController userSwitcherController =
+ Dependency.get(UserSwitcherController.class);
+ if (userSwitcherController.useFullscreenUserSwitcher()) {
+ mFullscreenUserSwitcher = new FullscreenUserSwitcher(this,
+ userSwitcherController,
(ViewStub) mStatusBarWindow.findViewById(R.id.fullscreen_user_switcher_stub));
} else {
super.createUserSwitcher();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/ConnectedDeviceSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/ConnectedDeviceSignalController.java
index a3e1b3a..c308930 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/car/ConnectedDeviceSignalController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/ConnectedDeviceSignalController.java
@@ -15,6 +15,7 @@
import android.util.TypedValue;
import android.view.View;
import android.widget.ImageView;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.statusbar.ScalingDrawableWrapper;
import com.android.systemui.statusbar.policy.BluetoothController;
@@ -67,10 +68,9 @@
private BluetoothHeadsetClient mBluetoothHeadsetClient;
- public ConnectedDeviceSignalController(Context context, View signalsView,
- BluetoothController controller) {
+ public ConnectedDeviceSignalController(Context context, View signalsView) {
mContext = context;
- mController = controller;
+ mController = Dependency.get(BluetoothController.class);
mSignalsView = signalsView;
mNetworkSignalView = (ImageView)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/AutoTileManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/AutoTileManager.java
index a011162..31cfa66 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/AutoTileManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/AutoTileManager.java
@@ -16,7 +16,10 @@
import android.content.Context;
import android.os.Handler;
+import android.os.Looper;
import android.provider.Settings.Secure;
+
+import com.android.systemui.Dependency;
import com.android.systemui.Prefs;
import com.android.systemui.Prefs.Key;
import com.android.systemui.qs.SecureSetting;
@@ -37,12 +40,12 @@
public AutoTileManager(Context context, QSTileHost host) {
mContext = context;
mHost = host;
- mHandler = new Handler(mHost.getLooper());
+ mHandler = new Handler((Looper) Dependency.get(Dependency.BG_LOOPER));
if (!Prefs.getBoolean(context, Key.QS_HOTSPOT_ADDED, false)) {
- host.getHotspotController().addCallback(mHotspotCallback);
+ Dependency.get(HotspotController.class).addCallback(mHotspotCallback);
}
if (!Prefs.getBoolean(context, Key.QS_DATA_SAVER_ADDED, false)) {
- host.getNetworkController().getDataSaverController().addCallback(mDataSaverListener);
+ Dependency.get(DataSaverController.class).addCallback(mDataSaverListener);
}
if (!Prefs.getBoolean(context, Key.QS_INVERT_COLORS_ADDED, false)) {
mColorsSetting = new SecureSetting(mContext, mHandler,
@@ -52,43 +55,33 @@
if (value != 0) {
mHost.addTile("inversion");
Prefs.putBoolean(mContext, Key.QS_INVERT_COLORS_ADDED, true);
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mColorsSetting.setListening(false);
- }
- });
+ mHandler.post(() -> mColorsSetting.setListening(false));
}
}
};
mColorsSetting.setListening(true);
}
if (!Prefs.getBoolean(context, Key.QS_WORK_ADDED, false)) {
- host.getManagedProfileController().addCallback(mProfileCallback);
+ Dependency.get(ManagedProfileController.class).addCallback(mProfileCallback);
}
}
public void destroy() {
mColorsSetting.setListening(false);
- mHost.getHotspotController().removeCallback(mHotspotCallback);
- mHost.getNetworkController().getDataSaverController().removeCallback(mDataSaverListener);
- mHost.getManagedProfileController().removeCallback(mProfileCallback);
+ Dependency.get(HotspotController.class).removeCallback(mHotspotCallback);
+ Dependency.get(DataSaverController.class).removeCallback(mDataSaverListener);
+ Dependency.get(ManagedProfileController.class).removeCallback(mProfileCallback);
}
private final ManagedProfileController.Callback mProfileCallback =
new ManagedProfileController.Callback() {
@Override
public void onManagedProfileChanged() {
- if (mHost.getManagedProfileController().hasActiveProfile()) {
+ if (Dependency.get(ManagedProfileController.class).hasActiveProfile()) {
mHost.addTile("work");
Prefs.putBoolean(mContext, Key.QS_WORK_ADDED, true);
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mHost.getManagedProfileController().removeCallback(
- mProfileCallback);
- }
- });
+ mHandler.post(() -> Dependency.get(ManagedProfileController.class)
+ .removeCallback(mProfileCallback));
}
}
@@ -105,13 +98,8 @@
if (isDataSaving) {
mHost.addTile("saver");
Prefs.putBoolean(mContext, Key.QS_DATA_SAVER_ADDED, true);
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mHost.getNetworkController().getDataSaverController().removeCallback(
- mDataSaverListener);
- }
- });
+ mHandler.post(() -> Dependency.get(DataSaverController.class).removeCallback(
+ mDataSaverListener));
}
}
};
@@ -122,12 +110,8 @@
if (enabled) {
mHost.addTile("hotspot");
Prefs.putBoolean(mContext, Key.QS_HOTSPOT_ADDED, true);
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mHost.getHotspotController().removeCallback(mHotspotCallback);
- }
- });
+ mHandler.post(() -> Dependency.get(HotspotController.class)
+ .removeCallback(mHotspotCallback));
}
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
index a2c106a..d326787 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
@@ -58,6 +58,7 @@
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.EventLogConstants;
import com.android.systemui.EventLogTags;
+import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.assist.AssistManager;
@@ -66,7 +67,7 @@
import com.android.systemui.plugins.IntentButtonProvider.IntentButton.IconState;
import com.android.systemui.plugins.PluginListener;
import com.android.systemui.plugins.PluginManager;
-import com.android.systemui.plugins.qs.QS.ActivityStarter;
+import com.android.systemui.ActivityStarter;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.KeyguardAffordanceView;
import com.android.systemui.statusbar.KeyguardIndicationController;
@@ -230,6 +231,11 @@
mRightAffordanceView.setOnClickListener(this);
mLeftAffordanceView.setOnClickListener(this);
initAccessibility();
+ mActivityStarter = Dependency.get(ActivityStarter.class);
+ mFlashlightController = Dependency.get(FlashlightController.class);
+ mAccessibilityController = Dependency.get(AccessibilityController.class);
+ mAssistManager = Dependency.get(AssistManager.class);
+ updateLeftAffordance();
}
@Override
@@ -299,20 +305,6 @@
mRightAffordanceView.setContentDescription(state.contentDescription);
}
- public void setActivityStarter(ActivityStarter activityStarter) {
- mActivityStarter = activityStarter;
- }
-
- public void setFlashlightController(FlashlightController flashlightController) {
- mFlashlightController = flashlightController;
- }
-
- public void setAccessibilityController(AccessibilityController accessibilityController) {
- mAccessibilityController = accessibilityController;
- mLockIcon.setAccessibilityController(accessibilityController);
- accessibilityController.addStateChangedCallback(this);
- }
-
public void setPhoneStatusBar(PhoneStatusBar phoneStatusBar) {
mPhoneStatusBar = phoneStatusBar;
updateCameraVisibility(); // in case onFinishInflate() was called too early
@@ -761,11 +753,6 @@
mIndicationController = keyguardIndicationController;
}
- public void setAssistManager(AssistManager assistManager) {
- mAssistManager = assistManager;
- updateLeftAffordance();
- }
-
public void updateLeftAffordance() {
updateLeftAffordanceIcon();
updateLeftPreview();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
index e4c778c..ff58e54 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
@@ -28,13 +28,15 @@
import android.widget.RelativeLayout;
import android.widget.TextView;
-import com.android.systemui.BatteryMeterView;
+import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.qs.QSPanel;
import com.android.systemui.statusbar.policy.BatteryController;
+import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback;
import com.android.systemui.statusbar.policy.KeyguardUserSwitcher;
import com.android.systemui.statusbar.policy.UserInfoController;
+import com.android.systemui.statusbar.policy.UserInfoController.OnUserInfoChangedListener;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import java.text.NumberFormat;
@@ -43,7 +45,7 @@
* The header group on Keyguard.
*/
public class KeyguardStatusBarView extends RelativeLayout
- implements BatteryController.BatteryStateChangeCallback {
+ implements BatteryStateChangeCallback, OnUserInfoChangedListener {
private boolean mBatteryCharging;
private boolean mKeyguardUserSwitcherShowing;
@@ -78,6 +80,7 @@
mCarrierLabel = (TextView) findViewById(R.id.keyguard_carrier_text);
loadDimens();
updateUserSwitcher();
+ mBatteryController = Dependency.get(BatteryController.class);
}
@Override
@@ -203,23 +206,25 @@
mMultiUserSwitch.setKeyguardMode(keyguardSwitcherAvailable);
}
- public void setBatteryController(BatteryController batteryController) {
- mBatteryController = batteryController;
- ((BatteryMeterView) findViewById(R.id.battery)).setBatteryController(batteryController);
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ UserInfoController userInfoController = Dependency.get(UserInfoController.class);
+ userInfoController.addCallback(this);
+ mUserSwitcherController = Dependency.get(UserSwitcherController.class);
+ mMultiUserSwitch.setUserSwitcherController(mUserSwitcherController);
+ userInfoController.reloadUserInfo();
}
- public void setUserSwitcherController(UserSwitcherController controller) {
- mUserSwitcherController = controller;
- mMultiUserSwitch.setUserSwitcherController(controller);
+ @Override
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ Dependency.get(UserInfoController.class).removeCallback(this);
}
- public void setUserInfoController(UserInfoController userInfoController) {
- userInfoController.addCallback(new UserInfoController.OnUserInfoChangedListener() {
- @Override
- public void onUserInfoChanged(String name, Drawable picture, String userAccount) {
- mMultiUserAvatar.setImageDrawable(picture);
- }
- });
+ @Override
+ public void onUserInfoChanged(String name, Drawable picture, String userAccount) {
+ mMultiUserAvatar.setImageDrawable(picture);
}
public void setQSPanel(QSPanel qsp) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LightBarController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LightBarController.java
index 26b0d53..4535992 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LightBarController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LightBarController.java
@@ -19,6 +19,7 @@
import android.graphics.Rect;
import android.view.View;
+import com.android.systemui.Dependency;
import com.android.systemui.statusbar.policy.BatteryController;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT_TRANSPARENT;
@@ -60,11 +61,10 @@
private final Rect mLastFullscreenBounds = new Rect();
private final Rect mLastDockedBounds = new Rect();
- public LightBarController(StatusBarIconController statusBarIconController,
- BatteryController batteryController) {
+ public LightBarController(StatusBarIconController statusBarIconController) {
mStatusBarIconController = statusBarIconController;
- mBatteryController = batteryController;
- batteryController.addCallback(this);
+ mBatteryController = Dependency.get(BatteryController.class);
+ mBatteryController.addCallback(this);
}
public void setNavigationBar(LightBarTransitionsController navigationBar) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ManagedProfileControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ManagedProfileControllerImpl.java
index fc33ace..316bd5b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ManagedProfileControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ManagedProfileControllerImpl.java
@@ -38,8 +38,8 @@
private boolean mListening;
private int mCurrentUser;
- public ManagedProfileControllerImpl(QSTileHost host) {
- mContext = host.getContext();
+ public ManagedProfileControllerImpl(Context context) {
+ mContext = context;
mUserManager = UserManager.get(mContext);
mProfiles = new LinkedList<UserInfo>();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java
index 4d4f9d2..3cbac17 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java
@@ -29,7 +29,9 @@
import android.widget.Button;
import android.widget.FrameLayout;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
+import com.android.systemui.ActivityStarter;
import com.android.systemui.plugins.qs.QS.DetailAdapter;
import com.android.systemui.qs.QSPanel;
import com.android.systemui.statusbar.policy.KeyguardUserSwitcher;
@@ -65,7 +67,7 @@
public void setQsPanel(QSPanel qsPanel) {
mQsPanel = qsPanel;
- setUserSwitcherController(qsPanel.getHost().getUserSwitcherController());
+ setUserSwitcherController(Dependency.get(UserSwitcherController.class));
}
public boolean hasMultipleUsers() {
@@ -134,7 +136,7 @@
Intent intent = ContactsContract.QuickContact.composeQuickContactsIntent(
getContext(), v, ContactsContract.Profile.CONTENT_URI,
ContactsContract.QuickContact.MODE_LARGE, null);
- mQsPanel.getHost().startActivityDismissingKeyguard(intent);
+ Dependency.get(ActivityStarter.class).postStartActivityDismissingKeyguard(intent, 0);
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
index 3423a3c..3c46d26 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
@@ -64,7 +64,9 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.keyguard.LatencyTracker;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
+import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.SystemUIApplication;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.fragments.FragmentHostManager;
@@ -124,16 +126,17 @@
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mCommandQueue = SystemUIApplication.getComponent(getContext(), CommandQueue.class);
+ mCommandQueue = SysUiServiceProvider.getComponent(getContext(), CommandQueue.class);
mCommandQueue.addCallbacks(this);
- mPhoneStatusBar = SystemUIApplication.getComponent(getContext(), PhoneStatusBar.class);
- mRecents = SystemUIApplication.getComponent(getContext(), Recents.class);
- mDivider = SystemUIApplication.getComponent(getContext(), Divider.class);
+ mPhoneStatusBar = SysUiServiceProvider.getComponent(getContext(), PhoneStatusBar.class);
+ mRecents = SysUiServiceProvider.getComponent(getContext(), Recents.class);
+ mDivider = SysUiServiceProvider.getComponent(getContext(), Divider.class);
mWindowManager = getContext().getSystemService(WindowManager.class);
mAccessibilityManager = getContext().getSystemService(AccessibilityManager.class);
if (savedInstanceState != null) {
mDisabledFlags1 = savedInstanceState.getInt(EXTRA_DISABLE_STATE, 0);
}
+ mAssistManager = Dependency.get(AssistManager.class);
try {
WindowManagerGlobal.getWindowManagerService()
@@ -400,10 +403,6 @@
ButtonDispatcher homeButton = mNavigationBarView.getHomeButton();
homeButton.setOnTouchListener(this::onHomeTouch);
homeButton.setOnLongClickListener(this::onHomeLongClick);
-
- if (mAssistManager != null) {
- mAssistManager.onConfigurationChanged();
- }
}
private boolean onHomeTouch(View v, MotionEvent event) {
@@ -436,10 +435,6 @@
}
private void onVerticalChanged(boolean isVertical) {
- if (mAssistManager != null) {
- // TODO: Clean this up.
- mAssistManager.onConfigurationChanged();
- }
mPhoneStatusBar.setQsScrimEnabled(!isVertical);
}
@@ -562,11 +557,6 @@
// ----- Methods that PhoneStatusBar talks to (should be minimized) -----
- public void setAssistManager(AssistManager assistManager) {
- mAssistManager = assistManager;
- mAssistManager.onConfigurationChanged();
- }
-
public void setLightBarController(LightBarController lightBarController) {
mLightBarController = lightBarController;
mLightBarController.setNavigationBar(mNavigationBarView.getLightTransitionsController());
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 001edb3..cb9fbb9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -20,6 +20,7 @@
import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN;
import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
import static android.app.StatusBarManager.windowStateToString;
+
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT_TRANSPARENT;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE;
@@ -71,13 +72,11 @@
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
-import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.PowerManager;
-import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
@@ -120,8 +119,9 @@
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.keyguard.ViewMediatorCallback;
-import com.android.systemui.BatteryMeterView;
+import com.android.systemui.ActivityStarterDelegate;
import com.android.systemui.DemoMode;
+import com.android.systemui.Dependency;
import com.android.systemui.EventLogConstants;
import com.android.systemui.EventLogTags;
import com.android.systemui.Interpolators;
@@ -130,6 +130,7 @@
import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.SystemUIApplication;
import com.android.systemui.SystemUIFactory;
+import com.android.systemui.assist.AssistManager;
import com.android.systemui.classifier.FalsingLog;
import com.android.systemui.classifier.FalsingManager;
import com.android.systemui.doze.DozeHost;
@@ -138,7 +139,7 @@
import com.android.systemui.fragments.PluginFragmentListener;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.plugins.qs.QS;
-import com.android.systemui.plugins.qs.QS.ActivityStarter;
+import com.android.systemui.ActivityStarter;
import com.android.systemui.plugins.qs.QS.BaseStatusBarHeader;
import com.android.systemui.qs.QSFragment;
import com.android.systemui.qs.QSPanel;
@@ -168,27 +169,22 @@
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.VisualStabilityManager;
import com.android.systemui.statusbar.phone.UnlockMethodCache.OnUnlockMethodChangedListener;
-import com.android.systemui.statusbar.policy.AccessibilityController;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback;
import com.android.systemui.statusbar.policy.BatteryControllerImpl;
-import com.android.systemui.statusbar.policy.BluetoothControllerImpl;
import com.android.systemui.statusbar.policy.BrightnessMirrorController;
-import com.android.systemui.statusbar.policy.CastControllerImpl;
+import com.android.systemui.statusbar.policy.DeviceProvisionedController;
+import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener;
import com.android.systemui.statusbar.policy.EncryptionHelper;
-import com.android.systemui.statusbar.policy.FlashlightControllerImpl;
import com.android.systemui.statusbar.policy.HeadsUpManager;
-import com.android.systemui.statusbar.policy.HotspotControllerImpl;
+import com.android.systemui.statusbar.policy.KeyguardMonitor;
import com.android.systemui.statusbar.policy.KeyguardMonitorImpl;
import com.android.systemui.statusbar.policy.KeyguardUserSwitcher;
-import com.android.systemui.statusbar.policy.LocationControllerImpl;
import com.android.systemui.statusbar.policy.NetworkController;
-import com.android.systemui.statusbar.policy.NetworkControllerImpl;
-import com.android.systemui.statusbar.policy.NextAlarmControllerImpl;
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
import com.android.systemui.statusbar.policy.PreviewInflater;
-import com.android.systemui.statusbar.policy.RotationLockControllerImpl;
-import com.android.systemui.statusbar.policy.SecurityControllerImpl;
+import com.android.systemui.statusbar.policy.SecurityController;
+import com.android.systemui.statusbar.policy.UserInfoController;
import com.android.systemui.statusbar.policy.UserInfoControllerImpl;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.statusbar.policy.ZenModeController;
@@ -305,25 +301,8 @@
PhoneStatusBarPolicy mIconPolicy;
- // These are no longer handled by the policy, because we need custom strategies for them
- protected BluetoothControllerImpl mBluetoothController;
- SecurityControllerImpl mSecurityController;
- protected BatteryController mBatteryController;
- LocationControllerImpl mLocationController;
- NetworkControllerImpl mNetworkController;
- HotspotControllerImpl mHotspotController;
- RotationLockControllerImpl mRotationLockController;
- UserInfoControllerImpl mUserInfoController;
- protected ZenModeController mZenModeController;
- CastControllerImpl mCastController;
VolumeComponent mVolumeComponent;
- KeyguardUserSwitcher mKeyguardUserSwitcher;
- FlashlightControllerImpl mFlashlightController;
- protected UserSwitcherController mUserSwitcherController;
- NextAlarmControllerImpl mNextAlarmController;
- protected KeyguardMonitorImpl mKeyguardMonitor;
BrightnessMirrorController mBrightnessMirrorController;
- AccessibilityController mAccessibilityController;
protected FingerprintUnlockController mFingerprintUnlockController;
LightBarController mLightBarController;
protected LockscreenWallpaper mLockscreenWallpaper;
@@ -410,23 +389,16 @@
: null;
private ScreenPinningRequest mScreenPinningRequest;
- private HandlerThread mHandlerThread;
- private HandlerThread mTimeTickThread;
- private Handler mTimeTickHandler;
// ensure quick settings is disabled until the current user makes it through the setup wizard
private boolean mUserSetup = false;
- private ContentObserver mUserSetupObserver = new ContentObserver(new Handler()) {
+ private DeviceProvisionedListener mUserSetupObserver = new DeviceProvisionedListener() {
@Override
- public void onChange(boolean selfChange) {
- final boolean userSetup = 0 != Settings.Secure.getIntForUser(
- mContext.getContentResolver(),
- Settings.Secure.USER_SETUP_COMPLETE,
- 0 /*default */,
- mCurrentUserId);
+ public void onUserSetupChanged() {
+ final boolean userSetup = mDeviceProvisionedController.isUserSetup(
+ mDeviceProvisionedController.getCurrentUser());
if (MULTIUSER_DEBUG) Log.d(TAG, String.format("User setup changed: " +
- "selfChange=%s userSetup=%s mUserSetup=%s",
- selfChange, userSetup, mUserSetup));
+ "userSetup=%s mUserSetup=%s", userSetup, mUserSetup));
if (userSetup != mUserSetup) {
mUserSetup = userSetup;
@@ -435,9 +407,7 @@
if (mKeyguardBottomArea != null) {
mKeyguardBottomArea.setUserSetupComplete(mUserSetup);
}
- if (mNetworkController != null) {
- mNetworkController.setUserSetupComplete(mUserSetup);
- }
+ updateQsExpansionEnabled();
}
if (mIconPolicy != null) {
mIconPolicy.setCurrentUserSetup(mUserSetup);
@@ -638,6 +608,13 @@
}
};
+ private KeyguardUserSwitcher mKeyguardUserSwitcher;
+ private UserSwitcherController mUserSwitcherController;
+ private NetworkController mNetworkController;
+ private KeyguardMonitorImpl mKeyguardMonitor;
+ private BatteryController mBatteryController;
+ private DeviceProvisionedController mDeviceProvisionedController;
+
private void recycleAllVisibilityObjects(ArraySet<NotificationVisibility> array) {
final int N = array.size();
for (int i = 0 ; i < N; i++) {
@@ -671,19 +648,20 @@
@Override
public void start() {
+ mNetworkController = Dependency.get(NetworkController.class);
+ mUserSwitcherController = Dependency.get(UserSwitcherController.class);
+ mKeyguardMonitor = (KeyguardMonitorImpl) Dependency.get(KeyguardMonitor.class);
+ mBatteryController = Dependency.get(BatteryController.class);
+ mAssistManager = Dependency.get(AssistManager.class);
+ mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class);
+
mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
updateDisplaySize();
mScrimSrcModeEnabled = mContext.getResources().getBoolean(
R.bool.config_status_bar_scrim_behind_use_src);
- // Background thread for any controllers that need it.
- mHandlerThread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND);
- mHandlerThread.start();
- mTimeTickThread = new HandlerThread("TimeTick");
- mTimeTickThread.start();
- mTimeTickHandler = new Handler(mTimeTickThread.getLooper());
- DateTimeView.setReceiverHandler(mTimeTickHandler);
+ DateTimeView.setReceiverHandler(Dependency.get(Dependency.TIME_TICK_HANDLER));
putComponent(PhoneStatusBar.class, this);
super.start(); // calls createAndAddWindows()
@@ -694,9 +672,7 @@
// in session state
// Lastly, call to the icon policy to install/update all the icons.
- mIconPolicy = new PhoneStatusBarPolicy(mContext, mIconController, mCastController,
- mHotspotController, mUserInfoController, mBluetoothController,
- mRotationLockController, mNetworkController.getDataSaverController(), mNextAlarmController);
+ mIconPolicy = new PhoneStatusBarPolicy(mContext, mIconController);
mIconPolicy.setCurrentUserSetup(mUserSetup);
mSettingsObserver.onChange(false); // set up
@@ -717,12 +693,11 @@
mDozeServiceHost = new DozeServiceHost();
putComponent(DozeHost.class, mDozeServiceHost);
- setControllerUsers();
-
notifyUserAboutHiddenNotifications();
mScreenPinningRequest = new ScreenPinningRequest(mContext);
mFalsingManager = FalsingManager.getInstance(mContext);
+ Dependency.get(ActivityStarterDelegate.class).setActivityStarterImpl(this);
}
protected void createIconController() {
@@ -796,8 +771,6 @@
// no window manager? good luck with that
}
- mAssistManager = SystemUIFactory.getInstance().createAssistManager(this, context);
-
// figure out which pixel-format to use for the status bar.
mPixelFormat = PixelFormat.OPAQUE;
@@ -828,8 +801,6 @@
(KeyguardStatusView) mStatusBarWindow.findViewById(R.id.keyguard_status_view);
mKeyguardBottomArea =
(KeyguardBottomAreaView) mStatusBarWindow.findViewById(R.id.keyguard_bottom_area);
- mKeyguardBottomArea.setActivityStarter(this);
- mKeyguardBottomArea.setAssistManager(mAssistManager);
mKeyguardIndicationController = new KeyguardIndicationController(mContext,
(ViewGroup) mStatusBarWindow.findViewById(R.id.keyguard_indication_area),
mKeyguardBottomArea.getLockIcon());
@@ -840,7 +811,7 @@
createIconController();
- mBatteryController = createBatteryController();
+ // TODO: Find better place for this callback.
mBatteryController.addCallback(new BatteryStateChangeCallback() {
@Override
public void onPowerSaveChanged(boolean isPowerSave) {
@@ -856,7 +827,7 @@
}
});
- mLightBarController = new LightBarController(mIconController, mBatteryController);
+ mLightBarController = new LightBarController(mIconController);
if (mNavigationBar != null) {
mNavigationBar.setLightBarController(mLightBarController);
}
@@ -885,36 +856,12 @@
mNotificationPanel);
// Other icons
- mLocationController = new LocationControllerImpl(mContext,
- mHandlerThread.getLooper()); // will post a notification
- mNetworkController = new NetworkControllerImpl(mContext, mHandlerThread.getLooper());
- mNetworkController.setUserSetupComplete(mUserSetup);
- mHotspotController = new HotspotControllerImpl(mContext);
- mBluetoothController = new BluetoothControllerImpl(mContext, mHandlerThread.getLooper());
- mSecurityController = new SecurityControllerImpl(mContext);
- if (mContext.getResources().getBoolean(R.bool.config_showRotationLock)) {
- mRotationLockController = new RotationLockControllerImpl(mContext);
- }
- mUserInfoController = new UserInfoControllerImpl(mContext);
mVolumeComponent = getComponent(VolumeComponent.class);
- if (mVolumeComponent != null) {
- mZenModeController = mVolumeComponent.getZenController();
- }
- mCastController = new CastControllerImpl(mContext);
- initSignalCluster(mStatusBarView);
- initSignalCluster(mKeyguardStatusBar);
initEmergencyCryptkeeperText();
- mFlashlightController = new FlashlightControllerImpl(mContext);
- mKeyguardBottomArea.setFlashlightController(mFlashlightController);
mKeyguardBottomArea.setPhoneStatusBar(this);
mKeyguardBottomArea.setUserSetupComplete(mUserSetup);
- mAccessibilityController = new AccessibilityController(mContext);
- mKeyguardBottomArea.setAccessibilityController(mAccessibilityController);
- mNextAlarmController = new NextAlarmControllerImpl(mContext);
- mKeyguardMonitor = new KeyguardMonitorImpl(mContext);
- mUserSwitcherController = createUserSwitcherController();
if (UserManager.get(mContext).isUserSwitcherEnabled()) {
createUserSwitcher();
}
@@ -926,12 +873,7 @@
new PluginFragmentListener(container, QS.TAG, R.id.qs_frame, QSFragment.class, QS.class)
.startListening(QS.ACTION, QS.VERSION);
final QSTileHost qsh = SystemUIFactory.getInstance().createQSTileHost(mContext, this,
- mBluetoothController, mLocationController, mRotationLockController,
- mNetworkController, mZenModeController, mHotspotController,
- mCastController, mFlashlightController,
- mUserSwitcherController, mUserInfoController, mKeyguardMonitor,
- mSecurityController, mBatteryController, mIconController,
- mNextAlarmController);
+ mIconController);
mBrightnessMirrorController = new BrightnessMirrorController(mStatusBarWindow);
fragmentHostManager.addTagListener(QS.TAG, (tag, f) -> {
QS qs = (QS) f;
@@ -941,21 +883,9 @@
mQSPanel.setBrightnessMirror(mBrightnessMirrorController);
mKeyguardStatusBar.setQSPanel(mQSPanel);
}
- mHeader = qs.getHeader();
- initSignalCluster(mHeader);
- mHeader.setActivityStarter(PhoneStatusBar.this);
});
}
- // User info. Trigger first load.
- mKeyguardStatusBar.setUserInfoController(mUserInfoController);
- mKeyguardStatusBar.setUserSwitcherController(mUserSwitcherController);
- mUserInfoController.reloadUserInfo();
-
- ((BatteryMeterView) mStatusBarView.findViewById(R.id.battery)).setBatteryController(
- mBatteryController);
- mKeyguardStatusBar.setBatteryController(mBatteryController);
-
mReportRejectedTouch = mStatusBarWindow.findViewById(R.id.report_rejected_touch);
if (mReportRejectedTouch != null) {
updateReportRejectedTouchVisibility();
@@ -1016,7 +946,8 @@
android.Manifest.permission.DUMP, null);
// listen for USER_SETUP_COMPLETE setting (per-user)
- resetUserSetupObserver();
+ mDeviceProvisionedController.addCallback(mUserSetupObserver);
+ mUserSetupObserver.onUserSetupChanged();
// disable profiling bars, since they overlap and clutter the output on app windows
ThreadedRenderer.overrideProperty("disableProfileBars", "true");
@@ -1027,21 +958,9 @@
return mStatusBarView;
}
- public Handler getTimeTickHandler() {
- return mTimeTickHandler;
- }
-
- public static Handler getTimeTickHandler(Context context) {
- PhoneStatusBar statusBar = ((SysUiServiceProvider) context.getApplicationContext())
- .getComponent(PhoneStatusBar.class);
- return statusBar != null ? statusBar.getTimeTickHandler() :
- new Handler(Looper.getMainLooper());
- }
-
protected void createNavigationBar() {
mNavigationBarView = NavigationBarFragment.create(mContext, (tag, fragment) -> {
mNavigationBar = (NavigationBarFragment) fragment;
- mNavigationBar.setAssistManager(mAssistManager);
if (mLightBarController != null) {
mNavigationBar.setLightBarController(mLightBarController);
}
@@ -1096,10 +1015,10 @@
inflateEmptyShadeView();
updateEmptyShadeView();
mStatusBarKeyguardViewManager.onDensityOrFontScaleChanged();
- mUserInfoController.onDensityOrFontScaleChanged();
- if (mUserSwitcherController != null) {
- mUserSwitcherController.onDensityOrFontScaleChanged();
- }
+ // TODO: Bring these out of PhoneStatusBar.
+ ((UserInfoControllerImpl) Dependency.get(UserInfoController.class))
+ .onDensityOrFontScaleChanged();
+ Dependency.get(UserSwitcherController.class).onDensityOrFontScaleChanged();
if (mKeyguardUserSwitcher != null) {
mKeyguardUserSwitcher.onDensityOrFontScaleChanged();
}
@@ -1129,8 +1048,6 @@
R.dimen.signal_cluster_margin_start),
0, 0, 0);
newCluster.setLayoutParams(layoutParams);
- newCluster.setSecurityController(mSecurityController);
- newCluster.setNetworkController(mNetworkController);
viewParent.addView(newCluster, index);
return newCluster;
}
@@ -1161,11 +1078,7 @@
protected void createUserSwitcher() {
mKeyguardUserSwitcher = new KeyguardUserSwitcher(mContext,
(ViewStub) mStatusBarWindow.findViewById(R.id.keyguard_user_switcher),
- mKeyguardStatusBar, mNotificationPanel, mUserSwitcherController);
- }
-
- protected UserSwitcherController createUserSwitcherController() {
- return new UserSwitcherController(mContext, mKeyguardMonitor, mHandler, this);
+ mKeyguardStatusBar, mNotificationPanel);
}
protected void inflateStatusBarWindow(Context context) {
@@ -1173,15 +1086,6 @@
R.layout.super_status_bar, null);
}
- protected void initSignalCluster(View containerView) {
- SignalClusterView signalCluster =
- (SignalClusterView) containerView.findViewById(R.id.signal_cluster);
- if (signalCluster != null) {
- signalCluster.setSecurityController(mSecurityController);
- signalCluster.setNetworkController(mNetworkController);
- }
- }
-
public void clearAllNotifications() {
// animate-swipe all dismissable notifications, then animate the shade closed
@@ -2383,6 +2287,11 @@
}
@Override
+ public void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade) {
+ startActivityDismissingKeyguard(intent, onlyProvisioned, dismissShade);
+ }
+
+ @Override
public void startActivity(Intent intent, boolean dismissShade, Callback callback) {
startActivityDismissingKeyguard(intent, false, dismissShade, callback);
}
@@ -3229,30 +3138,7 @@
if (mStatusBarWindowManager != null) {
mStatusBarWindowManager.dump(fd, pw, args);
}
- if (mNetworkController != null) {
- mNetworkController.dump(fd, pw, args);
- }
- if (mBluetoothController != null) {
- mBluetoothController.dump(fd, pw, args);
- }
- if (mHotspotController != null) {
- mHotspotController.dump(fd, pw, args);
- }
- if (mCastController != null) {
- mCastController.dump(fd, pw, args);
- }
- if (mUserSwitcherController != null) {
- mUserSwitcherController.dump(fd, pw, args);
- }
- if (mBatteryController != null) {
- mBatteryController.dump(fd, pw, args);
- }
- if (mNextAlarmController != null) {
- mNextAlarmController.dump(fd, pw, args);
- }
- if (mSecurityController != null) {
- mSecurityController.dump(fd, pw, args);
- }
+
if (mHeadsUpManager != null) {
mHeadsUpManager.dump(fd, pw, args);
} else {
@@ -3266,9 +3152,6 @@
if (KeyguardUpdateMonitor.getInstance(mContext) != null) {
KeyguardUpdateMonitor.getInstance(mContext).dump(fd, pw, args);
}
- if (mFlashlightController != null) {
- mFlashlightController.dump(fd, pw, args);
- }
FalsingManager.getInstance(mContext).dump(pw);
FalsingLog.dump(pw);
@@ -3495,7 +3378,6 @@
updateRowStates();
mScreenPinningRequest.onConfigurationChanged();
- mNetworkController.onConfigurationChanged();
}
@Override
@@ -3505,8 +3387,6 @@
animateCollapsePanels();
updatePublicMode();
updateNotifications();
- resetUserSetupObserver();
- setControllerUsers();
clearCurrentMediaNotification();
setLockscreenUser(newUserId);
}
@@ -3517,26 +3397,6 @@
updateMediaMetaData(true, false);
}
- private void setControllerUsers() {
- if (mZenModeController != null) {
- mZenModeController.setUserId(mCurrentUserId);
- }
- if (mSecurityController != null) {
- mSecurityController.onUserSwitched(mCurrentUserId);
- }
- if (mNetworkController != null) {
- mNetworkController.onUserSwitched(mCurrentUserId);
- }
- }
-
- private void resetUserSetupObserver() {
- mContext.getContentResolver().unregisterContentObserver(mUserSetupObserver);
- mUserSetupObserver.onChange(false);
- mContext.getContentResolver().registerContentObserver(
- Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), true,
- mUserSetupObserver, mCurrentUserId);
- }
-
/**
* Reload some of our resources when the configuration changes.
*
@@ -3717,32 +3577,23 @@
}
};
+ @Override
public void postQSRunnableDismissingKeyguard(final Runnable runnable) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mLeaveOpenOnKeyguardHide = true;
- executeRunnableDismissingKeyguard(runnable, null, false, false, false);
- }
+ mHandler.post(() -> {
+ mLeaveOpenOnKeyguardHide = true;
+ executeRunnableDismissingKeyguard(runnable, null, false, false, false);
});
}
+ @Override
public void postStartActivityDismissingKeyguard(final PendingIntent intent) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- startPendingIntentDismissingKeyguard(intent);
- }
- });
+ mHandler.post(() -> startPendingIntentDismissingKeyguard(intent));
}
+ @Override
public void postStartActivityDismissingKeyguard(final Intent intent, int delay) {
- mHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- handleStartActivityDismissingKeyguard(intent, true /*onlyProvisioned*/);
- }
- }, delay);
+ mHandler.postDelayed(() ->
+ handleStartActivityDismissingKeyguard(intent, true /*onlyProvisioned*/), delay);
}
private void handleStartActivityDismissingKeyguard(Intent intent, boolean onlyProvisioned) {
@@ -3794,10 +3645,6 @@
mWindowManager.removeViewImmediate(mNavigationBarView);
mNavigationBarView = null;
}
- if (mHandlerThread != null) {
- mHandlerThread.quitSafely();
- mHandlerThread = null;
- }
mContext.unregisterReceiver(mBroadcastReceiver);
mContext.unregisterReceiver(mDemoReceiver);
mAssistManager.destroy();
@@ -3808,12 +3655,11 @@
(SignalClusterView) mKeyguardStatusBar.findViewById(R.id.signal_cluster);
final SignalClusterView signalClusterQs =
(SignalClusterView) mHeader.findViewById(R.id.signal_cluster);
- mNetworkController.removeCallback(signalCluster);
- mNetworkController.removeCallback(signalClusterKeyguard);
- mNetworkController.removeCallback(signalClusterQs);
if (mQSPanel != null && mQSPanel.getHost() != null) {
mQSPanel.getHost().destroy();
}
+ Dependency.get(ActivityStarterDelegate.class).setActivityStarterImpl(null);
+ mDeviceProvisionedController.removeCallback(mUserSetupObserver);
}
private boolean mDemoModeAllowed;
@@ -4988,7 +4834,7 @@
@Override
public boolean isPowerSaveActive() {
- return mBatteryController != null && mBatteryController.isPowerSave();
+ return mBatteryController.isPowerSave();
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
index 9ee1e8f..1044ecf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
@@ -36,6 +36,7 @@
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.TelephonyIntents;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.qs.tiles.DndTile;
import com.android.systemui.qs.tiles.RotationLockTile;
@@ -99,22 +100,19 @@
private BluetoothController mBluetooth;
- public PhoneStatusBarPolicy(Context context, StatusBarIconController iconController,
- CastController cast, HotspotController hotspot, UserInfoController userInfoController,
- BluetoothController bluetooth, RotationLockController rotationLockController,
- DataSaverController dataSaver, NextAlarmController nextAlarm) {
+ public PhoneStatusBarPolicy(Context context, StatusBarIconController iconController) {
mContext = context;
mIconController = iconController;
- mCast = cast;
- mHotspot = hotspot;
- mBluetooth = bluetooth;
+ mCast = Dependency.get(CastController.class);
+ mHotspot = Dependency.get(HotspotController.class);
+ mBluetooth = Dependency.get(BluetoothController.class);
mBluetooth.addCallback(this);
- mNextAlarm = nextAlarm;
+ mNextAlarm = Dependency.get(NextAlarmController.class);
mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
- mUserInfoController = userInfoController;
+ mUserInfoController = Dependency.get(UserInfoController.class);
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
- mRotationLockController = rotationLockController;
- mDataSaver = dataSaver;
+ mRotationLockController = Dependency.get(RotationLockController.class);
+ mDataSaver = Dependency.get(DataSaverController.class);
mSlotCast = context.getString(com.android.internal.R.string.status_bar_cast);
mSlotHotspot = context.getString(com.android.internal.R.string.status_bar_hotspot);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
index d4cf533..2f76cb1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
@@ -17,15 +17,11 @@
package com.android.systemui.statusbar.phone;
import android.app.ActivityManager;
-import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.Looper;
-import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
@@ -33,8 +29,8 @@
import android.service.quicksettings.Tile;
import android.text.TextUtils;
import android.util.Log;
-import android.view.View;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
import com.android.systemui.qs.external.CustomTile;
@@ -58,20 +54,6 @@
import com.android.systemui.qs.tiles.UserTile;
import com.android.systemui.qs.tiles.WifiTile;
import com.android.systemui.qs.tiles.WorkModeTile;
-import com.android.systemui.statusbar.policy.BatteryController;
-import com.android.systemui.statusbar.policy.BluetoothController;
-import com.android.systemui.statusbar.policy.CastController;
-import com.android.systemui.statusbar.policy.NextAlarmController;
-import com.android.systemui.statusbar.policy.FlashlightController;
-import com.android.systemui.statusbar.policy.HotspotController;
-import com.android.systemui.statusbar.policy.KeyguardMonitor;
-import com.android.systemui.statusbar.policy.LocationController;
-import com.android.systemui.statusbar.policy.NetworkController;
-import com.android.systemui.statusbar.policy.RotationLockController;
-import com.android.systemui.statusbar.policy.SecurityController;
-import com.android.systemui.statusbar.policy.UserInfoController;
-import com.android.systemui.statusbar.policy.UserSwitcherController;
-import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;
@@ -80,7 +62,6 @@
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
/** Platform implementation of the quick settings tile host **/
public class QSTileHost implements QSTile.Host, Tunable {
@@ -93,81 +74,31 @@
private final PhoneStatusBar mStatusBar;
private final LinkedHashMap<String, QSTile<?>> mTiles = new LinkedHashMap<>();
protected final ArrayList<String> mTileSpecs = new ArrayList<>();
- private final BluetoothController mBluetooth;
- private final LocationController mLocation;
- private final RotationLockController mRotation;
- private final NetworkController mNetwork;
- private final ZenModeController mZen;
- private final HotspotController mHotspot;
- private final CastController mCast;
- private final Looper mLooper;
- private final FlashlightController mFlashlight;
- private final UserSwitcherController mUserSwitcherController;
- private final UserInfoController mUserInfoController;
- private final KeyguardMonitor mKeyguard;
- private final SecurityController mSecurity;
- private final BatteryController mBattery;
- private final StatusBarIconController mIconController;
private final TileServices mServices;
private final List<Callback> mCallbacks = new ArrayList<>();
private final AutoTileManager mAutoTiles;
- private final ManagedProfileController mProfileController;
- private final NextAlarmController mNextAlarmController;
- private final HandlerThread mHandlerThread;
- private View mHeader;
+ private final StatusBarIconController mIconController;
private int mCurrentUser;
public QSTileHost(Context context, PhoneStatusBar statusBar,
- BluetoothController bluetooth, LocationController location,
- RotationLockController rotation, NetworkController network,
- ZenModeController zen, HotspotController hotspot,
- CastController cast, FlashlightController flashlight,
- UserSwitcherController userSwitcher, UserInfoController userInfo,
- KeyguardMonitor keyguard, SecurityController security,
- BatteryController battery, StatusBarIconController iconController,
- NextAlarmController nextAlarmController) {
+ StatusBarIconController iconController) {
+ mIconController = iconController;
mContext = context;
mStatusBar = statusBar;
- mBluetooth = bluetooth;
- mLocation = location;
- mRotation = rotation;
- mNetwork = network;
- mZen = zen;
- mHotspot = hotspot;
- mCast = cast;
- mFlashlight = flashlight;
- mUserSwitcherController = userSwitcher;
- mUserInfoController = userInfo;
- mKeyguard = keyguard;
- mSecurity = security;
- mBattery = battery;
- mIconController = iconController;
- mNextAlarmController = nextAlarmController;
- mProfileController = new ManagedProfileControllerImpl(this);
- mHandlerThread = new HandlerThread(QSTileHost.class.getSimpleName(),
- Process.THREAD_PRIORITY_BACKGROUND);
- mHandlerThread.start();
- mLooper = mHandlerThread.getLooper();
-
- mServices = new TileServices(this, mLooper);
+ mServices = new TileServices(this, Dependency.get(Dependency.BG_LOOPER));
TunerService.get(mContext).addTunable(this, TILES_SETTING);
// AutoTileManager can modify mTiles so make sure mTiles has already been initialized.
mAutoTiles = new AutoTileManager(context, this);
}
- public NextAlarmController getNextAlarmController() {
- return mNextAlarmController;
- }
-
- public void setHeaderView(View view) {
- mHeader = view;
+ public StatusBarIconController getIconController() {
+ return mIconController;
}
public void destroy() {
- mHandlerThread.quitSafely();
mTiles.values().forEach(tile -> tile.destroy());
mAutoTiles.destroy();
TunerService.get(mContext).removeTunable(this);
@@ -190,30 +121,10 @@
}
@Override
- public void startActivityDismissingKeyguard(final Intent intent) {
- mStatusBar.postStartActivityDismissingKeyguard(intent, 0);
- }
-
- @Override
- public void startActivityDismissingKeyguard(PendingIntent intent) {
- mStatusBar.postStartActivityDismissingKeyguard(intent);
- }
-
- @Override
- public void startRunnableDismissingKeyguard(Runnable runnable) {
- mStatusBar.postQSRunnableDismissingKeyguard(runnable);
- }
-
- @Override
public void warn(String message, Throwable t) {
// already logged
}
- public void animateToggleQSExpansion() {
- // TODO: Better path to animated panel expansion.
- mHeader.callOnClick();
- }
-
@Override
public void collapsePanels() {
mStatusBar.postAnimateCollapsePanels();
@@ -225,91 +136,15 @@
}
@Override
- public Looper getLooper() {
- return mLooper;
- }
-
- @Override
public Context getContext() {
return mContext;
}
- @Override
- public BluetoothController getBluetoothController() {
- return mBluetooth;
- }
-
- @Override
- public LocationController getLocationController() {
- return mLocation;
- }
-
- @Override
- public RotationLockController getRotationLockController() {
- return mRotation;
- }
-
- @Override
- public NetworkController getNetworkController() {
- return mNetwork;
- }
-
- @Override
- public ZenModeController getZenModeController() {
- return mZen;
- }
-
- @Override
- public HotspotController getHotspotController() {
- return mHotspot;
- }
-
- @Override
- public CastController getCastController() {
- return mCast;
- }
-
- @Override
- public FlashlightController getFlashlightController() {
- return mFlashlight;
- }
-
- @Override
- public KeyguardMonitor getKeyguardMonitor() {
- return mKeyguard;
- }
-
- @Override
- public UserSwitcherController getUserSwitcherController() {
- return mUserSwitcherController;
- }
-
- @Override
- public UserInfoController getUserInfoController() {
- return mUserInfoController;
- }
-
- @Override
- public BatteryController getBatteryController() {
- return mBattery;
- }
-
- public SecurityController getSecurityController() {
- return mSecurity;
- }
public TileServices getTileServices() {
return mServices;
}
- public StatusBarIconController getIconController() {
- return mIconController;
- }
-
- public ManagedProfileController getManagedProfileController() {
- return mProfileController;
- }
-
@Override
public void onTuningChanged(String key, String newValue) {
if (!TILES_SETTING.equals(key)) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java
index 2fa961d..9e93802 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java
@@ -40,10 +40,11 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.keyguard.KeyguardStatusView;
import com.android.settingslib.Utils;
+import com.android.systemui.ActivityStarter;
import com.android.systemui.BatteryMeterView;
+import com.android.systemui.Dependency;
import com.android.systemui.FontSizeUtils;
import com.android.systemui.R;
-import com.android.systemui.plugins.qs.QS.ActivityStarter;
import com.android.systemui.plugins.qs.QS.BaseStatusBarHeader;
import com.android.systemui.plugins.qs.QS.Callback;
import com.android.systemui.qs.QSPanel;
@@ -51,10 +52,9 @@
import com.android.systemui.qs.TouchAnimator;
import com.android.systemui.qs.TouchAnimator.Builder;
import com.android.systemui.statusbar.SignalClusterView;
-import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback;
+import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NetworkController.EmergencyListener;
-import com.android.systemui.statusbar.policy.NetworkControllerImpl;
import com.android.systemui.statusbar.policy.NextAlarmController;
import com.android.systemui.statusbar.policy.NextAlarmController.NextAlarmChangeCallback;
import com.android.systemui.statusbar.policy.UserInfoController;
@@ -71,6 +71,7 @@
private ActivityStarter mActivityStarter;
private NextAlarmController mNextAlarmController;
+ private UserInfoController mUserInfoController;
private SettingsButton mSettingsButton;
protected View mSettingsContainer;
@@ -118,7 +119,8 @@
mEdit = findViewById(android.R.id.edit);
findViewById(android.R.id.edit).setOnClickListener(view ->
- mHost.startRunnableDismissingKeyguard(() -> mQsPanel.showEdit(view)));
+ Dependency.get(ActivityStarter.class).postQSRunnableDismissingKeyguard(() ->
+ mQsPanel.showEdit(view)));
mDateTimeAlarmGroup = (ViewGroup) findViewById(R.id.date_time_alarm_group);
mDateTimeAlarmGroup.findViewById(R.id.empty_time_view).setVisibility(View.GONE);
@@ -151,6 +153,15 @@
((RippleDrawable) mExpandIndicator.getBackground()).setForceSoftware(true);
updateResources();
+
+ // Set the light/dark theming on the header status UI to match the current theme.
+ SignalClusterView cluster = (SignalClusterView) findViewById(R.id.signal_cluster);
+ int colorForeground = Utils.getColorAttr(getContext(), android.R.attr.colorForeground);
+ float intensity = colorForeground / (float) Color.WHITE;
+ cluster.setIconTint(colorForeground, intensity, new Rect(0, 0, 0, 0));
+ BatteryMeterView battery = (BatteryMeterView) findViewById(R.id.battery);
+ int colorSecondary = Utils.getColorAttr(getContext(), android.R.attr.textColorSecondary);
+ battery.setRawColors(colorForeground, colorSecondary);
}
@Override
@@ -248,11 +259,18 @@
mExpandIndicator.setExpanded(headerExpansionFraction > EXPAND_INDICATOR_THRESHOLD);
}
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ mNextAlarmController = Dependency.get(NextAlarmController.class);
+ mUserInfoController = Dependency.get(UserInfoController.class);
+ mActivityStarter = Dependency.get(ActivityStarter.class);
+ }
+
+ @Override
@VisibleForTesting
public void onDetachedFromWindow() {
setListening(false);
- mHost.getUserInfoController().removeCallback(this);
- mHost.getNetworkController().removeEmergencyListener(this);
super.onDetachedFromWindow();
}
@@ -304,16 +322,17 @@
private void updateListeners() {
if (mListening) {
mNextAlarmController.addCallback(this);
+ mUserInfoController.addCallback(this);
+ if (Dependency.get(NetworkController.class).hasVoiceCallingFeature()) {
+ Dependency.get(NetworkController.class).addEmergencyListener(this);
+ }
} else {
mNextAlarmController.removeCallback(this);
+ mUserInfoController.removeCallback(this);
+ Dependency.get(NetworkController.class).removeEmergencyListener(this);
}
}
- @Override
- public void setActivityStarter(ActivityStarter activityStarter) {
- mActivityStarter = activityStarter;
- }
-
public void setQSPanel(final QSPanel qsPanel) {
mQsPanel = qsPanel;
setupHost(qsPanel.getHost());
@@ -324,30 +343,9 @@
public void setupHost(final QSTileHost host) {
mHost = host;
- host.setHeaderView(mExpandIndicator);
+ //host.setHeaderView(mExpandIndicator);
mHeaderQsPanel.setQSPanelAndHeader(mQsPanel, this);
mHeaderQsPanel.setHost(host, null /* No customization in header */);
- setUserInfoController(host.getUserInfoController());
- setBatteryController(host.getBatteryController());
- setNextAlarmController(host.getNextAlarmController());
-
- final boolean isAPhone = mHost.getNetworkController().hasVoiceCallingFeature();
- if (isAPhone) {
- mHost.getNetworkController().addEmergencyListener(this);
- }
-
- // Set the light/dark theming on the header status UI to match the current theme.
- SignalClusterView cluster = (SignalClusterView) findViewById(R.id.signal_cluster);
- cluster.setNetworkController((NetworkControllerImpl) host.getNetworkController());
- cluster.setSecurityController(host.getSecurityController());
- int colorForeground = Utils.getColorAttr(getContext(), android.R.attr.colorForeground);
- float intensity = colorForeground / (float) Color.WHITE;
- cluster.setIconTint(colorForeground, intensity,
- new Rect(0, 0, 0, 0));
- BatteryMeterView battery = (BatteryMeterView) findViewById(R.id.battery);
- battery.setBatteryController(host.getBatteryController());
- int colorSecondary = Utils.getColorAttr(getContext(), android.R.attr.textColorSecondary);
- battery.setRawColors(colorForeground, colorSecondary);
}
@Override
@@ -357,7 +355,7 @@
mExpanded ? MetricsProto.MetricsEvent.ACTION_QS_EXPANDED_SETTINGS_LAUNCH
: MetricsProto.MetricsEvent.ACTION_QS_COLLAPSED_SETTINGS_LAUNCH);
if (mSettingsButton.isTunerClick()) {
- mHost.startRunnableDismissingKeyguard(() -> post(() -> {
+ Dependency.get(ActivityStarter.class).postQSRunnableDismissingKeyguard(() -> {
if (TunerService.isTunerEnabled(mContext)) {
TunerService.showResetRequest(mContext, () -> {
// Relaunch settings so that the tuner disappears.
@@ -370,7 +368,7 @@
}
startSettingsActivity();
- }));
+ });
} else {
startSettingsActivity();
}
@@ -385,18 +383,6 @@
true /* dismissShade */);
}
- public void setNextAlarmController(NextAlarmController nextAlarmController) {
- mNextAlarmController = nextAlarmController;
- }
-
- public void setBatteryController(BatteryController batteryController) {
- batteryController.addCallback(this);
- }
-
- public void setUserInfoController(UserInfoController userInfoController) {
- userInfoController.addCallback(this);
- }
-
@Override
public void setCallback(Callback qsPanelCallback) {
mHeaderQsPanel.setCallback(qsPanelCallback);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java
index 19dcf03..48ff1c1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java
@@ -17,12 +17,13 @@
package com.android.systemui.statusbar.policy;
import com.android.systemui.DemoMode;
+import com.android.systemui.Dumpable;
import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback;
import java.io.FileDescriptor;
import java.io.PrintWriter;
-public interface BatteryController extends DemoMode,
+public interface BatteryController extends DemoMode, Dumpable,
CallbackController<BatteryStateChangeCallback> {
/**
* Prints the current state of the {@link BatteryController} to the given {@link PrintWriter}.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java
index 4c1c378..df30e20 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothController.java
@@ -17,11 +17,12 @@
package com.android.systemui.statusbar.policy;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.systemui.Dumpable;
import com.android.systemui.statusbar.policy.BluetoothController.Callback;
import java.util.Collection;
-public interface BluetoothController extends CallbackController<Callback> {
+public interface BluetoothController extends CallbackController<Callback>, Dumpable {
boolean isBluetoothSupported();
boolean isBluetoothEnabled();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java
index 3142ddf..e7056a6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java
@@ -47,7 +47,7 @@
private final ArrayList<SignalCallback> mSignalCallbacks = new ArrayList<>();
public CallbackHandler() {
- super();
+ super(Looper.getMainLooper());
}
@VisibleForTesting
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/CastController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/CastController.java
index 6988af7..97be6ed 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/CastController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/CastController.java
@@ -16,11 +16,12 @@
package com.android.systemui.statusbar.policy;
+import com.android.systemui.Dumpable;
import com.android.systemui.statusbar.policy.CastController.Callback;
import java.util.Set;
-public interface CastController extends CallbackController<Callback> {
+public interface CastController extends CallbackController<Callback>, Dumpable {
void setDiscovering(boolean request);
void setCurrentUserId(int currentUserId);
Set<CastDevice> getCastDevices();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
index 1dbc664..9cc9749 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
@@ -38,8 +38,8 @@
import android.widget.TextView;
import com.android.systemui.DemoMode;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
-import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;
@@ -107,7 +107,7 @@
filter.addAction(Intent.ACTION_USER_SWITCHED);
getContext().registerReceiverAsUser(mIntentReceiver, UserHandle.ALL, filter,
- null, PhoneStatusBar.getTimeTickHandler(getContext()));
+ null, Dependency.get(Dependency.TIME_TICK_HANDLER));
TunerService.get(getContext()).addTunable(this, CLOCK_SECONDS,
StatusBarIconController.ICON_BLACKLIST);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DateView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DateView.java
index 5544c70..dc33633 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DateView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DateView.java
@@ -23,12 +23,11 @@
import android.content.res.TypedArray;
import android.icu.text.DateFormat;
import android.icu.text.DisplayContext;
-import android.os.Handler;
import android.util.AttributeSet;
import android.widget.TextView;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
-import com.android.systemui.statusbar.phone.PhoneStatusBar;
import java.util.Date;
import java.util.Locale;
@@ -87,7 +86,7 @@
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
filter.addAction(Intent.ACTION_LOCALE_CHANGED);
getContext().registerReceiver(mIntentReceiver, filter, null,
- PhoneStatusBar.getTimeTickHandler(getContext()));
+ Dependency.get(Dependency.TIME_TICK_HANDLER));
updateClock();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedController.java
new file mode 100644
index 0000000..aa4eaa7
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedController.java
@@ -0,0 +1,32 @@
+/*
+ * 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.policy;
+
+import android.content.Context;
+
+import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener;
+
+public interface DeviceProvisionedController extends CallbackController<DeviceProvisionedListener> {
+
+ boolean isDeviceProvisioned();
+ boolean isUserSetup(int currentUser);
+ int getCurrentUser();
+
+ interface DeviceProvisionedListener {
+ default void onDeviceProvisionedChanged() { }
+ default void onUserSwitched() { }
+ default void onUserSetupChanged() { }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedControllerImpl.java
new file mode 100644
index 0000000..0fc300d
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceProvisionedControllerImpl.java
@@ -0,0 +1,124 @@
+/*
+ * 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.policy;
+
+import android.app.ActivityManager;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.database.ContentObserver;
+import android.net.Uri;
+import android.provider.Settings.Global;
+import android.provider.Settings.Secure;
+
+import com.android.systemui.Dependency;
+import com.android.systemui.settings.CurrentUserTracker;
+
+import java.util.ArrayList;
+
+public class DeviceProvisionedControllerImpl extends CurrentUserTracker implements
+ DeviceProvisionedController {
+
+ private final ArrayList<DeviceProvisionedListener> mListeners = new ArrayList<>();
+ private final ContentResolver mContentResolver;
+ private final Context mContext;
+ private final Uri mDeviceProvisionedUri;
+ private final Uri mUserSetupUri;
+
+ public DeviceProvisionedControllerImpl(Context context) {
+ super(context);
+ mContext = context;
+ mContentResolver = context.getContentResolver();
+ mDeviceProvisionedUri = Global.getUriFor(Global.DEVICE_PROVISIONED);
+ mUserSetupUri = Secure.getUriFor(Secure.USER_SETUP_COMPLETE);
+ }
+
+ @Override
+ public boolean isDeviceProvisioned() {
+ return Global.getInt(mContentResolver, Global.DEVICE_PROVISIONED, 0) != 0;
+ }
+
+ @Override
+ public boolean isUserSetup(int currentUser) {
+ return Secure.getIntForUser(mContentResolver, Secure.USER_SETUP_COMPLETE, 0, currentUser)
+ != 0;
+ }
+
+ @Override
+ public int getCurrentUser() {
+ return ActivityManager.getCurrentUser();
+ }
+
+ @Override
+ public void addCallback(DeviceProvisionedListener listener) {
+ mListeners.add(listener);
+ if (mListeners.size() == 1) {
+ startListening(getCurrentUser());
+ }
+ }
+
+ @Override
+ public void removeCallback(DeviceProvisionedListener listener) {
+ mListeners.remove(listener);
+ if (mListeners.size() == 0) {
+ stopListening();
+ }
+ }
+
+ private void startListening(int user) {
+ mContentResolver.registerContentObserver(mDeviceProvisionedUri, true,
+ mSettingsObserver, 0);
+ mContentResolver.registerContentObserver(mUserSetupUri, true,
+ mSettingsObserver, user);
+ startTracking();
+ }
+
+ private void stopListening() {
+ stopTracking();
+ mContentResolver.unregisterContentObserver(mSettingsObserver);
+ }
+
+ @Override
+ public void onUserSwitched(int newUserId) {
+ stopListening();
+ startListening(newUserId);
+ notifyUserChanged();
+ notifyUserChanged();
+ }
+
+ private void notifyUserChanged() {
+ mListeners.forEach(c -> c.onUserSwitched());
+ }
+
+ private void notifySetupChanged() {
+ mListeners.forEach(c -> c.onUserSetupChanged());
+ }
+
+ private void notifyProvisionedChanged() {
+ mListeners.forEach(c -> c.onDeviceProvisionedChanged());
+ }
+
+ protected final ContentObserver mSettingsObserver = new ContentObserver(Dependency.get(
+ Dependency.MAIN_HANDLER)) {
+
+ @Override
+ public void onChange(boolean selfChange, Uri uri, int userId) {
+ if (mUserSetupUri.equals(uri)) {
+ notifySetupChanged();
+ } else {
+ notifyProvisionedChanged();
+ }
+ }
+ };
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java
index 6023f3e..e576f36 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java
@@ -14,9 +14,10 @@
package com.android.systemui.statusbar.policy;
+import com.android.systemui.Dumpable;
import com.android.systemui.statusbar.policy.FlashlightController.FlashlightListener;
-public interface FlashlightController extends CallbackController<FlashlightListener> {
+public interface FlashlightController extends CallbackController<FlashlightListener>, Dumpable {
boolean hasFlashlight();
void setFlashlight(boolean newState);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotController.java
index daf9d6b..0543678 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotController.java
@@ -16,9 +16,10 @@
package com.android.systemui.statusbar.policy;
+import com.android.systemui.Dumpable;
import com.android.systemui.statusbar.policy.HotspotController.Callback;
-public interface HotspotController extends CallbackController<Callback> {
+public interface HotspotController extends CallbackController<Callback>, Dumpable {
boolean isHotspotEnabled();
void setHotspotEnabled(boolean enabled);
boolean isHotspotSupported();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
index 1cf4050..4b283fed 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
@@ -30,6 +30,7 @@
import android.widget.FrameLayout;
import com.android.settingslib.animation.AppearAnimationUtils;
+import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.qs.tiles.UserDetailItemView;
@@ -56,10 +57,10 @@
private boolean mAnimating;
public KeyguardUserSwitcher(Context context, ViewStub userSwitcher,
- KeyguardStatusBarView statusBarView, NotificationPanelView panelView,
- UserSwitcherController userSwitcherController) {
+ KeyguardStatusBarView statusBarView, NotificationPanelView panelView) {
boolean keyguardUserSwitcherEnabled =
context.getResources().getBoolean(R.bool.config_keyguardUserSwitcher) || ALWAYS_ON;
+ UserSwitcherController userSwitcherController = Dependency.get(UserSwitcherController.class);
if (userSwitcherController != null && keyguardUserSwitcherEnabled) {
mUserSwitcherContainer = (Container) userSwitcher.inflate();
mBackground = new KeyguardUserSwitcherScrim(context);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
index 082fe82..a22fc6b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
@@ -21,17 +21,18 @@
import android.telephony.SubscriptionInfo;
import com.android.settingslib.net.DataUsageController;
import com.android.settingslib.wifi.AccessPoint;
+import com.android.systemui.DemoMode;
+import com.android.systemui.Dumpable;
import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
import java.util.List;
-public interface NetworkController extends CallbackController<SignalCallback> {
+public interface NetworkController extends CallbackController<SignalCallback>, DemoMode {
boolean hasMobileDataFeature();
void addCallback(SignalCallback cb);
void removeCallback(SignalCallback cb);
void setWifiEnabled(boolean enabled);
- void onUserSwitched(int newUserId);
AccessPointController getAccessPointController();
DataUsageController getMobileDataController();
DataSaverController getDataSaverController();
@@ -40,6 +41,9 @@
void addEmergencyListener(EmergencyListener listener);
void removeEmergencyListener(EmergencyListener listener);
+ void setUserSetupComplete(boolean userSetup);
+ boolean hasEmergencyCryptKeeperText();
+ boolean isRadioOn();
public interface SignalCallback {
default void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
index a7fab41..edf2c8a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
@@ -20,6 +20,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
@@ -42,8 +43,12 @@
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.settingslib.net.DataUsageController;
+import com.android.systemui.ConfigurationChangedReceiver;
import com.android.systemui.DemoMode;
+import com.android.systemui.Dumpable;
import com.android.systemui.R;
+import com.android.systemui.settings.CurrentUserTracker;
+import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -60,7 +65,8 @@
/** Platform implementation of the network controller. **/
public class NetworkControllerImpl extends BroadcastReceiver
- implements NetworkController, DemoMode, DataUsageController.NetworkNameProvider {
+ implements NetworkController, DemoMode, DataUsageController.NetworkNameProvider,
+ ConfigurationChangedReceiver, Dumpable {
// debug
static final String TAG = "NetworkController";
static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@@ -80,6 +86,7 @@
private final boolean mHasMobileDataFeature;
private final SubscriptionDefaults mSubDefaults;
private final DataSaverController mDataSaverController;
+ private final CurrentUserTracker mUserTracker;
private Config mConfig;
// Subcontrollers.
@@ -135,7 +142,8 @@
/**
* Construct this controller object and register for updates.
*/
- public NetworkControllerImpl(Context context, Looper bgLooper) {
+ public NetworkControllerImpl(Context context, Looper bgLooper,
+ DeviceProvisionedController deviceProvisionedController) {
this(context, (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE),
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE),
(WifiManager) context.getSystemService(Context.WIFI_SERVICE),
@@ -143,7 +151,8 @@
new CallbackHandler(),
new AccessPointControllerImpl(context, bgLooper),
new DataUsageController(context),
- new SubscriptionDefaults());
+ new SubscriptionDefaults(),
+ deviceProvisionedController);
mReceiverHandler.post(mRegisterListeners);
}
@@ -154,7 +163,8 @@
CallbackHandler callbackHandler,
AccessPointControllerImpl accessPointController,
DataUsageController dataUsageController,
- SubscriptionDefaults defaultsHandler) {
+ SubscriptionDefaults defaultsHandler,
+ DeviceProvisionedController deviceProvisionedController) {
mContext = context;
mConfig = config;
mReceiverHandler = new Handler(bgLooper);
@@ -191,6 +201,20 @@
// AIRPLANE_MODE_CHANGED is sent at boot; we've probably already missed it
updateAirplaneMode(true /* force callback */);
+ mUserTracker = new CurrentUserTracker(mContext) {
+ @Override
+ public void onUserSwitched(int newUserId) {
+ NetworkControllerImpl.this.onUserSwitched(newUserId);
+ }
+ };
+ mUserTracker.startTracking();
+ deviceProvisionedController.addCallback(new DeviceProvisionedListener() {
+ @Override
+ public void onUserSetupChanged() {
+ setUserSetupComplete(deviceProvisionedController.isUserSetup(
+ deviceProvisionedController.getCurrentUser()));
+ }
+ });
}
public DataSaverController getDataSaverController() {
@@ -358,8 +382,7 @@
}.execute();
}
- @Override
- public void onUserSwitched(int newUserId) {
+ private void onUserSwitched(int newUserId) {
mCurrentUserId = newUserId;
mAccessPoints.onUserSwitched(newUserId);
updateConnectivity();
@@ -413,7 +436,7 @@
}
}
- public void onConfigurationChanged() {
+ public void onConfigurationChanged(Configuration newConfig) {
mConfig = Config.readConfig(mContext);
mReceiverHandler.post(new Runnable() {
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NextAlarmController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NextAlarmController.java
index e5b0c03..366a752 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NextAlarmController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NextAlarmController.java
@@ -16,9 +16,10 @@
import android.app.AlarmManager;
+import com.android.systemui.Dumpable;
import com.android.systemui.statusbar.policy.NextAlarmController.NextAlarmChangeCallback;
-public interface NextAlarmController extends CallbackController<NextAlarmChangeCallback> {
+public interface NextAlarmController extends CallbackController<NextAlarmChangeCallback>, Dumpable {
public interface NextAlarmChangeCallback {
void onNextAlarmChanged(AlarmManager.AlarmClockInfo nextAlarm);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java
index 3142228..3f8e41a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java
@@ -15,9 +15,11 @@
*/
package com.android.systemui.statusbar.policy;
+import com.android.systemui.Dumpable;
import com.android.systemui.statusbar.policy.SecurityController.SecurityControllerCallback;
-public interface SecurityController extends CallbackController<SecurityControllerCallback> {
+public interface SecurityController extends CallbackController<SecurityControllerCallback>,
+ Dumpable {
/** Whether the device has device owner, even if not on this user. */
boolean isDeviceManaged();
boolean hasProfileOwner();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java
index df959bd..19ced23 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java
@@ -39,12 +39,13 @@
import com.android.internal.net.LegacyVpnInfo;
import com.android.internal.net.VpnConfig;
import com.android.systemui.R;
+import com.android.systemui.settings.CurrentUserTracker;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
-public class SecurityControllerImpl implements SecurityController {
+public class SecurityControllerImpl extends CurrentUserTracker implements SecurityController {
private static final String TAG = "SecurityController";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@@ -73,6 +74,7 @@
private int mVpnUserId;
public SecurityControllerImpl(Context context) {
+ super(context);
mContext = context;
mDevicePolicyManager = (DevicePolicyManager)
context.getSystemService(Context.DEVICE_POLICY_SERVICE);
@@ -87,6 +89,7 @@
// TODO: re-register network callback on user change.
mConnectivityManager.registerNetworkCallback(REQUEST, mNetworkCallback);
onUserSwitched(ActivityManager.getCurrentUser());
+ startTracking();
}
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
index 4785ba9..f71c5d1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
@@ -52,13 +52,14 @@
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.util.UserIcons;
import com.android.settingslib.RestrictedLockUtils;
+import com.android.systemui.Dependency;
import com.android.systemui.GuestResumeSessionReceiver;
import com.android.systemui.R;
import com.android.systemui.SystemUI;
import com.android.systemui.SystemUISecondaryUserService;
import com.android.systemui.plugins.qs.QS.DetailAdapter;
import com.android.systemui.qs.tiles.UserDetailView;
-import com.android.systemui.plugins.qs.QS.ActivityStarter;
+import com.android.systemui.ActivityStarter;
import com.android.systemui.statusbar.phone.SystemUIDialog;
import java.io.FileDescriptor;
@@ -645,11 +646,6 @@
}
@VisibleForTesting
- public KeyguardMonitor getKeyguardMonitor() {
- return mKeyguardMonitor;
- }
-
- @VisibleForTesting
public ArrayList<UserRecord> getUsers() {
return mUsers;
}
@@ -657,17 +653,19 @@
public static abstract class BaseUserAdapter extends BaseAdapter {
final UserSwitcherController mController;
+ private final KeyguardMonitor mKeyguardMonitor;
protected BaseUserAdapter(UserSwitcherController controller) {
mController = controller;
+ mKeyguardMonitor = Dependency.get(KeyguardMonitor.class);
controller.addAdapter(new WeakReference<>(this));
}
@Override
public int getCount() {
- boolean secureKeyguardShowing = mController.getKeyguardMonitor().isShowing()
- && mController.getKeyguardMonitor().isSecure()
- && !mController.getKeyguardMonitor().canSkipBouncer();
+ boolean secureKeyguardShowing = mKeyguardMonitor.isShowing()
+ && mKeyguardMonitor.isSecure()
+ && !mKeyguardMonitor.canSkipBouncer();
if (!secureKeyguardShowing) {
return mController.getUsers().size();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java
index bcdb62d..f195f7a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java
@@ -30,7 +30,6 @@
ZenRule getManualRule();
ZenModeConfig getConfig();
long getNextAlarm();
- void setUserId(int userId);
boolean isZenAvailable();
ComponentName getEffectsSuppressor();
boolean isCountdownConditionSupported();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java
index 96efea1..e80d3b3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java
@@ -40,13 +40,14 @@
import android.util.Slog;
import com.android.systemui.qs.GlobalSetting;
+import com.android.systemui.settings.CurrentUserTracker;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Objects;
/** Platform implementation of the zen mode controller. **/
-public class ZenModeControllerImpl implements ZenModeController {
+public class ZenModeControllerImpl extends CurrentUserTracker implements ZenModeController {
private static final String TAG = "ZenModeController";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@@ -66,6 +67,7 @@
private ZenModeConfig mConfig;
public ZenModeControllerImpl(Context context, Handler handler) {
+ super(context);
mContext = context;
mModeSetting = new GlobalSetting(mContext, handler, Global.ZEN_MODE) {
@Override
@@ -87,6 +89,7 @@
mSetupObserver = new SetupObserver(handler);
mSetupObserver.register();
mUserManager = context.getSystemService(UserManager.class);
+ startTracking();
}
@Override
@@ -137,7 +140,7 @@
}
@Override
- public void setUserId(int userId) {
+ public void onUserSwitched(int userId) {
mUserId = userId;
if (mRegistered) {
mContext.unregisterReceiver(mReceiver);