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