private void addTypeSpec(ResTypeSpec resTypeSpec) { mResTypeSpecs.put(resTypeSpec.getId(), resTypeSpec); }
public ResResSpec getResSpec(String name) throws AndrolibException { ResResSpec spec = getResSpecUnsafe(name); if (spec == null) { throw new UndefinedResObject(String.format("resource spec: %s/%s", getName(), name)); } return spec; }
public ResValue getValue(String package_, String type, String name) throws AndrolibException { return getPackage(package_).getType(type).getResSpec(name).getDefaultResource().getValue(); }
int typeId = mIn.readUnsignedByte() - mTypeIdOffset; if (mResTypeSpecs.containsKey(typeId)) { mResId = (0xff000000 & mResId) | mResTypeSpecs.get(typeId).getId() << 16; mTypeSpec = mResTypeSpecs.get(typeId); LOGGER.info("Sparse type flags detected: " + mTypeSpec.getName()); String resName = mTypeSpec.getName() + flags.getQualifiers(); if (mKeepBroken) { LOGGER.warning("Invalid config flags detected: " + resName);
ResValue value = entryData.mValue; if (mTypeSpec.isString() && value instanceof ResFileValue) { value = new ResStringValue(value.toString(), ((ResFileValue) value).getRawIntValue()); mTypeSpec.addResSpec(spec); mTypeSpec.addResSpec(spec);
@Override public String toString() { return mId.toString() + " " + mType.toString() + "/" + mName; } }
public ResResSpec(ResID id, String name, ResPackage pkg, ResTypeSpec type) { this.mId = id; String cleanName; ResResSpec resResSpec = type.getResSpecUnsafe(name); if (resResSpec != null) { cleanName = name + "_APKTOOL_DUPLICATENAME_" + id.toString(); } else { cleanName = (name.isEmpty() ? ("APKTOOL_DUMMYVAL_" + id.toString()) : name); } this.mName = cleanName; this.mPackage = pkg; this.mType = type; }
private void removeResSpec(ResResSpec spec) throws AndrolibException { if (mPkg.hasResSpec(spec.getId())) { mPkg.removeResSpec(spec); mTypeSpec.removeResSpec(spec); } }
private ResTypeSpec readSingleTableTypeSpec() throws AndrolibException, IOException { checkChunkType(Header.TYPE_SPEC_TYPE); int id = mIn.readUnsignedByte(); mIn.skipBytes(3); int entryCount = mIn.readInt(); if (mFlagsOffsets != null) { mFlagsOffsets.add(new FlagsOffset(mCountIn.getCount(), entryCount)); } /* flags */mIn.skipBytes(entryCount * 4); mTypeSpec = new ResTypeSpec(mTypeNames.getString(id - 1), mResTable, mPkg, id, entryCount); mPkg.addType(mTypeSpec); return mTypeSpec; }
private void addMissingResSpecs() throws AndrolibException { int resId = mResId & 0xffff0000; for (int i = 0; i < mMissingResSpecs.length; i++) { if (!mMissingResSpecs[i]) { continue; } ResResSpec spec = new ResResSpec(new ResID(resId | i), "APKTOOL_DUMMY_" + Integer.toHexString(i), mPkg, mTypeSpec); // If we already have this resID dont add it again. if (! mPkg.hasResSpec(new ResID(resId | i))) { mPkg.addResSpec(spec); mTypeSpec.addResSpec(spec); if (mType == null) { mType = mPkg.getOrCreateConfig(new ResConfigFlags()); } ResValue value = new ResBoolValue(false, 0, null); ResResource res = new ResResource(mType, spec, value); mPkg.addResource(res); mType.addResource(res); spec.addResource(res); } } }
.getType(m1.group(2)).getResSpec(m1.group(3)) .getId().id; if (m2.group(1) != null) {
public void addResSpec(ResResSpec spec) throws AndrolibException { if (mResSpecs.put(spec.getName(), spec) != null) { throw new AndrolibException(String.format("Multiple res specs: %s/%s", getName(), spec.getName())); } }
public String getFullName(boolean excludePackage, boolean excludeType) { return (excludePackage ? "" : getPackage().getName() + ":") + (excludeType ? "" : getType().getName() + "/") + getName(); }
public String getFilePath() { return mResSpec.getType().getName() + mConfig.getFlags().getQualifiers() + "/" + mResSpec.getName(); }
String inFileName = fileValue.getStrippedPath(); String outResName = res.getFilePath(); String typeName = res.getResSpec().getType().getName();
public ResBagValue bagFactory(int parent, Duo<Integer, ResScalarValue>[] items, ResTypeSpec resTypeSpec) throws AndrolibException { ResReferenceValue parentVal = newReference(parent, null); if (items.length == 0) { return new ResBagValue(parentVal); } int key = items[0].m1; if (key == ResAttr.BAG_KEY_ATTR_TYPE) { return ResAttr.factory(parentVal, items, this, mPackage); } String resTypeName = resTypeSpec.getName(); // Android O Preview added an unknown enum for c. This is hardcoded as 0 for now. if (ResTypeSpec.RES_TYPE_NAME_ARRAY.equals(resTypeName) || key == ResArrayValue.BAG_KEY_ARRAY_START || key == 0) { return new ResArrayValue(parentVal, items); } if (ResTypeSpec.RES_TYPE_NAME_PLURALS.equals(resTypeName) || (key >= ResPluralsValue.BAG_KEY_PLURALS_START && key <= ResPluralsValue.BAG_KEY_PLURALS_END)) { return new ResPluralsValue(parentVal, items); } if (ResTypeSpec.RES_TYPE_NAME_STYLES.equals(resTypeName)) { return new ResStyleValue(parentVal, items, this); } throw new AndrolibException("unsupported res type name for bags. Found: " + resTypeName); }
@Override public void serializeToResValuesXml(XmlSerializer serializer, ResResource res) throws IOException, AndrolibException { String type = res.getResSpec().getType().getName(); boolean item = !"reference".equals(mType) && !type.equals(mType);
@Override protected String encodeAsResXml() throws AndrolibException { if (isNull()) { return "@null"; } ResResSpec spec = getReferent(); if (spec == null) { return "@null"; } boolean newId = spec.hasDefaultResource() && spec.getDefaultResource().getValue() instanceof ResIdValue; // generate the beginning to fix @android String mStart = (mTheme ? '?' : '@') + (newId ? "+" : ""); return mStart + spec.getFullName(mPackage, mTheme && spec.getType().getName().equals("attr")); }