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; |
| 23 | import android.view.ViewGroup; |
| 24 | |
Gus Prevas | ab33679 | 2018-11-14 13:52:20 -0500 | [diff] [blame^] | 25 | import com.android.internal.colorextraction.ColorExtractor.GradientColors; |
Yohei Yukawa | 795f010 | 2018-04-13 14:55:30 -0700 | [diff] [blame] | 26 | import com.android.internal.util.function.TriConsumer; |
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; |
Lucas Dupin | 0df9b7a | 2018-03-15 17:53:17 -0700 | [diff] [blame] | 30 | import com.android.systemui.classifier.FalsingManager; |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 31 | import com.android.systemui.keyguard.DismissCallbackRegistry; |
Eliot Courtney | e77edea | 2017-11-15 14:25:21 +0900 | [diff] [blame] | 32 | import com.android.systemui.qs.QSTileHost; |
Kevin | a97ea05 | 2018-09-11 13:53:18 -0700 | [diff] [blame] | 33 | import com.android.systemui.statusbar.AmbientPulseManager; |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 34 | import com.android.systemui.statusbar.KeyguardIndicationController; |
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; |
Gus Prevas | ab33679 | 2018-11-14 13:52:20 -0500 | [diff] [blame^] | 37 | import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl; |
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; |
Kenny Guy | a0f6de8 | 2018-04-06 16:20:16 +0100 | [diff] [blame] | 42 | import com.android.systemui.statusbar.SmartReplyController; |
Gus Prevas | ab33679 | 2018-11-14 13:52:20 -0500 | [diff] [blame^] | 43 | import com.android.systemui.statusbar.StatusBarStateController; |
| 44 | import com.android.systemui.statusbar.notification.NotificationEntryManager; |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 45 | import com.android.systemui.statusbar.notification.VisualStabilityManager; |
Gus Prevas | ab33679 | 2018-11-14 13:52:20 -0500 | [diff] [blame^] | 46 | import com.android.systemui.statusbar.notification.logging.NotificationLogger; |
| 47 | import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager; |
| 48 | import com.android.systemui.statusbar.notification.row.NotificationGutsManager; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 49 | import com.android.systemui.statusbar.phone.DozeParameters; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 50 | import com.android.systemui.statusbar.phone.KeyguardBouncer; |
Milo Sredkov | b0f55e9 | 2018-04-04 16:13:28 +0100 | [diff] [blame] | 51 | import com.android.systemui.statusbar.phone.KeyguardDismissUtil; |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 52 | import com.android.systemui.statusbar.phone.LockIcon; |
Jorim Jaggi | e31f6b8 | 2016-07-01 16:15:09 -0700 | [diff] [blame] | 53 | import com.android.systemui.statusbar.phone.LockscreenWallpaper; |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame] | 54 | import com.android.systemui.statusbar.phone.NotificationGroupManager; |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 55 | import com.android.systemui.statusbar.phone.NotificationIconAreaController; |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 56 | import com.android.systemui.statusbar.phone.ScrimController; |
Yohei Yukawa | 795f010 | 2018-04-13 14:55:30 -0700 | [diff] [blame] | 57 | import com.android.systemui.statusbar.phone.ScrimState; |
Eliot Courtney | e77edea | 2017-11-15 14:25:21 +0900 | [diff] [blame] | 58 | import com.android.systemui.statusbar.phone.StatusBar; |
Xiaohui Chen | 311b98e | 2016-03-30 11:55:54 -0700 | [diff] [blame] | 59 | import com.android.systemui.statusbar.phone.StatusBarIconController; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 60 | import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; |
sanryhuang | 6378786 | 2018-05-18 15:57:43 +0800 | [diff] [blame] | 61 | import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler; |
Petr Cermak | 10011fa | 2018-02-05 19:00:54 +0000 | [diff] [blame] | 62 | import com.android.systemui.statusbar.policy.SmartReplyConstants; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 63 | |
Adrian Roos | a5c6322 | 2017-07-27 16:33:39 +0200 | [diff] [blame] | 64 | import java.util.function.Consumer; |
| 65 | |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 66 | /** |
| 67 | * Class factory to provide customizable SystemUI components. |
| 68 | */ |
| 69 | public class SystemUIFactory { |
| 70 | private static final String TAG = "SystemUIFactory"; |
| 71 | |
| 72 | static SystemUIFactory mFactory; |
| 73 | |
| 74 | public static SystemUIFactory getInstance() { |
| 75 | return mFactory; |
| 76 | } |
| 77 | |
| 78 | public static void createFromConfig(Context context) { |
| 79 | final String clsName = context.getString(R.string.config_systemUIFactoryComponent); |
| 80 | if (clsName == null || clsName.length() == 0) { |
| 81 | throw new RuntimeException("No SystemUIFactory component configured"); |
| 82 | } |
| 83 | |
| 84 | try { |
| 85 | Class<?> cls = null; |
| 86 | cls = context.getClassLoader().loadClass(clsName); |
| 87 | mFactory = (SystemUIFactory) cls.newInstance(); |
| 88 | } catch (Throwable t) { |
| 89 | Log.w(TAG, "Error creating SystemUIFactory component: " + clsName, t); |
| 90 | throw new RuntimeException(t); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | public SystemUIFactory() {} |
| 95 | |
| 96 | public StatusBarKeyguardViewManager createStatusBarKeyguardViewManager(Context context, |
| 97 | ViewMediatorCallback viewMediatorCallback, LockPatternUtils lockPatternUtils) { |
| 98 | return new StatusBarKeyguardViewManager(context, viewMediatorCallback, lockPatternUtils); |
| 99 | } |
| 100 | |
| 101 | public KeyguardBouncer createKeyguardBouncer(Context context, ViewMediatorCallback callback, |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 102 | LockPatternUtils lockPatternUtils, ViewGroup container, |
| 103 | DismissCallbackRegistry dismissCallbackRegistry, |
| 104 | KeyguardBouncer.BouncerExpansionCallback expansionCallback) { |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 105 | return new KeyguardBouncer(context, callback, lockPatternUtils, container, |
Lucas Dupin | 15a6b6c | 2018-04-16 14:50:20 +0800 | [diff] [blame] | 106 | dismissCallbackRegistry, FalsingManager.getInstance(context), expansionCallback); |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 107 | } |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 108 | |
shawnlin | 317db37 | 2018-04-09 19:49:48 +0800 | [diff] [blame] | 109 | public ScrimController createScrimController(ScrimView scrimBehind, ScrimView scrimInFront, |
Yohei Yukawa | 795f010 | 2018-04-13 14:55:30 -0700 | [diff] [blame] | 110 | LockscreenWallpaper lockscreenWallpaper, |
| 111 | TriConsumer<ScrimState, Float, GradientColors> scrimStateListener, |
Selim Cinek | 99e9adf | 2018-03-15 09:17:47 -0700 | [diff] [blame] | 112 | Consumer<Integer> scrimVisibleListener, DozeParameters dozeParameters, |
| 113 | AlarmManager alarmManager) { |
Yohei Yukawa | 795f010 | 2018-04-13 14:55:30 -0700 | [diff] [blame] | 114 | return new ScrimController(scrimBehind, scrimInFront, scrimStateListener, |
| 115 | scrimVisibleListener, dozeParameters, alarmManager); |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 116 | } |
Muyuan Li | 94ce94e | 2016-02-24 16:20:54 -0800 | [diff] [blame] | 117 | |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 118 | public NotificationIconAreaController createNotificationIconAreaController(Context context, |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 119 | StatusBar statusBar) { |
| 120 | return new NotificationIconAreaController(context, statusBar); |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 121 | } |
| 122 | |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 123 | public KeyguardIndicationController createKeyguardIndicationController(Context context, |
| 124 | ViewGroup indicationArea, LockIcon lockIcon) { |
| 125 | return new KeyguardIndicationController(context, indicationArea, lockIcon); |
| 126 | } |
| 127 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 128 | public QSTileHost createQSTileHost(Context context, StatusBar statusBar, |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 129 | StatusBarIconController iconController) { |
| 130 | return new QSTileHost(context, statusBar, iconController); |
Xiaohui Chen | 311b98e | 2016-03-30 11:55:54 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Adrian Roos | 09c43c8 | 2017-02-09 19:58:25 +0100 | [diff] [blame] | 133 | public void injectDependencies(ArrayMap<Object, DependencyProvider> providers, |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 134 | Context context) { |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 135 | providers.put(StatusBarStateController.class, StatusBarStateController::new); |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 136 | providers.put(NotificationLockscreenUserManager.class, |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 137 | () -> new NotificationLockscreenUserManagerImpl(context)); |
Eliot Courtney | 2b4c3a0 | 2017-11-27 13:27:46 +0900 | [diff] [blame] | 138 | providers.put(VisualStabilityManager.class, VisualStabilityManager::new); |
Eliot Courtney | 3985ad5 | 2017-11-17 16:51:52 +0900 | [diff] [blame] | 139 | providers.put(NotificationGroupManager.class, NotificationGroupManager::new); |
Eliot Courtney | a6d8cf2 | 2017-10-20 13:26:58 +0900 | [diff] [blame] | 140 | providers.put(NotificationMediaManager.class, () -> new NotificationMediaManager(context)); |
Eliot Courtney | 6c313d3 | 2017-12-14 19:57:51 +0900 | [diff] [blame] | 141 | providers.put(NotificationGutsManager.class, () -> new NotificationGutsManager(context)); |
Kevin | a97ea05 | 2018-09-11 13:53:18 -0700 | [diff] [blame] | 142 | providers.put(AmbientPulseManager.class, () -> new AmbientPulseManager(context)); |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 143 | providers.put(NotificationBlockingHelperManager.class, |
| 144 | () -> new NotificationBlockingHelperManager(context)); |
Eliot Courtney | e77edea | 2017-11-15 14:25:21 +0900 | [diff] [blame] | 145 | providers.put(NotificationRemoteInputManager.class, |
Eliot Courtney | 6c313d3 | 2017-12-14 19:57:51 +0900 | [diff] [blame] | 146 | () -> new NotificationRemoteInputManager(context)); |
Petr Cermak | 10011fa | 2018-02-05 19:00:54 +0000 | [diff] [blame] | 147 | providers.put(SmartReplyConstants.class, |
| 148 | () -> new SmartReplyConstants(Dependency.get(Dependency.MAIN_HANDLER), context)); |
Eliot Courtney | 6c313d3 | 2017-12-14 19:57:51 +0900 | [diff] [blame] | 149 | providers.put(NotificationListener.class, () -> new NotificationListener(context)); |
| 150 | providers.put(NotificationLogger.class, NotificationLogger::new); |
| 151 | providers.put(NotificationViewHierarchyManager.class, |
| 152 | () -> new NotificationViewHierarchyManager(context)); |
| 153 | providers.put(NotificationEntryManager.class, () -> new NotificationEntryManager(context)); |
Milo Sredkov | b0f55e9 | 2018-04-04 16:13:28 +0100 | [diff] [blame] | 154 | providers.put(KeyguardDismissUtil.class, KeyguardDismissUtil::new); |
Kenny Guy | a0f6de8 | 2018-04-06 16:20:16 +0100 | [diff] [blame] | 155 | providers.put(SmartReplyController.class, () -> new SmartReplyController()); |
sanryhuang | 6378786 | 2018-05-18 15:57:43 +0800 | [diff] [blame] | 156 | providers.put(RemoteInputQuickSettingsDisabler.class, |
| 157 | () -> new RemoteInputQuickSettingsDisabler(context)); |
Eliot Courtney | 0932228 | 2017-11-09 15:31:19 +0900 | [diff] [blame] | 158 | } |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 159 | } |