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.statusbar.ScrimView; 27 import com.android.systemui.statusbar.phone.KeyguardBouncer; 28 import com.android.systemui.statusbar.phone.NotificationIconAreaController; 29 import com.android.systemui.statusbar.phone.PhoneStatusBar; 30 import com.android.systemui.statusbar.phone.QSTileHost; 31 import com.android.systemui.statusbar.phone.ScrimController; 32 import com.android.systemui.statusbar.phone.StatusBarIconController; 33 import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; 34 import com.android.systemui.statusbar.phone.StatusBarWindowManager; 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; 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 getInstance()58 public static SystemUIFactory getInstance() { 59 return mFactory; 60 } 61 createFromConfig(Context context)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 SystemUIFactory()78 public SystemUIFactory() {} 79 createStatusBarKeyguardViewManager(Context context, ViewMediatorCallback viewMediatorCallback, LockPatternUtils lockPatternUtils)80 public StatusBarKeyguardViewManager createStatusBarKeyguardViewManager(Context context, 81 ViewMediatorCallback viewMediatorCallback, LockPatternUtils lockPatternUtils) { 82 return new StatusBarKeyguardViewManager(context, viewMediatorCallback, lockPatternUtils); 83 } 84 createKeyguardBouncer(Context context, ViewMediatorCallback callback, LockPatternUtils lockPatternUtils, StatusBarWindowManager windowManager, ViewGroup container)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 } 90 createScrimController(ScrimView scrimBehind, ScrimView scrimInFront, View headsUpScrim)91 public ScrimController createScrimController(ScrimView scrimBehind, ScrimView scrimInFront, 92 View headsUpScrim) { 93 return new ScrimController(scrimBehind, scrimInFront, headsUpScrim); 94 } 95 createNotificationIconAreaController(Context context, PhoneStatusBar phoneStatusBar)96 public NotificationIconAreaController createNotificationIconAreaController(Context context, 97 PhoneStatusBar phoneStatusBar) { 98 return new NotificationIconAreaController(context, phoneStatusBar); 99 } 100 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)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 createInstance(Class<T> classType)115 public <T> T createInstance(Class<T> classType) { 116 return null; 117 } 118 } 119