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