2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.tools.layoutlib.create;
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;
27 * Describes the work to be done by {@link AsmGenerator}.
29 public final class CreateInfo implements ICreateInfo {
32 * Returns the list of class from layoutlib_create to inject in layoutlib.
33 * The list can be empty but must not be null.
36 public Class<?>[] getInjectedClasses() {
37 return INJECTED_CLASSES;
41 * Returns the list of methods to rewrite as delegates.
42 * The list can be empty but must not be null.
45 public String[] getDelegateMethods() {
46 return DELEGATE_METHODS;
50 * Returns the list of classes on which to delegate all native methods.
51 * The list can be empty but must not be null.
54 public String[] getDelegateClassNatives() {
55 return DELEGATE_CLASS_NATIVES;
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.
63 * This usage is deprecated. Please use method 'delegates' instead.
66 public String[] getOverriddenMethods() {
67 return OVERRIDDEN_METHODS;
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.
76 public String[] getRenamedClasses() {
77 return RENAMED_CLASSES;
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.
88 public String[] getDeleteReturns() {
89 return DELETE_RETURNS;
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.
98 public String[] getJavaPkgClasses() {
99 return JAVA_PKG_CLASSES;
104 * The list of class from layoutlib_create to inject in layoutlib.
106 private final static Class<?>[] INJECTED_CLASSES = new Class<?>[] {
107 OverrideMethod.class,
108 MethodListener.class,
112 LayoutlibDelegate.class,
113 /* Java package classes */
116 IntegralToString.class,
117 UnsafeByteSequence.class,
122 * The list of methods to rewrite as delegates.
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",
152 * The list of classes on which to delegate all native methods.
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",
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.
208 private final static String[] OVERRIDDEN_METHODS = new String[] {
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.
215 private final static String[] RENAMED_CLASSES =
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",
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.
230 private final static String[] JAVA_PKG_CLASSES =
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",
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.
245 private final static String[] DELETE_RETURNS =
247 null }; // separator, for next class/methods list.