2 | * Copyright (C) 2008 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.internal.policy.impl; |
18 |
|
19 | import android.content.Context; |
20 | import android.util.Log; |
21 |
|
22 | import com.android.internal.policy.IPolicy; |
23 | import com.android.internal.policy.impl.PhoneLayoutInflater; |
24 | import com.android.internal.policy.impl.PhoneWindow; |
25 | import com.android.internal.policy.impl.PhoneWindowManager; |
26 |
|
27 | /** |
28 | * {@hide} |
29 | */ |
30 |
|
31 | // Simple implementation of the policy interface that spawns the right |
32 | // set of objects |
33 | public class Policy implements IPolicy { |
34 | private static final String TAG = "PhonePolicy"; |
35 |
|
36 | private static final String[] preload_classes = { |
37 | "com.android.internal.policy.impl.PhoneLayoutInflater", |
38 | "com.android.internal.policy.impl.PhoneWindow", |
39 | "com.android.internal.policy.impl.PhoneWindow$1", |
40 | "com.android.internal.policy.impl.PhoneWindow$ContextMenuCallback", |
41 | "com.android.internal.policy.impl.PhoneWindow$DecorView", |
42 | "com.android.internal.policy.impl.PhoneWindow$PanelFeatureState", |
43 | "com.android.internal.policy.impl.PhoneWindow$PanelFeatureState$SavedState", |
44 | }; |
45 |
|
46 | static { |
47 | // For performance reasons, preload some policy specific classes when |
48 | // the policy gets loaded. |
49 | for (String s : preload_classes) { |
50 | try { |
51 | Class.forName(s); |
52 | } catch (ClassNotFoundException ex) { |
53 | Log.e(TAG, "Could not preload class for phone policy: " + s); |
54 | } |
55 | } |
56 | } |
57 |
|
58 | public PhoneWindow makeNewWindow(Context context) { |
59 | return new PhoneWindow(context); |
60 | } |
61 |
|
62 | public PhoneLayoutInflater makeNewLayoutInflater(Context context) { |
63 | return new PhoneLayoutInflater(context); |
64 | } |
65 |
|
66 | public PhoneWindowManager makeNewWindowManager() { |
67 | return new PhoneWindowManager(); |
68 | } |
69 | } |