Skip to content

feat: update internal framework to API 32 (12L Release) #2743

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

Merged
merged 5 commits into from
Mar 21, 2022
Merged
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 @@ -87,7 +87,7 @@ private ResPackage[] readTableHeader() throws IOException, AndrolibException {
}

private ResPackage readTablePackage() throws IOException, AndrolibException {
checkChunkType(Header.TYPE_PACKAGE);
checkChunkType(Header.XML_TYPE_PACKAGE);
int id = mIn.readInt();

if (id == 0) {
Expand Down Expand Up @@ -128,11 +128,17 @@ private ResPackage readTablePackage() throws IOException, AndrolibException {
boolean flag = true;
while (flag) {
switch (mHeader.type) {
case Header.TYPE_LIBRARY:
case Header.XML_TYPE_SPEC_TYPE:
readTableTypeSpec();
break;
case Header.XML_TYPE_LIBRARY:
readLibraryType();
break;
case Header.TYPE_SPEC_TYPE:
readTableTypeSpec();
case Header.XML_TYPE_OVERLAY:
readOverlaySpec();
break;
case Header.XML_TYPE_STAGED_ALIAS:
readStagedAliasSpec();
break;
default:
flag = false;
Expand All @@ -144,7 +150,7 @@ private ResPackage readTablePackage() throws IOException, AndrolibException {
}

private void readLibraryType() throws AndrolibException, IOException {
checkChunkType(Header.TYPE_LIBRARY);
checkChunkType(Header.XML_TYPE_LIBRARY);
int libraryCount = mIn.readInt();

int packageId;
Expand All @@ -156,19 +162,40 @@ private void readLibraryType() throws AndrolibException, IOException {
LOGGER.info(String.format("Decoding Shared Library (%s), pkgId: %d", packageName, packageId));
}

while(nextChunk().type == Header.TYPE_TYPE) {
while(nextChunk().type == Header.XML_TYPE_TYPE) {
readTableTypeSpec();
}
}

private void readStagedAliasSpec() throws IOException {
int count = mIn.readInt();

for (int i = 0; i < count; i++) {
LOGGER.info(String.format("Skipping staged alias stagedId (%h) finalId: %h", mIn.readInt(), mIn.readInt()));
}

nextChunk();
}

private void readOverlaySpec() throws IOException {
/* policyFlags */mIn.skipInt();
int count = mIn.readInt();

for (int i = 0; i < count; i++) {
LOGGER.info(String.format("Skipping overlay (%h)", mIn.readInt()));
}

nextChunk();
}

private void readTableTypeSpec() throws AndrolibException, IOException {
mTypeSpec = readSingleTableTypeSpec();
addTypeSpec(mTypeSpec);

int type = nextChunk().type;
ResTypeSpec resTypeSpec;

while (type == Header.TYPE_SPEC_TYPE) {
while (type == Header.XML_TYPE_SPEC_TYPE) {
resTypeSpec = readSingleTableTypeSpec();
addTypeSpec(resTypeSpec);
type = nextChunk().type;
Expand All @@ -180,7 +207,7 @@ private void readTableTypeSpec() throws AndrolibException, IOException {
}
}

while (type == Header.TYPE_TYPE) {
while (type == Header.XML_TYPE_TYPE) {
readTableType();

// skip "TYPE 8 chunks" and/or padding data at the end of this chunk
Expand All @@ -196,7 +223,7 @@ private void readTableTypeSpec() throws AndrolibException, IOException {
}

private ResTypeSpec readSingleTableTypeSpec() throws AndrolibException, IOException {
checkChunkType(Header.TYPE_SPEC_TYPE);
checkChunkType(Header.XML_TYPE_SPEC_TYPE);
int id = mIn.readUnsignedByte();
mIn.skipBytes(3);
int entryCount = mIn.readInt();
Expand All @@ -212,7 +239,7 @@ private ResTypeSpec readSingleTableTypeSpec() throws AndrolibException, IOExcept
}

private ResType readTableType() throws IOException, AndrolibException {
checkChunkType(Header.TYPE_TYPE);
checkChunkType(Header.XML_TYPE_TYPE);
int typeId = mIn.readUnsignedByte() - mTypeIdOffset;
if (mResTypeSpecs.containsKey(typeId)) {
mResId = (0xff000000 & mResId) | mResTypeSpecs.get(typeId).getId() << 16;
Expand Down Expand Up @@ -604,8 +631,18 @@ public static Header read(ExtDataInput in, CountingInputStream countIn) throws I
return new Header(type, in.readShort(), in.readInt(), start);
}

public final static short TYPE_NONE = -1, TYPE_TABLE = 0x0002,
TYPE_PACKAGE = 0x0200, TYPE_TYPE = 0x0201, TYPE_SPEC_TYPE = 0x0202, TYPE_LIBRARY = 0x0203;
public final static short TYPE_NONE = -1;
public final static short TYPE_STRING_POOL = 0x0001;
public final static short TYPE_TABLE = 0x0002;
public final static short TYPE_XML = 0x0003;

public final static short XML_TYPE_PACKAGE = 0x0200;
public final static short XML_TYPE_TYPE = 0x0201;
public final static short XML_TYPE_SPEC_TYPE = 0x0202;
public final static short XML_TYPE_LIBRARY = 0x0203;
public final static short XML_TYPE_OVERLAY = 0x0204;
public final static short XML_TYPE_OVERLAY_POLICY = 0x0205;
public final static short XML_TYPE_STAGED_ALIAS = 0x0206;
}

public static class FlagsOffset {
Expand Down
Binary file not shown.