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