Search in sources :

Example 1 with ResRefField

use of jadx.core.dex.nodes.ResRefField in project jadx by skylot.

the class ConstStorage method getConstField.

@Nullable
public FieldNode getConstField(ClassNode cls, Object value, boolean searchGlobal) {
    DexNode dex = cls.dex();
    if (value instanceof Integer) {
        String str = resourcesNames.get(value);
        if (str != null) {
            return new ResRefField(dex, str.replace('/', '.'));
        }
    }
    if (!replaceEnabled) {
        return null;
    }
    boolean foundInGlobal = globalValues.contains(value);
    if (foundInGlobal && !searchGlobal) {
        return null;
    }
    ClassNode current = cls;
    while (current != null) {
        Values classValues = classes.get(current);
        if (classValues != null) {
            FieldNode field = classValues.get(value);
            if (field != null) {
                if (foundInGlobal) {
                    return null;
                }
                return field;
            }
        }
        ClassInfo parentClass = current.getClassInfo().getParentClass();
        if (parentClass == null) {
            break;
        }
        current = dex.resolveClass(parentClass);
    }
    if (searchGlobal) {
        return globalValues.get(value);
    }
    return null;
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) FieldNode(jadx.core.dex.nodes.FieldNode) DexNode(jadx.core.dex.nodes.DexNode) ResRefField(jadx.core.dex.nodes.ResRefField) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ClassNode (jadx.core.dex.nodes.ClassNode)1 DexNode (jadx.core.dex.nodes.DexNode)1 FieldNode (jadx.core.dex.nodes.FieldNode)1 ResRefField (jadx.core.dex.nodes.ResRefField)1 Nullable (org.jetbrains.annotations.Nullable)1