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.ArrayMap;
21 import android.util.Log;
22 import android.view.View;
23 import android.view.ViewGroup;
24 
25 import com.android.internal.widget.LockPatternUtils;
26 import com.android.keyguard.ViewMediatorCallback;
27 import com.android.systemui.Dependency.DependencyProvider;
28 import com.android.systemui.keyguard.DismissCallbackRegistry;
29 import com.android.systemui.statusbar.KeyguardIndicationController;
30 import com.android.systemui.statusbar.ScrimView;
31 import com.android.systemui.statusbar.phone.KeyguardBouncer;
32 import com.android.systemui.statusbar.phone.LightBarController;
33 import com.android.systemui.statusbar.phone.LockIcon;
34 import com.android.systemui.statusbar.phone.LockscreenWallpaper;
35 import com.android.systemui.statusbar.phone.NotificationIconAreaController;
36 import com.android.systemui.statusbar.phone.StatusBar;
37 import com.android.systemui.qs.QSTileHost;
38 import com.android.systemui.statusbar.phone.ScrimController;
39 import com.android.systemui.statusbar.phone.StatusBarIconController;
40 import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
41 import com.android.systemui.volume.VolumeDialogControllerImpl;
42 
43 /**
44  * Class factory to provide customizable SystemUI components.
45  */
46 public class SystemUIFactory {
47     private static final String TAG = "SystemUIFactory";
48 
49     static SystemUIFactory mFactory;
50 
getInstance()51     public static SystemUIFactory getInstance() {
52         return mFactory;
53     }
54 
createFromConfig(Context context)55     public static void createFromConfig(Context context) {
56         final String clsName = context.getString(R.string.config_systemUIFactoryComponent);
57         if (clsName == null || clsName.length() == 0) {
58             throw new RuntimeException("No SystemUIFactory component configured");
59         }
60 
61         try {
62             Class<?> cls = null;
63             cls = context.getClassLoader().loadClass(clsName);
64             mFactory = (SystemUIFactory) cls.newInstance();
65         } catch (Throwable t) {
66             Log.w(TAG, "Error creating SystemUIFactory component: " + clsName, t);
67             throw new RuntimeException(t);
68         }
69     }
70 
SystemUIFactory()71     public SystemUIFactory() {}
72 
createStatusBarKeyguardViewManager(Context context, ViewMediatorCallback viewMediatorCallback, LockPatternUtils lockPatternUtils)73     public StatusBarKeyguardViewManager createStatusBarKeyguardViewManager(Context context,
74             ViewMediatorCallback viewMediatorCallback, LockPatternUtils lockPatternUtils) {
75         return new StatusBarKeyguardViewManager(context, viewMediatorCallback, lockPatternUtils);
76     }
77 
createKeyguardBouncer(Context context, ViewMediatorCallback callback, LockPatternUtils lockPatternUtils, ViewGroup container, DismissCallbackRegistry dismissCallbackRegistry)78     public KeyguardBouncer createKeyguardBouncer(Context context, ViewMediatorCallback callback,
79             LockPatternUtils lockPatternUtils,
80             ViewGroup container, DismissCallbackRegistry dismissCallbackRegistry) {
81         return new KeyguardBouncer(context, callback, lockPatternUtils, container,
82                 dismissCallbackRegistry);
83     }
84 
createScrimController(LightBarController lightBarController, ScrimView scrimBehind, ScrimView scrimInFront, View headsUpScrim, LockscreenWallpaper lockscreenWallpaper)85     public ScrimController createScrimController(LightBarController lightBarController,
86             ScrimView scrimBehind, ScrimView scrimInFront, View headsUpScrim,
87             LockscreenWallpaper lockscreenWallpaper) {
88         return new ScrimController(lightBarController, scrimBehind, scrimInFront, headsUpScrim);
89     }
90 
createNotificationIconAreaController(Context context, StatusBar statusBar)91     public NotificationIconAreaController createNotificationIconAreaController(Context context,
92             StatusBar statusBar) {
93         return new NotificationIconAreaController(context, statusBar);
94     }
95 
createKeyguardIndicationController(Context context, ViewGroup indicationArea, LockIcon lockIcon)96     public KeyguardIndicationController createKeyguardIndicationController(Context context,
97             ViewGroup indicationArea, LockIcon lockIcon) {
98         return new KeyguardIndicationController(context, indicationArea, lockIcon);
99     }
100 
createQSTileHost(Context context, StatusBar statusBar, StatusBarIconController iconController)101     public QSTileHost createQSTileHost(Context context, StatusBar statusBar,
102             StatusBarIconController iconController) {
103         return new QSTileHost(context, statusBar, iconController);
104     }
105 
createInstance(Class<T> classType)106     public <T> T createInstance(Class<T> classType) {
107         return null;
108     }
109 
injectDependencies(ArrayMap<Object, DependencyProvider> providers, Context context)110     public void injectDependencies(ArrayMap<Object, DependencyProvider> providers,
111             Context context) { }
112 }
113