mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-12 13:57:46 +01:00
Merge branch 'master' into master
This commit is contained in:
commit
016dc25fa9
@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2018 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||||
|
* Copyright (C) 2018 Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package brut.androlib.err;
|
||||||
|
|
||||||
|
import brut.androlib.AndrolibException;
|
||||||
|
|
||||||
|
public class AXmlDecodingException extends AndrolibException {
|
||||||
|
|
||||||
|
public AXmlDecodingException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AXmlDecodingException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AXmlDecodingException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AXmlDecodingException() {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2018 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||||
|
* Copyright (C) 2018 Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package brut.androlib.err;
|
||||||
|
|
||||||
|
import brut.androlib.AndrolibException;
|
||||||
|
|
||||||
|
public class RawXmlEncounteredException extends AndrolibException {
|
||||||
|
|
||||||
|
public RawXmlEncounteredException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RawXmlEncounteredException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RawXmlEncounteredException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RawXmlEncounteredException() {
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,7 @@ package brut.androlib.res.decoder;
|
|||||||
|
|
||||||
import brut.androlib.AndrolibException;
|
import brut.androlib.AndrolibException;
|
||||||
import brut.androlib.err.CantFind9PatchChunk;
|
import brut.androlib.err.CantFind9PatchChunk;
|
||||||
|
import brut.androlib.err.RawXmlEncounteredException;
|
||||||
import brut.androlib.res.data.ResResource;
|
import brut.androlib.res.data.ResResource;
|
||||||
import brut.androlib.res.data.value.ResBoolValue;
|
import brut.androlib.res.data.value.ResBoolValue;
|
||||||
import brut.androlib.res.data.value.ResFileValue;
|
import brut.androlib.res.data.value.ResFileValue;
|
||||||
@ -118,6 +119,11 @@ public class ResFileDecoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decode(inDir, inFileName, outDir, outFileName, "xml");
|
decode(inDir, inFileName, outDir, outFileName, "xml");
|
||||||
|
} catch (RawXmlEncounteredException ex) {
|
||||||
|
// If we got an error to decode XML, lets assume the file is in raw format.
|
||||||
|
// This is a large assumption, that might increase runtime, but will save us for situations where
|
||||||
|
// XSD files are AXML`d on aapt1, but left in plaintext in aapt2.
|
||||||
|
decode(inDir, inFileName, outDir, outFileName, "raw");
|
||||||
} catch (AndrolibException ex) {
|
} catch (AndrolibException ex) {
|
||||||
LOGGER.log(Level.SEVERE, String.format(
|
LOGGER.log(Level.SEVERE, String.format(
|
||||||
"Could not decode file, replacing by FALSE value: %s",
|
"Could not decode file, replacing by FALSE value: %s",
|
||||||
|
@ -19,8 +19,9 @@ package brut.androlib.res.decoder;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
|
import brut.androlib.err.AXmlDecodingException;
|
||||||
|
import brut.androlib.err.RawXmlEncounteredException;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
import org.xmlpull.v1.wrapper.XmlPullParserWrapper;
|
import org.xmlpull.v1.wrapper.XmlPullParserWrapper;
|
||||||
@ -142,9 +143,9 @@ public class XmlPullStreamDecoder implements ResStreamDecoder {
|
|||||||
}
|
}
|
||||||
ser.flush();
|
ser.flush();
|
||||||
} catch (XmlPullParserException ex) {
|
} catch (XmlPullParserException ex) {
|
||||||
throw new AndrolibException("Could not decode XML", ex);
|
throw new AXmlDecodingException("Could not decode XML", ex);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new AndrolibException("Could not decode XML", ex);
|
throw new RawXmlEncounteredException("Could not decode XML", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,6 +156,4 @@ public class XmlPullStreamDecoder implements ResStreamDecoder {
|
|||||||
|
|
||||||
private final XmlPullParser mParser;
|
private final XmlPullParser mParser;
|
||||||
private final ExtXmlSerializer mSerial;
|
private final ExtXmlSerializer mSerial;
|
||||||
|
|
||||||
private final static Logger LOGGER = Logger.getLogger(XmlPullStreamDecoder.class.getName());
|
|
||||||
}
|
}
|
||||||
|
@ -198,6 +198,11 @@ public class BuildAndDecodeTest extends BaseTest {
|
|||||||
compareXmlFiles("res/xml/references.xml");
|
compareXmlFiles("res/xml/references.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void xmlXsdFileTest() throws BrutException {
|
||||||
|
compareXmlFiles("res/xml/ww_box_styles_schema.xsd");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void xmlIdsEmptyTest() throws BrutException {
|
public void xmlIdsEmptyTest() throws BrutException {
|
||||||
compareXmlFiles("res/values/ids.xml");
|
compareXmlFiles("res/values/ids.xml");
|
||||||
|
@ -98,4 +98,9 @@ public class BuildAndDecodeTest extends BaseTest {
|
|||||||
public void confirmManifestStructureTest() throws BrutException {
|
public void confirmManifestStructureTest() throws BrutException {
|
||||||
compareXmlFiles("AndroidManifest.xml");
|
compareXmlFiles("AndroidManifest.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void xmlXsdFileTest() throws BrutException {
|
||||||
|
compareXmlFiles("res/xml/ww_box_styles_schema.xsd");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<public type="string" name="hello_world" id="0x7f020000" />
|
<public type="string" name="hello_world" id="0x7f020000" />
|
||||||
|
<public type="xml" name="ww_box_styles_schema" id="0x7f1500df" />
|
||||||
</resources>
|
</resources>
|
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<xs:element name="test">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="person" type="xs:string"/>
|
||||||
|
<xs:element name="address">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="name" type="xs:string"/>
|
||||||
|
<xs:element name="address" type="xs:string"/>
|
||||||
|
<xs:element name="city" type="xs:string"/>
|
||||||
|
<xs:element name="country" type="xs:string"/>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<xs:element name="test">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="person" type="xs:string"/>
|
||||||
|
<xs:element name="address">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="name" type="xs:string"/>
|
||||||
|
<xs:element name="address" type="xs:string"/>
|
||||||
|
<xs:element name="city" type="xs:string"/>
|
||||||
|
<xs:element name="country" type="xs:string"/>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
Loading…
Reference in New Issue
Block a user