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/ActivityStarter.java b/packages/SystemUI/src/com/android/systemui/ActivityStarter.java
new file mode 100644
index 0000000..a4d8a10
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/ActivityStarter.java
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+import android.app.PendingIntent;
+import android.content.Intent;
+
+/**
+ * An interface to start activities. This is used as a callback from the views to
+ * {@link PhoneStatusBar} to allow custom handling for starting the activity, i.e. dismissing the
+ * Keyguard.
+ */
+public interface ActivityStarter {
+
+ void startPendingIntentDismissingKeyguard(PendingIntent intent);
+ void startActivity(Intent intent, boolean dismissShade);
+ void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade);
+ void startActivity(Intent intent, boolean dismissShade, Callback callback);
+ void postStartActivityDismissingKeyguard(Intent intent, int delay);
+ void postStartActivityDismissingKeyguard(PendingIntent intent);
+ void postQSRunnableDismissingKeyguard(Runnable runnable);
+
+ interface Callback {
+ void onActivityStarted(int resultCode);
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/ActivityStarterDelegate.java b/packages/SystemUI/src/com/android/systemui/ActivityStarterDelegate.java
new file mode 100644
index 0000000..4ae81a7
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/ActivityStarterDelegate.java
@@ -0,0 +1,73 @@
+/*
+ * 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;
+
+import android.app.PendingIntent;
+import android.content.Intent;
+
+/**
+ * Single common instance of ActivityStarter that can be gotten and referenced from anywhere, but
+ * delegates to an actual implementation such as PhoneStatusBar, assuming it exists.
+ */
+public class ActivityStarterDelegate implements ActivityStarter {
+
+ private ActivityStarter mActualStarter;
+
+ @Override
+ public void startPendingIntentDismissingKeyguard(PendingIntent intent) {
+ if (mActualStarter == null) return;
+ mActualStarter.startPendingIntentDismissingKeyguard(intent);
+ }
+
+ @Override
+ public void startActivity(Intent intent, boolean dismissShade) {
+ if (mActualStarter == null) return;
+ mActualStarter.startActivity(intent, dismissShade);
+ }
+
+ @Override
+ public void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade) {
+ if (mActualStarter == null) return;
+ mActualStarter.startActivity(intent, onlyProvisioned, dismissShade);
+ }
+
+ @Override
+ public void startActivity(Intent intent, boolean dismissShade, Callback callback) {
+ if (mActualStarter == null) return;
+ mActualStarter.startActivity(intent, dismissShade, callback);
+ }
+
+ @Override
+ public void postStartActivityDismissingKeyguard(Intent intent, int delay) {
+ if (mActualStarter == null) return;
+ mActualStarter.postStartActivityDismissingKeyguard(intent, delay);
+ }
+
+ @Override
+ public void postStartActivityDismissingKeyguard(PendingIntent intent) {
+ if (mActualStarter == null) return;
+ mActualStarter.postStartActivityDismissingKeyguard(intent);
+ }
+
+ @Override
+ public void postQSRunnableDismissingKeyguard(Runnable runnable) {
+ if (mActualStarter == null) return;
+ mActualStarter.postQSRunnableDismissingKeyguard(runnable);
+ }
+
+ public void setActivityStarterImpl(ActivityStarter starter) {
+ mActualStarter = starter;
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
index 030250a..b30b596 100644
--- a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
+++ b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
@@ -72,6 +72,10 @@
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
+ mBatteryController = Dependency.get(BatteryController.class);
+ mDrawable.setBatteryController(mBatteryController);
+ mBatteryController.addCallback(this);
+ mDrawable.startListening();
TunerService.get(getContext()).addTunable(this, StatusBarIconController.ICON_BLACKLIST);
}
@@ -95,13 +99,6 @@
}
- public void setBatteryController(BatteryController mBatteryController) {
- this.mBatteryController = mBatteryController;
- mDrawable.setBatteryController(mBatteryController);
- mBatteryController.addCallback(this);
- mDrawable.startListening();
- }
-
public void setDarkIntensity(float f) {
mDrawable.setDarkIntensity(f);
}
diff --git a/packages/SystemUI/src/com/android/systemui/ConfigurationChangedReceiver.java b/packages/SystemUI/src/com/android/systemui/ConfigurationChangedReceiver.java
new file mode 100644
index 0000000..4fba640
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/ConfigurationChangedReceiver.java
@@ -0,0 +1,21 @@
+/*
+ * 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;
+
+import android.content.res.Configuration;
+
+public interface ConfigurationChangedReceiver {
+ void onConfigurationChanged(Configuration newConfiguration);
+}
diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java
new file mode 100644
index 0000000..135b129
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/Dependency.java
@@ -0,0 +1,230 @@
+/*
+ * 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;
+
+import android.content.res.Configuration;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Looper;
+import android.os.Process;
+import android.util.ArrayMap;
+
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.systemui.assist.AssistManager;
+import com.android.systemui.statusbar.phone.ManagedProfileController;
+import com.android.systemui.statusbar.phone.ManagedProfileControllerImpl;
+import com.android.systemui.statusbar.policy.AccessibilityController;
+import com.android.systemui.statusbar.policy.BatteryController;
+import com.android.systemui.statusbar.policy.BatteryControllerImpl;
+import com.android.systemui.statusbar.policy.BluetoothController;
+import com.android.systemui.statusbar.policy.BluetoothControllerImpl;
+import com.android.systemui.statusbar.policy.CastController;
+import com.android.systemui.statusbar.policy.CastControllerImpl;
+import com.android.systemui.statusbar.policy.DataSaverController;
+import com.android.systemui.statusbar.policy.DeviceProvisionedController;
+import com.android.systemui.statusbar.policy.DeviceProvisionedControllerImpl;
+import com.android.systemui.statusbar.policy.FlashlightController;
+import com.android.systemui.statusbar.policy.FlashlightControllerImpl;
+import com.android.systemui.statusbar.policy.HotspotController;
+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.LocationController;
+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.NextAlarmController;
+import com.android.systemui.statusbar.policy.NextAlarmControllerImpl;
+import com.android.systemui.statusbar.policy.RotationLockController;
+import com.android.systemui.statusbar.policy.RotationLockControllerImpl;
+import com.android.systemui.statusbar.policy.SecurityController;
+import com.android.systemui.statusbar.policy.SecurityControllerImpl;
+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;
+import com.android.systemui.statusbar.policy.ZenModeControllerImpl;
+
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
+/**
+ * Class to handle ugly dependencies throughout sysui until we determine the
+ * long-term dependency injection solution.
+ *
+ * Classes added here should be things that are expected to live the lifetime of sysui,
+ * and are generally applicable to many parts of sysui. They will be lazily
+ * initialized to ensure they aren't created on form factors that don't need them
+ * (e.g. HotspotController on TV). Despite being lazily initialized, it is expected
+ * that all dependencies will be gotten during sysui startup, and not during runtime
+ * to avoid jank.
+ *
+ * All classes used here are expected to manage their own lifecycle, meaning if
+ * they have no clients they should not have any registered resources like bound
+ * services, registered receivers, etc.
+ */
+public class Dependency extends SystemUI {
+
+ /**
+ * Key for getting a background Looper for background work.
+ */
+ public static final String BG_LOOPER = "background_loooper";
+ /**
+ * Key for getting a Handler for receiving time tick broadcasts on.
+ */
+ public static final String TIME_TICK_HANDLER = "time_tick_handler";
+ /**
+ * Generic handler on the main thread.
+ */
+ public static final String MAIN_HANDLER = "main_handler";
+
+ private final ArrayMap<String, Object> mDependencies = new ArrayMap<>();
+ private final ArrayMap<String, DependencyProvider> mProviders = new ArrayMap<>();
+
+ @Override
+ public void start() {
+ sDependency = this;
+ // TODO: Think about ways to push these creation rules out of Dependency to cut down
+ // on imports.
+ mProviders.put(TIME_TICK_HANDLER, () -> {
+ HandlerThread thread = new HandlerThread("TimeTick");
+ thread.start();
+ return new Handler(thread.getLooper());
+ });
+ mProviders.put(BG_LOOPER, () -> {
+ HandlerThread thread = new HandlerThread("SysUiBg",
+ Process.THREAD_PRIORITY_BACKGROUND);
+ thread.start();
+ return thread.getLooper();
+ });
+ mProviders.put(MAIN_HANDLER, () -> new Handler(Looper.getMainLooper()));
+ mProviders.put(ActivityStarter.class.getName(), () -> new ActivityStarterDelegate());
+ mProviders.put(ActivityStarterDelegate.class.getName(), () ->
+ getDependency(ActivityStarter.class));
+
+ mProviders.put(BluetoothController.class.getName(), () ->
+ new BluetoothControllerImpl(mContext, getDependency(BG_LOOPER)));
+
+ mProviders.put(LocationController.class.getName(), () ->
+ new LocationControllerImpl(mContext, getDependency(BG_LOOPER)));
+
+ mProviders.put(RotationLockController.class.getName(), () ->
+ new RotationLockControllerImpl(mContext));
+
+ mProviders.put(NetworkController.class.getName(), () ->
+ new NetworkControllerImpl(mContext, getDependency(BG_LOOPER),
+ getDependency(DeviceProvisionedController.class)));
+
+ mProviders.put(ZenModeController.class.getName(), () ->
+ new ZenModeControllerImpl(mContext, getDependency(MAIN_HANDLER)));
+
+ mProviders.put(HotspotController.class.getName(), () ->
+ new HotspotControllerImpl(mContext));
+
+ mProviders.put(CastController.class.getName(), () ->
+ new CastControllerImpl(mContext));
+
+ mProviders.put(FlashlightController.class.getName(), () ->
+ new FlashlightControllerImpl(mContext));
+
+ mProviders.put(KeyguardMonitor.class.getName(), () ->
+ new KeyguardMonitorImpl(mContext));
+
+ mProviders.put(UserSwitcherController.class.getName(), () ->
+ new UserSwitcherController(mContext, getDependency(KeyguardMonitor.class),
+ getDependency(MAIN_HANDLER), getDependency(ActivityStarter.class)));
+
+ mProviders.put(UserInfoController.class.getName(), () ->
+ new UserInfoControllerImpl(mContext));
+
+ mProviders.put(BatteryController.class.getName(), () ->
+ new BatteryControllerImpl(mContext));
+
+ mProviders.put(ManagedProfileController.class.getName(), () ->
+ new ManagedProfileControllerImpl(mContext));
+
+ mProviders.put(NextAlarmController.class.getName(), () ->
+ new NextAlarmControllerImpl(mContext));
+
+ mProviders.put(DataSaverController.class.getName(), () ->
+ get(NetworkController.class).getDataSaverController());
+
+ mProviders.put(AccessibilityController.class.getName(), () ->
+ new AccessibilityController(mContext));
+
+ mProviders.put(DeviceProvisionedController.class.getName(), () ->
+ new DeviceProvisionedControllerImpl(mContext));
+
+ mProviders.put(AssistManager.class.getName(), () ->
+ new AssistManager(getDependency(DeviceProvisionedController.class), mContext));
+
+ mProviders.put(SecurityController.class.getName(), () ->
+ new SecurityControllerImpl(mContext));
+
+ // Put all dependencies above here so the factory can override them if it wants.
+ SystemUIFactory.getInstance().injectDependencies(mProviders, mContext);
+ }
+
+ @Override
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ super.dump(fd, pw, args);
+ pw.println("Dumping existing controllers:");
+ mDependencies.values().stream().filter(obj -> obj instanceof Dumpable)
+ .forEach(o -> ((Dumpable) o).dump(fd, pw, args));
+ }
+
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ mDependencies.values().stream().filter(obj -> obj instanceof ConfigurationChangedReceiver)
+ .forEach(o -> ((ConfigurationChangedReceiver) o).onConfigurationChanged(newConfig));
+ }
+
+ protected final <T> T getDependency(Class<T> cls) {
+ return getDependency(cls.getName());
+ }
+
+ protected final <T> T getDependency(String cls) {
+ T obj = (T) mDependencies.get(cls);
+ if (obj == null) {
+ obj = createDependency(cls);
+ mDependencies.put(cls, obj);
+ }
+ return obj;
+ }
+
+ @VisibleForTesting
+ protected <T> T createDependency(String cls) {
+ DependencyProvider<T> provider = mProviders.get(cls);
+ if (provider == null) {
+ throw new IllegalArgumentException("Unsupported dependency " + cls);
+ }
+ return provider.createDependency();
+ }
+
+ private static Dependency sDependency;
+
+ public interface DependencyProvider<T> {
+ T createDependency();
+ }
+
+ public static <T> T get(Class<T> cls) {
+ return sDependency.getDependency(cls.getName());
+ }
+
+ public static <T> T get(String cls) {
+ return sDependency.getDependency(cls);
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/Dumpable.java b/packages/SystemUI/src/com/android/systemui/Dumpable.java
new file mode 100644
index 0000000..65a6844
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/Dumpable.java
@@ -0,0 +1,22 @@
+/*
+ * 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;
+
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
+public interface Dumpable {
+ void dump(FileDescriptor fd, PrintWriter pw, String[] args);
+}
diff --git a/packages/SystemUI/src/com/android/systemui/SysUiServiceProvider.java b/packages/SystemUI/src/com/android/systemui/SysUiServiceProvider.java
index c4470cd..ff4b7cb 100644
--- a/packages/SystemUI/src/com/android/systemui/SysUiServiceProvider.java
+++ b/packages/SystemUI/src/com/android/systemui/SysUiServiceProvider.java
@@ -14,10 +14,16 @@
package com.android.systemui;
+import android.content.Context;
+
/**
* The interface for getting core components of SysUI. Exists for Testability
* since tests don't have SystemUIApplication as their ApplicationContext.
*/
public interface SysUiServiceProvider {
<T> T getComponent(Class<T> interfaceType);
+
+ public static <T> T getComponent(Context context, Class<T> interfaceType) {
+ return ((SysUiServiceProvider) context.getApplicationContext()).getComponent(interfaceType);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java
index bd4e3dc..f83a5d3 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java
@@ -29,7 +29,6 @@
import android.os.UserHandle;
import android.util.Log;
-import com.android.systemui.doze.DozeFactory;
import com.android.systemui.fragments.FragmentService;
import com.android.systemui.keyboard.KeyboardUI;
import com.android.systemui.keyguard.KeyguardViewMediator;
@@ -64,6 +63,7 @@
* The classes of the stuff to start.
*/
private final Class<?>[] SERVICES = new Class[] {
+ Dependency.class,
FragmentService.class,
TunerService.class,
CommandQueue.CommandQueueStart.class,
@@ -239,8 +239,4 @@
public SystemUI[] getServices() {
return mServices;
}
-
- public static <T> T getComponent(Context context, Class<T> interfaceType) {
- return ((SysUiServiceProvider) context.getApplicationContext()).getComponent(interfaceType);
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
index 10328a4..228996a 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
@@ -18,12 +18,14 @@
import android.content.ComponentName;
import android.content.Context;
+import android.util.ArrayMap;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.ViewMediatorCallback;
+import com.android.systemui.Dependency.DependencyProvider;
import com.android.systemui.R;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.keyguard.DismissCallbackRegistry;
@@ -114,24 +116,14 @@
}
public QSTileHost createQSTileHost(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) {
- return new QSTileHost(context, statusBar, bluetooth, location, rotation, network, zen,
- hotspot, cast, flashlight, userSwitcher, userInfo, keyguard, security, battery,
- iconController, nextAlarmController);
+ StatusBarIconController iconController) {
+ return new QSTileHost(context, statusBar, iconController);
}
public <T> T createInstance(Class<T> classType) {
return null;
}
- public AssistManager createAssistManager(BaseStatusBar bar, Context context) {
- return new AssistManager(bar, context);
- }
+ public void injectDependencies(ArrayMap<String, DependencyProvider> providers,
+ Context context) { }
}
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
index 2576bb7..09fdf5a 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
@@ -9,14 +9,15 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.os.AsyncTask;
import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
-import android.os.IBinder;
import android.os.RemoteException;
import android.os.UserHandle;
import android.provider.Settings;
@@ -33,14 +34,17 @@
import com.android.internal.app.IVoiceInteractionSessionListener;
import com.android.internal.app.IVoiceInteractionSessionShowCallback;
import com.android.keyguard.KeyguardUpdateMonitor;
+import com.android.settingslib.applications.InterestingConfigChanges;
+import com.android.systemui.ConfigurationChangedReceiver;
import com.android.systemui.R;
-import com.android.systemui.statusbar.BaseStatusBar;
+import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.statusbar.CommandQueue;
+import com.android.systemui.statusbar.policy.DeviceProvisionedController;
/**
* Class to manage everything related to assist in SystemUI.
*/
-public class AssistManager {
+public class AssistManager implements ConfigurationChangedReceiver {
private static final String TAG = "AssistManager";
private static final String ASSIST_ICON_METADATA_NAME =
@@ -52,9 +56,10 @@
protected final Context mContext;
private final WindowManager mWindowManager;
private final AssistDisclosure mAssistDisclosure;
+ private final InterestingConfigChanges mInterestingConfigChanges;
private AssistOrbContainer mView;
- private final BaseStatusBar mBar;
+ private final DeviceProvisionedController mDeviceProvisionedController;
protected final AssistUtils mAssistUtils;
private IVoiceInteractionSessionShowCallback mShowCallback =
@@ -79,14 +84,16 @@
}
};
- public AssistManager(BaseStatusBar bar, Context context) {
+ public AssistManager(DeviceProvisionedController controller, Context context) {
mContext = context;
- mBar = bar;
+ mDeviceProvisionedController = controller;
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
mAssistUtils = new AssistUtils(context);
mAssistDisclosure = new AssistDisclosure(context, new Handler());
registerVoiceInteractionSessionListener();
+ mInterestingConfigChanges = new InterestingConfigChanges(ActivityInfo.CONFIG_ORIENTATION);
+ onConfigurationChanged(context.getResources().getConfiguration());
}
protected void registerVoiceInteractionSessionListener() {
@@ -104,7 +111,10 @@
});
}
- public void onConfigurationChanged() {
+ public void onConfigurationChanged(Configuration newConfiguration) {
+ if (!mInterestingConfigChanges.applyNewConfig(mContext.getResources())) {
+ return;
+ }
boolean visible = false;
if (mView != null) {
visible = mView.isShowing();
@@ -183,13 +193,13 @@
}
private void startAssistActivity(Bundle args, @NonNull ComponentName assistComponent) {
- if (!mBar.isDeviceProvisioned()) {
+ if (!mDeviceProvisionedController.isDeviceProvisioned()) {
return;
}
// Close Recent Apps if needed
- mBar.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL |
- CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL);
+ SysUiServiceProvider.getComponent(mContext, CommandQueue.class).animateCollapsePanels(
+ CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL | CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL);
boolean structureEnabled = Settings.Secure.getIntForUser(mContext.getContentResolver(),
Settings.Secure.ASSIST_STRUCTURE_ENABLED, 1, UserHandle.USER_CURRENT) != 0;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java b/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java
index 5027144..a20b7ba 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java
@@ -33,11 +33,15 @@
import android.widget.TextView;
import com.android.internal.logging.MetricsLogger;
+import com.android.systemui.Dependency;
import com.android.systemui.FontSizeUtils;
import com.android.systemui.R;
+import com.android.systemui.SysUiServiceProvider;
+import com.android.systemui.ActivityStarter;
import com.android.systemui.plugins.qs.QS.BaseStatusBarHeader;
import com.android.systemui.plugins.qs.QS.Callback;
import com.android.systemui.plugins.qs.QS.DetailAdapter;
+import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.QSTileHost;
public class QSDetail extends LinearLayout {
@@ -160,7 +164,8 @@
setupDetailHeader(adapter);
if (toggleQs && !mFullyExpanded) {
mTriggeredExpand = true;
- mHost.animateToggleQSExpansion();
+ SysUiServiceProvider.getComponent(mContext, CommandQueue.class)
+ .animateExpandSettingsPanel(null);
} else {
mTriggeredExpand = false;
}
@@ -171,7 +176,8 @@
x = mOpenX;
y = mOpenY;
if (toggleQs && mTriggeredExpand) {
- mHost.animateToggleQSExpansion();
+ SysUiServiceProvider.getComponent(mContext, CommandQueue.class)
+ .animateCollapsePanels();
mTriggeredExpand = false;
}
}
@@ -231,12 +237,8 @@
protected void setupDetailFooter(DetailAdapter adapter) {
final Intent settingsIntent = adapter.getSettingsIntent();
mDetailSettingsButton.setVisibility(settingsIntent != null ? VISIBLE : GONE);
- mDetailSettingsButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mHost.startActivityDismissingKeyguard(settingsIntent);
- }
- });
+ mDetailSettingsButton.setOnClickListener(v -> Dependency.get(ActivityStarter.class)
+ .postStartActivityDismissingKeyguard(settingsIntent, 0));
}
protected void setupDetailHeader(final DetailAdapter adapter) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java b/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java
index fb3b1d9..0bf3f15 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java
@@ -19,11 +19,9 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
-import android.os.UserHandle;
import android.provider.Settings;
import android.text.SpannableStringBuilder;
import android.text.method.LinkMovementMethod;
@@ -33,12 +31,13 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
-import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;
+import com.android.systemui.Dependency;
import com.android.systemui.FontSizeUtils;
import com.android.systemui.R;
+import com.android.systemui.ActivityStarter;
import com.android.systemui.statusbar.phone.QSTileHost;
import com.android.systemui.statusbar.phone.SystemUIDialog;
import com.android.systemui.statusbar.policy.SecurityController;
@@ -55,12 +54,13 @@
private final ImageView mFooterIcon2;
private final Context mContext;
private final Callback mCallback = new Callback();
+ private final SecurityController mSecurityController;
+ private final ActivityStarter mActivityStarter;
+ private final Handler mMainHandler;
- private SecurityController mSecurityController;
private AlertDialog mDialog;
private QSTileHost mHost;
protected Handler mHandler;
- private final Handler mMainHandler;
private boolean mIsVisible;
private boolean mIsIconVisible;
@@ -81,13 +81,13 @@
mFooterIcon2Id = R.drawable.ic_qs_network_logging;
mContext = context;
mMainHandler = new Handler(Looper.getMainLooper());
+ mActivityStarter = Dependency.get(ActivityStarter.class);
+ mSecurityController = Dependency.get(SecurityController.class);
+ mHandler = new Handler((Looper) Dependency.get(Dependency.BG_LOOPER));
}
- public void setHostEnvironment(QSTileHost host, SecurityController securityController,
- Looper looper) {
+ public void setHostEnvironment(QSTileHost host) {
mHost = host;
- mSecurityController = securityController;
- mHandler = new H(looper);
}
public void setListening(boolean listening) {
@@ -173,7 +173,7 @@
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_NEGATIVE) {
final Intent settingsIntent = new Intent(ACTION_VPN_SETTINGS);
- mHost.startActivityDismissingKeyguard(settingsIntent);
+ mActivityStarter.postStartActivityDismissingKeyguard(settingsIntent, 0);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
index 2de32cc..e004828 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -190,12 +190,11 @@
mHost = host;
mHost.addCallback(this);
setTiles(mHost.getTiles());
- mFooter.setHostEnvironment(host, host.getSecurityController(), host.getLooper());
+ mFooter.setHostEnvironment(host);
mCustomizePanel = customizer;
if (mCustomizePanel != null) {
mCustomizePanel.setHost(mHost);
}
- mBrightnessController.setBackgroundLooper(host.getLooper());
}
public QSTileHost getHost() {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
index dad37b0..e18654e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
@@ -17,7 +17,6 @@
package com.android.systemui.qs;
import android.app.ActivityManager;
-import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
@@ -32,22 +31,11 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settingslib.RestrictedLockUtils;
+import com.android.systemui.Dependency;
+import com.android.systemui.ActivityStarter;
import com.android.systemui.plugins.qs.QS.DetailAdapter;
import com.android.systemui.qs.QSTile.State;
import com.android.systemui.qs.external.TileServices;
-import com.android.systemui.statusbar.phone.ManagedProfileController;
-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.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.UserInfoController;
-import com.android.systemui.statusbar.policy.UserSwitcherController;
-import com.android.systemui.statusbar.policy.ZenModeController;
import java.util.ArrayList;
import java.util.Collection;
@@ -100,7 +88,7 @@
protected QSTile(Host host) {
mHost = host;
mContext = host.getContext();
- mHandler = new H(host.getLooper());
+ mHandler = new H(Dependency.get(Dependency.BG_LOOPER));
}
/**
@@ -242,7 +230,8 @@
protected void handleLongClick() {
MetricsLogger.action(mContext, MetricsEvent.ACTION_QS_LONG_PRESS, getTileSpec());
- mHost.startActivityDismissingKeyguard(getLongClickIntent());
+ Dependency.get(ActivityStarter.class).postStartActivityDismissingKeyguard(
+ getLongClickIntent(), 0);
}
public abstract Intent getLongClickIntent();
@@ -381,7 +370,8 @@
if (mState.disabledByPolicy) {
Intent intent = RestrictedLockUtils.getShowAdminSupportDetailsIntent(
mContext, mState.enforcedAdmin);
- mHost.startActivityDismissingKeyguard(intent);
+ Dependency.get(ActivityStarter.class).postStartActivityDismissingKeyguard(
+ intent, 0);
} else {
mAnnounceNextStateChange = true;
handleClick();
@@ -436,36 +426,17 @@
}
public interface Host {
- void startActivityDismissingKeyguard(Intent intent);
- void startActivityDismissingKeyguard(PendingIntent intent);
- void startRunnableDismissingKeyguard(Runnable runnable);
void warn(String message, Throwable t);
void collapsePanels();
- void animateToggleQSExpansion();
void openPanels();
- Looper getLooper();
Context getContext();
Collection<QSTile<?>> getTiles();
void addCallback(Callback callback);
void removeCallback(Callback callback);
- BluetoothController getBluetoothController();
- LocationController getLocationController();
- RotationLockController getRotationLockController();
- NetworkController getNetworkController();
- ZenModeController getZenModeController();
- HotspotController getHotspotController();
- CastController getCastController();
- FlashlightController getFlashlightController();
- KeyguardMonitor getKeyguardMonitor();
- UserSwitcherController getUserSwitcherController();
- UserInfoController getUserInfoController();
- BatteryController getBatteryController();
TileServices getTileServices();
void removeTile(String tileSpec);
- ManagedProfileController getManagedProfileController();
-
- public interface Callback {
+ interface Callback {
void onTilesChanged();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
index 0be53b4..730b55d 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
@@ -36,13 +36,14 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.plugins.qs.QS;
import com.android.systemui.qs.QSDetailClipper;
import com.android.systemui.qs.QSTile;
import com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer;
-import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.phone.QSTileHost;
+import com.android.systemui.statusbar.policy.KeyguardMonitor;
import com.android.systemui.statusbar.policy.KeyguardMonitor.Callback;
import java.util.ArrayList;
@@ -140,7 +141,7 @@
mNotifQsContainer.setCustomizerShowing(true);
announceForAccessibility(mContext.getString(
R.string.accessibility_desc_quick_settings_edit));
- mHost.getKeyguardMonitor().addCallback(mKeyguardCallback);
+ Dependency.get(KeyguardMonitor.class).addCallback(mKeyguardCallback);
}
}
@@ -156,7 +157,7 @@
mNotifQsContainer.setCustomizerShowing(false);
announceForAccessibility(mContext.getString(
R.string.accessibility_desc_quick_settings));
- mHost.getKeyguardMonitor().removeCallback(mKeyguardCallback);
+ Dependency.get(KeyguardMonitor.class).removeCallback(mKeyguardCallback);
}
}
@@ -206,12 +207,9 @@
mTileAdapter.saveSpecs(mHost);
}
- private final Callback mKeyguardCallback = new Callback() {
- @Override
- public void onKeyguardChanged() {
- if (mHost.getKeyguardMonitor().isShowing()) {
- hide(0, 0);
- }
+ private final Callback mKeyguardCallback = () -> {
+ if (Dependency.get(KeyguardMonitor.class).isShowing()) {
+ hide(0, 0);
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/TileQueryHelper.java b/packages/SystemUI/src/com/android/systemui/qs/customize/TileQueryHelper.java
index 0cd6490..72e6fcc0 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/customize/TileQueryHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/customize/TileQueryHelper.java
@@ -30,6 +30,7 @@
import android.service.quicksettings.TileService;
import android.widget.Button;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
import com.android.systemui.qs.QSTile.DrawableIcon;
@@ -59,7 +60,7 @@
private void addSystemTiles(final QSTileHost host) {
String possible = mContext.getString(R.string.quick_settings_tiles_stock);
String[] possibleTiles = possible.split(",");
- final Handler qsHandler = new Handler(host.getLooper());
+ final Handler qsHandler = new Handler((Looper) Dependency.get(Dependency.BG_LOOPER));
final Handler mainHandler = new Handler(Looper.getMainLooper());
for (int i = 0; i < possibleTiles.length; i++) {
final String spec = possibleTiles[i];
diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/CustomTile.java b/packages/SystemUI/src/com/android/systemui/qs/external/CustomTile.java
index cff4846..3afbc35 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/external/CustomTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/external/CustomTile.java
@@ -39,6 +39,8 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.systemui.R;
+import com.android.systemui.Dependency;
+import com.android.systemui.ActivityStarter;
import com.android.systemui.qs.QSTile;
import com.android.systemui.qs.external.TileLifecycleManager.TileChangeListener;
import com.android.systemui.statusbar.phone.QSTileHost;
@@ -306,13 +308,10 @@
}
public void startUnlockAndRun() {
- mHost.startRunnableDismissingKeyguard(new Runnable() {
- @Override
- public void run() {
- try {
- mService.onUnlockComplete();
- } catch (RemoteException e) {
- }
+ Dependency.get(ActivityStarter.class).postQSRunnableDismissingKeyguard(() -> {
+ try {
+ mService.onUnlockComplete();
+ } catch (RemoteException e) {
}
});
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/TileServices.java b/packages/SystemUI/src/com/android/systemui/qs/external/TileServices.java
index 015a4c0..5c23eb7 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/external/TileServices.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/external/TileServices.java
@@ -30,13 +30,13 @@
import android.os.RemoteException;
import android.os.UserHandle;
import android.service.quicksettings.IQSService;
-import android.service.quicksettings.IQSTileService;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import android.util.ArrayMap;
import android.util.Log;
import com.android.internal.statusbar.StatusBarIcon;
+import com.android.systemui.Dependency;
import com.android.systemui.statusbar.phone.QSTileHost;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.policy.KeyguardMonitor;
@@ -284,13 +284,13 @@
@Override
public boolean isLocked() {
- KeyguardMonitor keyguardMonitor = mHost.getKeyguardMonitor();
+ KeyguardMonitor keyguardMonitor = Dependency.get(KeyguardMonitor.class);
return keyguardMonitor.isShowing();
}
@Override
public boolean isSecure() {
- KeyguardMonitor keyguardMonitor = mHost.getKeyguardMonitor();
+ KeyguardMonitor keyguardMonitor = Dependency.get(KeyguardMonitor.class);
return keyguardMonitor.isSecure() && keyguardMonitor.isShowing();
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BatteryTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BatteryTile.java
index a82f550..7e04b67 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BatteryTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BatteryTile.java
@@ -38,10 +38,12 @@
import com.android.settingslib.BatteryInfo;
import com.android.settingslib.graph.UsageView;
import com.android.systemui.BatteryMeterDrawable;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.plugins.qs.QS.DetailAdapter;
import com.android.systemui.qs.QSTile;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
+import com.android.systemui.qs.external.TileColorPicker;
import com.android.systemui.statusbar.policy.BatteryController;
import java.text.NumberFormat;
@@ -59,7 +61,7 @@
public BatteryTile(Host host) {
super(host);
- mBatteryController = host.getBatteryController();
+ mBatteryController = Dependency.get(BatteryController.class);
}
@Override
@@ -273,7 +275,7 @@
mDetailShown = true;
v.getContext().registerReceiver(mReceiver,
new IntentFilter(Intent.ACTION_TIME_TICK), null,
- PhoneStatusBar.getTimeTickHandler(v.getContext()));
+ Dependency.get(Dependency.TIME_TICK_HANDLER));
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
index 15f3c90..91e76ca 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
@@ -32,7 +32,9 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+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.QSDetailItems;
import com.android.systemui.qs.QSDetailItems.Item;
@@ -48,10 +50,12 @@
private final BluetoothController mController;
private final BluetoothDetailAdapter mDetailAdapter;
+ private final ActivityStarter mActivityStarter;
public BluetoothTile(Host host) {
super(host);
- mController = host.getBluetoothController();
+ mController = Dependency.get(BluetoothController.class);
+ mActivityStarter = Dependency.get(ActivityStarter.class);
mDetailAdapter = (BluetoothDetailAdapter) createDetailAdapter();
}
@@ -90,7 +94,8 @@
@Override
protected void handleSecondaryClick() {
if (!mController.canConfigBluetooth()) {
- mHost.startActivityDismissingKeyguard(new Intent(Settings.ACTION_BLUETOOTH_SETTINGS));
+ mActivityStarter.postStartActivityDismissingKeyguard(
+ new Intent(Settings.ACTION_BLUETOOTH_SETTINGS), 0);
return;
}
showDetail(true);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java
index d61e2f2..7415765 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java
@@ -28,7 +28,9 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+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.QSDetailItems;
import com.android.systemui.qs.QSDetailItems.Item;
@@ -49,12 +51,14 @@
private final CastDetailAdapter mDetailAdapter;
private final KeyguardMonitor mKeyguard;
private final Callback mCallback = new Callback();
+ private final ActivityStarter mActivityStarter;
public CastTile(Host host) {
super(host);
- mController = host.getCastController();
+ mController = Dependency.get(CastController.class);
mDetailAdapter = new CastDetailAdapter();
- mKeyguard = host.getKeyguardMonitor();
+ mKeyguard = Dependency.get(KeyguardMonitor.class);
+ mActivityStarter = Dependency.get(ActivityStarter.class);
}
@Override
@@ -101,13 +105,10 @@
@Override
protected void handleClick() {
if (mKeyguard.isSecure() && !mKeyguard.canSkipBouncer()) {
- mHost.startRunnableDismissingKeyguard(new Runnable() {
- @Override
- public void run() {
- MetricsLogger.action(mContext, getMetricsCategory());
- showDetail(true);
- mHost.openPanels();
- }
+ mActivityStarter.postQSRunnableDismissingKeyguard(() -> {
+ MetricsLogger.action(mContext, getMetricsCategory());
+ showDetail(true);
+ mHost.openPanels();
});
return;
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
index 5f7c803..75c4a75 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
@@ -29,7 +29,9 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settingslib.net.DataUsageController;
+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.QSIconView;
import com.android.systemui.qs.QSTile;
@@ -48,10 +50,12 @@
private final CellularDetailAdapter mDetailAdapter;
private final CellSignalCallback mSignalCallback = new CellSignalCallback();
+ private final ActivityStarter mActivityStarter;
public CellularTile(Host host) {
super(host);
- mController = host.getNetworkController();
+ mController = Dependency.get(NetworkController.class);
+ mActivityStarter = Dependency.get(ActivityStarter.class);
mDataController = mController.getMobileDataController();
mDetailAdapter = new CellularDetailAdapter();
}
@@ -96,7 +100,7 @@
if (mDataController.isMobileDataSupported()) {
showDetail(true);
} else {
- mHost.startActivityDismissingKeyguard(CELLULAR_SETTINGS);
+ mActivityStarter.postStartActivityDismissingKeyguard(CELLULAR_SETTINGS, 0);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/DataSaverTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/DataSaverTile.java
index aadc8e7..412fe3d 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/DataSaverTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/DataSaverTile.java
@@ -21,11 +21,13 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.systemui.Dependency;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
import com.android.systemui.statusbar.phone.SystemUIDialog;
import com.android.systemui.statusbar.policy.DataSaverController;
+import com.android.systemui.statusbar.policy.NetworkController;
public class DataSaverTile extends QSTile<QSTile.BooleanState> implements
DataSaverController.Listener{
@@ -34,7 +36,7 @@
public DataSaverTile(Host host) {
super(host);
- mDataSaverController = host.getNetworkController().getDataSaverController();
+ mDataSaverController = Dependency.get(NetworkController.class).getDataSaverController();
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
index a25b7ea..3c1f504 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
@@ -35,9 +35,11 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.systemui.Dependency;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.SysUIToast;
+import com.android.systemui.ActivityStarter;
import com.android.systemui.plugins.qs.QS.DetailAdapter;
import com.android.systemui.qs.QSTile;
import com.android.systemui.statusbar.policy.ZenModeController;
@@ -74,7 +76,7 @@
public DndTile(Host host) {
super(host);
- mController = host.getZenModeController();
+ mController = Dependency.get(ZenModeController.class);
mDetailAdapter = new DndDetailAdapter();
mContext.registerReceiver(mReceiver, new IntentFilter(ACTION_SET_VISIBLE));
mReceiverRegistered = true;
@@ -313,7 +315,8 @@
private final ZenModePanel.Callback mZenModePanelCallback = new ZenModePanel.Callback() {
@Override
public void onPrioritySettings() {
- mHost.startActivityDismissingKeyguard(ZEN_PRIORITY_SETTINGS);
+ Dependency.get(ActivityStarter.class).postStartActivityDismissingKeyguard(
+ ZEN_PRIORITY_SETTINGS, 0);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java
index 4bbc458..ac82753 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java
@@ -27,6 +27,7 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
import com.android.systemui.statusbar.policy.FlashlightController;
@@ -45,14 +46,12 @@
public FlashlightTile(Host host) {
super(host);
- mFlashlightController = host.getFlashlightController();
- mFlashlightController.addCallback(this);
+ mFlashlightController = Dependency.get(FlashlightController.class);
}
@Override
protected void handleDestroy() {
super.handleDestroy();
- mFlashlightController.removeCallback(this);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
index 9d495ce..70f8109 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java
@@ -29,6 +29,7 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.qs.GlobalSetting;
import com.android.systemui.qs.QSTile;
@@ -52,7 +53,7 @@
public HotspotTile(Host host) {
super(host);
- mController = host.getHotspotController();
+ mController = Dependency.get(HotspotController.class);
mAirplaneMode = new GlobalSetting(mContext, mHandler, Global.AIRPLANE_MODE_ON) {
@Override
protected void handleValueChanged(int value) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/IntentTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/IntentTile.java
index f968816..fcc9596 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/IntentTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/IntentTile.java
@@ -31,6 +31,8 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.systemui.Dependency;
+import com.android.systemui.ActivityStarter;
import com.android.systemui.qs.QSTile;
import java.util.Arrays;
@@ -105,7 +107,7 @@
try {
if (pi != null) {
if (pi.isActivity()) {
- getHost().startActivityDismissingKeyguard(pi);
+ Dependency.get(ActivityStarter.class).postStartActivityDismissingKeyguard(pi);
} else {
pi.send();
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java
index 002e2a6..5374f18 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java
@@ -18,14 +18,15 @@
import android.content.Intent;
import android.os.UserManager;
-
import android.provider.Settings;
import android.service.quicksettings.Tile;
import android.widget.Switch;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
+import com.android.systemui.ActivityStarter;
import com.android.systemui.qs.QSTile;
import com.android.systemui.statusbar.policy.KeyguardMonitor;
import com.android.systemui.statusbar.policy.LocationController;
@@ -47,8 +48,8 @@
public LocationTile(Host host) {
super(host);
- mController = host.getLocationController();
- mKeyguard = host.getKeyguardMonitor();
+ mController = Dependency.get(LocationController.class);
+ mKeyguard = Dependency.get(KeyguardMonitor.class);
}
@Override
@@ -75,18 +76,15 @@
@Override
protected void handleClick() {
if (mKeyguard.isSecure() && mKeyguard.isShowing()) {
- mHost.startRunnableDismissingKeyguard(new Runnable() {
- @Override
- public void run() {
- final boolean wasEnabled = (Boolean) mState.value;
- mHost.openPanels();
- MetricsLogger.action(mContext, getMetricsCategory(), !wasEnabled);
- mController.setLocationEnabled(!wasEnabled);
- }
+ Dependency.get(ActivityStarter.class).postQSRunnableDismissingKeyguard(() -> {
+ final boolean wasEnabled = mState.value;
+ mHost.openPanels();
+ MetricsLogger.action(mContext, getMetricsCategory(), !wasEnabled);
+ mController.setLocationEnabled(!wasEnabled);
});
return;
}
- final boolean wasEnabled = (Boolean) mState.value;
+ final boolean wasEnabled = mState.value;
MetricsLogger.action(mContext, getMetricsCategory(), !wasEnabled);
mController.setLocationEnabled(!wasEnabled);
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java
index 9be67da..2c0af17 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java
@@ -26,6 +26,7 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
import com.android.systemui.statusbar.policy.RotationLockController;
@@ -51,7 +52,7 @@
public RotationLockTile(Host host) {
super(host);
- mController = host.getRotationLockController();
+ mController = Dependency.get(RotationLockController.class);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/UserTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/UserTile.java
index 246c23e..c20c6bb 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/UserTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/UserTile.java
@@ -22,6 +22,7 @@
import android.util.Pair;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.systemui.Dependency;
import com.android.systemui.plugins.qs.QS.DetailAdapter;
import com.android.systemui.qs.QSTile;
import com.android.systemui.statusbar.policy.UserInfoController;
@@ -35,8 +36,8 @@
public UserTile(Host host) {
super(host);
- mUserSwitcherController = host.getUserSwitcherController();
- mUserInfoController = host.getUserInfoController();
+ mUserSwitcherController = Dependency.get(UserSwitcherController.class);
+ mUserInfoController = Dependency.get(UserInfoController.class);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
index 7d99041..54b41ac 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
@@ -31,7 +31,9 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settingslib.wifi.AccessPoint;
+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.QSDetailItems;
import com.android.systemui.qs.QSDetailItems.Item;
@@ -55,12 +57,14 @@
private final QSTile.SignalState mStateBeforeClick = newTileState();
protected final WifiSignalCallback mSignalCallback = new WifiSignalCallback();
+ private final ActivityStarter mActivityStarter;
public WifiTile(Host host) {
super(host);
- mController = host.getNetworkController();
+ mController = Dependency.get(NetworkController.class);
mWifiController = mController.getAccessPointController();
mDetailAdapter = (WifiDetailAdapter) createDetailAdapter();
+ mActivityStarter = Dependency.get(ActivityStarter.class);
}
@Override
@@ -115,7 +119,8 @@
@Override
protected void handleSecondaryClick() {
if (!mWifiController.canConfigWifi()) {
- mHost.startActivityDismissingKeyguard(new Intent(Settings.ACTION_WIFI_SETTINGS));
+ mActivityStarter.postStartActivityDismissingKeyguard(
+ new Intent(Settings.ACTION_WIFI_SETTINGS), 0);
return;
}
showDetail(true);
@@ -329,7 +334,7 @@
@Override
public void onSettingsActivityTriggered(Intent settingsIntent) {
- mHost.startActivityDismissingKeyguard(settingsIntent);
+ mActivityStarter.postStartActivityDismissingKeyguard(settingsIntent, 0);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java
index 207deff..ae4d6c9 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java
@@ -23,6 +23,7 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
import com.android.systemui.statusbar.phone.ManagedProfileController;
@@ -41,7 +42,7 @@
public WorkModeTile(Host host) {
super(host);
- mProfileController = host.getManagedProfileController();
+ mProfileController = Dependency.get(ManagedProfileController.class);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java b/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java
index 3059a05..7825e9e 100644
--- a/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java
+++ b/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java
@@ -37,6 +37,7 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.systemui.Dependency;
import java.util.ArrayList;
@@ -70,7 +71,7 @@
private final CurrentUserTracker mUserTracker;
private final IVrManager mVrManager;
- private Handler mBackgroundHandler;
+ private final Handler mBackgroundHandler;
private final BrightnessObserver mBrightnessObserver;
private ArrayList<BrightnessStateChangeCallback> mChangeCallbacks =
@@ -276,7 +277,7 @@
mContext = context;
mIcon = icon;
mControl = control;
- mBackgroundHandler = new Handler(Looper.getMainLooper());
+ mBackgroundHandler = new Handler((Looper) Dependency.get(Dependency.BG_LOOPER));
mUserTracker = new CurrentUserTracker(mContext) {
@Override
public void onUserSwitched(int newUserId) {
@@ -298,10 +299,6 @@
mVrManager = IVrManager.Stub.asInterface(ServiceManager.getService("vrmanager"));
}
- public void setBackgroundLooper(Looper backgroundLooper) {
- mBackgroundHandler = new Handler(backgroundLooper);
- }
-
public void addStateChangedCallback(BrightnessStateChangeCallback cb) {
mChangeCallbacks.add(cb);
}
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);
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeComponent.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeComponent.java
index 1f0ee57..36c673c 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeComponent.java
@@ -25,7 +25,6 @@
import java.io.PrintWriter;
public interface VolumeComponent extends DemoMode {
- ZenModeController getZenController();
void dismissNow();
void onConfigurationChanged(Configuration newConfig);
void dump(FileDescriptor fd, PrintWriter pw, String[] args);
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogComponent.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogComponent.java
index f195a0b..137a12f 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogComponent.java
@@ -16,20 +16,17 @@
package com.android.systemui.volume;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.media.AudioManager;
import android.media.VolumePolicy;
import android.os.Bundle;
import android.os.Handler;
-import android.provider.Settings;
-import android.util.Log;
import android.view.WindowManager;
-import com.android.systemui.R;
+import com.android.systemui.ActivityStarter;
+import com.android.systemui.Dependency;
import com.android.systemui.SystemUI;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.keyguard.KeyguardViewMediator;
@@ -37,11 +34,9 @@
import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.tuner.TunerService;
-import com.android.systemui.volume.car.CarVolumeDialogController;
import java.io.FileDescriptor;
import java.io.PrintWriter;
-import java.lang.reflect.Constructor;
/**
* Implementation of VolumeComponent backed by the new volume dialog.
@@ -69,15 +64,14 @@
400 // vibrateToSilentDebounce
);
- public VolumeDialogComponent(SystemUI sysui, Context context, Handler handler,
- ZenModeController zen) {
+ public VolumeDialogComponent(SystemUI sysui, Context context, Handler handler) {
mSysui = sysui;
mContext = context;
mController = SystemUIFactory.getInstance().createVolumeDialogController(context, null);
mController.setUserActivityListener(this);
- mZenModeController = zen;
+ mZenModeController = Dependency.get(ZenModeController.class);
mDialog = new VolumeDialog(context, WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY,
- mController, zen, mVolumeDialogCallback);
+ mController, mZenModeController, mVolumeDialogCallback);
applyConfiguration();
TunerService.get(mContext).addTunable(this, VOLUME_DOWN_SILENT, VOLUME_UP_SILENT,
VOLUME_SILENT_DO_NOT_DISTURB);
@@ -134,11 +128,6 @@
}
@Override
- public ZenModeController getZenController() {
- return mZenModeController;
- }
-
- @Override
public void onConfigurationChanged(Configuration newConfig) {
// noop
}
@@ -166,7 +155,7 @@
}
private void startSettings(Intent intent) {
- mSysui.getComponent(PhoneStatusBar.class).startActivityDismissingKeyguard(intent,
+ Dependency.get(ActivityStarter.class).startActivity(intent,
true /* onlyProvisioned */, true /* dismissShade */);
}
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
index 73d9ea7..02969e4 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java
@@ -42,8 +42,7 @@
public void start() {
mEnabled = mContext.getResources().getBoolean(R.bool.enable_volume_ui);
if (!mEnabled) return;
- final ZenModeController zenController = new ZenModeControllerImpl(mContext, mHandler);
- mVolumeComponent = new VolumeDialogComponent(this, mContext, null, zenController);
+ mVolumeComponent = new VolumeDialogComponent(this, mContext, null);
putComponent(VolumeComponent.class, getVolumeComponent());
setDefaultVolumeController();
}