CreateInfo.java revision bc101806249eb883f89c4a770a8c27f9ac315837
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.tools.layoutlib.create; 18 19/** 20 * Describes the work to be done by {@link AsmGenerator}. 21 */ 22public final class CreateInfo implements ICreateInfo { 23 24 /** 25 * Returns the list of class from layoutlib_create to inject in layoutlib. 26 * The list can be empty but must not be null. 27 */ 28 public Class<?>[] getInjectedClasses() { 29 return INJECTED_CLASSES; 30 } 31 32 /** 33 * Returns the list of methods to rewrite as delegates. 34 * The list can be empty but must not be null. 35 */ 36 public String[] getDelegateMethods() { 37 return DELEGATE_METHODS; 38 } 39 40 /** 41 * Returns the list of classes on which to delegate all native methods. 42 * The list can be empty but must not be null. 43 */ 44 public String[] getDelegateClassNatives() { 45 return DELEGATE_CLASS_NATIVES; 46 } 47 48 /** 49 * Returns The list of methods to stub out. Each entry must be in the form 50 * "package.package.OuterClass$InnerClass#MethodName". 51 * The list can be empty but must not be null. 52 */ 53 public String[] getOverriddenMethods() { 54 return OVERRIDDEN_METHODS; 55 } 56 57 /** 58 * Returns the list of classes to rename, must be an even list: the binary FQCN 59 * of class to replace followed by the new FQCN. 60 * The list can be empty but must not be null. 61 */ 62 public String[] getRenamedClasses() { 63 return RENAMED_CLASSES; 64 } 65 66 /** 67 * Returns the list of classes for which the methods returning them should be deleted. 68 * The array contains a list of null terminated section starting with the name of the class 69 * to rename in which the methods are deleted, followed by a list of return types identifying 70 * the methods to delete. 71 * The list can be empty but must not be null. 72 */ 73 public String[] getDeleteReturns() { 74 return DELETE_RETURNS; 75 } 76 77 //----- 78 79 /** 80 * The list of class from layoutlib_create to inject in layoutlib. 81 */ 82 private final static Class<?>[] INJECTED_CLASSES = new Class<?>[] { 83 OverrideMethod.class, 84 MethodListener.class, 85 MethodAdapter.class, 86 CreateInfo.class 87 }; 88 89 /** 90 * The list of methods to rewrite as delegates. 91 */ 92 private final static String[] DELEGATE_METHODS = new String[] { 93 // TODO: comment out once DelegateClass is working 94 // "android.view.View#isInEditMode", 95 // "android.content.res.Resources$Theme#obtainStyledAttributes", 96 }; 97 98 /** 99 * The list of classes on which to delegate all native methods. 100 */ 101 private final static String[] DELEGATE_CLASS_NATIVES = new String[] { 102 // TODO: comment out once DelegateClass is working 103 // "android.graphics.Paint" 104 }; 105 106 /** 107 * The list of methods to stub out. Each entry must be in the form 108 * "package.package.OuterClass$InnerClass#MethodName". 109 */ 110 private final static String[] OVERRIDDEN_METHODS = new String[] { 111 // TODO: remove once DelegateClass is working 112 "android.view.View#isInEditMode", 113 "android.content.res.Resources$Theme#obtainStyledAttributes", 114 }; 115 116 /** 117 * The list of classes to rename, must be an even list: the binary FQCN 118 * of class to replace followed by the new FQCN. 119 */ 120 private final static String[] RENAMED_CLASSES = 121 new String[] { 122 "android.graphics.Bitmap", "android.graphics._Original_Bitmap", 123 "android.graphics.BitmapFactory", "android.graphics._Original_BitmapFactory", 124 "android.graphics.BitmapShader", "android.graphics._Original_BitmapShader", 125 "android.graphics.Canvas", "android.graphics._Original_Canvas", 126 "android.graphics.ComposeShader", "android.graphics._Original_ComposeShader", 127 "android.graphics.DashPathEffect", "android.graphics._Original_DashPathEffect", 128 "android.graphics.LinearGradient", "android.graphics._Original_LinearGradient", 129 "android.graphics.Matrix", "android.graphics._Original_Matrix", 130 "android.graphics.Paint", "android.graphics._Original_Paint", 131 "android.graphics.Path", "android.graphics._Original_Path", 132 "android.graphics.PorterDuffXfermode", "android.graphics._Original_PorterDuffXfermode", 133 "android.graphics.RadialGradient", "android.graphics._Original_RadialGradient", 134 "android.graphics.Shader", "android.graphics._Original_Shader", 135 "android.graphics.SweepGradient", "android.graphics._Original_SweepGradient", 136 "android.graphics.Typeface", "android.graphics._Original_Typeface", 137 "android.os.ServiceManager", "android.os._Original_ServiceManager", 138 "android.util.FloatMath", "android.util._Original_FloatMath", 139 "android.view.SurfaceView", "android.view._Original_SurfaceView", 140 "android.view.accessibility.AccessibilityManager", "android.view.accessibility._Original_AccessibilityManager", 141 }; 142 143 /** 144 * List of classes for which the methods returning them should be deleted. 145 * The array contains a list of null terminated section starting with the name of the class 146 * to rename in which the methods are deleted, followed by a list of return types identifying 147 * the methods to delete. 148 */ 149 private final static String[] DELETE_RETURNS = 150 new String[] { 151 "android.graphics.Paint", // class to delete methods from 152 "android.graphics.Paint$Align", // list of type identifying methods to delete 153 "android.graphics.Paint$Style", 154 "android.graphics.Paint$Join", 155 "android.graphics.Paint$Cap", 156 "android.graphics.Paint$FontMetrics", 157 "android.graphics.Paint$FontMetricsInt", 158 null }; // separator, for next class/methods list. 159} 160 161