Home | History | Annotate | Download | only in create
      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 
     21 /**
     22  * Describes the work to be done by {@link AsmGenerator}.
     23  */
     24 public final class CreateInfo implements ICreateInfo {
     25 
     26     /**
     27      * Returns the list of class from layoutlib_create to inject in layoutlib.
     28      * The list can be empty but must not be null.
     29      */
     30     @Override
     31     public Class<?>[] getInjectedClasses() {
     32         return INJECTED_CLASSES;
     33     }
     34 
     35     /**
     36      * Returns the list of methods to rewrite as delegates.
     37      * The list can be empty but must not be null.
     38      */
     39     @Override
     40     public String[] getDelegateMethods() {
     41         return DELEGATE_METHODS;
     42     }
     43 
     44     /**
     45      * Returns the list of classes on which to delegate all native methods.
     46      * The list can be empty but must not be null.
     47      */
     48     @Override
     49     public String[] getDelegateClassNatives() {
     50         return DELEGATE_CLASS_NATIVES;
     51     }
     52 
     53     /**
     54      * Returns The list of methods to stub out. Each entry must be in the form
     55      * "package.package.OuterClass$InnerClass#MethodName".
     56      * The list can be empty but must not be null.
     57      * <p/>
     58      * This usage is deprecated. Please use method 'delegates' instead.
     59      */
     60     @Override
     61     public String[] getOverriddenMethods() {
     62         return OVERRIDDEN_METHODS;
     63     }
     64 
     65     /**
     66      * Returns the list of classes to rename, must be an even list: the binary FQCN
     67      * of class to replace followed by the new FQCN.
     68      * The list can be empty but must not be null.
     69      */
     70     @Override
     71     public String[] getRenamedClasses() {
     72         return RENAMED_CLASSES;
     73     }
     74 
     75     /**
     76      * Returns the list of classes for which the methods returning them should be deleted.
     77      * The array contains a list of null terminated section starting with the name of the class
     78      * to rename in which the methods are deleted, followed by a list of return types identifying
     79      * the methods to delete.
     80      * The list can be empty but must not be null.
     81      */
     82     @Override
     83     public String[] getDeleteReturns() {
     84         return DELETE_RETURNS;
     85     }
     86 
     87     //-----
     88 
     89     /**
     90      * The list of class from layoutlib_create to inject in layoutlib.
     91      */
     92     private final static Class<?>[] INJECTED_CLASSES = new Class<?>[] {
     93             OverrideMethod.class,
     94             MethodListener.class,
     95             MethodAdapter.class,
     96             ICreateInfo.class,
     97             CreateInfo.class,
     98             LayoutlibDelegate.class
     99         };
    100 
    101     /**
    102      * The list of methods to rewrite as delegates.
    103      */
    104     public final static String[] DELEGATE_METHODS = new String[] {
    105         "android.app.Fragment#instantiate", //(Landroid/content/Context;Ljava/lang/String;Landroid/os/Bundle;)Landroid/app/Fragment;",
    106         "android.content.res.Resources$Theme#obtainStyledAttributes",
    107         "android.content.res.Resources$Theme#resolveAttribute",
    108         "android.content.res.TypedArray#getValueAt",
    109         "android.graphics.BitmapFactory#finishDecode",
    110         "android.os.Handler#sendMessageAtTime",
    111         "android.os.HandlerThread#run",
    112         "android.os.Build#getString",
    113         "android.view.Display#getWindowManager",
    114         "android.view.LayoutInflater#rInflate",
    115         "android.view.LayoutInflater#parseInclude",
    116         "android.view.View#isInEditMode",
    117         "android.view.ViewRootImpl#isInTouchMode",
    118         "android.view.inputmethod.InputMethodManager#getInstance",
    119         "android.util.Log#println_native",
    120         "com.android.internal.util.XmlUtils#convertValueToInt",
    121         "com.android.internal.textservice.ITextServicesManager$Stub#asInterface",
    122     };
    123 
    124     /**
    125      * The list of classes on which to delegate all native methods.
    126      */
    127     public final static String[] DELEGATE_CLASS_NATIVES = new String[] {
    128         "android.animation.PropertyValuesHolder",
    129         "android.graphics.AvoidXfermode",
    130         "android.graphics.Bitmap",
    131         "android.graphics.BitmapFactory",
    132         "android.graphics.BitmapShader",
    133         "android.graphics.BlurMaskFilter",
    134         "android.graphics.Canvas",
    135         "android.graphics.ColorFilter",
    136         "android.graphics.ColorMatrixColorFilter",
    137         "android.graphics.ComposePathEffect",
    138         "android.graphics.ComposeShader",
    139         "android.graphics.CornerPathEffect",
    140         "android.graphics.DashPathEffect",
    141         "android.graphics.DiscretePathEffect",
    142         "android.graphics.DrawFilter",
    143         "android.graphics.EmbossMaskFilter",
    144         "android.graphics.LayerRasterizer",
    145         "android.graphics.LightingColorFilter",
    146         "android.graphics.LinearGradient",
    147         "android.graphics.MaskFilter",
    148         "android.graphics.Matrix",
    149         "android.graphics.NinePatch",
    150         "android.graphics.Paint",
    151         "android.graphics.PaintFlagsDrawFilter",
    152         "android.graphics.Path",
    153         "android.graphics.PathDashPathEffect",
    154         "android.graphics.PathEffect",
    155         "android.graphics.PixelXorXfermode",
    156         "android.graphics.PorterDuffColorFilter",
    157         "android.graphics.PorterDuffXfermode",
    158         "android.graphics.RadialGradient",
    159         "android.graphics.Rasterizer",
    160         "android.graphics.Region",
    161         "android.graphics.Shader",
    162         "android.graphics.SumPathEffect",
    163         "android.graphics.SweepGradient",
    164         "android.graphics.Typeface",
    165         "android.graphics.Xfermode",
    166         "android.os.SystemClock",
    167         "android.text.AndroidBidi",
    168         "android.util.FloatMath",
    169         "android.view.Display",
    170         "libcore.icu.ICU",
    171     };
    172 
    173     /**
    174      * The list of methods to stub out. Each entry must be in the form
    175      *  "package.package.OuterClass$InnerClass#MethodName".
    176      *  This usage is deprecated. Please use method 'delegates' instead.
    177      */
    178     private final static String[] OVERRIDDEN_METHODS = new String[] {
    179     };
    180 
    181     /**
    182      *  The list of classes to rename, must be an even list: the binary FQCN
    183      *  of class to replace followed by the new FQCN.
    184      */
    185     private final static String[] RENAMED_CLASSES =
    186         new String[] {
    187             "android.os.ServiceManager",                       "android.os._Original_ServiceManager",
    188             "android.view.SurfaceView",                        "android.view._Original_SurfaceView",
    189             "android.view.accessibility.AccessibilityManager", "android.view.accessibility._Original_AccessibilityManager",
    190             "android.webkit.WebView",                          "android.webkit._Original_WebView",
    191             "com.android.internal.policy.PolicyManager",       "com.android.internal.policy._Original_PolicyManager",
    192         };
    193 
    194     /**
    195      * List of classes for which the methods returning them should be deleted.
    196      * The array contains a list of null terminated section starting with the name of the class
    197      * to rename in which the methods are deleted, followed by a list of return types identifying
    198      * the methods to delete.
    199      */
    200     private final static String[] DELETE_RETURNS =
    201         new String[] {
    202             null };                         // separator, for next class/methods list.
    203 }
    204 
    205