• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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;
21 import android.view.View;
22 import android.view.ViewGroup;
23 
24 import com.android.internal.widget.LockPatternUtils;
25 import com.android.keyguard.ViewMediatorCallback;
26 import com.android.systemui.R;
27 import com.android.systemui.assist.AssistManager;
28 import com.android.systemui.statusbar.BaseStatusBar;
29 import com.android.systemui.statusbar.ScrimView;
30 import com.android.systemui.statusbar.phone.KeyguardBouncer;
31 import com.android.systemui.statusbar.phone.LockscreenWallpaper;
32 import com.android.systemui.statusbar.phone.NotificationIconAreaController;
33 import com.android.systemui.statusbar.phone.PhoneStatusBar;
34 import com.android.systemui.statusbar.phone.QSTileHost;
35 import com.android.systemui.statusbar.phone.ScrimController;
36 import com.android.systemui.statusbar.phone.StatusBarIconController;
37 import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
38 import com.android.systemui.statusbar.phone.StatusBarWindowManager;
39 import com.android.systemui.statusbar.policy.BatteryController;
40 import com.android.systemui.statusbar.policy.BluetoothController;
41 import com.android.systemui.statusbar.policy.CastController;
42 import com.android.systemui.statusbar.policy.FlashlightController;
43 import com.android.systemui.statusbar.policy.HotspotController;
44 import com.android.systemui.statusbar.policy.KeyguardMonitor;
45 import com.android.systemui.statusbar.policy.LocationController;
46 import com.android.systemui.statusbar.policy.NetworkController;
47 import com.android.systemui.statusbar.policy.NextAlarmController;
48 import com.android.systemui.statusbar.policy.RotationLockController;
49 import com.android.systemui.statusbar.policy.SecurityController;
50 import com.android.systemui.statusbar.policy.UserInfoController;
51 import com.android.systemui.statusbar.policy.UserSwitcherController;
52 import com.android.systemui.statusbar.policy.ZenModeController;
53 
54 /**
55  * Class factory to provide customizable SystemUI components.
56  */
57 public class SystemUIFactory {
58     private static final String TAG = "SystemUIFactory";
59 
60     static SystemUIFactory mFactory;
61 
getInstance()62     public static SystemUIFactory getInstance() {
63         return mFactory;
64     }
65 
createFromConfig(Context context)66     public static void createFromConfig(Context context) {
67         final String clsName = context.getString(R.string.config_systemUIFactoryComponent);
68         if (clsName == null || clsName.length() == 0) {
69             throw new RuntimeException("No SystemUIFactory component configured");
70         }
71 
72         try {
73             Class<?> cls = null;
74             cls = context.getClassLoader().loadClass(clsName);
75             mFactory = (SystemUIFactory) cls.newInstance();
76         } catch (Throwable t) {
77             Log.w(TAG, "Error creating SystemUIFactory component: " + clsName, t);
78             throw new RuntimeException(t);
79         }
80     }
81 
SystemUIFactory()82     public SystemUIFactory() {}
83 
createStatusBarKeyguardViewManager(Context context, ViewMediatorCallback viewMediatorCallback, LockPatternUtils lockPatternUtils)84     public StatusBarKeyguardViewManager createStatusBarKeyguardViewManager(Context context,
85             ViewMediatorCallback viewMediatorCallback, LockPatternUtils lockPatternUtils) {
86         return new StatusBarKeyguardViewManager(context, viewMediatorCallback, lockPatternUtils);
87     }
88 
createKeyguardBouncer(Context context, ViewMediatorCallback callback, LockPatternUtils lockPatternUtils, StatusBarWindowManager windowManager, ViewGroup container)89     public KeyguardBouncer createKeyguardBouncer(Context context, ViewMediatorCallback callback,
90             LockPatternUtils lockPatternUtils, StatusBarWindowManager windowManager,
91             ViewGroup container) {
92         return new KeyguardBouncer(context, callback, lockPatternUtils, windowManager, container);
93     }
94 
createScrimController(ScrimView scrimBehind, ScrimView scrimInFront, View headsUpScrim, LockscreenWallpaper lockscreenWallpaper)95     public ScrimController createScrimController(ScrimView scrimBehind, ScrimView scrimInFront,
96             View headsUpScrim, LockscreenWallpaper lockscreenWallpaper) {
97         return new ScrimController(scrimBehind, scrimInFront, headsUpScrim);
98     }
99 
createNotificationIconAreaController(Context context, PhoneStatusBar phoneStatusBar)100     public NotificationIconAreaController createNotificationIconAreaController(Context context,
101             PhoneStatusBar phoneStatusBar) {
102         return new NotificationIconAreaController(context, phoneStatusBar);
103     }
104 
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)105     public QSTileHost createQSTileHost(Context context, PhoneStatusBar statusBar,
106             BluetoothController bluetooth, LocationController location,
107             RotationLockController rotation, NetworkController network,
108             ZenModeController zen, HotspotController hotspot,
109             CastController cast, FlashlightController flashlight,
110             UserSwitcherController userSwitcher, UserInfoController userInfo,
111             KeyguardMonitor keyguard, SecurityController security,
112             BatteryController battery, StatusBarIconController iconController,
113             NextAlarmController nextAlarmController) {
114         return new QSTileHost(context, statusBar, bluetooth, location, rotation, network, zen,
115                 hotspot, cast, flashlight, userSwitcher, userInfo, keyguard, security, battery,
116                 iconController, nextAlarmController);
117     }
118 
createInstance(Class<T> classType)119     public <T> T createInstance(Class<T> classType) {
120         return null;
121     }
122 
createAssistManager(BaseStatusBar bar, Context context)123     public AssistManager createAssistManager(BaseStatusBar bar, Context context) {
124         return new AssistManager(bar, context);
125     }
126 }
127