blob: 41cce74a31dcd0c5ff54c9f3ca9a4f943a203ffe [file] [log] [blame]
Xiyuan Xia1b30f792016-01-06 08:50:30 -08001/*
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
17package com.android.systemui;
18
19import android.content.Context;
20import android.util.Log;
Xiaohui Chen5da71352016-02-22 10:04:41 -080021import android.view.View;
Xiyuan Xia1b30f792016-01-06 08:50:30 -080022import android.view.ViewGroup;
23
24import com.android.internal.widget.LockPatternUtils;
25import com.android.keyguard.ViewMediatorCallback;
Xiaohui Chen5da71352016-02-22 10:04:41 -080026import com.android.systemui.statusbar.ScrimView;
Xiyuan Xia1b30f792016-01-06 08:50:30 -080027import com.android.systemui.statusbar.phone.KeyguardBouncer;
Xiaohui Chen5da71352016-02-22 10:04:41 -080028import com.android.systemui.statusbar.phone.ScrimController;
Xiyuan Xia1b30f792016-01-06 08:50:30 -080029import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
30import com.android.systemui.statusbar.phone.StatusBarWindowManager;
31
32/**
33 * Class factory to provide customizable SystemUI components.
34 */
35public class SystemUIFactory {
36 private static final String TAG = "SystemUIFactory";
37
38 static SystemUIFactory mFactory;
39
40 public static SystemUIFactory getInstance() {
41 return mFactory;
42 }
43
44 public static void createFromConfig(Context context) {
45 final String clsName = context.getString(R.string.config_systemUIFactoryComponent);
46 if (clsName == null || clsName.length() == 0) {
47 throw new RuntimeException("No SystemUIFactory component configured");
48 }
49
50 try {
51 Class<?> cls = null;
52 cls = context.getClassLoader().loadClass(clsName);
53 mFactory = (SystemUIFactory) cls.newInstance();
54 } catch (Throwable t) {
55 Log.w(TAG, "Error creating SystemUIFactory component: " + clsName, t);
56 throw new RuntimeException(t);
57 }
58 }
59
60 public SystemUIFactory() {}
61
62 public StatusBarKeyguardViewManager createStatusBarKeyguardViewManager(Context context,
63 ViewMediatorCallback viewMediatorCallback, LockPatternUtils lockPatternUtils) {
64 return new StatusBarKeyguardViewManager(context, viewMediatorCallback, lockPatternUtils);
65 }
66
67 public KeyguardBouncer createKeyguardBouncer(Context context, ViewMediatorCallback callback,
68 LockPatternUtils lockPatternUtils, StatusBarWindowManager windowManager,
69 ViewGroup container) {
70 return new KeyguardBouncer(context, callback, lockPatternUtils, windowManager, container);
71 }
Xiaohui Chen5da71352016-02-22 10:04:41 -080072
73 public ScrimController createScrimController(ScrimView scrimBehind, ScrimView scrimInFront,
74 View headsUpScrim, boolean scrimSrcEnabled) {
75 return new ScrimController(scrimBehind, scrimInFront, headsUpScrim, scrimSrcEnabled);
76 }
Xiyuan Xia1b30f792016-01-06 08:50:30 -080077}