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 | |
Yao Chen | 634acb9 | 2016-04-13 16:17:47 -0700 | [diff] [blame] | 19 | import android.content.ComponentName; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 20 | import android.content.Context; |
| 21 | import android.util.Log; |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 22 | import android.view.View; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 23 | import android.view.ViewGroup; |
| 24 | |
| 25 | import com.android.internal.widget.LockPatternUtils; |
| 26 | import com.android.keyguard.ViewMediatorCallback; |
Annie Chin | 1ea4935 | 2016-05-27 15:23:35 -0700 | [diff] [blame] | 27 | import com.android.systemui.R; |
Annie Chin | 937a991 | 2016-05-31 10:14:23 -0700 | [diff] [blame] | 28 | import com.android.systemui.assist.AssistManager; |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame^] | 29 | import com.android.systemui.keyguard.DismissCallbackRegistry; |
Annie Chin | 937a991 | 2016-05-31 10:14:23 -0700 | [diff] [blame] | 30 | import com.android.systemui.statusbar.BaseStatusBar; |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 31 | import com.android.systemui.statusbar.ScrimView; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 32 | import com.android.systemui.statusbar.phone.KeyguardBouncer; |
Jorim Jaggi | e31f6b8 | 2016-07-01 16:15:09 -0700 | [diff] [blame] | 33 | import com.android.systemui.statusbar.phone.LockscreenWallpaper; |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 34 | import com.android.systemui.statusbar.phone.NotificationIconAreaController; |
| 35 | import com.android.systemui.statusbar.phone.PhoneStatusBar; |
Xiaohui Chen | 311b98e | 2016-03-30 11:55:54 -0700 | [diff] [blame] | 36 | import com.android.systemui.statusbar.phone.QSTileHost; |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 37 | import com.android.systemui.statusbar.phone.ScrimController; |
Xiaohui Chen | 311b98e | 2016-03-30 11:55:54 -0700 | [diff] [blame] | 38 | import com.android.systemui.statusbar.phone.StatusBarIconController; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 39 | import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; |
| 40 | import com.android.systemui.statusbar.phone.StatusBarWindowManager; |
Xiaohui Chen | 311b98e | 2016-03-30 11:55:54 -0700 | [diff] [blame] | 41 | import com.android.systemui.statusbar.policy.BatteryController; |
| 42 | import com.android.systemui.statusbar.policy.BluetoothController; |
| 43 | import com.android.systemui.statusbar.policy.CastController; |
| 44 | import com.android.systemui.statusbar.policy.FlashlightController; |
| 45 | import com.android.systemui.statusbar.policy.HotspotController; |
| 46 | import com.android.systemui.statusbar.policy.KeyguardMonitor; |
| 47 | import com.android.systemui.statusbar.policy.LocationController; |
| 48 | import com.android.systemui.statusbar.policy.NetworkController; |
| 49 | import com.android.systemui.statusbar.policy.NextAlarmController; |
| 50 | import com.android.systemui.statusbar.policy.RotationLockController; |
| 51 | import com.android.systemui.statusbar.policy.SecurityController; |
| 52 | import com.android.systemui.statusbar.policy.UserInfoController; |
| 53 | import com.android.systemui.statusbar.policy.UserSwitcherController; |
| 54 | import com.android.systemui.statusbar.policy.ZenModeController; |
Yao Chen | 634acb9 | 2016-04-13 16:17:47 -0700 | [diff] [blame] | 55 | import com.android.systemui.volume.VolumeDialogController; |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * Class factory to provide customizable SystemUI components. |
| 59 | */ |
| 60 | public class SystemUIFactory { |
| 61 | private static final String TAG = "SystemUIFactory"; |
| 62 | |
| 63 | static SystemUIFactory mFactory; |
| 64 | |
| 65 | public static SystemUIFactory getInstance() { |
| 66 | return mFactory; |
| 67 | } |
| 68 | |
| 69 | public static void createFromConfig(Context context) { |
| 70 | final String clsName = context.getString(R.string.config_systemUIFactoryComponent); |
| 71 | if (clsName == null || clsName.length() == 0) { |
| 72 | throw new RuntimeException("No SystemUIFactory component configured"); |
| 73 | } |
| 74 | |
| 75 | try { |
| 76 | Class<?> cls = null; |
| 77 | cls = context.getClassLoader().loadClass(clsName); |
| 78 | mFactory = (SystemUIFactory) cls.newInstance(); |
| 79 | } catch (Throwable t) { |
| 80 | Log.w(TAG, "Error creating SystemUIFactory component: " + clsName, t); |
| 81 | throw new RuntimeException(t); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | public SystemUIFactory() {} |
| 86 | |
| 87 | public StatusBarKeyguardViewManager createStatusBarKeyguardViewManager(Context context, |
| 88 | ViewMediatorCallback viewMediatorCallback, LockPatternUtils lockPatternUtils) { |
| 89 | return new StatusBarKeyguardViewManager(context, viewMediatorCallback, lockPatternUtils); |
| 90 | } |
| 91 | |
| 92 | public KeyguardBouncer createKeyguardBouncer(Context context, ViewMediatorCallback callback, |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame^] | 93 | LockPatternUtils lockPatternUtils, |
| 94 | ViewGroup container, DismissCallbackRegistry dismissCallbackRegistry) { |
| 95 | return new KeyguardBouncer(context, callback, lockPatternUtils, container, |
| 96 | dismissCallbackRegistry); |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 97 | } |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 98 | |
| 99 | public ScrimController createScrimController(ScrimView scrimBehind, ScrimView scrimInFront, |
Jorim Jaggi | e31f6b8 | 2016-07-01 16:15:09 -0700 | [diff] [blame] | 100 | View headsUpScrim, LockscreenWallpaper lockscreenWallpaper) { |
Selim Cinek | 2550325 | 2016-03-03 15:31:43 -0800 | [diff] [blame] | 101 | return new ScrimController(scrimBehind, scrimInFront, headsUpScrim); |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 102 | } |
Muyuan Li | 94ce94e | 2016-02-24 16:20:54 -0800 | [diff] [blame] | 103 | |
Yao Chen | 634acb9 | 2016-04-13 16:17:47 -0700 | [diff] [blame] | 104 | public VolumeDialogController createVolumeDialogController(Context context, |
| 105 | ComponentName name) { |
| 106 | return new VolumeDialogController(context, name); |
| 107 | } |
| 108 | |
Xiaohui Chen | eb04a99 | 2016-03-22 14:58:03 -0700 | [diff] [blame] | 109 | public NotificationIconAreaController createNotificationIconAreaController(Context context, |
| 110 | PhoneStatusBar phoneStatusBar) { |
| 111 | return new NotificationIconAreaController(context, phoneStatusBar); |
| 112 | } |
| 113 | |
Xiaohui Chen | 311b98e | 2016-03-30 11:55:54 -0700 | [diff] [blame] | 114 | public QSTileHost createQSTileHost(Context context, PhoneStatusBar statusBar, |
| 115 | BluetoothController bluetooth, LocationController location, |
| 116 | RotationLockController rotation, NetworkController network, |
| 117 | ZenModeController zen, HotspotController hotspot, |
| 118 | CastController cast, FlashlightController flashlight, |
| 119 | UserSwitcherController userSwitcher, UserInfoController userInfo, |
| 120 | KeyguardMonitor keyguard, SecurityController security, |
| 121 | BatteryController battery, StatusBarIconController iconController, |
| 122 | NextAlarmController nextAlarmController) { |
| 123 | return new QSTileHost(context, statusBar, bluetooth, location, rotation, network, zen, |
| 124 | hotspot, cast, flashlight, userSwitcher, userInfo, keyguard, security, battery, |
| 125 | iconController, nextAlarmController); |
| 126 | } |
| 127 | |
Muyuan Li | 94ce94e | 2016-02-24 16:20:54 -0800 | [diff] [blame] | 128 | public <T> T createInstance(Class<T> classType) { |
| 129 | return null; |
| 130 | } |
Annie Chin | 1ea4935 | 2016-05-27 15:23:35 -0700 | [diff] [blame] | 131 | |
Annie Chin | 937a991 | 2016-05-31 10:14:23 -0700 | [diff] [blame] | 132 | public AssistManager createAssistManager(BaseStatusBar bar, Context context) { |
| 133 | return new AssistManager(bar, context); |
| 134 | } |
Xiyuan Xia | 1b30f79 | 2016-01-06 08:50:30 -0800 | [diff] [blame] | 135 | } |