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