FileDocCategorySizeDatePackage
BridgeContext.javaAPI DocAndroid 5.1 API46926Thu Mar 12 22:22:44 GMT 2015com.android.layoutlib.bridge.android

BridgeContext

public final class BridgeContext extends android.content.Context
Custom implementation of Context/Activity to handle non compiled resources.

Fields Summary
private final HashMap
mViewKeyMap
The map adds cookies to each view so that IDE can link xml tags to views.
private final HashMap
mViewKeyHelpMap
In some cases, when inflating an xml, some objects are created. Then later, the objects are converted to views. This map stores the mapping from objects to cookies which can then be used to populate the mViewKeyMap.
private android.content.res.Resources
mSystemResources
private final Object
mProjectKey
private final android.util.DisplayMetrics
mMetrics
private final com.android.ide.common.rendering.api.RenderResources
mRenderResources
private final android.content.res.Configuration
mConfig
private final android.content.pm.ApplicationInfo
mApplicationInfo
private final com.android.ide.common.rendering.api.IProjectCallback
mProjectCallback
private final android.view.WindowManager
mWindowManager
private final android.hardware.display.DisplayManager
mDisplayManager
private android.content.res.Resources.Theme
mTheme
private final Map
mDefaultPropMaps
private Map
mDynamicIdToStyleMap
private Map
mStyleToDynamicIdMap
private int
mDynamicIdGenerator
private Map
mTypedArrayCache
private android.view.BridgeInflater
mBridgeInflater
private BridgeContentResolver
mContentResolver
private final com.android.layoutlib.bridge.impl.Stack
mParserStack
private android.content.SharedPreferences
mSharedPreferences
Constructors Summary
public BridgeContext(Object projectKey, android.util.DisplayMetrics metrics, com.android.ide.common.rendering.api.RenderResources renderResources, com.android.ide.common.rendering.api.IProjectCallback projectCallback, android.content.res.Configuration config, int targetSdkVersion, boolean hasRtlSupport)

param
projectKey An Object identifying the project. This is used for the cache mechanism.
param
metrics the {@link DisplayMetrics}.
param
renderResources the configured resources (both framework and projects) for this render.
param
config the Configuration object for this render.
param
targetSdkVersion the targetSdkVersion of the application.


                                                     
        
             
             
             
             
              
        mProjectKey = projectKey;
        mMetrics = metrics;
        mProjectCallback = projectCallback;

        mRenderResources = renderResources;
        mConfig = config;

        mApplicationInfo = new ApplicationInfo();
        mApplicationInfo.targetSdkVersion = targetSdkVersion;
        if (hasRtlSupport) {
            mApplicationInfo.flags = mApplicationInfo.flags | ApplicationInfo.FLAG_SUPPORTS_RTL;
        }

        mWindowManager = new WindowManagerImpl(mMetrics);
        mDisplayManager = new DisplayManager(this);
    
Methods Summary
public voidaddCookie(java.lang.Object o, java.lang.Object cookie)

        mViewKeyHelpMap.put(o, cookie);
    
public voidaddViewKey(android.view.View view, java.lang.Object viewKey)

        mViewKeyMap.put(view, viewKey);
    
public booleanbindService(android.content.Intent arg0, android.content.ServiceConnection arg1, int arg2)

        // pass
        return false;
    
public intcheckCallingOrSelfPermission(java.lang.String arg0)

        // pass
        return 0;
    
public intcheckCallingOrSelfUriPermission(android.net.Uri arg0, int arg1)

        // pass
        return 0;
    
public intcheckCallingPermission(java.lang.String arg0)

        // pass
        return 0;
    
public intcheckCallingUriPermission(android.net.Uri arg0, int arg1)

        // pass
        return 0;
    
public intcheckPermission(java.lang.String arg0, int arg1, int arg2)

        // pass
        return 0;
    
public intcheckPermission(java.lang.String arg0, int arg1, int arg2, android.os.IBinder arg3)

        // pass
        return 0;
    
public intcheckUriPermission(android.net.Uri arg0, int arg1, int arg2, int arg3)

        // pass
        return 0;
    
public intcheckUriPermission(android.net.Uri arg0, int arg1, int arg2, int arg3, android.os.IBinder arg4)

        // pass
        return 0;
    
public intcheckUriPermission(android.net.Uri arg0, java.lang.String arg1, java.lang.String arg2, int arg3, int arg4, int arg5)

        // pass
        return 0;
    
public voidclearWallpaper()

        // pass

    
public android.content.ContextcreateApplicationContext(android.content.pm.ApplicationInfo application, int flags)

        return null;
    
public android.content.ContextcreateConfigurationContext(android.content.res.Configuration overrideConfiguration)

        // pass
        return null;
    
public android.content.ContextcreateDisplayContext(android.view.Display display)

        // pass
        return null;
    
public android.content.ContextcreatePackageContext(java.lang.String arg0, int arg1)

        // pass
        return null;
    
public android.content.ContextcreatePackageContextAsUser(java.lang.String arg0, int arg1, android.os.UserHandle user)

        // pass
        return null;
    
private android.content.res.BridgeTypedArraycreateStyleBasedTypedArray(com.android.ide.common.rendering.api.StyleResourceValue style, int[] attrs)
Creates a {@link BridgeTypedArray} by filling the values defined by the int[] with the values found in the given style. If no style is specified, the default theme, along with the styles applied to it are used.

see
#obtainStyledAttributes(int, int[])


        List<Pair<String, Boolean>> attributes = searchAttrs(attrs);

        BridgeTypedArray ta = ((BridgeResources) mSystemResources).newTypeArray(attrs.length,
                false);

        // for each attribute, get its name so that we can search it in the style
        for (int i = 0 ; i < attrs.length ; i++) {
            Pair<String, Boolean> attribute = attributes.get(i);

            if (attribute != null) {
                // look for the value in the given style
                ResourceValue resValue;
                if (style != null) {
                    resValue = mRenderResources.findItemInStyle(style, attribute.getFirst(),
                            attribute.getSecond());
                } else {
                    resValue = mRenderResources.findItemInTheme(attribute.getFirst(),
                            attribute.getSecond());
                }

                if (resValue != null) {
                    // resolve it to make sure there are no references left.
                    ta.bridgeSetValue(i, attribute.getFirst(), attribute.getSecond(),
                            mRenderResources.resolveResValue(resValue));
                }
            }
        }

        ta.sealArray();

        return ta;
    
public java.lang.String[]databaseList()

        // pass
        return null;
    
public booleandeleteDatabase(java.lang.String arg0)

        // pass
        return false;
    
public booleandeleteFile(java.lang.String arg0)

        // pass
        return false;
    
public voiddisposeResources()
Disposes the {@link Resources} singleton.

        BridgeResources.disposeSystem();
    
public voidenforceCallingOrSelfPermission(java.lang.String arg0, java.lang.String arg1)

        // pass

    
public voidenforceCallingOrSelfUriPermission(android.net.Uri arg0, int arg1, java.lang.String arg2)

        // pass

    
public voidenforceCallingPermission(java.lang.String arg0, java.lang.String arg1)

        // pass

    
public voidenforceCallingUriPermission(android.net.Uri arg0, int arg1, java.lang.String arg2)

        // pass

    
public voidenforcePermission(java.lang.String arg0, int arg1, int arg2, java.lang.String arg3)

        // pass

    
public voidenforceUriPermission(android.net.Uri arg0, int arg1, int arg2, int arg3, java.lang.String arg4)

        // pass

    
public voidenforceUriPermission(android.net.Uri arg0, java.lang.String arg1, java.lang.String arg2, int arg3, int arg4, int arg5, java.lang.String arg6)

        // pass

    
public java.lang.String[]fileList()

        // pass
        return null;
    
public android.content.ContextgetApplicationContext()

        return this;
    
public android.content.pm.ApplicationInfogetApplicationInfo()

        return mApplicationInfo;
    
public android.content.res.AssetManagergetAssets()

        // pass
        return null;
    
public java.lang.StringgetBasePackageName()

        // pass
        return null;
    
public java.io.FilegetCacheDir()

        // pass
        return null;
    
public java.lang.ClassLoadergetClassLoader()

        return this.getClass().getClassLoader();
    
public java.io.FilegetCodeCacheDir()

        // pass
        return null;
    
public android.content.res.ConfigurationgetConfiguration()

        return mConfig;
    
public android.content.ContentResolvergetContentResolver()

        if (mContentResolver == null) {
            mContentResolver = new BridgeContentResolver(this);
        }
        return mContentResolver;
    
public java.lang.ObjectgetCookie(java.lang.Object o)

        return mViewKeyHelpMap.get(o);
    
public BridgeXmlBlockParsergetCurrentParser()
Returns the current parser at the top the of the stack.

return
a parser or null.

        return mParserStack.peek();
    
public java.io.FilegetDatabasePath(java.lang.String arg0)

        // pass
        return null;
    
public java.util.MapgetDefaultPropMap(java.lang.Object key)

        return mDefaultPropMaps.get(key);
    
public java.io.FilegetDir(java.lang.String arg0, int arg1)

        // pass
        return null;
    
public android.view.DisplayAdjustmentsgetDisplayAdjustments(int displayId)

        // pass
        return null;
    
public intgetDynamicIdByStyle(com.android.ide.common.rendering.api.StyleResourceValue resValue)

        if (mDynamicIdToStyleMap == null) {
            // create the maps.
            mDynamicIdToStyleMap = new HashMap<Integer, StyleResourceValue>();
            mStyleToDynamicIdMap = new HashMap<StyleResourceValue, Integer>();
        }

        // look for an existing id
        Integer id = mStyleToDynamicIdMap.get(resValue);

        if (id == null) {
            // generate a new id
            id = ++mDynamicIdGenerator;

            // and add it to the maps.
            mDynamicIdToStyleMap.put(id, resValue);
            mStyleToDynamicIdMap.put(resValue, id);
        }

        return id;
    
public java.io.FilegetExternalCacheDir()

        // pass
        return null;
    
public java.io.File[]getExternalCacheDirs()

        // pass
        return new File[0];
    
public java.io.FilegetExternalFilesDir(java.lang.String type)

        // pass
        return null;
    
public java.io.File[]getExternalFilesDirs(java.lang.String type)

        // pass
        return new File[0];
    
public java.io.File[]getExternalMediaDirs()

        // pass
        return new File[0];
    
public java.io.FilegetFileStreamPath(java.lang.String arg0)

        // pass
        return null;
    
public java.io.FilegetFilesDir()

        // pass
        return null;
    
public intgetFrameworkResourceValue(com.android.resources.ResourceType resType, java.lang.String resName, int defValue)

        if (getRenderResources().getFrameworkResource(resType, resName) != null) {
            // Bridge.getResourceId creates a new resource id if an existing one isn't found. So,
            // we check for the existence of the resource before calling it.
            return Bridge.getResourceId(resType, resName);
        }

        return defValue;
    
public android.os.LoopergetMainLooper()

        return Looper.myLooper();
    
public android.util.DisplayMetricsgetMetrics()

        return mMetrics;
    
public java.io.FilegetNoBackupFilesDir()

        // pass
        return null;
    
public java.io.FilegetObbDir()

        Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "OBB not supported", null);
        return null;
    
public java.io.File[]getObbDirs()

        // pass
        return new File[0];
    
public java.lang.StringgetOpPackageName()

        // pass
        return null;
    
public java.lang.StringgetPackageCodePath()

        // pass
        return null;
    
public android.content.pm.PackageManagergetPackageManager()

        // pass
        return null;
    
public java.lang.StringgetPackageName()

        // pass
        return null;
    
public java.lang.StringgetPackageResourcePath()

        // pass
        return null;
    
private com.android.ide.common.rendering.api.ILayoutPullParsergetParser(com.android.ide.common.rendering.api.ResourceReference resource)

        ILayoutPullParser parser;
        if (resource instanceof ResourceValue) {
            parser = mProjectCallback.getParser((ResourceValue) resource);
        } else {
            parser = mProjectCallback.getParser(resource.getName());
        }
        return parser;
    
public BridgeXmlBlockParsergetPreviousParser()
Returns the previous parser.

return
a parser or null if there isn't any previous parser

        if (mParserStack.size() < 2) {
            return null;
        }
        return mParserStack.get(mParserStack.size() - 2);
    
public com.android.ide.common.rendering.api.IProjectCallbackgetProjectCallback()

        return mProjectCallback;
    
public java.lang.ObjectgetProjectKey()

        return mProjectKey;
    
public intgetProjectResourceValue(com.android.resources.ResourceType resType, java.lang.String resName, int defValue)

        // getResourceId creates a new resource id if an existing resource id isn't found. So, we
        // check for the existence of the resource before calling it.
        if (getRenderResources().getProjectResource(resType, resName) != null) {
            if (mProjectCallback != null) {
                Integer value = mProjectCallback.getResourceId(resType, resName);
                if (value != null) {
                    return value;
                }
            }
        }

        return defValue;
    
public com.android.ide.common.rendering.api.RenderResourcesgetRenderResources()

        return mRenderResources;
    
public android.content.res.ResourcesgetResources()

        return mSystemResources;
    
public android.content.SharedPreferencesgetSharedPreferences(java.lang.String arg0, int arg1)

        if (mSharedPreferences == null) {
            mSharedPreferences = new BridgeSharedPreferences();
        }
        return mSharedPreferences;
    
public java.io.FilegetSharedPrefsFile(java.lang.String name)

        // pass
        return null;
    
private com.android.ide.common.rendering.api.StyleResourceValuegetStyleByDynamicId(int i)

        if (mDynamicIdToStyleMap != null) {
            return mDynamicIdToStyleMap.get(i);
        }

        return null;
    
public java.lang.ObjectgetSystemService(java.lang.String service)

        if (LAYOUT_INFLATER_SERVICE.equals(service)) {
            return mBridgeInflater;
        }

        if (TEXT_SERVICES_MANAGER_SERVICE.equals(service)) {
            // we need to return a valid service to avoid NPE
            return TextServicesManager.getInstance();
        }

        if (WINDOW_SERVICE.equals(service)) {
            return mWindowManager;
        }

        // needed by SearchView
        if (INPUT_METHOD_SERVICE.equals(service)) {
            return null;
        }

        if (POWER_SERVICE.equals(service)) {
            return new PowerManager(this, new BridgePowerManager(), new Handler());
        }

        if (DISPLAY_SERVICE.equals(service)) {
            return mDisplayManager;
        }

        if (ACCESSIBILITY_SERVICE.equals(service)) {
            return AccessibilityManager.getInstance(this);
        }

        throw new UnsupportedOperationException("Unsupported Service: " + service);
    
public android.content.res.Resources.ThemegetTheme()

        return mTheme;
    
public intgetUserId()

        return 0; // not used
    
public java.lang.ObjectgetViewKey(android.view.View view)

        return mViewKeyMap.get(view);
    
public android.graphics.drawable.DrawablegetWallpaper()

        // pass
        return null;
    
public intgetWallpaperDesiredMinimumHeight()

        return -1;
    
public intgetWallpaperDesiredMinimumWidth()

        return -1;
    
public voidgrantUriPermission(java.lang.String arg0, android.net.Uri arg1, int arg2)

        // pass

    
public com.android.util.PairinflateView(com.android.ide.common.rendering.api.ResourceReference resource, android.view.ViewGroup parent, boolean attachToRoot, boolean skipCallbackParser)

        boolean isPlatformLayout = resource.isFramework();

        if (!isPlatformLayout && !skipCallbackParser) {
            // check if the project callback can provide us with a custom parser.
            ILayoutPullParser parser = getParser(resource);

            if (parser != null) {
                BridgeXmlBlockParser blockParser = new BridgeXmlBlockParser(parser,
                        this, resource.isFramework());
                try {
                    pushParser(blockParser);
                    return Pair.of(
                            mBridgeInflater.inflate(blockParser, parent, attachToRoot),
                            true);
                } finally {
                    popParser();
                }
            }
        }

        ResourceValue resValue;
        if (resource instanceof ResourceValue) {
            resValue = (ResourceValue) resource;
        } else {
            if (isPlatformLayout) {
                resValue = mRenderResources.getFrameworkResource(ResourceType.LAYOUT,
                        resource.getName());
            } else {
                resValue = mRenderResources.getProjectResource(ResourceType.LAYOUT,
                        resource.getName());
            }
        }

        if (resValue != null) {

            File xml = new File(resValue.getValue());
            if (xml.isFile()) {
                // we need to create a pull parser around the layout XML file, and then
                // give that to our XmlBlockParser
                try {
                    XmlPullParser parser = ParserFactory.create(xml);

                    // set the resource ref to have correct view cookies
                    mBridgeInflater.setResourceReference(resource);

                    BridgeXmlBlockParser blockParser = new BridgeXmlBlockParser(parser,
                            this, resource.isFramework());
                    try {
                        pushParser(blockParser);
                        return Pair.of(
                                mBridgeInflater.inflate(blockParser, parent, attachToRoot),
                                false);
                    } finally {
                        popParser();
                    }
                } catch (XmlPullParserException e) {
                    Bridge.getLog().error(LayoutLog.TAG_BROKEN,
                            "Failed to configure parser for " + xml, e, null /*data*/);
                    // we'll return null below.
                } catch (FileNotFoundException e) {
                    // this shouldn't happen since we check above.
                } finally {
                    mBridgeInflater.setResourceReference(null);
                }
            } else {
                Bridge.getLog().error(LayoutLog.TAG_BROKEN,
                        String.format("File %s is missing!", xml), null);
            }
        } else {
            Bridge.getLog().error(LayoutLog.TAG_BROKEN,
                    String.format("Layout %s%s does not exist.", isPlatformLayout ? "android:" : "",
                            resource.getName()), null);
        }

        return Pair.of(null, false);
    
public voidinitResources()
Initializes the {@link Resources} singleton to be linked to this {@link Context}, its {@link DisplayMetrics}, {@link Configuration}, and {@link IProjectCallback}.

see
#disposeResources()

        AssetManager assetManager = AssetManager.getSystem();

        mSystemResources = BridgeResources.initSystem(
                this,
                assetManager,
                mMetrics,
                mConfig,
                mProjectCallback);
        mTheme = mSystemResources.newTheme();
    
public booleanisRestricted()

        return false;
    
public final android.content.res.BridgeTypedArrayobtainStyledAttributes(int[] attrs)

        // No style is specified here, so create the typed array based on the default theme
        // and the styles already applied to it. A null value of style indicates that the default
        // theme should be used.
        return createStyleBasedTypedArray(null, attrs);
    
public final android.content.res.BridgeTypedArrayobtainStyledAttributes(int resid, int[] attrs)

        StyleResourceValue style = null;
        // get the StyleResourceValue based on the resId;
        if (resid != 0) {
            style = getStyleByDynamicId(resid);

            if (style == null) {
                // In some cases, style may not be a dynamic id, so we do a full search.
                ResourceReference ref = resolveId(resid);
                if (ref != null) {
                    style = mRenderResources.getStyle(ref.getName(), ref.isFramework());
                }
            }

            if (style == null) {
                throw new Resources.NotFoundException();
            }
        }

        if (mTypedArrayCache == null) {
            mTypedArrayCache = new HashMap<int[], Map<Integer,BridgeTypedArray>>();

            Map<Integer, BridgeTypedArray> map = new HashMap<Integer, BridgeTypedArray>();
            mTypedArrayCache.put(attrs, map);

            BridgeTypedArray ta = createStyleBasedTypedArray(style, attrs);
            map.put(resid, ta);

            return ta;
        }

        // get the 2nd map
        Map<Integer, BridgeTypedArray> map = mTypedArrayCache.get(attrs);
        if (map == null) {
            map = new HashMap<Integer, BridgeTypedArray>();
            mTypedArrayCache.put(attrs, map);
        }

        // get the array from the 2nd map
        BridgeTypedArray ta = map.get(resid);

        if (ta == null) {
            ta = createStyleBasedTypedArray(style, attrs);
            map.put(resid, ta);
        }

        return ta;
    
public final android.content.res.BridgeTypedArrayobtainStyledAttributes(android.util.AttributeSet set, int[] attrs)

        return obtainStyledAttributes(set, attrs, 0, 0);
    
public android.content.res.BridgeTypedArrayobtainStyledAttributes(android.util.AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes)


        Map<String, String> defaultPropMap = null;
        boolean isPlatformFile = true;

        // Hint: for XmlPullParser, attach source //DEVICE_SRC/dalvik/libcore/xml/src/java
        if (set instanceof BridgeXmlBlockParser) {
            BridgeXmlBlockParser parser = null;
            parser = (BridgeXmlBlockParser)set;

            isPlatformFile = parser.isPlatformFile();

            Object key = parser.getViewCookie();
            if (key != null) {
                defaultPropMap = mDefaultPropMaps.get(key);
                if (defaultPropMap == null) {
                    defaultPropMap = new HashMap<String, String>();
                    mDefaultPropMaps.put(key, defaultPropMap);
                }
            }

        } else if (set instanceof BridgeLayoutParamsMapAttributes) {
            // this is only for temp layout params generated dynamically, so this is never
            // platform content.
            isPlatformFile = false;
        } else if (set != null) { // null parser is ok
            // really this should not be happening since its instantiated in Bridge
            Bridge.getLog().error(LayoutLog.TAG_BROKEN,
                    "Parser is not a BridgeXmlBlockParser!", null /*data*/);
            return null;
        }

        List<Pair<String, Boolean>> attributeList = searchAttrs(attrs);

        BridgeTypedArray ta = ((BridgeResources) mSystemResources).newTypeArray(attrs.length,
                isPlatformFile);

        // look for a custom style.
        String customStyle = null;
        if (set != null) {
            customStyle = set.getAttributeValue(null /* namespace*/, "style");
        }

        StyleResourceValue customStyleValues = null;
        if (customStyle != null) {
            ResourceValue item = mRenderResources.findResValue(customStyle,
                    isPlatformFile /*forceFrameworkOnly*/);

            // resolve it in case it links to something else
            item = mRenderResources.resolveResValue(item);

            if (item instanceof StyleResourceValue) {
                customStyleValues = (StyleResourceValue)item;
            }
        }

        // resolve the defStyleAttr value into a IStyleResourceValue
        StyleResourceValue defStyleValues = null;

        if (defStyleAttr != 0) {
            // get the name from the int.
            Pair<String, Boolean> defStyleAttribute = searchAttr(defStyleAttr);

            if (defaultPropMap != null) {
                String defStyleName = defStyleAttribute.getFirst();
                if (defStyleAttribute.getSecond()) {
                    defStyleName = "android:" + defStyleName;
                }
                defaultPropMap.put("style", defStyleName);
            }

            // look for the style in the current theme, and its parent:
            ResourceValue item = mRenderResources.findItemInTheme(defStyleAttribute.getFirst(),
                    defStyleAttribute.getSecond());

            if (item != null) {
                // item is a reference to a style entry. Search for it.
                item = mRenderResources.findResValue(item.getValue(), item.isFramework());

                if (item instanceof StyleResourceValue) {
                    defStyleValues = (StyleResourceValue)item;
                }
            } else {
                Bridge.getLog().error(LayoutLog.TAG_RESOURCES_RESOLVE_THEME_ATTR,
                        String.format(
                                "Failed to find style '%s' in current theme",
                                defStyleAttribute.getFirst()),
                        null /*data*/);
            }
        } else if (defStyleRes != 0) {
            boolean isFrameworkRes = true;
            Pair<ResourceType, String> value = Bridge.resolveResourceId(defStyleRes);
            if (value == null) {
                value = mProjectCallback.resolveResourceId(defStyleRes);
                isFrameworkRes = false;
            }

            if (value != null) {
                if ((value.getFirst() == ResourceType.STYLE)) {
                    // look for the style in all resources:
                    StyleResourceValue item = mRenderResources.getStyle(value.getSecond(),
                            isFrameworkRes);
                    if (item != null) {
                        if (defaultPropMap != null) {
                            defaultPropMap.put("style", item.getName());
                        }

                        defStyleValues = item;
                    } else {
                        Bridge.getLog().error(null,
                                String.format(
                                        "Style with id 0x%x (resolved to '%s') does not exist.",
                                        defStyleRes, value.getSecond()),
                                null);
                    }
                } else {
                    Bridge.getLog().error(null,
                            String.format(
                                    "Resource id 0x%x is not of type STYLE (instead %s)",
                                    defStyleRes, value.getFirst().toString()),
                            null);
                }
            } else {
                Bridge.getLog().error(null,
                        String.format(
                                "Failed to find style with id 0x%x in current theme",
                                defStyleRes),
                        null);
            }
        }

        String appNamespace = mProjectCallback.getNamespace();

        if (attributeList != null) {
            for (int index = 0 ; index < attributeList.size() ; index++) {
                Pair<String, Boolean> attribute = attributeList.get(index);

                if (attribute == null) {
                    continue;
                }

                String attrName = attribute.getFirst();
                boolean frameworkAttr = attribute.getSecond();
                String value = null;
                if (set != null) {
                    value = set.getAttributeValue(
                            frameworkAttr ? BridgeConstants.NS_RESOURCES : appNamespace,
                                    attrName);

                    // if this is an app attribute, and the first get fails, try with the
                    // new res-auto namespace as well
                    if (!frameworkAttr && value == null) {
                        value = set.getAttributeValue(BridgeConstants.NS_APP_RES_AUTO, attrName);
                    }
                }

                // if there's no direct value for this attribute in the XML, we look for default
                // values in the widget defStyle, and then in the theme.
                if (value == null) {
                    ResourceValue resValue = null;

                    // look for the value in the custom style first (and its parent if needed)
                    if (customStyleValues != null) {
                        resValue = mRenderResources.findItemInStyle(customStyleValues,
                                attrName, frameworkAttr);
                    }

                    // then look for the value in the default Style (and its parent if needed)
                    if (resValue == null && defStyleValues != null) {
                        resValue = mRenderResources.findItemInStyle(defStyleValues,
                                attrName, frameworkAttr);
                    }

                    // if the item is not present in the defStyle, we look in the main theme (and
                    // its parent themes)
                    if (resValue == null) {
                        resValue = mRenderResources.findItemInTheme(attrName, frameworkAttr);
                    }

                    // if we found a value, we make sure this doesn't reference another value.
                    // So we resolve it.
                    if (resValue != null) {
                        // put the first default value, before the resolution.
                        if (defaultPropMap != null) {
                            defaultPropMap.put(attrName, resValue.getValue());
                        }

                        resValue = mRenderResources.resolveResValue(resValue);
                    }

                    ta.bridgeSetValue(index, attrName, frameworkAttr, resValue);
                } else {
                    // there is a value in the XML, but we need to resolve it in case it's
                    // referencing another resource or a theme value.
                    ta.bridgeSetValue(index, attrName, frameworkAttr,
                            mRenderResources.resolveValue(null, attrName, value, isPlatformFile));
                }
            }
        }

        ta.sealArray();

        return ta;
    
public java.io.FileInputStreamopenFileInput(java.lang.String arg0)

        // pass
        return null;
    
public java.io.FileOutputStreamopenFileOutput(java.lang.String arg0, int arg1)

        // pass
        return null;
    
public android.database.sqlite.SQLiteDatabaseopenOrCreateDatabase(java.lang.String arg0, int arg1, android.database.sqlite.SQLiteDatabase.CursorFactory arg2)

        // pass
        return null;
    
public android.database.sqlite.SQLiteDatabaseopenOrCreateDatabase(java.lang.String arg0, int arg1, android.database.sqlite.SQLiteDatabase.CursorFactory arg2, android.database.DatabaseErrorHandler arg3)

        // pass
        return null;
    
public android.graphics.drawable.DrawablepeekWallpaper()

        // pass
        return null;
    
public voidpopParser()
Removes the parser at the top of the stack

        BridgeXmlBlockParser parser = mParserStack.pop();
        if (ParserFactory.LOG_PARSER) {
            System.out.println("POPD " + parser.getParser().toString());
        }
    
public voidpushParser(BridgeXmlBlockParser parser)
Adds a parser to the stack.

param
parser the parser to add.

        if (ParserFactory.LOG_PARSER) {
            System.out.println("PUSH " + parser.getParser().toString());
        }
        mParserStack.push(parser);
    
public android.content.IntentregisterReceiver(android.content.BroadcastReceiver arg0, android.content.IntentFilter arg1)

        // pass
        return null;
    
public android.content.IntentregisterReceiver(android.content.BroadcastReceiver arg0, android.content.IntentFilter arg1, java.lang.String arg2, android.os.Handler arg3)

        // pass
        return null;
    
public android.content.IntentregisterReceiverAsUser(android.content.BroadcastReceiver arg0, android.os.UserHandle arg0p5, android.content.IntentFilter arg1, java.lang.String arg2, android.os.Handler arg3)

        // pass
        return null;
    
public voidremoveStickyBroadcast(android.content.Intent arg0)

        // pass

    
public voidremoveStickyBroadcastAsUser(android.content.Intent intent, android.os.UserHandle user)

        // pass
    
public com.android.ide.common.rendering.api.ResourceReferenceresolveId(int id)

        // first get the String related to this id in the framework
        Pair<ResourceType, String> resourceInfo = Bridge.resolveResourceId(id);

        if (resourceInfo != null) {
            return new ResourceReference(resourceInfo.getSecond(), true);
        }

        // didn't find a match in the framework? look in the project.
        if (mProjectCallback != null) {
            resourceInfo = mProjectCallback.resolveResourceId(id);

            if (resourceInfo != null) {
                return new ResourceReference(resourceInfo.getSecond(), false);
            }
        }

        // The base value for R.style is 0x01030000 and the custom style is 0x02030000.
        // So, if the second byte is 03, it's probably a style.
        if ((id >> 16 & 0xFF) == 0x03) {
            return getStyleByDynamicId(id);
        }
        return null;
    
public booleanresolveThemeAttribute(int resid, android.util.TypedValue outValue, boolean resolveRefs)

        Pair<ResourceType, String> resourceInfo = Bridge.resolveResourceId(resid);
        boolean isFrameworkRes = true;
        if (resourceInfo == null) {
            resourceInfo = mProjectCallback.resolveResourceId(resid);
            isFrameworkRes = false;
        }

        if (resourceInfo == null) {
            return false;
        }

        ResourceValue value = mRenderResources.findItemInTheme(resourceInfo.getSecond(),
                isFrameworkRes);
        if (resolveRefs) {
            value = mRenderResources.resolveResValue(value);
        }

        if (value == null) {
            // unable to find the attribute.
            return false;
        }

        // check if this is a style resource
        if (value instanceof StyleResourceValue) {
            // get the id that will represent this style.
            outValue.resourceId = getDynamicIdByStyle((StyleResourceValue)value);
            return true;
        }

        int a;
        // if this is a framework value.
        if (value.isFramework()) {
            // look for idName in the android R classes.
            // use 0 a default res value as it's not a valid id value.
            a = getFrameworkResourceValue(value.getResourceType(), value.getName(), 0 /*defValue*/);
        } else {
            // look for idName in the project R class.
            // use 0 a default res value as it's not a valid id value.
            a = getProjectResourceValue(value.getResourceType(), value.getName(), 0 /*defValue*/);
        }

        if (a != 0) {
            outValue.resourceId = a;
            return true;
        }

        return false;
    
public voidrevokeUriPermission(android.net.Uri arg0, int arg1)

        // pass

    
public com.android.util.PairsearchAttr(int attr)
Searches for the attribute referenced by its internal id.

param
attr An attribute reference given to obtainStyledAttributes such as defStyle.
return
A (name, isFramework) pair describing the attribute if found. Returns null if nothing is found.

        Pair<ResourceType, String> info = Bridge.resolveResourceId(attr);
        if (info != null) {
            return Pair.of(info.getSecond(), Boolean.TRUE);
        }

        info = mProjectCallback.resolveResourceId(attr);
        if (info != null) {
            return Pair.of(info.getSecond(), Boolean.FALSE);
        }

        return null;
    
private java.util.ListsearchAttrs(int[] attrs)
The input int[] attrs is a list of attributes. The returns a list of information about each attributes. The information is (name, isFramework)

param
attrs An attribute array reference given to obtainStyledAttributes.
return
List of attribute information.

        List<Pair<String, Boolean>> results = new ArrayList<Pair<String, Boolean>>(attrs.length);

        // for each attribute, get its name so that we can search it in the style
        for (int attr : attrs) {
            Pair<ResourceType, String> resolvedResource = Bridge.resolveResourceId(attr);
            boolean isFramework = false;
            if (resolvedResource != null) {
                isFramework = true;
            } else {
                resolvedResource = mProjectCallback.resolveResourceId(attr);
            }

            if (resolvedResource != null) {
                results.add(Pair.of(resolvedResource.getSecond(), isFramework));
            } else {
                results.add(null);
            }
        }

        return results;
    
public voidsendBroadcast(android.content.Intent arg0)

        // pass

    
public voidsendBroadcast(android.content.Intent arg0, java.lang.String arg1)

        // pass

    
public voidsendBroadcast(android.content.Intent intent, java.lang.String receiverPermission, int appOp)

        // pass
    
public voidsendBroadcastAsUser(android.content.Intent intent, android.os.UserHandle user)

        // pass
    
public voidsendBroadcastAsUser(android.content.Intent intent, android.os.UserHandle user, java.lang.String receiverPermission)

        // pass
    
public voidsendOrderedBroadcast(android.content.Intent arg0, java.lang.String arg1)

        // pass

    
public voidsendOrderedBroadcast(android.content.Intent arg0, java.lang.String arg1, android.content.BroadcastReceiver arg2, android.os.Handler arg3, int arg4, java.lang.String arg5, android.os.Bundle arg6)

        // pass

    
public voidsendOrderedBroadcast(android.content.Intent intent, java.lang.String receiverPermission, int appOp, android.content.BroadcastReceiver resultReceiver, android.os.Handler scheduler, int initialCode, java.lang.String initialData, android.os.Bundle initialExtras)

        // pass
    
public voidsendOrderedBroadcastAsUser(android.content.Intent intent, android.os.UserHandle user, java.lang.String receiverPermission, android.content.BroadcastReceiver resultReceiver, android.os.Handler scheduler, int initialCode, java.lang.String initialData, android.os.Bundle initialExtras)

        // pass
    
public voidsendOrderedBroadcastAsUser(android.content.Intent intent, android.os.UserHandle user, java.lang.String receiverPermission, int appOp, android.content.BroadcastReceiver resultReceiver, android.os.Handler scheduler, int initialCode, java.lang.String initialData, android.os.Bundle initialExtras)

        // pass
    
public voidsendStickyBroadcast(android.content.Intent arg0)

        // pass

    
public voidsendStickyBroadcastAsUser(android.content.Intent intent, android.os.UserHandle user)

        // pass
    
public voidsendStickyOrderedBroadcast(android.content.Intent intent, android.content.BroadcastReceiver resultReceiver, android.os.Handler scheduler, int initialCode, java.lang.String initialData, android.os.Bundle initialExtras)

        // pass
    
public voidsendStickyOrderedBroadcastAsUser(android.content.Intent intent, android.os.UserHandle user, android.content.BroadcastReceiver resultReceiver, android.os.Handler scheduler, int initialCode, java.lang.String initialData, android.os.Bundle initialExtras)

        // pass
    
public voidsetBridgeInflater(android.view.BridgeInflater inflater)

        mBridgeInflater = inflater;
    
public voidsetTheme(int arg0)

        // pass

    
public voidsetWallpaper(android.graphics.Bitmap arg0)

        // pass

    
public voidsetWallpaper(java.io.InputStream arg0)

        // pass

    
public voidstartActivities(android.content.Intent[] arg0)

        // pass

    
public voidstartActivities(android.content.Intent[] arg0, android.os.Bundle arg1)

        // pass

    
public voidstartActivity(android.content.Intent arg0)

        // pass
    
public voidstartActivity(android.content.Intent arg0, android.os.Bundle arg1)

        // pass
    
public booleanstartInstrumentation(android.content.ComponentName arg0, java.lang.String arg1, android.os.Bundle arg2)

        // pass
        return false;
    
public voidstartIntentSender(android.content.IntentSender intent, android.content.Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)

        // pass
    
public voidstartIntentSender(android.content.IntentSender intent, android.content.Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, android.os.Bundle options)

        // pass
    
public android.content.ComponentNamestartService(android.content.Intent arg0)

        // pass
        return null;
    
public android.content.ComponentNamestartServiceAsUser(android.content.Intent arg0, android.os.UserHandle arg1)

        // pass
        return null;
    
public booleanstopService(android.content.Intent arg0)

        // pass
        return false;
    
public booleanstopServiceAsUser(android.content.Intent arg0, android.os.UserHandle arg1)

        // pass
        return false;
    
public voidunbindService(android.content.ServiceConnection arg0)

        // pass

    
public voidunregisterReceiver(android.content.BroadcastReceiver arg0)

        // pass