Merge "Fix issue with using locally defined attrs in a shared lib" into lmp-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
cd8e73817d
@ -1324,7 +1324,21 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla
|
|||||||
config.density = 0;
|
config.density = 0;
|
||||||
|
|
||||||
// Skip through XML attributes until the end or the next possible match.
|
// Skip through XML attributes until the end or the next possible match.
|
||||||
while (ix < NX && curIdent > curXmlAttr) {
|
// We make two assumptions about the order of attributes:
|
||||||
|
// 1) Among attributes with the same package ID, the attributes are
|
||||||
|
// sorted by increasing resource ID.
|
||||||
|
// 2) Groups of attributes with the same package ID are in the same
|
||||||
|
// order.
|
||||||
|
// 3) The same sorting is applied to the input attributes as is
|
||||||
|
// to the attributes in the XML.
|
||||||
|
//
|
||||||
|
// ex: 02010000, 02010001, 010100f4, 010100f5
|
||||||
|
//
|
||||||
|
// The total order of attributes (including package ID) can not be linear
|
||||||
|
// as shared libraries get assigned dynamic package IDs at runtime, which
|
||||||
|
// may break the sort order established at build time.
|
||||||
|
while (ix < NX && (Res_GETPACKAGE(curIdent) != Res_GETPACKAGE(curXmlAttr) ||
|
||||||
|
curIdent > curXmlAttr)) {
|
||||||
ix++;
|
ix++;
|
||||||
curXmlAttr = xmlParser->getAttributeNameResID(ix);
|
curXmlAttr = xmlParser->getAttributeNameResID(ix);
|
||||||
}
|
}
|
||||||
@ -1339,7 +1353,9 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Skip through the style values until the end or the next possible match.
|
// Skip through the style values until the end or the next possible match.
|
||||||
while (styleEnt < endStyleEnt && curIdent > styleEnt->map.name.ident) {
|
while (styleEnt < endStyleEnt &&
|
||||||
|
(Res_GETPACKAGE(curIdent) != Res_GETPACKAGE(styleEnt->map.name.ident) ||
|
||||||
|
curIdent > styleEnt->map.name.ident)) {
|
||||||
styleEnt++;
|
styleEnt++;
|
||||||
}
|
}
|
||||||
// Retrieve the current style attribute if it matches, and step to next.
|
// Retrieve the current style attribute if it matches, and step to next.
|
||||||
@ -1355,7 +1371,9 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Skip through the default style values until the end or the next possible match.
|
// Skip through the default style values until the end or the next possible match.
|
||||||
while (defStyleEnt < endDefStyleEnt && curIdent > defStyleEnt->map.name.ident) {
|
while (defStyleEnt < endDefStyleEnt &&
|
||||||
|
(Res_GETPACKAGE(curIdent) != Res_GETPACKAGE(defStyleEnt->map.name.ident) ||
|
||||||
|
curIdent > defStyleEnt->map.name.ident)) {
|
||||||
defStyleEnt++;
|
defStyleEnt++;
|
||||||
}
|
}
|
||||||
// Retrieve the current default style attribute if it matches, and step to next.
|
// Retrieve the current default style attribute if it matches, and step to next.
|
||||||
@ -1517,7 +1535,8 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job
|
|||||||
config.density = 0;
|
config.density = 0;
|
||||||
|
|
||||||
// Skip through XML attributes until the end or the next possible match.
|
// Skip through XML attributes until the end or the next possible match.
|
||||||
while (ix < NX && curIdent > curXmlAttr) {
|
while (ix < NX && (Res_GETPACKAGE(curIdent) != Res_GETPACKAGE(curXmlAttr) ||
|
||||||
|
curIdent > curXmlAttr)) {
|
||||||
ix++;
|
ix++;
|
||||||
curXmlAttr = xmlParser->getAttributeNameResID(ix);
|
curXmlAttr = xmlParser->getAttributeNameResID(ix);
|
||||||
}
|
}
|
||||||
|
@ -1185,7 +1185,11 @@ uint32_t ResXMLParser::getAttributeNameResID(size_t idx) const
|
|||||||
{
|
{
|
||||||
int32_t id = getAttributeNameID(idx);
|
int32_t id = getAttributeNameID(idx);
|
||||||
if (id >= 0 && (size_t)id < mTree.mNumResIds) {
|
if (id >= 0 && (size_t)id < mTree.mNumResIds) {
|
||||||
return dtohl(mTree.mResIds[id]);
|
uint32_t resId = dtohl(mTree.mResIds[id]);
|
||||||
|
if (mTree.mDynamicRefTable == NULL ||
|
||||||
|
mTree.mDynamicRefTable->lookupResourceId(&resId) == NO_ERROR) {
|
||||||
|
return resId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
26
tests/SharedLibrary/lib/res/layout/main.xml
Normal file
26
tests/SharedLibrary/lib/res/layout/main.xml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/sample_layout"/>
|
||||||
|
|
||||||
|
<com.google.android.test.shared_library.AddressView xmlns:address="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="#03a9f4"
|
||||||
|
address:name="Librarian L"
|
||||||
|
address:streetNumber="21"
|
||||||
|
address:streetName="Android Lane"
|
||||||
|
address:city="AndroidVille"
|
||||||
|
address:state="OS"
|
||||||
|
address:zip="12345"
|
||||||
|
address:country="Mobile"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -28,4 +28,5 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string name="racoon">Racoon</string>
|
<string name="racoon">Racoon</string>
|
||||||
|
<string name="sample_layout">This is an example of a layout this library provides.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -18,15 +18,11 @@ package com.google.android.test.shared_library;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
public class ActivityMain extends Activity {
|
public class ActivityMain extends Activity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.main);
|
||||||
TextView content = new TextView(this);
|
|
||||||
content.setText("Dummy main entry for this apk; not really needed...");
|
|
||||||
setContentView(content);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user