11b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia/* 21b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia * Copyright (C) 2016 The Android Open Source Project 31b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia * 41b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia * Licensed under the Apache License, Version 2.0 (the "License"); 51b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia * you may not use this file except in compliance with the License. 61b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia * You may obtain a copy of the License at 71b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia * 81b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia * http://www.apache.org/licenses/LICENSE-2.0 91b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia * 101b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia * Unless required by applicable law or agreed to in writing, software 111b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia * distributed under the License is distributed on an "AS IS" BASIS, 121b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia * See the License for the specific language governing permissions and 141b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia * limitations under the License 151b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia */ 161b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia 171b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xiapackage com.android.systemui; 181b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia 191b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xiaimport android.content.Context; 201b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xiaimport android.util.Log; 215da713599f4e83c99b5c52291c967c813350e669Xiaohui Chenimport android.view.View; 221b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xiaimport android.view.ViewGroup; 231b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia 241b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xiaimport com.android.internal.widget.LockPatternUtils; 251b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xiaimport com.android.keyguard.ViewMediatorCallback; 261ea49352cb01ffaac889c52de04571390d32fc31Annie Chinimport com.android.systemui.R; 27937a991be46c355f57dcb5cebf9ff645fe87633fAnnie Chinimport com.android.systemui.assist.AssistManager; 28937a991be46c355f57dcb5cebf9ff645fe87633fAnnie Chinimport com.android.systemui.statusbar.BaseStatusBar; 295da713599f4e83c99b5c52291c967c813350e669Xiaohui Chenimport com.android.systemui.statusbar.ScrimView; 301b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xiaimport com.android.systemui.statusbar.phone.KeyguardBouncer; 31e31f6b8024d1a0cfa71894e9a8ce1b39a9f85b2fJorim Jaggiimport com.android.systemui.statusbar.phone.LockscreenWallpaper; 32eb04a9992ea995eaf35a9afbdab060af7bd8e775Xiaohui Chenimport com.android.systemui.statusbar.phone.NotificationIconAreaController; 33eb04a9992ea995eaf35a9afbdab060af7bd8e775Xiaohui Chenimport com.android.systemui.statusbar.phone.PhoneStatusBar; 34311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chenimport com.android.systemui.statusbar.phone.QSTileHost; 355da713599f4e83c99b5c52291c967c813350e669Xiaohui Chenimport com.android.systemui.statusbar.phone.ScrimController; 36311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chenimport com.android.systemui.statusbar.phone.StatusBarIconController; 371b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xiaimport com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; 381b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xiaimport com.android.systemui.statusbar.phone.StatusBarWindowManager; 39311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chenimport com.android.systemui.statusbar.policy.BatteryController; 40311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chenimport com.android.systemui.statusbar.policy.BluetoothController; 41311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chenimport com.android.systemui.statusbar.policy.CastController; 42311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chenimport com.android.systemui.statusbar.policy.FlashlightController; 43311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chenimport com.android.systemui.statusbar.policy.HotspotController; 44311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chenimport com.android.systemui.statusbar.policy.KeyguardMonitor; 45311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chenimport com.android.systemui.statusbar.policy.LocationController; 46311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chenimport com.android.systemui.statusbar.policy.NetworkController; 47311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chenimport com.android.systemui.statusbar.policy.NextAlarmController; 48311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chenimport com.android.systemui.statusbar.policy.RotationLockController; 49311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chenimport com.android.systemui.statusbar.policy.SecurityController; 50311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chenimport com.android.systemui.statusbar.policy.UserInfoController; 51311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chenimport com.android.systemui.statusbar.policy.UserSwitcherController; 52311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chenimport com.android.systemui.statusbar.policy.ZenModeController; 531b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia 541b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia/** 551b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia * Class factory to provide customizable SystemUI components. 561b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia */ 571b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xiapublic class SystemUIFactory { 581b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia private static final String TAG = "SystemUIFactory"; 591b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia 601b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia static SystemUIFactory mFactory; 611b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia 621b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia public static SystemUIFactory getInstance() { 631b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia return mFactory; 641b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia } 651b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia 661b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia public static void createFromConfig(Context context) { 671b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia final String clsName = context.getString(R.string.config_systemUIFactoryComponent); 681b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia if (clsName == null || clsName.length() == 0) { 691b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia throw new RuntimeException("No SystemUIFactory component configured"); 701b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia } 711b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia 721b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia try { 731b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia Class<?> cls = null; 741b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia cls = context.getClassLoader().loadClass(clsName); 751b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia mFactory = (SystemUIFactory) cls.newInstance(); 761b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia } catch (Throwable t) { 771b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia Log.w(TAG, "Error creating SystemUIFactory component: " + clsName, t); 781b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia throw new RuntimeException(t); 791b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia } 801b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia } 811b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia 821b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia public SystemUIFactory() {} 831b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia 841b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia public StatusBarKeyguardViewManager createStatusBarKeyguardViewManager(Context context, 851b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia ViewMediatorCallback viewMediatorCallback, LockPatternUtils lockPatternUtils) { 861b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia return new StatusBarKeyguardViewManager(context, viewMediatorCallback, lockPatternUtils); 871b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia } 881b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia 891b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia public KeyguardBouncer createKeyguardBouncer(Context context, ViewMediatorCallback callback, 901b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia LockPatternUtils lockPatternUtils, StatusBarWindowManager windowManager, 911b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia ViewGroup container) { 921b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia return new KeyguardBouncer(context, callback, lockPatternUtils, windowManager, container); 931b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia } 945da713599f4e83c99b5c52291c967c813350e669Xiaohui Chen 955da713599f4e83c99b5c52291c967c813350e669Xiaohui Chen public ScrimController createScrimController(ScrimView scrimBehind, ScrimView scrimInFront, 96e31f6b8024d1a0cfa71894e9a8ce1b39a9f85b2fJorim Jaggi View headsUpScrim, LockscreenWallpaper lockscreenWallpaper) { 97255032591826a8a0373505a163d5c96d681541cfSelim Cinek return new ScrimController(scrimBehind, scrimInFront, headsUpScrim); 985da713599f4e83c99b5c52291c967c813350e669Xiaohui Chen } 9994ce94e96069ab6c2ece4864ba4c7692f3168352Muyuan Li 100eb04a9992ea995eaf35a9afbdab060af7bd8e775Xiaohui Chen public NotificationIconAreaController createNotificationIconAreaController(Context context, 101eb04a9992ea995eaf35a9afbdab060af7bd8e775Xiaohui Chen PhoneStatusBar phoneStatusBar) { 102eb04a9992ea995eaf35a9afbdab060af7bd8e775Xiaohui Chen return new NotificationIconAreaController(context, phoneStatusBar); 103eb04a9992ea995eaf35a9afbdab060af7bd8e775Xiaohui Chen } 104eb04a9992ea995eaf35a9afbdab060af7bd8e775Xiaohui Chen 105311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chen public QSTileHost createQSTileHost(Context context, PhoneStatusBar statusBar, 106311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chen BluetoothController bluetooth, LocationController location, 107311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chen RotationLockController rotation, NetworkController network, 108311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chen ZenModeController zen, HotspotController hotspot, 109311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chen CastController cast, FlashlightController flashlight, 110311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chen UserSwitcherController userSwitcher, UserInfoController userInfo, 111311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chen KeyguardMonitor keyguard, SecurityController security, 112311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chen BatteryController battery, StatusBarIconController iconController, 113311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chen NextAlarmController nextAlarmController) { 114311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chen return new QSTileHost(context, statusBar, bluetooth, location, rotation, network, zen, 115311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chen hotspot, cast, flashlight, userSwitcher, userInfo, keyguard, security, battery, 116311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chen iconController, nextAlarmController); 117311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chen } 118311b98eacd05bda69adcc9c5c80807abaff85fdfXiaohui Chen 11994ce94e96069ab6c2ece4864ba4c7692f3168352Muyuan Li public <T> T createInstance(Class<T> classType) { 12094ce94e96069ab6c2ece4864ba4c7692f3168352Muyuan Li return null; 12194ce94e96069ab6c2ece4864ba4c7692f3168352Muyuan Li } 1221ea49352cb01ffaac889c52de04571390d32fc31Annie Chin 123937a991be46c355f57dcb5cebf9ff645fe87633fAnnie Chin public AssistManager createAssistManager(BaseStatusBar bar, Context context) { 124937a991be46c355f57dcb5cebf9ff645fe87633fAnnie Chin return new AssistManager(bar, context); 125937a991be46c355f57dcb5cebf9ff645fe87633fAnnie Chin } 1261b30f79cffbe9e0c2b974fa3ee48001edcdd6c05Xiyuan Xia} 127