blob: 681b39e1ba4381cc2d566c31fc9612c00e9d9038 [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;
21import android.view.ViewGroup;
22
23import com.android.internal.widget.LockPatternUtils;
24import com.android.keyguard.ViewMediatorCallback;
25import com.android.systemui.statusbar.phone.KeyguardBouncer;
26import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
27import com.android.systemui.statusbar.phone.StatusBarWindowManager;
28
29/**
30 * Class factory to provide customizable SystemUI components.
31 */
32public class SystemUIFactory {
33 private static final String TAG = "SystemUIFactory";
34
35 static SystemUIFactory mFactory;
36
37 public static SystemUIFactory getInstance() {
38 return mFactory;
39 }
40
41 public static void createFromConfig(Context context) {
42 final String clsName = context.getString(R.string.config_systemUIFactoryComponent);
43 if (clsName == null || clsName.length() == 0) {
44 throw new RuntimeException("No SystemUIFactory component configured");
45 }
46
47 try {
48 Class<?> cls = null;
49 cls = context.getClassLoader().loadClass(clsName);
50 mFactory = (SystemUIFactory) cls.newInstance();
51 } catch (Throwable t) {
52 Log.w(TAG, "Error creating SystemUIFactory component: " + clsName, t);
53 throw new RuntimeException(t);
54 }
55 }
56
57 public SystemUIFactory() {}
58
59 public StatusBarKeyguardViewManager createStatusBarKeyguardViewManager(Context context,
60 ViewMediatorCallback viewMediatorCallback, LockPatternUtils lockPatternUtils) {
61 return new StatusBarKeyguardViewManager(context, viewMediatorCallback, lockPatternUtils);
62 }
63
64 public KeyguardBouncer createKeyguardBouncer(Context context, ViewMediatorCallback callback,
65 LockPatternUtils lockPatternUtils, StatusBarWindowManager windowManager,
66 ViewGroup container) {
67 return new KeyguardBouncer(context, callback, lockPatternUtils, windowManager, container);
68 }
69}