Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui; |
| 18 | |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 19 | import android.app.AlarmManager; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 20 | import android.content.Context; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 21 | import android.util.ArrayMap; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 22 | import android.util.Log; |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 23 | import android.view.View; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 24 | import android.view.ViewGroup; |
| 25 | |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 26 | import com.android.internal.logging.MetricsLogger; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 27 | import com.android.internal.widget.LockPatternUtils; |
| 28 | import com.android.keyguard.ViewMediatorCallback; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 29 | import com.android.systemui.Dependency.DependencyProvider; |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 30 | import com.android.systemui.keyguard.DismissCallbackRegistry; |
Eliot Courtney | e77edea | 2017-11-15 14:25:21 +0900 | [diff] [blame] | 31 | import com.android.systemui.qs.QSTileHost; |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 32 | import com.android.systemui.statusbar.KeyguardIndicationController; |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 33 | import com.android.systemui.statusbar.NotificationEntryManager; |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 34 | import com.android.systemui.statusbar.NotificationGutsManager; |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame] | 35 | import com.android.systemui.statusbar.NotificationListener; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame^] | 36 | import com.android.systemui.statusbar.NotificationLockscreenUserManager; |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame] | 37 | import com.android.systemui.statusbar.NotificationLogger; |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 38 | import com.android.systemui.statusbar.NotificationMediaManager; |
Eliot Courtney | e77edea | 2017-11-15 14:25:21 +0900 | [diff] [blame] | 39 | import com.android.systemui.statusbar.NotificationRemoteInputManager; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame^] | 40 | import com.android.systemui.statusbar.NotificationViewHierarchyManager; |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 41 | import com.android.systemui.statusbar.ScrimView; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame^] | 42 | import com.android.systemui.statusbar.notification.VisualStabilityManager; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 43 | import com.android.systemui.statusbar.phone.DozeParameters; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 44 | import com.android.systemui.statusbar.phone.KeyguardBouncer; |
Jorim Jaggi | 40db029 | 2016-06-27 17:58:03 -0700 | [diff] [blame] | 45 | import com.android.systemui.statusbar.phone.LightBarController; |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 46 | import com.android.systemui.statusbar.phone.LockIcon; |
Jorim Jaggi | e31f6b8 | 2016-07-01 16:15:09 -0700 | [diff] [blame] | 47 | import com.android.systemui.statusbar.phone.LockscreenWallpaper; |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame] | 48 | import com.android.systemui.statusbar.phone.NotificationGroupManager; |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 49 | import com.android.systemui.statusbar.phone.NotificationIconAreaController; |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 50 | import com.android.systemui.statusbar.phone.ScrimController; |
Eliot Courtney | e77edea | 2017-11-15 14:25:21 +0900 | [diff] [blame] | 51 | import com.android.systemui.statusbar.phone.StatusBar; |
Xiaohui Chen | 311b98e | 2016-03-30 11:55:54 -0700 | [diff] [blame] | 52 | import com.android.systemui.statusbar.phone.StatusBarIconController; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 53 | import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 54 | import com.android.systemui.statusbar.policy.DeviceProvisionedController; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 55 | |
Adrian Roos | a5c6322 | 2017-07-27 16:33:39 +0200 | [diff] [blame] | 56 | import java.util.function.Consumer; |
| 57 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 58 | /** |
| 59 | * Class factory to provide customizable SystemUI components. |
| 60 | */ |
| 61 | public class SystemUIFactory { |
| 62 | private static final String TAG = "SystemUIFactory"; |
| 63 | |
| 64 | static SystemUIFactory mFactory; |
| 65 | |
| 66 | public static SystemUIFactory getInstance() { |
| 67 | return mFactory; |
| 68 | } |
| 69 | |
| 70 | public static void createFromConfig(Context context) { |
| 71 | final String clsName = context.getString(R.string.config_systemUIFactoryComponent); |
| 72 | if (clsName == null || clsName.length() == 0) { |
| 73 | throw new RuntimeException("No SystemUIFactory component configured"); |
| 74 | } |
| 75 | |
| 76 | try { |
| 77 | Class<?> cls = null; |
| 78 | cls = context.getClassLoader().loadClass(clsName); |
| 79 | mFactory = (SystemUIFactory) cls.newInstance(); |
| 80 | } catch (Throwable t) { |
| 81 | Log.w(TAG, "Error creating SystemUIFactory component: " + clsName, t); |
| 82 | throw new RuntimeException(t); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | public SystemUIFactory() {} |
| 87 | |
| 88 | public StatusBarKeyguardViewManager createStatusBarKeyguardViewManager(Context context, |
| 89 | ViewMediatorCallback viewMediatorCallback, LockPatternUtils lockPatternUtils) { |
| 90 | return new StatusBarKeyguardViewManager(context, viewMediatorCallback, lockPatternUtils); |
| 91 | } |
| 92 | |
| 93 | public KeyguardBouncer createKeyguardBouncer(Context context, ViewMediatorCallback callback, |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 94 | LockPatternUtils lockPatternUtils, |
| 95 | ViewGroup container, DismissCallbackRegistry dismissCallbackRegistry) { |
| 96 | return new KeyguardBouncer(context, callback, lockPatternUtils, container, |
| 97 | dismissCallbackRegistry); |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 98 | } |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 99 | |
Jorim Jaggi | 40db029 | 2016-06-27 17:58:03 -0700 | [diff] [blame] | 100 | public ScrimController createScrimController(LightBarController lightBarController, |
| 101 | ScrimView scrimBehind, ScrimView scrimInFront, View headsUpScrim, |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 102 | LockscreenWallpaper lockscreenWallpaper, Consumer<Integer> scrimVisibleListener, |
| 103 | DozeParameters dozeParameters, AlarmManager alarmManager) { |
Adrian Roos | a5c6322 | 2017-07-27 16:33:39 +0200 | [diff] [blame] | 104 | return new ScrimController(lightBarController, scrimBehind, scrimInFront, headsUpScrim, |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 105 | scrimVisibleListener, dozeParameters, alarmManager); |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 106 | } |
Muyuan Li | 94ce94e | 2016-02-24 16:20:54 -0800 | [diff] [blame] | 107 | |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 108 | public NotificationIconAreaController createNotificationIconAreaController(Context context, |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 109 | StatusBar statusBar) { |
| 110 | return new NotificationIconAreaController(context, statusBar); |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 111 | } |
| 112 | |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 113 | public KeyguardIndicationController createKeyguardIndicationController(Context context, |
| 114 | ViewGroup indicationArea, LockIcon lockIcon) { |
| 115 | return new KeyguardIndicationController(context, indicationArea, lockIcon); |
| 116 | } |
| 117 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 118 | public QSTileHost createQSTileHost(Context context, StatusBar statusBar, |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 119 | StatusBarIconController iconController) { |
| 120 | return new QSTileHost(context, statusBar, iconController); |
Xiaohui Chen | 311b98e | 2016-03-30 11:55:54 -0700 | [diff] [blame] | 121 | } |
| 122 | |
Adrian Roos | 09c43c8 | 2017-02-09 19:58:25 +0100 | [diff] [blame] | 123 | public void injectDependencies(ArrayMap<Object, DependencyProvider> providers, |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 124 | Context context) { |
| 125 | providers.put(NotificationLockscreenUserManager.class, |
| 126 | () -> new NotificationLockscreenUserManager(context)); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame^] | 127 | providers.put(VisualStabilityManager.class, VisualStabilityManager::new); |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame] | 128 | providers.put(NotificationGroupManager.class, NotificationGroupManager::new); |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 129 | providers.put(NotificationMediaManager.class, () -> new NotificationMediaManager(context)); |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 130 | providers.put(NotificationGutsManager.class, () -> new NotificationGutsManager( |
| 131 | Dependency.get(NotificationLockscreenUserManager.class), context)); |
Eliot Courtney | e77edea | 2017-11-15 14:25:21 +0900 | [diff] [blame] | 132 | providers.put(NotificationRemoteInputManager.class, |
| 133 | () -> new NotificationRemoteInputManager( |
| 134 | Dependency.get(NotificationLockscreenUserManager.class), context)); |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame] | 135 | providers.put(NotificationListener.class, () -> new NotificationListener( |
| 136 | Dependency.get(NotificationRemoteInputManager.class), context)); |
| 137 | providers.put(NotificationLogger.class, () -> new NotificationLogger( |
| 138 | Dependency.get(NotificationListener.class), |
| 139 | Dependency.get(UiOffloadThread.class))); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame^] | 140 | providers.put(NotificationViewHierarchyManager.class, () -> |
| 141 | new NotificationViewHierarchyManager( |
| 142 | Dependency.get(NotificationLockscreenUserManager.class), |
| 143 | Dependency.get(NotificationGroupManager.class), |
| 144 | Dependency.get(VisualStabilityManager.class), |
| 145 | context)); |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 146 | providers.put(NotificationEntryManager.class, () -> |
| 147 | new NotificationEntryManager( |
| 148 | Dependency.get(NotificationLockscreenUserManager.class), |
| 149 | Dependency.get(NotificationGroupManager.class), |
| 150 | Dependency.get(NotificationGutsManager.class), |
| 151 | Dependency.get(NotificationRemoteInputManager.class), |
| 152 | Dependency.get(NotificationMediaManager.class), |
| 153 | Dependency.get(ForegroundServiceController.class), |
| 154 | Dependency.get(NotificationListener.class), |
| 155 | Dependency.get(MetricsLogger.class), |
| 156 | Dependency.get(DeviceProvisionedController.class), |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame^] | 157 | Dependency.get(VisualStabilityManager.class), |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 158 | Dependency.get(UiOffloadThread.class), |
| 159 | context)); |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 160 | } |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 161 | } |