Skip to content

Commit c6a06d4

Browse files
adampAndroid (Google) Code Review
authored andcommitted
Merge "Revert "Fix issue with using locally defined attrs in a shared lib"" into lmp-dev
2 parents aee5c9e + 908c748 commit c6a06d4

5 files changed

Lines changed: 10 additions & 56 deletions

File tree

core/jni/android_util_AssetManager.cpp

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,21 +1324,7 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla
13241324
config.density = 0;
13251325

13261326
// Skip through XML attributes until the end or the next possible match.
1327-
// We make two assumptions about the order of attributes:
1328-
// 1) Among attributes with the same package ID, the attributes are
1329-
// sorted by increasing resource ID.
1330-
// 2) Groups of attributes with the same package ID are in the same
1331-
// order.
1332-
// 3) The same sorting is applied to the input attributes as is
1333-
// to the attributes in the XML.
1334-
//
1335-
// ex: 02010000, 02010001, 010100f4, 010100f5
1336-
//
1337-
// The total order of attributes (including package ID) can not be linear
1338-
// as shared libraries get assigned dynamic package IDs at runtime, which
1339-
// may break the sort order established at build time.
1340-
while (ix < NX && (Res_GETPACKAGE(curIdent) != Res_GETPACKAGE(curXmlAttr) ||
1341-
curIdent > curXmlAttr)) {
1327+
while (ix < NX && curIdent > curXmlAttr) {
13421328
ix++;
13431329
curXmlAttr = xmlParser->getAttributeNameResID(ix);
13441330
}
@@ -1353,9 +1339,7 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla
13531339
}
13541340

13551341
// Skip through the style values until the end or the next possible match.
1356-
while (styleEnt < endStyleEnt &&
1357-
(Res_GETPACKAGE(curIdent) != Res_GETPACKAGE(styleEnt->map.name.ident) ||
1358-
curIdent > styleEnt->map.name.ident)) {
1342+
while (styleEnt < endStyleEnt && curIdent > styleEnt->map.name.ident) {
13591343
styleEnt++;
13601344
}
13611345
// Retrieve the current style attribute if it matches, and step to next.
@@ -1371,9 +1355,7 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla
13711355
}
13721356

13731357
// Skip through the default style values until the end or the next possible match.
1374-
while (defStyleEnt < endDefStyleEnt &&
1375-
(Res_GETPACKAGE(curIdent) != Res_GETPACKAGE(defStyleEnt->map.name.ident) ||
1376-
curIdent > defStyleEnt->map.name.ident)) {
1358+
while (defStyleEnt < endDefStyleEnt && curIdent > defStyleEnt->map.name.ident) {
13771359
defStyleEnt++;
13781360
}
13791361
// Retrieve the current default style attribute if it matches, and step to next.
@@ -1535,8 +1517,7 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job
15351517
config.density = 0;
15361518

15371519
// Skip through XML attributes until the end or the next possible match.
1538-
while (ix < NX && (Res_GETPACKAGE(curIdent) != Res_GETPACKAGE(curXmlAttr) ||
1539-
curIdent > curXmlAttr)) {
1520+
while (ix < NX && curIdent > curXmlAttr) {
15401521
ix++;
15411522
curXmlAttr = xmlParser->getAttributeNameResID(ix);
15421523
}

libs/androidfw/ResourceTypes.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,11 +1185,7 @@ uint32_t ResXMLParser::getAttributeNameResID(size_t idx) const
11851185
{
11861186
int32_t id = getAttributeNameID(idx);
11871187
if (id >= 0 && (size_t)id < mTree.mNumResIds) {
1188-
uint32_t resId = dtohl(mTree.mResIds[id]);
1189-
if (mTree.mDynamicRefTable == NULL ||
1190-
mTree.mDynamicRefTable->lookupResourceId(&resId) == NO_ERROR) {
1191-
return resId;
1192-
}
1188+
return dtohl(mTree.mResIds[id]);
11931189
}
11941190
return 0;
11951191
}

tests/SharedLibrary/lib/res/layout/main.xml

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/SharedLibrary/lib/res/values/strings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,4 @@
2828
</string-array>
2929

3030
<string name="racoon">Racoon</string>
31-
<string name="sample_layout">This is an example of a layout this library provides.</string>
3231
</resources>

tests/SharedLibrary/lib/src/com/google/android/test/shared_library/ActivityMain.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@
1818

1919
import android.app.Activity;
2020
import android.os.Bundle;
21+
import android.widget.TextView;
2122

2223
public class ActivityMain extends Activity {
2324
@Override
2425
protected void onCreate(Bundle savedInstanceState) {
2526
super.onCreate(savedInstanceState);
26-
setContentView(R.layout.main);
27+
28+
TextView content = new TextView(this);
29+
content.setText("Dummy main entry for this apk; not really needed...");
30+
setContentView(content);
2731
}
2832
}

0 commit comments

Comments
 (0)