OSDN Git Service

am 09c3c2ed: am ba31d628: am db94ea9e: am f970d2c2: am 79c3f678: am 206c691b: am...
[android-x86/frameworks-base.git] / tools / layoutlib / create / src / com / android / tools / layoutlib / create / CreateInfo.java
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
17 package com.android.tools.layoutlib.create;
18
19 import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
20 import com.android.tools.layoutlib.java.AutoCloseable;
21 import com.android.tools.layoutlib.java.Charsets;
22 import com.android.tools.layoutlib.java.IntegralToString;
23 import com.android.tools.layoutlib.java.Objects;
24 import com.android.tools.layoutlib.java.UnsafeByteSequence;
25
26 /**
27  * Describes the work to be done by {@link AsmGenerator}.
28  */
29 public final class CreateInfo implements ICreateInfo {
30
31     /**
32      * Returns the list of class from layoutlib_create to inject in layoutlib.
33      * The list can be empty but must not be null.
34      */
35     @Override
36     public Class<?>[] getInjectedClasses() {
37         return INJECTED_CLASSES;
38     }
39
40     /**
41      * Returns the list of methods to rewrite as delegates.
42      * The list can be empty but must not be null.
43      */
44     @Override
45     public String[] getDelegateMethods() {
46         return DELEGATE_METHODS;
47     }
48
49     /**
50      * Returns the list of classes on which to delegate all native methods.
51      * The list can be empty but must not be null.
52      */
53     @Override
54     public String[] getDelegateClassNatives() {
55         return DELEGATE_CLASS_NATIVES;
56     }
57
58     /**
59      * Returns The list of methods to stub out. Each entry must be in the form
60      * "package.package.OuterClass$InnerClass#MethodName".
61      * The list can be empty but must not be null.
62      * <p/>
63      * This usage is deprecated. Please use method 'delegates' instead.
64      */
65     @Override
66     public String[] getOverriddenMethods() {
67         return OVERRIDDEN_METHODS;
68     }
69
70     /**
71      * Returns the list of classes to rename, must be an even list: the binary FQCN
72      * of class to replace followed by the new FQCN.
73      * The list can be empty but must not be null.
74      */
75     @Override
76     public String[] getRenamedClasses() {
77         return RENAMED_CLASSES;
78     }
79
80     /**
81      * Returns the list of classes for which the methods returning them should be deleted.
82      * The array contains a list of null terminated section starting with the name of the class
83      * to rename in which the methods are deleted, followed by a list of return types identifying
84      * the methods to delete.
85      * The list can be empty but must not be null.
86      */
87     @Override
88     public String[] getDeleteReturns() {
89         return DELETE_RETURNS;
90     }
91
92     /**
93      * Returns the list of classes to refactor, must be an even list: the binary FQCN of class to
94      * replace followed by the new FQCN. All references to the old class should be updated to the
95      * new class. The list can be empty but must not be null.
96      */
97     @Override
98     public String[] getJavaPkgClasses() {
99       return JAVA_PKG_CLASSES;
100     }
101     //-----
102
103     /**
104      * The list of class from layoutlib_create to inject in layoutlib.
105      */
106     private final static Class<?>[] INJECTED_CLASSES = new Class<?>[] {
107             OverrideMethod.class,
108             MethodListener.class,
109             MethodAdapter.class,
110             ICreateInfo.class,
111             CreateInfo.class,
112             LayoutlibDelegate.class,
113             /* Java package classes */
114             AutoCloseable.class,
115             Objects.class,
116             IntegralToString.class,
117             UnsafeByteSequence.class,
118             Charsets.class,
119         };
120
121     /**
122      * The list of methods to rewrite as delegates.
123      */
124     public final static String[] DELEGATE_METHODS = new String[] {
125         "android.app.Fragment#instantiate", //(Landroid/content/Context;Ljava/lang/String;Landroid/os/Bundle;)Landroid/app/Fragment;",
126         "android.content.res.Resources$Theme#obtainStyledAttributes",
127         "android.content.res.Resources$Theme#resolveAttribute",
128         "android.content.res.AssetManager#newTheme",
129         "android.content.res.AssetManager#deleteTheme",
130         "android.content.res.AssetManager#applyThemeStyle",
131         "android.content.res.TypedArray#getValueAt",
132         "android.graphics.BitmapFactory#finishDecode",
133         "android.os.Handler#sendMessageAtTime",
134         "android.os.HandlerThread#run",
135         "android.text.format.DateFormat#is24HourFormat",
136         "android.view.Choreographer#getRefreshRate",
137         "android.view.Display#updateDisplayInfoLocked",
138         "android.view.Display#getWindowManager",
139         "android.view.LayoutInflater#rInflate",
140         "android.view.LayoutInflater#parseInclude",
141         "android.view.View#isInEditMode",
142         "android.view.ViewRootImpl#isInTouchMode",
143         "android.view.WindowManagerGlobal#getWindowManagerService",
144         "android.view.inputmethod.InputMethodManager#getInstance",
145         "android.view.MenuInflater#registerMenu",
146         "com.android.internal.view.menu.MenuBuilder#createNewMenuItem",
147         "com.android.internal.util.XmlUtils#convertValueToInt",
148         "com.android.internal.textservice.ITextServicesManager$Stub#asInterface",
149     };
150
151     /**
152      * The list of classes on which to delegate all native methods.
153      */
154     public final static String[] DELEGATE_CLASS_NATIVES = new String[] {
155         "android.animation.PropertyValuesHolder",
156         "android.graphics.AvoidXfermode",
157         "android.graphics.Bitmap",
158         "android.graphics.BitmapFactory",
159         "android.graphics.BitmapShader",
160         "android.graphics.BlurMaskFilter",
161         "android.graphics.Canvas",
162         "android.graphics.ColorFilter",
163         "android.graphics.ColorMatrixColorFilter",
164         "android.graphics.ComposePathEffect",
165         "android.graphics.ComposeShader",
166         "android.graphics.CornerPathEffect",
167         "android.graphics.DashPathEffect",
168         "android.graphics.DiscretePathEffect",
169         "android.graphics.DrawFilter",
170         "android.graphics.EmbossMaskFilter",
171         "android.graphics.LayerRasterizer",
172         "android.graphics.LightingColorFilter",
173         "android.graphics.LinearGradient",
174         "android.graphics.MaskFilter",
175         "android.graphics.Matrix",
176         "android.graphics.NinePatch",
177         "android.graphics.Paint",
178         "android.graphics.PaintFlagsDrawFilter",
179         "android.graphics.Path",
180         "android.graphics.PathDashPathEffect",
181         "android.graphics.PathEffect",
182         "android.graphics.PixelXorXfermode",
183         "android.graphics.PorterDuffColorFilter",
184         "android.graphics.PorterDuffXfermode",
185         "android.graphics.RadialGradient",
186         "android.graphics.Rasterizer",
187         "android.graphics.Region",
188         "android.graphics.Shader",
189         "android.graphics.SumPathEffect",
190         "android.graphics.SweepGradient",
191         "android.graphics.Typeface",
192         "android.graphics.Xfermode",
193         "android.os.SystemClock",
194         "android.os.SystemProperties",
195         "android.text.AndroidBidi",
196         "android.text.format.Time",
197         "android.util.FloatMath",
198         "android.view.Display",
199         "libcore.icu.DateIntervalFormat",
200         "libcore.icu.ICU",
201     };
202
203     /**
204      * The list of methods to stub out. Each entry must be in the form
205      *  "package.package.OuterClass$InnerClass#MethodName".
206      *  This usage is deprecated. Please use method 'delegates' instead.
207      */
208     private final static String[] OVERRIDDEN_METHODS = new String[] {
209     };
210
211     /**
212      *  The list of classes to rename, must be an even list: the binary FQCN
213      *  of class to replace followed by the new FQCN.
214      */
215     private final static String[] RENAMED_CLASSES =
216         new String[] {
217             "android.os.ServiceManager",                       "android.os._Original_ServiceManager",
218             "android.util.LruCache",                           "android.util._Original_LruCache",
219             "android.view.SurfaceView",                        "android.view._Original_SurfaceView",
220             "android.view.accessibility.AccessibilityManager", "android.view.accessibility._Original_AccessibilityManager",
221             "android.webkit.WebView",                          "android.webkit._Original_WebView",
222             "com.android.internal.policy.PolicyManager",       "com.android.internal.policy._Original_PolicyManager",
223         };
224
225     /**
226      * The list of class references to update, must be an even list: the binary
227      * FQCN of class to replace followed by the new FQCN. The classes to
228      * replace are to be excluded from the output.
229      */
230     private final static String[] JAVA_PKG_CLASSES =
231         new String[] {
232             "java.lang.AutoCloseable",                         "com.android.tools.layoutlib.java.AutoCloseable",
233             "java.util.Objects",                               "com.android.tools.layoutlib.java.Objects",
234             "java.nio.charset.Charsets",                       "com.android.tools.layoutlib.java.Charsets",
235             "java.lang.IntegralToString",                      "com.android.tools.layoutlib.java.IntegralToString",
236             "java.lang.UnsafeByteSequence",                    "com.android.tools.layoutlib.java.UnsafeByteSequence",
237         };
238
239     /**
240      * List of classes for which the methods returning them should be deleted.
241      * The array contains a list of null terminated section starting with the name of the class
242      * to rename in which the methods are deleted, followed by a list of return types identifying
243      * the methods to delete.
244      */
245     private final static String[] DELETE_RETURNS =
246         new String[] {
247             null };                         // separator, for next class/methods list.
248 }
249