Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert change that broke loading framework packages #3185

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ private void buildNonDefaultSources(ExtFile appDir)
File[] dexFiles = appDir.listFiles();
if (dexFiles != null) {
for (File dex : dexFiles) {

// skip classes.dex because we have handled it in buildSources()
if (dex.getName().endsWith(".dex") && ! dex.getName().equalsIgnoreCase("classes.dex")) {
buildSourcesRaw(appDir, dex.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import java.util.logging.Logger;

public class ResourcesDecoder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import brut.androlib.exceptions.CantFindFrameworkResException;
import brut.androlib.exceptions.UndefinedResObjectException;
import brut.androlib.res.data.ResID;
import brut.androlib.res.data.ResPackage;
import brut.androlib.res.data.ResResSpec;
import brut.androlib.res.data.ResTable;
import brut.androlib.res.data.value.ResAttr;
Expand All @@ -28,7 +29,8 @@
public class ResAttrDecoder {
public String decode(int type, int value, String rawValue, int attrResId)
throws AndrolibException {
ResScalarValue resValue = mResTable.getCurrentResPackage().getValueFactory().factory(type, value, rawValue);
ResPackage pkg = mResTable.getCurrentResPackage();
ResScalarValue resValue = pkg.getValueFactory().factory(type, value, rawValue);

String decoded = null;
if (attrResId > 0) {
Expand All @@ -46,14 +48,24 @@ public String decodeFromResourceId(int attrResId)
throws AndrolibException {

if (attrResId != 0) {
ResID resId = new ResID(attrResId);
ResPackage pkg = mResTable.getCurrentResPackage();
int attrId = attrResId;

try {
ResResSpec resResSpec = mResTable.getResSpec(resId);
// See also: brut.androlib.res.data.ResTable.getResSpec
if (attrId >> 24 == 0) {
int packageId = pkg.getId();
int pkgId = (packageId == 0 ? 2 : packageId);
attrId = (0xFF000000 & (pkgId << 24)) | attrId;
}

// Retrieve the ResSpec in a package by id
ResID resId = new ResID(attrId);
if (pkg.hasResSpec(resId)) {
ResResSpec resResSpec = pkg.getResSpec(resId);
if (resResSpec != null) {
return resResSpec.getName();
}
} catch (UndefinedResObjectException | CantFindFrameworkResException ignored) {}
}
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.android.tools.smali.dexlib2.Opcodes;
import com.android.tools.smali.dexlib2.writer.builder.DexBuilder;
import com.android.tools.smali.dexlib2.writer.io.FileDataStore;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
Expand Down
1 change: 1 addition & 0 deletions brut.j.util/src/main/java/brut/util/Duo.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public Duo(T1 t1, T2 t2) {
this.m2 = t2;
}

@SuppressWarnings("unchecked")
@Override
public boolean equals(Object obj) {
if (obj == null) {
Expand Down