mirror of
https://github.com/revanced/ARSCLib.git
synced 2025-05-02 23:24:26 +02:00
rename packages
This commit is contained in:
parent
4ffd13c793
commit
71cf694c33
20
README.md
20
README.md
@ -60,21 +60,21 @@ cd ARSCLib
|
|||||||
<details><summary> <code><b>See java example</b></code></summary>
|
<details><summary> <code><b>See java example</b></code></summary>
|
||||||
|
|
||||||
```java
|
```java
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
import com.reandroid.arsc.chunk.TableBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.PackageBlock;
|
import com.reandroid.arsc.chunk.PackageBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.AndroidManifestBlock;
|
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.ResXmlElement;
|
import com.reandroid.arsc.chunk.xml.ResXmlElement;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.ResXmlAttribute;
|
import com.reandroid.arsc.chunk.xml.ResXmlAttribute;
|
||||||
|
|
||||||
public static void exampleManifest() throws IOException{
|
public static void exampleManifest()throws IOException{
|
||||||
File inFile=new File("AndroidManifest.xml");
|
File inFile=new File("AndroidManifest.xml");
|
||||||
|
|
||||||
// *** Loading AndroidManifest ***
|
// *** Loading AndroidManifest ***
|
||||||
AndroidManifestBlock manifestBlock = AndroidManifestBlock.load(inFile);
|
AndroidManifestBlock manifestBlock=AndroidManifestBlock.load(inFile);
|
||||||
|
|
||||||
System.out.println("Package name: "+manifestBlock.getPackageName());
|
System.out.println("Package name: "+manifestBlock.getPackageName());
|
||||||
|
|
||||||
List<String> usesPermissionList = manifestBlock.getUsesPermissions();
|
List<String> usesPermissionList=manifestBlock.getUsesPermissions();
|
||||||
for(String usesPermission:usesPermissionList){
|
for(String usesPermission:usesPermissionList){
|
||||||
System.out.println("Uses permission: "+usesPermission);
|
System.out.println("Uses permission: "+usesPermission);
|
||||||
}
|
}
|
||||||
@ -90,9 +90,9 @@ public static void exampleManifest() throws IOException{
|
|||||||
manifestBlock.setVersionName("9.0.4");
|
manifestBlock.setVersionName("9.0.4");
|
||||||
|
|
||||||
// Modify xml attribute
|
// Modify xml attribute
|
||||||
List<ResXmlElement> activityList = manifestBlock.listActivities();
|
List<ResXmlElement> activityList=manifestBlock.listActivities();
|
||||||
for(ResXmlElement activityElement:activityList){
|
for(ResXmlElement activityElement:activityList){
|
||||||
ResXmlAttribute attributeName = activityElement.searchAttributeByResourceId(AndroidManifestBlock.ID_name);
|
ResXmlAttribute attributeName=activityElement.searchAttributeByResourceId(AndroidManifestBlock.ID_name);
|
||||||
System.out.println("Old activity name: "+attributeName.getValueAsString());
|
System.out.println("Old activity name: "+attributeName.getValueAsString());
|
||||||
attributeName.setValueAsString("com.app.MyActivity");
|
attributeName.setValueAsString("com.app.MyActivity");
|
||||||
System.out.println("New activity name: "+attributeName.getValueAsString());
|
System.out.println("New activity name: "+attributeName.getValueAsString());
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
|
|
||||||
group 'com.reandroid.lib.arsc'
|
group 'com.reandroid'
|
||||||
version '1.1.4'
|
version '1.1.4'
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
public interface APKLogger {
|
public interface APKLogger {
|
||||||
void logMessage(String msg);
|
void logMessage(String msg);
|
@ -13,12 +13,12 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.APKArchive;
|
import com.reandroid.archive.APKArchive;
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
import com.reandroid.arsc.chunk.TableBlock;
|
||||||
import com.reandroid.lib.arsc.pool.TableStringPool;
|
import com.reandroid.arsc.pool.TableStringPool;
|
||||||
import com.reandroid.lib.arsc.pool.builder.StringPoolMerger;
|
import com.reandroid.arsc.pool.builder.StringPoolMerger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
@ -13,13 +13,13 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.InputSource;
|
import com.reandroid.archive.InputSource;
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
import com.reandroid.arsc.chunk.TableBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.AndroidManifestBlock;
|
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.ResXmlBlock;
|
import com.reandroid.arsc.chunk.xml.ResXmlDocument;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@ -71,9 +71,9 @@ public class ApkJsonDecoder {
|
|||||||
InputSource inputSource= resFile.getInputSource();
|
InputSource inputSource= resFile.getInputSource();
|
||||||
String path=inputSource.getAlias();
|
String path=inputSource.getAlias();
|
||||||
File file=toResJson(dir, path);
|
File file=toResJson(dir, path);
|
||||||
ResXmlBlock resXmlBlock=new ResXmlBlock();
|
ResXmlDocument resXmlDocument =new ResXmlDocument();
|
||||||
resXmlBlock.readBytes(inputSource.openStream());
|
resXmlDocument.readBytes(inputSource.openStream());
|
||||||
JSONObject jsonObject=resXmlBlock.toJson();
|
JSONObject jsonObject= resXmlDocument.toJson();
|
||||||
jsonObject.write(file);
|
jsonObject.write(file);
|
||||||
addDecoded(path);
|
addDecoded(path);
|
||||||
}
|
}
|
@ -13,12 +13,12 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.APKArchive;
|
import com.reandroid.archive.APKArchive;
|
||||||
import com.reandroid.archive.FileInputSource;
|
import com.reandroid.archive.FileInputSource;
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
import com.reandroid.arsc.chunk.TableBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.AndroidManifestBlock;
|
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
@ -13,18 +13,18 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.*;
|
import com.reandroid.archive.*;
|
||||||
import com.reandroid.lib.arsc.array.PackageArray;
|
import com.reandroid.arsc.array.PackageArray;
|
||||||
import com.reandroid.lib.arsc.chunk.BaseChunk;
|
import com.reandroid.arsc.chunk.Chunk;
|
||||||
import com.reandroid.lib.arsc.chunk.PackageBlock;
|
import com.reandroid.arsc.chunk.PackageBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
import com.reandroid.arsc.chunk.TableBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.AndroidManifestBlock;
|
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
||||||
import com.reandroid.lib.arsc.group.StringGroup;
|
import com.reandroid.arsc.group.StringGroup;
|
||||||
import com.reandroid.lib.arsc.item.TableString;
|
import com.reandroid.arsc.item.TableString;
|
||||||
import com.reandroid.lib.arsc.pool.TableStringPool;
|
import com.reandroid.arsc.pool.TableStringPool;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -75,6 +75,9 @@ public class ApkModule {
|
|||||||
writeApk(file, null);
|
writeApk(file, null);
|
||||||
}
|
}
|
||||||
public void writeApk(File file, WriteProgress progress) throws IOException {
|
public void writeApk(File file, WriteProgress progress) throws IOException {
|
||||||
|
writeApk(file, progress, null);
|
||||||
|
}
|
||||||
|
public void writeApk(File file, WriteProgress progress, WriteInterceptor interceptor) throws IOException {
|
||||||
uncompressNonXmlResFiles();
|
uncompressNonXmlResFiles();
|
||||||
APKArchive archive=getApkArchive();
|
APKArchive archive=getApkArchive();
|
||||||
InputSource table=archive.getInputSource(TableBlock.FILE_NAME);
|
InputSource table=archive.getInputSource(TableBlock.FILE_NAME);
|
||||||
@ -96,6 +99,7 @@ public class ApkModule {
|
|||||||
}
|
}
|
||||||
ZipSerializer serializer=new ZipSerializer(archive.listInputSources());
|
ZipSerializer serializer=new ZipSerializer(archive.listInputSources());
|
||||||
serializer.setWriteProgress(progress);
|
serializer.setWriteProgress(progress);
|
||||||
|
serializer.setWriteInterceptor(interceptor);
|
||||||
serializer.writeZip(file);
|
serializer.writeZip(file);
|
||||||
}
|
}
|
||||||
private void uncompressNonXmlResFiles() throws IOException {
|
private void uncompressNonXmlResFiles() throws IOException {
|
||||||
@ -288,7 +292,7 @@ public class ApkModule {
|
|||||||
}else if(inputSource instanceof SingleJsonTableInputSource){
|
}else if(inputSource instanceof SingleJsonTableInputSource){
|
||||||
tableBlock=((SingleJsonTableInputSource)inputSource).getTableBlock();
|
tableBlock=((SingleJsonTableInputSource)inputSource).getTableBlock();
|
||||||
}else if(inputSource instanceof BlockInputSource){
|
}else if(inputSource instanceof BlockInputSource){
|
||||||
BaseChunk block = ((BlockInputSource<?>) inputSource).getBlock();
|
Chunk block = ((BlockInputSource<?>) inputSource).getBlock();
|
||||||
tableBlock=(TableBlock) block;
|
tableBlock=(TableBlock) block;
|
||||||
}else {
|
}else {
|
||||||
InputStream inputStream = inputSource.openStream();
|
InputStream inputStream = inputSource.openStream();
|
||||||
@ -372,7 +376,7 @@ public class ApkModule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(DexFileInputSource source:comingList){
|
for(DexFileInputSource source:comingList){
|
||||||
String name=DexFileInputSource.getDexName(index);
|
String name= DexFileInputSource.getDexName(index);
|
||||||
DexFileInputSource add=new DexFileInputSource(name, source.getInputSource());
|
DexFileInputSource add=new DexFileInputSource(name, source.getInputSource());
|
||||||
archive.add(add);
|
archive.add(add);
|
||||||
logMessage("Added ["+module.getModuleName()+"] "
|
logMessage("Added ["+module.getModuleName()+"] "
|
@ -13,23 +13,23 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.InputSource;
|
import com.reandroid.archive.InputSource;
|
||||||
import com.reandroid.lib.apk.xmldecoder.XMLBagDecoder;
|
import com.reandroid.apk.xmldecoder.XMLBagDecoder;
|
||||||
import com.reandroid.lib.apk.xmldecoder.XMLNamespaceValidator;
|
import com.reandroid.apk.xmldecoder.XMLNamespaceValidator;
|
||||||
import com.reandroid.lib.arsc.chunk.PackageBlock;
|
import com.reandroid.arsc.chunk.PackageBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
import com.reandroid.arsc.chunk.TableBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.TypeBlock;
|
import com.reandroid.arsc.chunk.TypeBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.AndroidManifestBlock;
|
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.ResXmlBlock;
|
import com.reandroid.arsc.chunk.xml.ResXmlDocument;
|
||||||
import com.reandroid.lib.arsc.container.SpecTypePair;
|
import com.reandroid.arsc.container.SpecTypePair;
|
||||||
import com.reandroid.lib.arsc.decoder.ValueDecoder;
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
import com.reandroid.lib.arsc.value.*;
|
import com.reandroid.arsc.value.*;
|
||||||
import com.reandroid.lib.common.EntryStore;
|
import com.reandroid.common.EntryStore;
|
||||||
import com.reandroid.lib.common.Frameworks;
|
import com.reandroid.common.Frameworks;
|
||||||
import com.reandroid.lib.common.TableEntryStore;
|
import com.reandroid.common.TableEntryStore;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
import com.reandroid.xml.XMLAttribute;
|
import com.reandroid.xml.XMLAttribute;
|
||||||
import com.reandroid.xml.XMLDocument;
|
import com.reandroid.xml.XMLDocument;
|
||||||
import com.reandroid.xml.XMLElement;
|
import com.reandroid.xml.XMLElement;
|
||||||
@ -130,8 +130,8 @@ import java.util.*;
|
|||||||
throws IOException, XMLException{
|
throws IOException, XMLException{
|
||||||
EntryBlock entryBlock=resFile.pickOne();
|
EntryBlock entryBlock=resFile.pickOne();
|
||||||
PackageBlock packageBlock=entryBlock.getPackageBlock();
|
PackageBlock packageBlock=entryBlock.getPackageBlock();
|
||||||
ResXmlBlock resXmlBlock=new ResXmlBlock();
|
ResXmlDocument resXmlDocument =new ResXmlDocument();
|
||||||
resXmlBlock.readBytes(resFile.getInputSource().openStream());
|
resXmlDocument.readBytes(resFile.getInputSource().openStream());
|
||||||
|
|
||||||
File pkgDir=new File(outDir, getPackageDirName(packageBlock));
|
File pkgDir=new File(outDir, getPackageDirName(packageBlock));
|
||||||
File resDir=new File(pkgDir, ApkUtil.RES_DIR_NAME);
|
File resDir=new File(pkgDir, ApkUtil.RES_DIR_NAME);
|
||||||
@ -140,9 +140,9 @@ import java.util.*;
|
|||||||
File file=new File(resDir, path);
|
File file=new File(resDir, path);
|
||||||
|
|
||||||
logVerbose("Decoding: "+path);
|
logVerbose("Decoding: "+path);
|
||||||
XMLNamespaceValidator namespaceValidator=new XMLNamespaceValidator(resXmlBlock);
|
XMLNamespaceValidator namespaceValidator=new XMLNamespaceValidator(resXmlDocument);
|
||||||
namespaceValidator.validate();
|
namespaceValidator.validate();
|
||||||
XMLDocument xmlDocument=resXmlBlock.decodeToXml(entryStore, packageBlock.getId());
|
XMLDocument xmlDocument= resXmlDocument.decodeToXml(entryStore, packageBlock.getId());
|
||||||
xmlDocument.save(file, true);
|
xmlDocument.save(file, true);
|
||||||
|
|
||||||
addDecodedEntry(resFile.pickOne());
|
addDecodedEntry(resFile.pickOne());
|
@ -13,13 +13,12 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.APKArchive;
|
import com.reandroid.archive.APKArchive;
|
||||||
import com.reandroid.archive.FileInputSource;
|
import com.reandroid.archive.FileInputSource;
|
||||||
import com.reandroid.lib.apk.xmlencoder.RESEncoder;
|
import com.reandroid.apk.xmlencoder.RESEncoder;
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
import com.reandroid.arsc.chunk.TableBlock;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
|
||||||
import com.reandroid.xml.XMLException;
|
import com.reandroid.xml.XMLException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.InputSource;
|
import com.reandroid.archive.InputSource;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public class ApkUtil {
|
|||||||
public static String toArchiveResourcePath(File dir, File file){
|
public static String toArchiveResourcePath(File dir, File file){
|
||||||
String path = toArchivePath(dir, file);
|
String path = toArchivePath(dir, file);
|
||||||
if(path.endsWith(ApkUtil.JSON_FILE_EXTENSION)){
|
if(path.endsWith(ApkUtil.JSON_FILE_EXTENSION)){
|
||||||
int i2=path.length()-ApkUtil.JSON_FILE_EXTENSION.length();
|
int i2=path.length()- ApkUtil.JSON_FILE_EXTENSION.length();
|
||||||
path=path.substring(0, i2);
|
path=path.substring(0, i2);
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
@ -13,20 +13,16 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.ByteInputSource;
|
import com.reandroid.archive.ByteInputSource;
|
||||||
import com.reandroid.archive.InputSource;
|
import com.reandroid.arsc.base.Block;
|
||||||
import com.reandroid.lib.arsc.base.Block;
|
import com.reandroid.arsc.chunk.Chunk;
|
||||||
import com.reandroid.lib.arsc.chunk.BaseChunk;
|
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
public class BlockInputSource<T extends BaseChunk> extends ByteInputSource{
|
public class BlockInputSource<T extends Chunk> extends ByteInputSource{
|
||||||
private final T mBlock;
|
private final T mBlock;
|
||||||
public BlockInputSource(String name, T block) {
|
public BlockInputSource(String name, T block) {
|
||||||
super(new byte[0], name);
|
super(new byte[0], name);
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.InputSource;
|
import com.reandroid.archive.InputSource;
|
||||||
|
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.InputSource;
|
import com.reandroid.archive.InputSource;
|
||||||
|
|
@ -13,16 +13,16 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.APKArchive;
|
import com.reandroid.archive.APKArchive;
|
||||||
import com.reandroid.archive.InputSource;
|
import com.reandroid.archive.InputSource;
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
import com.reandroid.arsc.chunk.TableBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.AndroidManifestBlock;
|
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.ResXmlAttribute;
|
import com.reandroid.arsc.chunk.xml.ResXmlAttribute;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.ResXmlElement;
|
import com.reandroid.arsc.chunk.xml.ResXmlElement;
|
||||||
import com.reandroid.lib.arsc.util.FrameworkTable;
|
import com.reandroid.arsc.util.FrameworkTable;
|
||||||
import com.reandroid.lib.arsc.value.ValueType;
|
import com.reandroid.arsc.value.ValueType;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
@ -13,11 +13,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.FileInputSource;
|
import com.reandroid.archive.FileInputSource;
|
||||||
import com.reandroid.archive.InputSource;
|
import com.reandroid.archive.InputSource;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.AndroidManifestBlock;
|
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -13,14 +13,13 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.FileInputSource;
|
import com.reandroid.archive.FileInputSource;
|
||||||
import com.reandroid.archive.InputSource;
|
import com.reandroid.archive.InputSource;
|
||||||
import com.reandroid.lib.arsc.base.Block;
|
import com.reandroid.arsc.chunk.xml.ResXmlDocument;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.ResXmlBlock;
|
import com.reandroid.json.JSONException;
|
||||||
import com.reandroid.lib.json.JSONException;
|
import com.reandroid.json.JSONObject;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
@ -37,28 +36,28 @@ public class JsonXmlInputSource extends InputSource {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public InputStream openStream() throws IOException {
|
public InputStream openStream() throws IOException {
|
||||||
ResXmlBlock resXmlBlock= getResXmlBlock();
|
ResXmlDocument resXmlDocument = getResXmlBlock();
|
||||||
return new ByteArrayInputStream(resXmlBlock.getBytes());
|
return new ByteArrayInputStream(resXmlDocument.getBytes());
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public long getLength() throws IOException{
|
public long getLength() throws IOException{
|
||||||
ResXmlBlock resXmlBlock = getResXmlBlock();
|
ResXmlDocument resXmlDocument = getResXmlBlock();
|
||||||
return resXmlBlock.countBytes();
|
return resXmlDocument.countBytes();
|
||||||
}
|
}
|
||||||
private ResXmlBlock getResXmlBlock() throws IOException{
|
private ResXmlDocument getResXmlBlock() throws IOException{
|
||||||
logVerbose("From json: "+getAlias());
|
logVerbose("From json: "+getAlias());
|
||||||
ResXmlBlock resXmlBlock=newInstance();
|
ResXmlDocument resXmlDocument =newInstance();
|
||||||
InputStream inputStream=inputSource.openStream();
|
InputStream inputStream=inputSource.openStream();
|
||||||
try{
|
try{
|
||||||
JSONObject jsonObject=new JSONObject(inputStream);
|
JSONObject jsonObject=new JSONObject(inputStream);
|
||||||
resXmlBlock.fromJson(jsonObject);
|
resXmlDocument.fromJson(jsonObject);
|
||||||
}catch (JSONException ex){
|
}catch (JSONException ex){
|
||||||
throw new IOException(inputSource.getAlias()+": "+ex.getMessage(), ex);
|
throw new IOException(inputSource.getAlias()+": "+ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
return resXmlBlock;
|
return resXmlDocument;
|
||||||
}
|
}
|
||||||
ResXmlBlock newInstance(){
|
ResXmlDocument newInstance(){
|
||||||
return new ResXmlBlock();
|
return new ResXmlDocument();
|
||||||
}
|
}
|
||||||
void setAPKLogger(APKLogger logger) {
|
void setAPKLogger(APKLogger logger) {
|
||||||
this.apkLogger = logger;
|
this.apkLogger = logger;
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.InputSource;
|
import com.reandroid.archive.InputSource;
|
||||||
|
|
@ -13,14 +13,14 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.InputSource;
|
import com.reandroid.archive.InputSource;
|
||||||
import com.reandroid.lib.apk.xmlencoder.XMLEncodeSource;
|
import com.reandroid.apk.xmlencoder.XMLEncodeSource;
|
||||||
import com.reandroid.lib.arsc.chunk.TypeBlock;
|
import com.reandroid.arsc.chunk.TypeBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.ResXmlBlock;
|
import com.reandroid.arsc.chunk.xml.ResXmlDocument;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -117,7 +117,7 @@ public class ResFile {
|
|||||||
}else{
|
}else{
|
||||||
try {
|
try {
|
||||||
InputStream inputStream=getInputSource().openStream();
|
InputStream inputStream=getInputSource().openStream();
|
||||||
mBinXml=ResXmlBlock.isResXmlBlock(inputStream);
|
mBinXml= ResXmlDocument.isResXmlBlock(inputStream);
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
@ -131,9 +131,9 @@ public class ResFile {
|
|||||||
String fileName=getFilePath()+ApkUtil.JSON_FILE_EXTENSION;
|
String fileName=getFilePath()+ApkUtil.JSON_FILE_EXTENSION;
|
||||||
fileName=fileName.replace('/', File.separatorChar);
|
fileName=fileName.replace('/', File.separatorChar);
|
||||||
File file=new File(rootDir, fileName);
|
File file=new File(rootDir, fileName);
|
||||||
ResXmlBlock resXmlBlock=new ResXmlBlock();
|
ResXmlDocument resXmlDocument =new ResXmlDocument();
|
||||||
resXmlBlock.readBytes(getInputSource().openStream());
|
resXmlDocument.readBytes(getInputSource().openStream());
|
||||||
JSONObject jsonObject=resXmlBlock.toJson();
|
JSONObject jsonObject= resXmlDocument.toJson();
|
||||||
jsonObject.write(file);
|
jsonObject.write(file);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
@ -13,15 +13,15 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.chunk.PackageBlock;
|
import com.reandroid.arsc.chunk.PackageBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
import com.reandroid.arsc.chunk.TableBlock;
|
||||||
import com.reandroid.lib.arsc.group.EntryGroup;
|
import com.reandroid.arsc.group.EntryGroup;
|
||||||
import com.reandroid.lib.arsc.pool.SpecStringPool;
|
import com.reandroid.arsc.pool.SpecStringPool;
|
||||||
import com.reandroid.lib.arsc.util.ResNameMap;
|
import com.reandroid.arsc.util.ResNameMap;
|
||||||
import com.reandroid.lib.json.JSONArray;
|
import com.reandroid.json.JSONArray;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
import com.reandroid.xml.*;
|
import com.reandroid.xml.*;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
@ -13,13 +13,13 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.FileInputSource;
|
import com.reandroid.archive.FileInputSource;
|
||||||
import com.reandroid.archive.InputSource;
|
import com.reandroid.archive.InputSource;
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
import com.reandroid.arsc.chunk.TableBlock;
|
||||||
import com.reandroid.lib.json.JSONException;
|
import com.reandroid.json.JSONException;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
@ -13,10 +13,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.InputSource;
|
import com.reandroid.archive.InputSource;
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
import com.reandroid.arsc.chunk.TableBlock;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
@ -13,17 +13,17 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.chunk.PackageBlock;
|
import com.reandroid.arsc.chunk.PackageBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
import com.reandroid.arsc.chunk.TableBlock;
|
||||||
import com.reandroid.lib.arsc.pool.SpecStringPool;
|
import com.reandroid.arsc.pool.SpecStringPool;
|
||||||
import com.reandroid.lib.arsc.pool.TableStringPool;
|
import com.reandroid.arsc.pool.TableStringPool;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
import com.reandroid.lib.arsc.value.ValueType;
|
import com.reandroid.arsc.value.ValueType;
|
||||||
import com.reandroid.lib.json.JSONArray;
|
import com.reandroid.json.JSONArray;
|
||||||
import com.reandroid.lib.json.JSONException;
|
import com.reandroid.json.JSONException;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
@ -13,15 +13,15 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.BuildInfo;
|
import com.reandroid.arsc.BuildInfo;
|
||||||
import com.reandroid.lib.arsc.chunk.PackageBlock;
|
import com.reandroid.arsc.chunk.PackageBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.StagedAlias;
|
import com.reandroid.arsc.chunk.StagedAlias;
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
import com.reandroid.arsc.chunk.TableBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.TypeBlock;
|
import com.reandroid.arsc.chunk.TypeBlock;
|
||||||
import com.reandroid.lib.arsc.container.SpecTypePair;
|
import com.reandroid.arsc.container.SpecTypePair;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
@ -13,15 +13,15 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.chunk.PackageBlock;
|
import com.reandroid.arsc.chunk.PackageBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.StagedAlias;
|
import com.reandroid.arsc.chunk.StagedAlias;
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
import com.reandroid.arsc.chunk.TableBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.TypeBlock;
|
import com.reandroid.arsc.chunk.TypeBlock;
|
||||||
import com.reandroid.lib.arsc.value.ResConfig;
|
import com.reandroid.arsc.value.ResConfig;
|
||||||
import com.reandroid.lib.json.JSONArray;
|
import com.reandroid.json.JSONArray;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
@ -13,13 +13,13 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.archive.InputSource;
|
import com.reandroid.archive.InputSource;
|
||||||
import com.reandroid.archive.ZipArchive;
|
import com.reandroid.archive.ZipArchive;
|
||||||
import com.reandroid.lib.json.JSONArray;
|
import com.reandroid.json.JSONArray;
|
||||||
import com.reandroid.lib.json.JSONConvert;
|
import com.reandroid.json.JSONConvert;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
@ -13,9 +13,9 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk;
|
package com.reandroid.apk;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.item.StringItem;
|
import com.reandroid.arsc.item.StringItem;
|
||||||
import com.reandroid.xml.XMLElement;
|
import com.reandroid.xml.XMLElement;
|
||||||
|
|
||||||
public class XmlHelper {
|
public class XmlHelper {
|
@ -13,10 +13,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmldecoder;
|
package com.reandroid.apk.xmldecoder;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.value.ResValueBag;
|
import com.reandroid.arsc.value.ResValueBag;
|
||||||
import com.reandroid.lib.common.EntryStore;
|
import com.reandroid.common.EntryStore;
|
||||||
import com.reandroid.xml.XMLElement;
|
import com.reandroid.xml.XMLElement;
|
||||||
|
|
||||||
abstract class BagDecoder {
|
abstract class BagDecoder {
|
@ -13,15 +13,15 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmldecoder;
|
package com.reandroid.apk.xmldecoder;
|
||||||
|
|
||||||
import com.reandroid.lib.apk.ApkUtil;
|
import com.reandroid.apk.ApkUtil;
|
||||||
import com.reandroid.lib.apk.XmlHelper;
|
import com.reandroid.apk.XmlHelper;
|
||||||
import com.reandroid.lib.arsc.decoder.ValueDecoder;
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBag;
|
import com.reandroid.arsc.value.ResValueBag;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBagItem;
|
import com.reandroid.arsc.value.ResValueBagItem;
|
||||||
import com.reandroid.lib.arsc.value.ValueType;
|
import com.reandroid.arsc.value.ValueType;
|
||||||
import com.reandroid.lib.common.EntryStore;
|
import com.reandroid.common.EntryStore;
|
||||||
import com.reandroid.xml.XMLElement;
|
import com.reandroid.xml.XMLElement;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
@ -13,12 +13,12 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmldecoder;
|
package com.reandroid.apk.xmldecoder;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.value.ResValueBag;
|
import com.reandroid.arsc.value.ResValueBag;
|
||||||
import com.reandroid.lib.arsc.value.attribute.AttributeBag;
|
import com.reandroid.arsc.value.attribute.AttributeBag;
|
||||||
import com.reandroid.lib.arsc.value.attribute.AttributeBagItem;
|
import com.reandroid.arsc.value.attribute.AttributeBagItem;
|
||||||
import com.reandroid.lib.common.EntryStore;
|
import com.reandroid.common.EntryStore;
|
||||||
import com.reandroid.xml.XMLElement;
|
import com.reandroid.xml.XMLElement;
|
||||||
|
|
||||||
class XMLAttrDecoder extends BagDecoder{
|
class XMLAttrDecoder extends BagDecoder{
|
@ -13,10 +13,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmldecoder;
|
package com.reandroid.apk.xmldecoder;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.value.ResValueBag;
|
import com.reandroid.arsc.value.ResValueBag;
|
||||||
import com.reandroid.lib.common.EntryStore;
|
import com.reandroid.common.EntryStore;
|
||||||
import com.reandroid.xml.XMLElement;
|
import com.reandroid.xml.XMLElement;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
@ -13,15 +13,15 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmldecoder;
|
package com.reandroid.apk.xmldecoder;
|
||||||
|
|
||||||
import com.reandroid.lib.apk.XmlHelper;
|
import com.reandroid.apk.XmlHelper;
|
||||||
import com.reandroid.lib.arsc.chunk.PackageBlock;
|
import com.reandroid.arsc.chunk.PackageBlock;
|
||||||
import com.reandroid.lib.arsc.decoder.ValueDecoder;
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBag;
|
import com.reandroid.arsc.value.ResValueBag;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBagItem;
|
import com.reandroid.arsc.value.ResValueBagItem;
|
||||||
import com.reandroid.lib.arsc.value.ValueType;
|
import com.reandroid.arsc.value.ValueType;
|
||||||
import com.reandroid.lib.common.EntryStore;
|
import com.reandroid.common.EntryStore;
|
||||||
import com.reandroid.xml.XMLElement;
|
import com.reandroid.xml.XMLElement;
|
||||||
|
|
||||||
class XMLCommonBagDecoder extends BagDecoder{
|
class XMLCommonBagDecoder extends BagDecoder{
|
@ -13,9 +13,9 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmldecoder;
|
package com.reandroid.apk.xmldecoder;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.chunk.xml.*;
|
import com.reandroid.arsc.chunk.xml.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -25,12 +25,12 @@ public class XMLNamespaceValidator {
|
|||||||
private static final String URI_APP="http://schemas.android.com/apk/res-auto";
|
private static final String URI_APP="http://schemas.android.com/apk/res-auto";
|
||||||
private static final String PREFIX_ANDROID ="android";
|
private static final String PREFIX_ANDROID ="android";
|
||||||
private static final String PREFIX_APP="app";
|
private static final String PREFIX_APP="app";
|
||||||
private final ResXmlBlock xmlBlock;
|
private final ResXmlDocument xmlBlock;
|
||||||
private List<ResXmlAttribute> mAttributeList;
|
private List<ResXmlAttribute> mAttributeList;
|
||||||
private ResXmlElement mRootElement;
|
private ResXmlElement mRootElement;
|
||||||
private ResXmlStartNamespace mNsAndroid;
|
private ResXmlStartNamespace mNsAndroid;
|
||||||
private ResXmlStartNamespace mNsApp;
|
private ResXmlStartNamespace mNsApp;
|
||||||
public XMLNamespaceValidator(ResXmlBlock xmlBlock){
|
public XMLNamespaceValidator(ResXmlDocument xmlBlock){
|
||||||
this.xmlBlock=xmlBlock;
|
this.xmlBlock=xmlBlock;
|
||||||
}
|
}
|
||||||
public void validate(){
|
public void validate(){
|
@ -13,16 +13,16 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmldecoder;
|
package com.reandroid.apk.xmldecoder;
|
||||||
|
|
||||||
import com.reandroid.lib.apk.XmlHelper;
|
import com.reandroid.apk.XmlHelper;
|
||||||
import com.reandroid.lib.arsc.decoder.ValueDecoder;
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
import com.reandroid.lib.arsc.value.BaseResValue;
|
import com.reandroid.arsc.value.BaseResValue;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBag;
|
import com.reandroid.arsc.value.ResValueBag;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBagItem;
|
import com.reandroid.arsc.value.ResValueBagItem;
|
||||||
import com.reandroid.lib.arsc.value.ValueType;
|
import com.reandroid.arsc.value.ValueType;
|
||||||
import com.reandroid.lib.arsc.value.plurals.PluralsQuantity;
|
import com.reandroid.arsc.value.plurals.PluralsQuantity;
|
||||||
import com.reandroid.lib.common.EntryStore;
|
import com.reandroid.common.EntryStore;
|
||||||
import com.reandroid.xml.XMLElement;
|
import com.reandroid.xml.XMLElement;
|
||||||
|
|
||||||
class XMLPluralsDecoder extends BagDecoder{
|
class XMLPluralsDecoder extends BagDecoder{
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
public class EncodeException extends IllegalArgumentException{
|
public class EncodeException extends IllegalArgumentException{
|
||||||
public EncodeException(String message){
|
public EncodeException(String message){
|
@ -13,24 +13,23 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.lib.apk.APKLogger;
|
import com.reandroid.apk.APKLogger;
|
||||||
import com.reandroid.lib.apk.ResourceIds;
|
import com.reandroid.apk.ResourceIds;
|
||||||
import com.reandroid.lib.arsc.chunk.PackageBlock;
|
import com.reandroid.arsc.chunk.PackageBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
import com.reandroid.arsc.chunk.TableBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.TypeBlock;
|
import com.reandroid.arsc.chunk.TypeBlock;
|
||||||
import com.reandroid.lib.arsc.container.SpecTypePair;
|
import com.reandroid.arsc.container.SpecTypePair;
|
||||||
import com.reandroid.lib.arsc.decoder.ValueDecoder;
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
import com.reandroid.lib.arsc.group.EntryGroup;
|
import com.reandroid.arsc.group.EntryGroup;
|
||||||
import com.reandroid.lib.arsc.item.SpecString;
|
import com.reandroid.arsc.item.SpecString;
|
||||||
import com.reandroid.lib.arsc.util.FrameworkTable;
|
import com.reandroid.arsc.util.FrameworkTable;
|
||||||
import com.reandroid.lib.arsc.util.ResNameMap;
|
import com.reandroid.arsc.util.ResNameMap;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
import com.reandroid.lib.common.Frameworks;
|
import com.reandroid.common.Frameworks;
|
||||||
import com.reandroid.lib.common.ResourceResolver;
|
import com.reandroid.common.ResourceResolver;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
@ -13,16 +13,16 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.archive.APKArchive;
|
import com.reandroid.archive.APKArchive;
|
||||||
import com.reandroid.archive.FileInputSource;
|
import com.reandroid.archive.FileInputSource;
|
||||||
import com.reandroid.archive.InputSource;
|
import com.reandroid.archive.InputSource;
|
||||||
import com.reandroid.lib.apk.ApkUtil;
|
import com.reandroid.apk.ApkUtil;
|
||||||
import com.reandroid.lib.apk.UncompressedFiles;
|
import com.reandroid.apk.UncompressedFiles;
|
||||||
import com.reandroid.lib.arsc.chunk.PackageBlock;
|
import com.reandroid.arsc.chunk.PackageBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.TypeBlock;
|
import com.reandroid.arsc.chunk.TypeBlock;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
import com.reandroid.xml.source.XMLFileSource;
|
import com.reandroid.xml.source.XMLFileSource;
|
||||||
import com.reandroid.xml.source.XMLSource;
|
import com.reandroid.xml.source.XMLSource;
|
||||||
|
|
@ -13,14 +13,14 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.lib.apk.APKLogger;
|
import com.reandroid.apk.APKLogger;
|
||||||
import com.reandroid.lib.apk.ResourceIds;
|
import com.reandroid.apk.ResourceIds;
|
||||||
import com.reandroid.lib.arsc.chunk.PackageBlock;
|
import com.reandroid.arsc.chunk.PackageBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
import com.reandroid.arsc.chunk.TableBlock;
|
||||||
import com.reandroid.lib.arsc.pool.TypeStringPool;
|
import com.reandroid.arsc.pool.TypeStringPool;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
@ -13,14 +13,14 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
|
import com.reandroid.apk.*;
|
||||||
import com.reandroid.archive.APKArchive;
|
import com.reandroid.archive.APKArchive;
|
||||||
import com.reandroid.lib.apk.*;
|
import com.reandroid.arsc.chunk.PackageBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.PackageBlock;
|
import com.reandroid.arsc.chunk.TableBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.TableBlock;
|
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.AndroidManifestBlock;
|
import com.reandroid.common.Frameworks;
|
||||||
import com.reandroid.lib.common.Frameworks;
|
|
||||||
import com.reandroid.xml.XMLDocument;
|
import com.reandroid.xml.XMLDocument;
|
||||||
import com.reandroid.xml.XMLException;
|
import com.reandroid.xml.XMLException;
|
||||||
import com.reandroid.xml.source.XMLFileSource;
|
import com.reandroid.xml.source.XMLFileSource;
|
||||||
@ -64,7 +64,7 @@
|
|||||||
List<File> pubXmlFileList = searchPublicXmlFiles(mainDir);
|
List<File> pubXmlFileList = searchPublicXmlFiles(mainDir);
|
||||||
if(pubXmlFileList.size()==0){
|
if(pubXmlFileList.size()==0){
|
||||||
throw new IOException("No .*/values/"
|
throw new IOException("No .*/values/"
|
||||||
+ApkUtil.FILE_NAME_PUBLIC_XML+" file found in '"+mainDir);
|
+ ApkUtil.FILE_NAME_PUBLIC_XML+" file found in '"+mainDir);
|
||||||
}
|
}
|
||||||
preloadStringPool(pubXmlFileList);
|
preloadStringPool(pubXmlFileList);
|
||||||
|
|
@ -13,9 +13,8 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.lib.apk.ApkUtil;
|
|
||||||
import com.reandroid.xml.XMLDocument;
|
import com.reandroid.xml.XMLDocument;
|
||||||
import com.reandroid.xml.XMLElement;
|
import com.reandroid.xml.XMLElement;
|
||||||
import com.reandroid.xml.XMLException;
|
import com.reandroid.xml.XMLException;
|
@ -13,13 +13,13 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.array.StyleArray;
|
import com.reandroid.arsc.array.StyleArray;
|
||||||
import com.reandroid.lib.arsc.decoder.ValueDecoder;
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
import com.reandroid.lib.arsc.item.StyleItem;
|
import com.reandroid.arsc.item.StyleItem;
|
||||||
import com.reandroid.lib.arsc.item.TableString;
|
import com.reandroid.arsc.item.TableString;
|
||||||
import com.reandroid.lib.arsc.pool.TableStringPool;
|
import com.reandroid.arsc.pool.TableStringPool;
|
||||||
import com.reandroid.xml.XMLDocument;
|
import com.reandroid.xml.XMLDocument;
|
||||||
import com.reandroid.xml.XMLElement;
|
import com.reandroid.xml.XMLElement;
|
||||||
import com.reandroid.xml.XMLSpanInfo;
|
import com.reandroid.xml.XMLSpanInfo;
|
@ -13,11 +13,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.archive.ByteInputSource;
|
import com.reandroid.archive.ByteInputSource;
|
||||||
import com.reandroid.lib.apk.CrcOutputStream;
|
import com.reandroid.apk.CrcOutputStream;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.ResXmlBlock;
|
import com.reandroid.arsc.chunk.xml.ResXmlDocument;
|
||||||
import com.reandroid.xml.XMLException;
|
import com.reandroid.xml.XMLException;
|
||||||
import com.reandroid.xml.source.XMLSource;
|
import com.reandroid.xml.source.XMLSource;
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ import java.io.OutputStream;
|
|||||||
public class XMLEncodeSource extends ByteInputSource {
|
public class XMLEncodeSource extends ByteInputSource {
|
||||||
private final EncodeMaterials encodeMaterials;
|
private final EncodeMaterials encodeMaterials;
|
||||||
private final XMLSource xmlSource;
|
private final XMLSource xmlSource;
|
||||||
private ResXmlBlock resXmlBlock;
|
private ResXmlDocument resXmlDocument;
|
||||||
public XMLEncodeSource(EncodeMaterials encodeMaterials, XMLSource xmlSource){
|
public XMLEncodeSource(EncodeMaterials encodeMaterials, XMLSource xmlSource){
|
||||||
super(new byte[0], xmlSource.getPath());
|
super(new byte[0], xmlSource.getPath());
|
||||||
this.encodeMaterials=encodeMaterials;
|
this.encodeMaterials=encodeMaterials;
|
||||||
@ -39,9 +39,9 @@ public class XMLEncodeSource extends ByteInputSource {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public long getCrc() throws IOException{
|
public long getCrc() throws IOException{
|
||||||
ResXmlBlock resXmlBlock = getResXmlBlock();
|
ResXmlDocument resXmlDocument = getResXmlBlock();
|
||||||
CrcOutputStream outputStream=new CrcOutputStream();
|
CrcOutputStream outputStream=new CrcOutputStream();
|
||||||
resXmlBlock.writeBytes(outputStream);
|
resXmlDocument.writeBytes(outputStream);
|
||||||
return outputStream.getCrcValue();
|
return outputStream.getCrcValue();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
@ -57,26 +57,26 @@ public class XMLEncodeSource extends ByteInputSource {
|
|||||||
//should not reach here
|
//should not reach here
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
}
|
}
|
||||||
public ResXmlBlock getResXmlBlock() throws IOException{
|
public ResXmlDocument getResXmlBlock() throws IOException{
|
||||||
if(resXmlBlock!=null){
|
if(resXmlDocument !=null){
|
||||||
return resXmlBlock;
|
return resXmlDocument;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
XMLFileEncoder xmlFileEncoder=new XMLFileEncoder(encodeMaterials);
|
XMLFileEncoder xmlFileEncoder=new XMLFileEncoder(encodeMaterials);
|
||||||
xmlFileEncoder.setCurrentPath(xmlSource.getPath());
|
xmlFileEncoder.setCurrentPath(xmlSource.getPath());
|
||||||
encodeMaterials.logVerbose("Encoding xml: "+xmlSource.getPath());
|
encodeMaterials.logVerbose("Encoding xml: "+xmlSource.getPath());
|
||||||
resXmlBlock = xmlFileEncoder.encode(xmlSource.getXMLDocument());
|
resXmlDocument = xmlFileEncoder.encode(xmlSource.getXMLDocument());
|
||||||
} catch (XMLException ex) {
|
} catch (XMLException ex) {
|
||||||
throw new EncodeException("XMLException on: '"+xmlSource.getPath()
|
throw new EncodeException("XMLException on: '"+xmlSource.getPath()
|
||||||
+"'\n '"+ex.getMessage()+"'");
|
+"'\n '"+ex.getMessage()+"'");
|
||||||
}
|
}
|
||||||
return resXmlBlock;
|
return resXmlDocument;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void disposeInputSource(){
|
public void disposeInputSource(){
|
||||||
this.xmlSource.disposeXml();
|
this.xmlSource.disposeXml();
|
||||||
if(this.resXmlBlock!=null){
|
if(this.resXmlDocument !=null){
|
||||||
resXmlBlock=null;
|
resXmlDocument =null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,15 +13,15 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.chunk.xml.*;
|
import com.reandroid.arsc.chunk.xml.*;
|
||||||
import com.reandroid.lib.arsc.decoder.ValueDecoder;
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBag;
|
import com.reandroid.arsc.value.ResValueBag;
|
||||||
import com.reandroid.lib.arsc.value.ValueType;
|
import com.reandroid.arsc.value.ValueType;
|
||||||
import com.reandroid.lib.arsc.value.attribute.AttributeBag;
|
import com.reandroid.arsc.value.attribute.AttributeBag;
|
||||||
import com.reandroid.lib.arsc.value.attribute.AttributeValueType;
|
import com.reandroid.arsc.value.attribute.AttributeValueType;
|
||||||
import com.reandroid.xml.*;
|
import com.reandroid.xml.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -29,7 +29,7 @@ import java.io.InputStream;
|
|||||||
|
|
||||||
public class XMLFileEncoder {
|
public class XMLFileEncoder {
|
||||||
private final EncodeMaterials materials;
|
private final EncodeMaterials materials;
|
||||||
private ResXmlBlock resXmlBlock;
|
private ResXmlDocument resXmlDocument;
|
||||||
private String mCurrentPath;
|
private String mCurrentPath;
|
||||||
public XMLFileEncoder(EncodeMaterials materials){
|
public XMLFileEncoder(EncodeMaterials materials){
|
||||||
this.materials=materials;
|
this.materials=materials;
|
||||||
@ -39,7 +39,7 @@ public class XMLFileEncoder {
|
|||||||
public void setCurrentPath(String path) {
|
public void setCurrentPath(String path) {
|
||||||
this.mCurrentPath = path;
|
this.mCurrentPath = path;
|
||||||
}
|
}
|
||||||
public ResXmlBlock encode(String xmlString){
|
public ResXmlDocument encode(String xmlString){
|
||||||
try {
|
try {
|
||||||
return encode(XMLDocument.load(xmlString));
|
return encode(XMLDocument.load(xmlString));
|
||||||
} catch (XMLException ex) {
|
} catch (XMLException ex) {
|
||||||
@ -47,7 +47,7 @@ public class XMLFileEncoder {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public ResXmlBlock encode(InputStream inputStream){
|
public ResXmlDocument encode(InputStream inputStream){
|
||||||
try {
|
try {
|
||||||
return encode(XMLDocument.load(inputStream));
|
return encode(XMLDocument.load(inputStream));
|
||||||
} catch (XMLException ex) {
|
} catch (XMLException ex) {
|
||||||
@ -55,7 +55,7 @@ public class XMLFileEncoder {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public ResXmlBlock encode(File xmlFile){
|
public ResXmlDocument encode(File xmlFile){
|
||||||
setCurrentPath(xmlFile.getAbsolutePath());
|
setCurrentPath(xmlFile.getAbsolutePath());
|
||||||
try {
|
try {
|
||||||
return encode(XMLDocument.load(xmlFile));
|
return encode(XMLDocument.load(xmlFile));
|
||||||
@ -64,19 +64,19 @@ public class XMLFileEncoder {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public ResXmlBlock encode(XMLDocument xmlDocument){
|
public ResXmlDocument encode(XMLDocument xmlDocument){
|
||||||
resXmlBlock=new ResXmlBlock();
|
resXmlDocument =new ResXmlDocument();
|
||||||
buildIdMap(xmlDocument);
|
buildIdMap(xmlDocument);
|
||||||
buildElement(xmlDocument);
|
buildElement(xmlDocument);
|
||||||
resXmlBlock.refresh();
|
resXmlDocument.refresh();
|
||||||
return resXmlBlock;
|
return resXmlDocument;
|
||||||
}
|
}
|
||||||
public ResXmlBlock getResXmlBlock(){
|
public ResXmlDocument getResXmlBlock(){
|
||||||
return resXmlBlock;
|
return resXmlDocument;
|
||||||
}
|
}
|
||||||
private void buildElement(XMLDocument xmlDocument){
|
private void buildElement(XMLDocument xmlDocument){
|
||||||
XMLElement element = xmlDocument.getDocumentElement();
|
XMLElement element = xmlDocument.getDocumentElement();
|
||||||
ResXmlElement resXmlElement = resXmlBlock.createRootElement(element.getTagName());
|
ResXmlElement resXmlElement = resXmlDocument.createRootElement(element.getTagName());
|
||||||
buildElement(element, resXmlElement);
|
buildElement(element, resXmlElement);
|
||||||
}
|
}
|
||||||
private void buildElement(XMLElement element, ResXmlElement resXmlElement){
|
private void buildElement(XMLElement element, ResXmlElement resXmlElement){
|
||||||
@ -136,7 +136,7 @@ public class XMLFileEncoder {
|
|||||||
}else {
|
}else {
|
||||||
xmlAttribute.setValueType(ValueType.REFERENCE);
|
xmlAttribute.setValueType(ValueType.REFERENCE);
|
||||||
}
|
}
|
||||||
xmlAttribute.setRawValue(materials.resolveReference(valueText));
|
xmlAttribute.setData(materials.resolveReference(valueText));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(entryBlock!=null){
|
if(entryBlock!=null){
|
||||||
@ -147,7 +147,7 @@ public class XMLFileEncoder {
|
|||||||
attributeBag.encodeEnumOrFlagValue(valueText);
|
attributeBag.encodeEnumOrFlagValue(valueText);
|
||||||
if(encodeResult!=null){
|
if(encodeResult!=null){
|
||||||
xmlAttribute.setValueType(encodeResult.valueType);
|
xmlAttribute.setValueType(encodeResult.valueType);
|
||||||
xmlAttribute.setRawValue(encodeResult.value);
|
xmlAttribute.setData(encodeResult.value);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(attributeBag.isEqualType(AttributeValueType.STRING)) {
|
if(attributeBag.isEqualType(AttributeValueType.STRING)) {
|
||||||
@ -164,7 +164,7 @@ public class XMLFileEncoder {
|
|||||||
ValueDecoder.encodeGuessAny(valueText);
|
ValueDecoder.encodeGuessAny(valueText);
|
||||||
if(encodeResult!=null){
|
if(encodeResult!=null){
|
||||||
xmlAttribute.setValueType(encodeResult.valueType);
|
xmlAttribute.setValueType(encodeResult.valueType);
|
||||||
xmlAttribute.setRawValue(encodeResult.value);
|
xmlAttribute.setData(encodeResult.value);
|
||||||
}else {
|
}else {
|
||||||
xmlAttribute.setValueAsString(ValueDecoder
|
xmlAttribute.setValueAsString(ValueDecoder
|
||||||
.unEscapeSpecialCharacter(valueText));
|
.unEscapeSpecialCharacter(valueText));
|
||||||
@ -187,7 +187,7 @@ public class XMLFileEncoder {
|
|||||||
ResIdBuilder idBuilder=new ResIdBuilder();
|
ResIdBuilder idBuilder=new ResIdBuilder();
|
||||||
XMLElement element= xmlDocument.getDocumentElement();
|
XMLElement element= xmlDocument.getDocumentElement();
|
||||||
searchResIds(idBuilder, element);
|
searchResIds(idBuilder, element);
|
||||||
idBuilder.buildTo(resXmlBlock.getResXmlIDMap());
|
idBuilder.buildTo(resXmlDocument.getResXmlIDMap());
|
||||||
}
|
}
|
||||||
private void searchResIds(ResIdBuilder idBuilder, XMLElement element){
|
private void searchResIds(ResIdBuilder idBuilder, XMLElement element){
|
||||||
for(XMLAttribute attribute : element.listAttributes()){
|
for(XMLAttribute attribute : element.listAttributes()){
|
@ -13,16 +13,16 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.chunk.PackageBlock;
|
import com.reandroid.arsc.chunk.PackageBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.TypeBlock;
|
import com.reandroid.arsc.chunk.TypeBlock;
|
||||||
import com.reandroid.lib.arsc.container.SpecTypePair;
|
import com.reandroid.arsc.container.SpecTypePair;
|
||||||
import com.reandroid.lib.arsc.decoder.ValueDecoder;
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
import com.reandroid.lib.arsc.item.SpecString;
|
import com.reandroid.arsc.item.SpecString;
|
||||||
import com.reandroid.lib.arsc.pool.TypeStringPool;
|
import com.reandroid.arsc.pool.TypeStringPool;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
import com.reandroid.lib.arsc.value.ValueType;
|
import com.reandroid.arsc.value.ValueType;
|
||||||
import com.reandroid.xml.XMLDocument;
|
import com.reandroid.xml.XMLDocument;
|
||||||
import com.reandroid.xml.XMLElement;
|
import com.reandroid.xml.XMLElement;
|
||||||
|
|
@ -13,14 +13,14 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.lib.apk.ApkUtil;
|
import com.reandroid.apk.ApkUtil;
|
||||||
import com.reandroid.lib.arsc.array.ResValueBagItemArray;
|
import com.reandroid.arsc.array.ResValueBagItemArray;
|
||||||
import com.reandroid.lib.arsc.decoder.ValueDecoder;
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBag;
|
import com.reandroid.arsc.value.ResValueBag;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBagItem;
|
import com.reandroid.arsc.value.ResValueBagItem;
|
||||||
import com.reandroid.lib.arsc.value.ValueType;
|
import com.reandroid.arsc.value.ValueType;
|
||||||
import com.reandroid.xml.XMLElement;
|
import com.reandroid.xml.XMLElement;
|
||||||
|
|
||||||
class XMLValuesEncoderArray extends XMLValuesEncoderBag{
|
class XMLValuesEncoderArray extends XMLValuesEncoderBag{
|
@ -13,16 +13,16 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.array.ResValueBagItemArray;
|
import com.reandroid.arsc.array.ResValueBagItemArray;
|
||||||
import com.reandroid.lib.arsc.decoder.ValueDecoder;
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBag;
|
import com.reandroid.arsc.value.ResValueBag;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBagItem;
|
import com.reandroid.arsc.value.ResValueBagItem;
|
||||||
import com.reandroid.lib.arsc.value.ValueType;
|
import com.reandroid.arsc.value.ValueType;
|
||||||
import com.reandroid.lib.arsc.value.attribute.AttributeBag;
|
import com.reandroid.arsc.value.attribute.AttributeBag;
|
||||||
import com.reandroid.lib.arsc.value.attribute.AttributeItemType;
|
import com.reandroid.arsc.value.attribute.AttributeItemType;
|
||||||
import com.reandroid.lib.arsc.value.attribute.AttributeValueType;
|
import com.reandroid.arsc.value.attribute.AttributeValueType;
|
||||||
import com.reandroid.xml.XMLAttribute;
|
import com.reandroid.xml.XMLAttribute;
|
||||||
import com.reandroid.xml.XMLElement;
|
import com.reandroid.xml.XMLElement;
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ class XMLValuesEncoderAttr extends XMLValuesEncoderBag{
|
|||||||
|
|
||||||
formatItem.setIdHigh((short) 0x0100);
|
formatItem.setIdHigh((short) 0x0100);
|
||||||
formatItem.setIdLow(AttributeItemType.FORMAT.getValue());
|
formatItem.setIdLow(AttributeItemType.FORMAT.getValue());
|
||||||
formatItem.setType(ValueType.INT_DEC);
|
formatItem.setValueType(ValueType.INT_DEC);
|
||||||
formatItem.setDataHigh(getChildTypes(parentElement));
|
formatItem.setDataHigh(getChildTypes(parentElement));
|
||||||
|
|
||||||
AttributeValueType[] valueTypes = AttributeValueType
|
AttributeValueType[] valueTypes = AttributeValueType
|
||||||
@ -78,7 +78,7 @@ class XMLValuesEncoderAttr extends XMLValuesEncoderBag{
|
|||||||
ResValueBagItem bagItem = bagItemArray.get(bagIndex);
|
ResValueBagItem bagItem = bagItemArray.get(bagIndex);
|
||||||
bagItem.setIdHigh((short) 0x0100);
|
bagItem.setIdHigh((short) 0x0100);
|
||||||
bagItem.setIdLow(itemType.getValue());
|
bagItem.setIdLow(itemType.getValue());
|
||||||
bagItem.setType(ValueType.INT_DEC);
|
bagItem.setValueType(ValueType.INT_DEC);
|
||||||
bagItem.setData(ValueDecoder.parseInteger(attribute.getValue()));
|
bagItem.setData(ValueDecoder.parseInteger(attribute.getValue()));
|
||||||
bagIndex++;
|
bagIndex++;
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ class XMLValuesEncoderAttr extends XMLValuesEncoderBag{
|
|||||||
|
|
||||||
ResValueBagItem bagItem = bagItemArray.get(i+offset);
|
ResValueBagItem bagItem = bagItemArray.get(i+offset);
|
||||||
bagItem.setId(resourceId);
|
bagItem.setId(resourceId);
|
||||||
bagItem.setType(encodeResult.valueType);
|
bagItem.setValueType(encodeResult.valueType);
|
||||||
bagItem.setData(encodeResult.value);
|
bagItem.setData(encodeResult.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,10 +13,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBag;
|
import com.reandroid.arsc.value.ResValueBag;
|
||||||
import com.reandroid.xml.XMLElement;
|
import com.reandroid.xml.XMLElement;
|
||||||
|
|
||||||
class XMLValuesEncoderBag extends XMLValuesEncoder{
|
class XMLValuesEncoderBag extends XMLValuesEncoder{
|
@ -13,10 +13,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.decoder.ValueDecoder;
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
|
|
||||||
class XMLValuesEncoderColor extends XMLValuesEncoder{
|
class XMLValuesEncoderColor extends XMLValuesEncoder{
|
||||||
XMLValuesEncoderColor(EncodeMaterials materials) {
|
XMLValuesEncoderColor(EncodeMaterials materials) {
|
@ -13,10 +13,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.decoder.ValueDecoder;
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
|
|
||||||
class XMLValuesEncoderCommon extends XMLValuesEncoder{
|
class XMLValuesEncoderCommon extends XMLValuesEncoder{
|
||||||
XMLValuesEncoderCommon(EncodeMaterials materials) {
|
XMLValuesEncoderCommon(EncodeMaterials materials) {
|
@ -13,10 +13,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.decoder.ValueDecoder;
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
|
|
||||||
class XMLValuesEncoderDimen extends XMLValuesEncoder{
|
class XMLValuesEncoderDimen extends XMLValuesEncoder{
|
||||||
XMLValuesEncoderDimen(EncodeMaterials materials) {
|
XMLValuesEncoderDimen(EncodeMaterials materials) {
|
@ -13,9 +13,9 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
|
|
||||||
class XMLValuesEncoderId extends XMLValuesEncoder{
|
class XMLValuesEncoderId extends XMLValuesEncoder{
|
||||||
public XMLValuesEncoderId(EncodeMaterials materials) {
|
public XMLValuesEncoderId(EncodeMaterials materials) {
|
@ -13,11 +13,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.decoder.ValueDecoder;
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
import com.reandroid.lib.arsc.value.ValueType;
|
import com.reandroid.arsc.value.ValueType;
|
||||||
|
|
||||||
class XMLValuesEncoderInteger extends XMLValuesEncoder{
|
class XMLValuesEncoderInteger extends XMLValuesEncoder{
|
||||||
XMLValuesEncoderInteger(EncodeMaterials materials) {
|
XMLValuesEncoderInteger(EncodeMaterials materials) {
|
@ -13,14 +13,14 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.array.ResValueBagItemArray;
|
import com.reandroid.arsc.array.ResValueBagItemArray;
|
||||||
import com.reandroid.lib.arsc.decoder.ValueDecoder;
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBag;
|
import com.reandroid.arsc.value.ResValueBag;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBagItem;
|
import com.reandroid.arsc.value.ResValueBagItem;
|
||||||
import com.reandroid.lib.arsc.value.ValueType;
|
import com.reandroid.arsc.value.ValueType;
|
||||||
import com.reandroid.lib.arsc.value.plurals.PluralsQuantity;
|
import com.reandroid.arsc.value.plurals.PluralsQuantity;
|
||||||
import com.reandroid.xml.XMLElement;
|
import com.reandroid.xml.XMLElement;
|
||||||
|
|
||||||
class XMLValuesEncoderPlurals extends XMLValuesEncoderBag{
|
class XMLValuesEncoderPlurals extends XMLValuesEncoderBag{
|
||||||
@ -46,10 +46,10 @@ class XMLValuesEncoderPlurals extends XMLValuesEncoderBag{
|
|||||||
String valueText=child.getTextContent();
|
String valueText=child.getTextContent();
|
||||||
|
|
||||||
if(ValueDecoder.isReference(valueText)){
|
if(ValueDecoder.isReference(valueText)){
|
||||||
bagItem.setType(ValueType.REFERENCE);
|
bagItem.setValueType(ValueType.REFERENCE);
|
||||||
bagItem.setData(getMaterials().resolveReference(valueText));
|
bagItem.setData(getMaterials().resolveReference(valueText));
|
||||||
}else if(EncodeUtil.isEmpty(valueText)) {
|
}else if(EncodeUtil.isEmpty(valueText)) {
|
||||||
bagItem.setType(ValueType.NULL);
|
bagItem.setValueType(ValueType.NULL);
|
||||||
bagItem.setData(0);
|
bagItem.setData(0);
|
||||||
}else{
|
}else{
|
||||||
bagItem.setValueAsString(ValueDecoder
|
bagItem.setValueAsString(ValueDecoder
|
@ -13,17 +13,12 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.decoder.ValueDecoder;
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
import com.reandroid.xml.XMLDocument;
|
|
||||||
import com.reandroid.xml.XMLElement;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
class XMLValuesEncoderString extends XMLValuesEncoder{
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
class XMLValuesEncoderString extends XMLValuesEncoder{
|
|
||||||
XMLValuesEncoderString(EncodeMaterials materials) {
|
XMLValuesEncoderString(EncodeMaterials materials) {
|
||||||
super(materials);
|
super(materials);
|
||||||
}
|
}
|
@ -13,16 +13,16 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.apk.xmlencoder;
|
package com.reandroid.apk.xmlencoder;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.array.ResValueBagItemArray;
|
import com.reandroid.arsc.array.ResValueBagItemArray;
|
||||||
import com.reandroid.lib.arsc.decoder.ValueDecoder;
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBag;
|
import com.reandroid.arsc.value.ResValueBag;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBagItem;
|
import com.reandroid.arsc.value.ResValueBagItem;
|
||||||
import com.reandroid.lib.arsc.value.ValueType;
|
import com.reandroid.arsc.value.ValueType;
|
||||||
import com.reandroid.lib.arsc.value.attribute.AttributeBag;
|
import com.reandroid.arsc.value.attribute.AttributeBag;
|
||||||
import com.reandroid.lib.arsc.value.attribute.AttributeValueType;
|
import com.reandroid.arsc.value.attribute.AttributeValueType;
|
||||||
import com.reandroid.xml.XMLElement;
|
import com.reandroid.xml.XMLElement;
|
||||||
|
|
||||||
|
|
||||||
@ -89,9 +89,9 @@ class XMLValuesEncoderStyle extends XMLValuesEncoderBag{
|
|||||||
}
|
}
|
||||||
if(ValueDecoder.isReference(valueText)){
|
if(ValueDecoder.isReference(valueText)){
|
||||||
if(valueText.startsWith("?")){
|
if(valueText.startsWith("?")){
|
||||||
bagItem.setType(ValueType.ATTRIBUTE);
|
bagItem.setValueType(ValueType.ATTRIBUTE);
|
||||||
}else {
|
}else {
|
||||||
bagItem.setType(ValueType.REFERENCE);
|
bagItem.setValueType(ValueType.REFERENCE);
|
||||||
}
|
}
|
||||||
bagItem.setData(getMaterials().resolveReference(valueText));
|
bagItem.setData(getMaterials().resolveReference(valueText));
|
||||||
}else if(attributeBag.isEqualType(AttributeValueType.STRING)) {
|
}else if(attributeBag.isEqualType(AttributeValueType.STRING)) {
|
@ -20,7 +20,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
public class ByteInputSource extends InputSource{
|
public class ByteInputSource extends InputSource {
|
||||||
private byte[] inBytes;
|
private byte[] inBytes;
|
||||||
public ByteInputSource(byte[] inBytes, String name) {
|
public ByteInputSource(byte[] inBytes, String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
@ -17,7 +17,7 @@ package com.reandroid.archive;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
public class FileInputSource extends InputSource{
|
public class FileInputSource extends InputSource {
|
||||||
private final File file;
|
private final File file;
|
||||||
public FileInputSource(File file, String name){
|
public FileInputSource(File file, String name){
|
||||||
super(name);
|
super(name);
|
||||||
|
16
src/main/java/com/reandroid/lib/arsc/chunk/xml/ResXmlEndNamespace.java → src/main/java/com/reandroid/archive/WriteInterceptor.java
Executable file → Normal file
16
src/main/java/com/reandroid/lib/arsc/chunk/xml/ResXmlEndNamespace.java → src/main/java/com/reandroid/archive/WriteInterceptor.java
Executable file → Normal file
@ -13,18 +13,8 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.chunk.xml;
|
package com.reandroid.archive;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.chunk.ChunkType;
|
public interface WriteInterceptor {
|
||||||
|
InputSource onWriteArchive(InputSource inputSource);
|
||||||
public class ResXmlEndNamespace extends ResXmlNamespace<ResXmlStartNamespace>{
|
|
||||||
public ResXmlEndNamespace() {
|
|
||||||
super(ChunkType.XML_END_NAMESPACE);
|
|
||||||
}
|
|
||||||
public ResXmlStartNamespace getStart(){
|
|
||||||
return getPair();
|
|
||||||
}
|
|
||||||
public void setStart(ResXmlStartNamespace namespace){
|
|
||||||
setPair(namespace);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -20,7 +20,7 @@ import java.io.InputStream;
|
|||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
public class ZipEntrySource extends InputSource{
|
public class ZipEntrySource extends InputSource {
|
||||||
private final ZipFile zipFile;
|
private final ZipFile zipFile;
|
||||||
private final ZipEntry zipEntry;
|
private final ZipEntry zipEntry;
|
||||||
public ZipEntrySource(ZipFile zipFile, ZipEntry zipEntry){
|
public ZipEntrySource(ZipFile zipFile, ZipEntry zipEntry){
|
||||||
|
@ -23,9 +23,14 @@ import java.util.zip.ZipOutputStream;
|
|||||||
public class ZipSerializer {
|
public class ZipSerializer {
|
||||||
private final List<InputSource> mSourceList;
|
private final List<InputSource> mSourceList;
|
||||||
private WriteProgress writeProgress;
|
private WriteProgress writeProgress;
|
||||||
|
private WriteInterceptor writeInterceptor;
|
||||||
public ZipSerializer(List<InputSource> sourceList){
|
public ZipSerializer(List<InputSource> sourceList){
|
||||||
this.mSourceList=sourceList;
|
this.mSourceList=sourceList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setWriteInterceptor(WriteInterceptor writeInterceptor) {
|
||||||
|
this.writeInterceptor = writeInterceptor;
|
||||||
|
}
|
||||||
public void setWriteProgress(WriteProgress writeProgress){
|
public void setWriteProgress(WriteProgress writeProgress){
|
||||||
this.writeProgress=writeProgress;
|
this.writeProgress=writeProgress;
|
||||||
}
|
}
|
||||||
@ -52,6 +57,10 @@ public class ZipSerializer {
|
|||||||
WriteProgress progress=writeProgress;
|
WriteProgress progress=writeProgress;
|
||||||
ZipOutputStream zipOutputStream=new ZipOutputStream(outputStream);
|
ZipOutputStream zipOutputStream=new ZipOutputStream(outputStream);
|
||||||
for(InputSource inputSource:mSourceList){
|
for(InputSource inputSource:mSourceList){
|
||||||
|
inputSource = interceptWrite(inputSource);
|
||||||
|
if(inputSource==null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if(progress!=null){
|
if(progress!=null){
|
||||||
progress.onCompressFile(inputSource.getAlias(), inputSource.getMethod(), length);
|
progress.onCompressFile(inputSource.getAlias(), inputSource.getMethod(), length);
|
||||||
}
|
}
|
||||||
@ -78,4 +87,11 @@ public class ZipSerializer {
|
|||||||
}
|
}
|
||||||
return zipEntry;
|
return zipEntry;
|
||||||
}
|
}
|
||||||
|
private InputSource interceptWrite(InputSource inputSource){
|
||||||
|
WriteInterceptor interceptor=writeInterceptor;
|
||||||
|
if(interceptor!=null){
|
||||||
|
return interceptor.onWriteArchive(inputSource);
|
||||||
|
}
|
||||||
|
return inputSource;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc;
|
package com.reandroid.arsc;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
@ -13,17 +13,17 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.item.IntegerArray;
|
import com.reandroid.arsc.item.IntegerArray;
|
||||||
import com.reandroid.lib.arsc.item.IntegerItem;
|
import com.reandroid.arsc.item.IntegerItem;
|
||||||
import com.reandroid.lib.arsc.value.BaseResValue;
|
import com.reandroid.arsc.value.BaseResValue;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
import com.reandroid.lib.arsc.value.ResValueInt;
|
import com.reandroid.arsc.value.ResValueInt;
|
||||||
import com.reandroid.lib.arsc.value.ValueType;
|
import com.reandroid.arsc.value.ValueType;
|
||||||
import com.reandroid.lib.json.JSONConvert;
|
import com.reandroid.json.JSONConvert;
|
||||||
import com.reandroid.lib.json.JSONArray;
|
import com.reandroid.json.JSONArray;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
@ -13,15 +13,15 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.base.BlockArray;
|
import com.reandroid.arsc.base.BlockArray;
|
||||||
import com.reandroid.lib.arsc.io.BlockReader;
|
import com.reandroid.arsc.io.BlockReader;
|
||||||
import com.reandroid.lib.arsc.item.IntegerItem;
|
import com.reandroid.arsc.item.IntegerItem;
|
||||||
import com.reandroid.lib.arsc.value.LibraryInfo;
|
import com.reandroid.arsc.value.LibraryInfo;
|
||||||
import com.reandroid.lib.json.JSONConvert;
|
import com.reandroid.json.JSONConvert;
|
||||||
import com.reandroid.lib.json.JSONArray;
|
import com.reandroid.json.JSONArray;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -13,17 +13,17 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.base.Block;
|
import com.reandroid.arsc.base.Block;
|
||||||
import com.reandroid.lib.arsc.base.BlockArray;
|
import com.reandroid.arsc.base.BlockArray;
|
||||||
import com.reandroid.lib.arsc.base.BlockCounter;
|
import com.reandroid.arsc.base.BlockCounter;
|
||||||
import com.reandroid.lib.arsc.io.BlockLoad;
|
import com.reandroid.arsc.io.BlockLoad;
|
||||||
import com.reandroid.lib.arsc.io.BlockReader;
|
import com.reandroid.arsc.io.BlockReader;
|
||||||
import com.reandroid.lib.arsc.item.ByteArray;
|
import com.reandroid.arsc.item.ByteArray;
|
||||||
import com.reandroid.lib.arsc.item.IntegerArray;
|
import com.reandroid.arsc.item.IntegerArray;
|
||||||
import com.reandroid.lib.arsc.item.IntegerItem;
|
import com.reandroid.arsc.item.IntegerItem;
|
||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
@ -13,17 +13,17 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.base.Block;
|
import com.reandroid.arsc.base.Block;
|
||||||
import com.reandroid.lib.arsc.base.BlockArray;
|
import com.reandroid.arsc.base.BlockArray;
|
||||||
import com.reandroid.lib.arsc.chunk.PackageBlock;
|
import com.reandroid.arsc.chunk.PackageBlock;
|
||||||
import com.reandroid.lib.arsc.io.BlockLoad;
|
import com.reandroid.arsc.io.BlockLoad;
|
||||||
import com.reandroid.lib.arsc.io.BlockReader;
|
import com.reandroid.arsc.io.BlockReader;
|
||||||
import com.reandroid.lib.arsc.item.IntegerItem;
|
import com.reandroid.arsc.item.IntegerItem;
|
||||||
import com.reandroid.lib.json.JSONConvert;
|
import com.reandroid.json.JSONConvert;
|
||||||
import com.reandroid.lib.json.JSONArray;
|
import com.reandroid.json.JSONArray;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
@ -13,13 +13,12 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.base.BlockArray;
|
import com.reandroid.arsc.base.BlockArray;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBag;
|
import com.reandroid.arsc.value.ResValueBagItem;
|
||||||
import com.reandroid.lib.arsc.value.ResValueBagItem;
|
import com.reandroid.json.JSONConvert;
|
||||||
import com.reandroid.lib.json.JSONConvert;
|
import com.reandroid.json.JSONArray;
|
||||||
import com.reandroid.lib.json.JSONArray;
|
|
||||||
|
|
||||||
public class ResValueBagItemArray extends BlockArray<ResValueBagItem> implements JSONConvert<JSONArray> {
|
public class ResValueBagItemArray extends BlockArray<ResValueBagItem> implements JSONConvert<JSONArray> {
|
||||||
public ResValueBagItemArray(){
|
public ResValueBagItemArray(){
|
@ -13,17 +13,17 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.base.Block;
|
import com.reandroid.arsc.base.Block;
|
||||||
import com.reandroid.lib.arsc.base.BlockArray;
|
import com.reandroid.arsc.base.BlockArray;
|
||||||
import com.reandroid.lib.arsc.header.HeaderBlock;
|
import com.reandroid.arsc.header.HeaderBlock;
|
||||||
import com.reandroid.lib.arsc.io.BlockReader;
|
import com.reandroid.arsc.io.BlockReader;
|
||||||
import com.reandroid.lib.arsc.chunk.xml.ResXmlAttribute;
|
import com.reandroid.arsc.chunk.xml.ResXmlAttribute;
|
||||||
import com.reandroid.lib.arsc.item.ShortItem;
|
import com.reandroid.arsc.item.ShortItem;
|
||||||
import com.reandroid.lib.json.JSONConvert;
|
import com.reandroid.json.JSONConvert;
|
||||||
import com.reandroid.lib.json.JSONArray;
|
import com.reandroid.json.JSONArray;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -33,18 +33,22 @@ public class ResXmlAttributeArray extends BlockArray<ResXmlAttribute>
|
|||||||
private final HeaderBlock mHeaderBlock;
|
private final HeaderBlock mHeaderBlock;
|
||||||
private final ShortItem mAttributeStart;
|
private final ShortItem mAttributeStart;
|
||||||
private final ShortItem mAttributeCount;
|
private final ShortItem mAttributeCount;
|
||||||
public ResXmlAttributeArray(HeaderBlock headerBlock, ShortItem attributeStart, ShortItem attributeCount){
|
private final ShortItem mAttributesUnitSize;
|
||||||
|
public ResXmlAttributeArray(HeaderBlock headerBlock,
|
||||||
|
ShortItem attributeStart,
|
||||||
|
ShortItem attributeCount,
|
||||||
|
ShortItem attributesUnitSize){
|
||||||
this.mHeaderBlock=headerBlock;
|
this.mHeaderBlock=headerBlock;
|
||||||
this.mAttributeStart=attributeStart;
|
this.mAttributeStart=attributeStart;
|
||||||
this.mAttributeCount=attributeCount;
|
this.mAttributeCount=attributeCount;
|
||||||
|
this.mAttributesUnitSize=attributesUnitSize;
|
||||||
}
|
}
|
||||||
public ResXmlAttribute getFirstIntAttribute(){
|
public void setAttributesUnitSize(int size){
|
||||||
for(ResXmlAttribute attribute:listItems()){
|
ResXmlAttribute[] attributes=getChildes();
|
||||||
if(attribute.hasIntegerValue()){
|
for(int i=0;i<attributes.length;i++){
|
||||||
return attribute;
|
attributes[i].setAttributesUnitSize(size);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
mAttributesUnitSize.set((short) size);
|
||||||
}
|
}
|
||||||
public void sortAttributes(){
|
public void sortAttributes(){
|
||||||
sort(this);
|
sort(this);
|
||||||
@ -64,7 +68,7 @@ public class ResXmlAttributeArray extends BlockArray<ResXmlAttribute>
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ResXmlAttribute newInstance() {
|
public ResXmlAttribute newInstance() {
|
||||||
return new ResXmlAttribute();
|
return new ResXmlAttribute(mAttributesUnitSize.unsignedInt());
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ResXmlAttribute[] newInstance(int len) {
|
public ResXmlAttribute[] newInstance(int len) {
|
@ -13,15 +13,12 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.base.BlockArray;
|
import com.reandroid.arsc.base.BlockArray;
|
||||||
import com.reandroid.lib.arsc.header.HeaderBlock;
|
import com.reandroid.arsc.header.HeaderBlock;
|
||||||
import com.reandroid.lib.arsc.io.BlockReader;
|
import com.reandroid.arsc.io.BlockReader;
|
||||||
import com.reandroid.lib.arsc.item.ResXmlID;
|
import com.reandroid.arsc.item.ResXmlID;
|
||||||
import com.reandroid.lib.json.JSONConvert;
|
|
||||||
import com.reandroid.lib.json.JSONArray;
|
|
||||||
import com.reandroid.lib.json.JSONObject;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
@ -13,11 +13,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.item.IntegerArray;
|
import com.reandroid.arsc.item.IntegerArray;
|
||||||
import com.reandroid.lib.arsc.item.IntegerItem;
|
import com.reandroid.arsc.item.IntegerItem;
|
||||||
import com.reandroid.lib.arsc.item.ResXmlString;
|
import com.reandroid.arsc.item.ResXmlString;
|
||||||
|
|
||||||
public class ResXmlStringArray extends StringArray<ResXmlString> {
|
public class ResXmlStringArray extends StringArray<ResXmlString> {
|
||||||
public ResXmlStringArray(IntegerArray offsets, IntegerItem itemCount, IntegerItem itemStart, boolean is_utf8) {
|
public ResXmlStringArray(IntegerArray offsets, IntegerItem itemCount, IntegerItem itemStart, boolean is_utf8) {
|
@ -13,10 +13,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.base.BlockArray;
|
import com.reandroid.arsc.base.BlockArray;
|
||||||
import com.reandroid.lib.arsc.chunk.SpecBlock;
|
import com.reandroid.arsc.chunk.SpecBlock;
|
||||||
|
|
||||||
public class SpecBlockArray extends BlockArray<SpecBlock> {
|
public class SpecBlockArray extends BlockArray<SpecBlock> {
|
||||||
public SpecBlockArray(){
|
public SpecBlockArray(){
|
@ -13,11 +13,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.item.IntegerArray;
|
import com.reandroid.arsc.item.IntegerArray;
|
||||||
import com.reandroid.lib.arsc.item.IntegerItem;
|
import com.reandroid.arsc.item.IntegerItem;
|
||||||
import com.reandroid.lib.arsc.item.SpecString;
|
import com.reandroid.arsc.item.SpecString;
|
||||||
|
|
||||||
public class SpecStringArray extends StringArray<SpecString> {
|
public class SpecStringArray extends StringArray<SpecString> {
|
||||||
public SpecStringArray(IntegerArray offsets, IntegerItem itemCount, IntegerItem itemStart, boolean is_utf8) {
|
public SpecStringArray(IntegerArray offsets, IntegerItem itemCount, IntegerItem itemStart, boolean is_utf8) {
|
@ -13,17 +13,16 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.base.BlockArray;
|
import com.reandroid.arsc.base.BlockArray;
|
||||||
import com.reandroid.lib.arsc.chunk.PackageBlock;
|
import com.reandroid.arsc.chunk.TypeBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.TypeBlock;
|
import com.reandroid.arsc.container.SpecTypePair;
|
||||||
import com.reandroid.lib.arsc.container.SpecTypePair;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.ResConfig;
|
||||||
import com.reandroid.lib.arsc.value.ResConfig;
|
import com.reandroid.json.JSONConvert;
|
||||||
import com.reandroid.lib.json.JSONConvert;
|
import com.reandroid.json.JSONArray;
|
||||||
import com.reandroid.lib.json.JSONArray;
|
import com.reandroid.json.JSONObject;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -13,16 +13,16 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.base.Block;
|
import com.reandroid.arsc.base.Block;
|
||||||
import com.reandroid.lib.arsc.base.BlockArray;
|
import com.reandroid.arsc.base.BlockArray;
|
||||||
import com.reandroid.lib.arsc.io.BlockLoad;
|
import com.reandroid.arsc.io.BlockLoad;
|
||||||
import com.reandroid.lib.arsc.io.BlockReader;
|
import com.reandroid.arsc.io.BlockReader;
|
||||||
import com.reandroid.lib.arsc.item.IntegerItem;
|
import com.reandroid.arsc.item.IntegerItem;
|
||||||
import com.reandroid.lib.arsc.value.StagedAliasEntry;
|
import com.reandroid.arsc.value.StagedAliasEntry;
|
||||||
import com.reandroid.lib.json.JSONArray;
|
import com.reandroid.json.JSONArray;
|
||||||
import com.reandroid.lib.json.JSONConvert;
|
import com.reandroid.json.JSONConvert;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -13,14 +13,14 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.item.IntegerArray;
|
import com.reandroid.arsc.item.IntegerArray;
|
||||||
import com.reandroid.lib.arsc.item.IntegerItem;
|
import com.reandroid.arsc.item.IntegerItem;
|
||||||
import com.reandroid.lib.arsc.item.StringItem;
|
import com.reandroid.arsc.item.StringItem;
|
||||||
import com.reandroid.lib.json.JSONConvert;
|
import com.reandroid.json.JSONConvert;
|
||||||
import com.reandroid.lib.json.JSONArray;
|
import com.reandroid.json.JSONArray;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
|
|
||||||
import java.util.AbstractList;
|
import java.util.AbstractList;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
@ -13,15 +13,15 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.io.BlockReader;
|
import com.reandroid.arsc.io.BlockReader;
|
||||||
import com.reandroid.lib.arsc.item.ByteArray;
|
import com.reandroid.arsc.item.ByteArray;
|
||||||
import com.reandroid.lib.arsc.item.IntegerArray;
|
import com.reandroid.arsc.item.IntegerArray;
|
||||||
import com.reandroid.lib.arsc.item.IntegerItem;
|
import com.reandroid.arsc.item.IntegerItem;
|
||||||
import com.reandroid.lib.arsc.item.StyleItem;
|
import com.reandroid.arsc.item.StyleItem;
|
||||||
import com.reandroid.lib.json.JSONConvert;
|
import com.reandroid.json.JSONConvert;
|
||||||
import com.reandroid.lib.json.JSONArray;
|
import com.reandroid.json.JSONArray;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -13,11 +13,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.item.IntegerArray;
|
import com.reandroid.arsc.item.IntegerArray;
|
||||||
import com.reandroid.lib.arsc.item.IntegerItem;
|
import com.reandroid.arsc.item.IntegerItem;
|
||||||
import com.reandroid.lib.arsc.item.TableString;
|
import com.reandroid.arsc.item.TableString;
|
||||||
|
|
||||||
public class TableStringArray extends StringArray<TableString> {
|
public class TableStringArray extends StringArray<TableString> {
|
||||||
public TableStringArray(IntegerArray offsets, IntegerItem itemCount, IntegerItem itemStart, boolean is_utf8) {
|
public TableStringArray(IntegerArray offsets, IntegerItem itemCount, IntegerItem itemStart, boolean is_utf8) {
|
@ -13,22 +13,21 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.chunk.ChunkType;
|
import com.reandroid.arsc.chunk.ChunkType;
|
||||||
import com.reandroid.lib.arsc.base.Block;
|
import com.reandroid.arsc.base.Block;
|
||||||
import com.reandroid.lib.arsc.base.BlockArray;
|
import com.reandroid.arsc.base.BlockArray;
|
||||||
import com.reandroid.lib.arsc.chunk.SpecBlock;
|
import com.reandroid.arsc.chunk.SpecBlock;
|
||||||
import com.reandroid.lib.arsc.chunk.TypeBlock;
|
import com.reandroid.arsc.chunk.TypeBlock;
|
||||||
import com.reandroid.lib.arsc.container.SpecTypePair;
|
import com.reandroid.arsc.header.HeaderBlock;
|
||||||
import com.reandroid.lib.arsc.header.HeaderBlock;
|
import com.reandroid.arsc.io.BlockReader;
|
||||||
import com.reandroid.lib.arsc.io.BlockReader;
|
import com.reandroid.arsc.item.TypeString;
|
||||||
import com.reandroid.lib.arsc.item.TypeString;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.ResConfig;
|
||||||
import com.reandroid.lib.arsc.value.ResConfig;
|
import com.reandroid.json.JSONConvert;
|
||||||
import com.reandroid.lib.json.JSONConvert;
|
import com.reandroid.json.JSONArray;
|
||||||
import com.reandroid.lib.json.JSONArray;
|
import com.reandroid.json.JSONObject;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.AbstractList;
|
import java.util.AbstractList;
|
@ -13,11 +13,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.item.IntegerArray;
|
import com.reandroid.arsc.item.IntegerArray;
|
||||||
import com.reandroid.lib.arsc.item.IntegerItem;
|
import com.reandroid.arsc.item.IntegerItem;
|
||||||
import com.reandroid.lib.arsc.item.TypeString;
|
import com.reandroid.arsc.item.TypeString;
|
||||||
|
|
||||||
public class TypeStringArray extends StringArray<TypeString> {
|
public class TypeStringArray extends StringArray<TypeString> {
|
||||||
private int lastCreateIndex;
|
private int lastCreateIndex;
|
@ -13,10 +13,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.base;
|
package com.reandroid.arsc.base;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.io.BlockLoad;
|
import com.reandroid.arsc.io.BlockLoad;
|
||||||
import com.reandroid.lib.arsc.io.BlockReader;
|
import com.reandroid.arsc.io.BlockReader;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.base;
|
package com.reandroid.arsc.base;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.base;
|
package com.reandroid.arsc.base;
|
||||||
|
|
||||||
public interface BlockArrayCreator<T extends Block> extends BlockCreator<T>{
|
public interface BlockArrayCreator<T extends Block> extends BlockCreator<T>{
|
||||||
T[] newInstance(int len);
|
T[] newInstance(int len);
|
@ -13,10 +13,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.base;
|
package com.reandroid.arsc.base;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.container.BlockList;
|
import com.reandroid.arsc.container.BlockList;
|
||||||
import com.reandroid.lib.arsc.io.BlockReader;
|
import com.reandroid.arsc.io.BlockReader;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.base;
|
package com.reandroid.arsc.base;
|
||||||
|
|
||||||
public class BlockCounter {
|
public class BlockCounter {
|
||||||
public final Block END;
|
public final Block END;
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.base;
|
package com.reandroid.arsc.base;
|
||||||
|
|
||||||
public interface BlockCreator<T extends Block> {
|
public interface BlockCreator<T extends Block> {
|
||||||
T newInstance();
|
T newInstance();
|
@ -13,20 +13,28 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.chunk;
|
package com.reandroid.arsc.chunk;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.container.ExpandableBlockContainer;
|
import com.reandroid.arsc.base.Block;
|
||||||
import com.reandroid.lib.arsc.header.HeaderBlock;
|
import com.reandroid.arsc.container.ExpandableBlockContainer;
|
||||||
import com.reandroid.lib.arsc.io.BlockReader;
|
import com.reandroid.arsc.container.SingleBlockContainer;
|
||||||
|
import com.reandroid.arsc.header.HeaderBlock;
|
||||||
|
import com.reandroid.arsc.io.BlockReader;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public abstract class BaseChunk<T extends HeaderBlock> extends ExpandableBlockContainer {
|
public abstract class Chunk<T extends HeaderBlock> extends ExpandableBlockContainer {
|
||||||
private final T mHeaderBlock;
|
private final T mHeaderBlock;
|
||||||
protected BaseChunk(T headerBlock, int initialChildesCount) {
|
protected final SingleBlockContainer<Block> firstPlaceHolder;
|
||||||
super(initialChildesCount+1);
|
protected Chunk(T headerBlock, int initialChildesCount) {
|
||||||
|
super(initialChildesCount+2);
|
||||||
this.mHeaderBlock = headerBlock;
|
this.mHeaderBlock = headerBlock;
|
||||||
|
this.firstPlaceHolder = new SingleBlockContainer<>();
|
||||||
addChild(headerBlock);
|
addChild(headerBlock);
|
||||||
|
addChild(firstPlaceHolder);
|
||||||
|
}
|
||||||
|
public SingleBlockContainer<Block> getFirstPlaceHolder() {
|
||||||
|
return firstPlaceHolder;
|
||||||
}
|
}
|
||||||
void setHeaderLoaded(HeaderBlock.HeaderLoaded headerLoaded){
|
void setHeaderLoaded(HeaderBlock.HeaderLoaded headerLoaded){
|
||||||
getHeaderBlock().setHeaderLoaded(headerLoaded);
|
getHeaderBlock().setHeaderLoaded(headerLoaded);
|
||||||
@ -47,9 +55,7 @@ public abstract class BaseChunk<T extends HeaderBlock> extends ExpandableBlockCo
|
|||||||
public void onReadBytes(BlockReader reader) throws IOException {
|
public void onReadBytes(BlockReader reader) throws IOException {
|
||||||
HeaderBlock headerBlock=reader.readHeaderBlock();
|
HeaderBlock headerBlock=reader.readHeaderBlock();
|
||||||
checkInvalidChunk(headerBlock);
|
checkInvalidChunk(headerBlock);
|
||||||
BlockReader chunkReader = reader.create(
|
BlockReader chunkReader = reader.create(headerBlock.getChunkSize());
|
||||||
reader.getPosition(),
|
|
||||||
headerBlock.getChunkSize());
|
|
||||||
super.onReadBytes(chunkReader);
|
super.onReadBytes(chunkReader);
|
||||||
reader.offset(headerBlock.getChunkSize());
|
reader.offset(headerBlock.getChunkSize());
|
||||||
chunkReader.close();
|
chunkReader.close();
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.chunk;
|
package com.reandroid.arsc.chunk;
|
||||||
|
|
||||||
public enum ChunkType {
|
public enum ChunkType {
|
||||||
NULL((short)0x0000),
|
NULL((short)0x0000),
|
@ -13,17 +13,15 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.chunk;
|
package com.reandroid.arsc.chunk;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.array.LibraryInfoArray;
|
import com.reandroid.arsc.array.LibraryInfoArray;
|
||||||
import com.reandroid.lib.arsc.header.LibraryHeader;
|
import com.reandroid.arsc.header.LibraryHeader;
|
||||||
import com.reandroid.lib.arsc.item.IntegerItem;
|
import com.reandroid.arsc.value.LibraryInfo;
|
||||||
import com.reandroid.lib.arsc.value.LibraryInfo;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class LibraryBlock extends BaseChunk<LibraryHeader> {
|
public class LibraryBlock extends Chunk<LibraryHeader> {
|
||||||
private final LibraryInfoArray mLibraryInfoArray;
|
private final LibraryInfoArray mLibraryInfoArray;
|
||||||
public LibraryBlock() {
|
public LibraryBlock() {
|
||||||
super(new LibraryHeader(),1);
|
super(new LibraryHeader(),1);
|
@ -13,15 +13,14 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.chunk;
|
package com.reandroid.arsc.chunk;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.base.Block;
|
import com.reandroid.arsc.base.Block;
|
||||||
import com.reandroid.lib.arsc.header.HeaderBlock;
|
import com.reandroid.arsc.header.HeaderBlock;
|
||||||
import com.reandroid.lib.arsc.header.OverlayableHeader;
|
import com.reandroid.arsc.header.OverlayableHeader;
|
||||||
import com.reandroid.lib.arsc.io.BlockLoad;
|
import com.reandroid.arsc.io.BlockLoad;
|
||||||
import com.reandroid.lib.arsc.io.BlockReader;
|
import com.reandroid.arsc.io.BlockReader;
|
||||||
import com.reandroid.lib.arsc.item.ByteArray;
|
import com.reandroid.arsc.item.ByteArray;
|
||||||
import com.reandroid.lib.arsc.item.FixedLengthString;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -30,7 +29,7 @@
|
|||||||
* We didn't test this class with resource table, if someone found a resource/apk please
|
* We didn't test this class with resource table, if someone found a resource/apk please
|
||||||
* create issue on https://github.com/REAndroid/ARSCLib
|
* create issue on https://github.com/REAndroid/ARSCLib
|
||||||
* */
|
* */
|
||||||
public class Overlayable extends BaseChunk<OverlayableHeader> implements BlockLoad {
|
public class Overlayable extends Chunk<OverlayableHeader> implements BlockLoad {
|
||||||
/**
|
/**
|
||||||
* @link body
|
* @link body
|
||||||
* As on AOSP there is only a description of header struct but no mention about
|
* As on AOSP there is only a description of header struct but no mention about
|
@ -13,14 +13,14 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.chunk;
|
package com.reandroid.arsc.chunk;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.base.Block;
|
import com.reandroid.arsc.base.Block;
|
||||||
import com.reandroid.lib.arsc.header.OverlayablePolicyHeader;
|
import com.reandroid.arsc.header.OverlayablePolicyHeader;
|
||||||
import com.reandroid.lib.arsc.io.BlockLoad;
|
import com.reandroid.arsc.io.BlockLoad;
|
||||||
import com.reandroid.lib.arsc.io.BlockReader;
|
import com.reandroid.arsc.io.BlockReader;
|
||||||
import com.reandroid.lib.arsc.item.IntegerArray;
|
import com.reandroid.arsc.item.IntegerArray;
|
||||||
import com.reandroid.lib.arsc.item.IntegerItem;
|
import com.reandroid.arsc.item.IntegerItem;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -30,7 +30,7 @@
|
|||||||
* We didn't test this class with resource table, if someone found a resource/apk please
|
* We didn't test this class with resource table, if someone found a resource/apk please
|
||||||
* create issue on https://github.com/REAndroid/ARSCLib
|
* create issue on https://github.com/REAndroid/ARSCLib
|
||||||
* */
|
* */
|
||||||
public class OverlayablePolicy extends BaseChunk<OverlayablePolicyHeader> implements BlockLoad {
|
public class OverlayablePolicy extends Chunk<OverlayablePolicyHeader> implements BlockLoad {
|
||||||
private final IntegerArray tableRefArray;
|
private final IntegerArray tableRefArray;
|
||||||
public OverlayablePolicy(){
|
public OverlayablePolicy(){
|
||||||
super(new OverlayablePolicyHeader(), 1);
|
super(new OverlayablePolicyHeader(), 1);
|
@ -13,37 +13,31 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.chunk;
|
package com.reandroid.arsc.chunk;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.BuildInfo;
|
import com.reandroid.arsc.BuildInfo;
|
||||||
import com.reandroid.lib.arsc.array.LibraryInfoArray;
|
import com.reandroid.arsc.array.LibraryInfoArray;
|
||||||
import com.reandroid.lib.arsc.array.SpecTypePairArray;
|
import com.reandroid.arsc.array.SpecTypePairArray;
|
||||||
import com.reandroid.lib.arsc.base.Block;
|
import com.reandroid.arsc.base.Block;
|
||||||
import com.reandroid.lib.arsc.container.BlockList;
|
import com.reandroid.arsc.container.BlockList;
|
||||||
import com.reandroid.lib.arsc.container.PackageBody;
|
import com.reandroid.arsc.container.PackageBody;
|
||||||
import com.reandroid.lib.arsc.container.SingleBlockContainer;
|
import com.reandroid.arsc.container.SpecTypePair;
|
||||||
import com.reandroid.lib.arsc.container.SpecTypePair;
|
import com.reandroid.arsc.group.EntryGroup;
|
||||||
import com.reandroid.lib.arsc.group.EntryGroup;
|
import com.reandroid.arsc.header.PackageHeader;
|
||||||
import com.reandroid.lib.arsc.header.PackageHeader;
|
import com.reandroid.arsc.item.ReferenceItem;
|
||||||
import com.reandroid.lib.arsc.io.BlockLoad;
|
import com.reandroid.arsc.pool.SpecStringPool;
|
||||||
import com.reandroid.lib.arsc.io.BlockReader;
|
import com.reandroid.arsc.pool.TableStringPool;
|
||||||
import com.reandroid.lib.arsc.item.FixedLengthString;
|
import com.reandroid.arsc.pool.TypeStringPool;
|
||||||
import com.reandroid.lib.arsc.item.IntegerItem;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
import com.reandroid.lib.arsc.item.ReferenceItem;
|
import com.reandroid.arsc.value.LibraryInfo;
|
||||||
import com.reandroid.lib.arsc.pool.SpecStringPool;
|
import com.reandroid.arsc.value.StagedAliasEntry;
|
||||||
import com.reandroid.lib.arsc.pool.TableStringPool;
|
import com.reandroid.json.JSONConvert;
|
||||||
import com.reandroid.lib.arsc.pool.TypeStringPool;
|
import com.reandroid.json.JSONObject;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
|
||||||
import com.reandroid.lib.arsc.value.LibraryInfo;
|
|
||||||
import com.reandroid.lib.arsc.value.StagedAliasEntry;
|
|
||||||
import com.reandroid.lib.json.JSONConvert;
|
|
||||||
import com.reandroid.lib.json.JSONObject;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
public class PackageBlock extends BaseChunk<PackageHeader>
|
public class PackageBlock extends Chunk<PackageHeader>
|
||||||
implements JSONConvert<JSONObject>, Comparable<PackageBlock> {
|
implements JSONConvert<JSONObject>, Comparable<PackageBlock> {
|
||||||
|
|
||||||
private final TypeStringPool mTypeStringPool;
|
private final TypeStringPool mTypeStringPool;
|
@ -13,19 +13,19 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.chunk;
|
package com.reandroid.arsc.chunk;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.array.TypeBlockArray;
|
import com.reandroid.arsc.array.TypeBlockArray;
|
||||||
import com.reandroid.lib.arsc.base.Block;
|
import com.reandroid.arsc.base.Block;
|
||||||
import com.reandroid.lib.arsc.container.SpecTypePair;
|
import com.reandroid.arsc.container.SpecTypePair;
|
||||||
import com.reandroid.lib.arsc.header.SpecHeader;
|
import com.reandroid.arsc.header.SpecHeader;
|
||||||
import com.reandroid.lib.arsc.item.*;
|
import com.reandroid.arsc.item.*;
|
||||||
import com.reandroid.lib.json.JSONConvert;
|
import com.reandroid.json.JSONConvert;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SpecBlock extends BaseChunk<SpecHeader> implements JSONConvert<JSONObject> {
|
public class SpecBlock extends Chunk<SpecHeader> implements JSONConvert<JSONObject> {
|
||||||
private final SpecFlagsArray specFlagsArray;
|
private final SpecFlagsArray specFlagsArray;
|
||||||
public SpecBlock() {
|
public SpecBlock() {
|
||||||
super(new SpecHeader(), 1);
|
super(new SpecHeader(), 1);
|
@ -13,16 +13,15 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.chunk;
|
package com.reandroid.arsc.chunk;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.array.StagedAliasEntryArray;
|
import com.reandroid.arsc.array.StagedAliasEntryArray;
|
||||||
import com.reandroid.lib.arsc.header.StagedAliasHeader;
|
import com.reandroid.arsc.header.StagedAliasHeader;
|
||||||
import com.reandroid.lib.arsc.item.IntegerItem;
|
import com.reandroid.arsc.value.StagedAliasEntry;
|
||||||
import com.reandroid.lib.arsc.value.StagedAliasEntry;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public class StagedAlias extends BaseChunk<StagedAliasHeader>{
|
public class StagedAlias extends Chunk<StagedAliasHeader> {
|
||||||
private final StagedAliasEntryArray stagedAliasEntryArray;
|
private final StagedAliasEntryArray stagedAliasEntryArray;
|
||||||
public StagedAlias() {
|
public StagedAlias() {
|
||||||
super(new StagedAliasHeader(), 1);
|
super(new StagedAliasHeader(), 1);
|
@ -13,28 +13,28 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.chunk;
|
package com.reandroid.arsc.chunk;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.BuildInfo;
|
import com.reandroid.arsc.BuildInfo;
|
||||||
import com.reandroid.lib.arsc.array.PackageArray;
|
import com.reandroid.arsc.array.PackageArray;
|
||||||
import com.reandroid.lib.arsc.group.EntryGroup;
|
import com.reandroid.arsc.group.EntryGroup;
|
||||||
import com.reandroid.lib.arsc.header.HeaderBlock;
|
import com.reandroid.arsc.header.HeaderBlock;
|
||||||
import com.reandroid.lib.arsc.header.TableHeader;
|
import com.reandroid.arsc.header.InfoHeader;
|
||||||
import com.reandroid.lib.arsc.io.BlockReader;
|
import com.reandroid.arsc.header.TableHeader;
|
||||||
import com.reandroid.lib.arsc.item.IntegerItem;
|
import com.reandroid.arsc.io.BlockReader;
|
||||||
import com.reandroid.lib.arsc.pool.TableStringPool;
|
import com.reandroid.arsc.pool.TableStringPool;
|
||||||
import com.reandroid.lib.arsc.value.StagedAliasEntry;
|
import com.reandroid.arsc.value.StagedAliasEntry;
|
||||||
import com.reandroid.lib.common.Frameworks;
|
import com.reandroid.common.Frameworks;
|
||||||
import com.reandroid.lib.json.JSONConvert;
|
import com.reandroid.json.JSONConvert;
|
||||||
import com.reandroid.lib.json.JSONArray;
|
import com.reandroid.json.JSONArray;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class TableBlock extends BaseChunk<TableHeader> implements JSONConvert<JSONObject> {
|
public class TableBlock extends Chunk<TableHeader> implements JSONConvert<JSONObject> {
|
||||||
private final TableStringPool mTableStringPool;
|
private final TableStringPool mTableStringPool;
|
||||||
private final PackageArray mPackageArray;
|
private final PackageArray mPackageArray;
|
||||||
private final Set<TableBlock> mFrameWorks=new HashSet<>();
|
private final Set<TableBlock> mFrameWorks=new HashSet<>();
|
||||||
@ -75,7 +75,32 @@ public class TableBlock extends BaseChunk<TableHeader> implements JSONConvert<JS
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onReadBytes(BlockReader reader) throws IOException {
|
public void onReadBytes(BlockReader reader) throws IOException {
|
||||||
super.onReadBytes(reader);
|
TableHeader tableHeader = getHeaderBlock();
|
||||||
|
tableHeader.readBytes(reader);
|
||||||
|
if(tableHeader.getChunkType()!=ChunkType.TABLE){
|
||||||
|
throw new IOException("Not resource table: "+tableHeader);
|
||||||
|
}
|
||||||
|
boolean stringPoolLoaded=false;
|
||||||
|
InfoHeader infoHeader = reader.readHeaderBlock();
|
||||||
|
PackageArray packageArray=mPackageArray;
|
||||||
|
packageArray.clearChildes();
|
||||||
|
while(infoHeader!=null && reader.isAvailable()){
|
||||||
|
ChunkType chunkType=infoHeader.getChunkType();
|
||||||
|
if(chunkType==ChunkType.STRING){
|
||||||
|
if(!stringPoolLoaded){
|
||||||
|
mTableStringPool.readBytes(reader);
|
||||||
|
stringPoolLoaded=true;
|
||||||
|
}
|
||||||
|
}else if(chunkType==ChunkType.PACKAGE){
|
||||||
|
PackageBlock packageBlock=packageArray.createNext();
|
||||||
|
packageBlock.readBytes(reader);
|
||||||
|
}else {
|
||||||
|
UnknownChunk unknownChunk=new UnknownChunk();
|
||||||
|
unknownChunk.readBytes(reader);
|
||||||
|
addChild(unknownChunk);
|
||||||
|
}
|
||||||
|
infoHeader=reader.readHeaderBlock();
|
||||||
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
}
|
}
|
||||||
|
|
@ -13,21 +13,20 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.chunk;
|
package com.reandroid.arsc.chunk;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.array.EntryBlockArray;
|
import com.reandroid.arsc.array.EntryBlockArray;
|
||||||
import com.reandroid.lib.arsc.array.TypeBlockArray;
|
import com.reandroid.arsc.base.Block;
|
||||||
import com.reandroid.lib.arsc.base.Block;
|
import com.reandroid.arsc.container.SpecTypePair;
|
||||||
import com.reandroid.lib.arsc.container.SpecTypePair;
|
import com.reandroid.arsc.header.TypeHeader;
|
||||||
import com.reandroid.lib.arsc.header.TypeHeader;
|
import com.reandroid.arsc.io.BlockLoad;
|
||||||
import com.reandroid.lib.arsc.io.BlockLoad;
|
import com.reandroid.arsc.io.BlockReader;
|
||||||
import com.reandroid.lib.arsc.io.BlockReader;
|
import com.reandroid.arsc.item.*;
|
||||||
import com.reandroid.lib.arsc.item.*;
|
import com.reandroid.arsc.pool.TypeStringPool;
|
||||||
import com.reandroid.lib.arsc.pool.TypeStringPool;
|
import com.reandroid.arsc.value.EntryBlock;
|
||||||
import com.reandroid.lib.arsc.value.EntryBlock;
|
import com.reandroid.arsc.value.ResConfig;
|
||||||
import com.reandroid.lib.arsc.value.ResConfig;
|
import com.reandroid.json.JSONConvert;
|
||||||
import com.reandroid.lib.json.JSONConvert;
|
import com.reandroid.json.JSONObject;
|
||||||
import com.reandroid.lib.json.JSONObject;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -35,7 +34,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TypeBlock extends BaseChunk<TypeHeader>
|
public class TypeBlock extends Chunk<TypeHeader>
|
||||||
implements BlockLoad, JSONConvert<JSONObject>, Comparable<TypeBlock> {
|
implements BlockLoad, JSONConvert<JSONObject>, Comparable<TypeBlock> {
|
||||||
|
|
||||||
private final EntryBlockArray mEntryArray;
|
private final EntryBlockArray mEntryArray;
|
@ -13,10 +13,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.chunk;
|
package com.reandroid.arsc.chunk;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.header.HeaderBlock;
|
import com.reandroid.arsc.header.HeaderBlock;
|
||||||
import com.reandroid.lib.arsc.item.ByteArray;
|
import com.reandroid.arsc.item.ByteArray;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ package com.reandroid.lib.arsc.chunk;
|
|||||||
* This class can load any valid chunk, aimed to
|
* This class can load any valid chunk, aimed to
|
||||||
* handle any future android changes
|
* handle any future android changes
|
||||||
* */
|
* */
|
||||||
public class UnknownChunk extends BaseChunk<HeaderBlock> implements HeaderBlock.HeaderLoaded {
|
public class UnknownChunk extends Chunk<HeaderBlock> implements HeaderBlock.HeaderLoaded {
|
||||||
private final ByteArray body;
|
private final ByteArray body;
|
||||||
public UnknownChunk() {
|
public UnknownChunk() {
|
||||||
super(new HeaderBlock(INITIAL_CHUNK_TYPE), 1);
|
super(new HeaderBlock(INITIAL_CHUNK_TYPE), 1);
|
@ -13,9 +13,9 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.chunk.xml;
|
package com.reandroid.arsc.chunk.xml;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.value.ValueType;
|
import com.reandroid.arsc.value.ValueType;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -24,7 +24,7 @@ import java.io.InputStream;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AndroidManifestBlock extends ResXmlBlock{
|
public class AndroidManifestBlock extends ResXmlDocument {
|
||||||
public AndroidManifestBlock(){
|
public AndroidManifestBlock(){
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ public class AndroidManifestBlock extends ResXmlBlock{
|
|||||||
if(iconAttribute==null || iconAttribute.getValueType() != ValueType.REFERENCE){
|
if(iconAttribute==null || iconAttribute.getValueType() != ValueType.REFERENCE){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return iconAttribute.getRawValue();
|
return iconAttribute.getData();
|
||||||
}
|
}
|
||||||
public void setIconResourceId(int resourceId){
|
public void setIconResourceId(int resourceId){
|
||||||
ResXmlElement applicationElement = getApplicationElement();
|
ResXmlElement applicationElement = getApplicationElement();
|
||||||
@ -51,7 +51,7 @@ public class AndroidManifestBlock extends ResXmlBlock{
|
|||||||
ResXmlAttribute iconAttribute =
|
ResXmlAttribute iconAttribute =
|
||||||
applicationElement.getOrCreateAndroidAttribute(NAME_icon, ID_icon);
|
applicationElement.getOrCreateAndroidAttribute(NAME_icon, ID_icon);
|
||||||
iconAttribute.setValueType(ValueType.REFERENCE);
|
iconAttribute.setValueType(ValueType.REFERENCE);
|
||||||
iconAttribute.setRawValue(resourceId);
|
iconAttribute.setData(resourceId);
|
||||||
}
|
}
|
||||||
public boolean isDebuggable(){
|
public boolean isDebuggable(){
|
||||||
ResXmlElement application=getApplicationElement();
|
ResXmlElement application=getApplicationElement();
|
||||||
@ -315,7 +315,7 @@ public class AndroidManifestBlock extends ResXmlBlock{
|
|||||||
builder.append("}");
|
builder.append("}");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
public static boolean isAndroidManifestBlock(ResXmlBlock xmlBlock){
|
public static boolean isAndroidManifestBlock(ResXmlDocument xmlBlock){
|
||||||
if(xmlBlock==null){
|
if(xmlBlock==null){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
212
src/main/java/com/reandroid/arsc/chunk/xml/BaseXmlChunk.java
Executable file
212
src/main/java/com/reandroid/arsc/chunk/xml/BaseXmlChunk.java
Executable file
@ -0,0 +1,212 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 github.com/REAndroid
|
||||||
|
*
|
||||||
|
* 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 com.reandroid.arsc.chunk.xml;
|
||||||
|
|
||||||
|
import com.reandroid.arsc.chunk.ChunkType;
|
||||||
|
import com.reandroid.arsc.base.Block;
|
||||||
|
import com.reandroid.arsc.chunk.Chunk;
|
||||||
|
import com.reandroid.arsc.header.XmlNodeHeader;
|
||||||
|
import com.reandroid.arsc.item.IntegerItem;
|
||||||
|
import com.reandroid.arsc.item.ResXmlString;
|
||||||
|
import com.reandroid.arsc.pool.ResXmlStringPool;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
class BaseXmlChunk extends Chunk<XmlNodeHeader> {
|
||||||
|
private final IntegerItem mNamespaceReference;
|
||||||
|
private final IntegerItem mStringReference;
|
||||||
|
|
||||||
|
BaseXmlChunk(ChunkType chunkType, int initialChildesCount) {
|
||||||
|
super(new XmlNodeHeader(chunkType), initialChildesCount+2);
|
||||||
|
|
||||||
|
this.mNamespaceReference=new IntegerItem(-1);
|
||||||
|
this.mStringReference=new IntegerItem(-1);
|
||||||
|
|
||||||
|
addChild(mNamespaceReference);
|
||||||
|
addChild(mStringReference);
|
||||||
|
}
|
||||||
|
Set<ResXmlString> clearStringReferences(){
|
||||||
|
Set<ResXmlString> results=new HashSet<>();
|
||||||
|
ResXmlString xmlString;
|
||||||
|
xmlString=unLinkStringReference(getHeaderBlock().getCommentReference());
|
||||||
|
if(xmlString!=null){
|
||||||
|
results.add(xmlString);
|
||||||
|
}
|
||||||
|
xmlString=unLinkStringReference(mNamespaceReference);
|
||||||
|
if(xmlString!=null){
|
||||||
|
results.add(xmlString);
|
||||||
|
}
|
||||||
|
xmlString=unLinkStringReference(mStringReference);
|
||||||
|
if(xmlString!=null){
|
||||||
|
results.add(xmlString);
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
void linkStringReferences(){
|
||||||
|
linkStringReference(getHeaderBlock().getCommentReference());
|
||||||
|
linkStringReference(mNamespaceReference);
|
||||||
|
linkStringReference(mStringReference);
|
||||||
|
}
|
||||||
|
private void linkStringReference(IntegerItem item){
|
||||||
|
ResXmlString xmlString = getResXmlString(item.get());
|
||||||
|
if(xmlString!=null){
|
||||||
|
xmlString.addReferenceIfAbsent(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ResXmlString unLinkStringReference(IntegerItem item){
|
||||||
|
ResXmlString xmlString = getResXmlString(item.get());
|
||||||
|
if(xmlString!=null){
|
||||||
|
xmlString.removeReference(item);
|
||||||
|
}
|
||||||
|
return xmlString;
|
||||||
|
}
|
||||||
|
public void setLineNumber(int val){
|
||||||
|
getHeaderBlock().getLineNumber().set(val);
|
||||||
|
}
|
||||||
|
public int getLineNumber(){
|
||||||
|
return getHeaderBlock().getLineNumber().get();
|
||||||
|
}
|
||||||
|
public void setCommentReference(int val){
|
||||||
|
IntegerItem comment=getHeaderBlock().getCommentReference();
|
||||||
|
unLinkStringReference(comment);
|
||||||
|
getHeaderBlock().getCommentReference().set(val);
|
||||||
|
linkStringReference(comment);
|
||||||
|
}
|
||||||
|
public int getCommentReference(){
|
||||||
|
return getHeaderBlock().getCommentReference().get();
|
||||||
|
}
|
||||||
|
public void setNamespaceReference(int val){
|
||||||
|
unLinkStringReference(mNamespaceReference);
|
||||||
|
mNamespaceReference.set(val);
|
||||||
|
linkStringReference(mNamespaceReference);
|
||||||
|
}
|
||||||
|
public int getNamespaceReference(){
|
||||||
|
return mNamespaceReference.get();
|
||||||
|
}
|
||||||
|
public void setStringReference(int val){
|
||||||
|
unLinkStringReference(mStringReference);
|
||||||
|
mStringReference.set(val);
|
||||||
|
linkStringReference(mStringReference);
|
||||||
|
}
|
||||||
|
public int getStringReference(){
|
||||||
|
return mStringReference.get();
|
||||||
|
}
|
||||||
|
public ResXmlString setString(String str){
|
||||||
|
ResXmlStringPool pool = getStringPool();
|
||||||
|
if(pool==null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
ResXmlString xmlString = pool.getOrCreate(str);
|
||||||
|
setStringReference(xmlString.getIndex());
|
||||||
|
return xmlString;
|
||||||
|
}
|
||||||
|
public ResXmlStringPool getStringPool(){
|
||||||
|
Block parent=getParent();
|
||||||
|
while (parent!=null){
|
||||||
|
if(parent instanceof ResXmlDocument){
|
||||||
|
return ((ResXmlDocument)parent).getStringPool();
|
||||||
|
}
|
||||||
|
if(parent instanceof ResXmlElement){
|
||||||
|
return ((ResXmlElement)parent).getStringPool();
|
||||||
|
}
|
||||||
|
parent=parent.getParent();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public ResXmlString getResXmlString(int ref){
|
||||||
|
if(ref<0){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
ResXmlStringPool stringPool=getStringPool();
|
||||||
|
if(stringPool!=null){
|
||||||
|
return stringPool.get(ref);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
ResXmlString getOrCreateResXmlString(String str){
|
||||||
|
ResXmlStringPool stringPool=getStringPool();
|
||||||
|
if(stringPool!=null){
|
||||||
|
return stringPool.getOrCreate(str);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String getString(int ref){
|
||||||
|
ResXmlString xmlString=getResXmlString(ref);
|
||||||
|
if(xmlString!=null){
|
||||||
|
return xmlString.get();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
ResXmlString getOrCreateString(String str){
|
||||||
|
ResXmlStringPool stringPool=getStringPool();
|
||||||
|
if(stringPool==null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return stringPool.getOrCreate(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName(){
|
||||||
|
return getString(getStringReference());
|
||||||
|
}
|
||||||
|
public String getUri(){
|
||||||
|
return getString(getNamespaceReference());
|
||||||
|
}
|
||||||
|
public String getComment(){
|
||||||
|
return getString(getCommentReference());
|
||||||
|
}
|
||||||
|
public void setComment(String comment){
|
||||||
|
if(comment==null||comment.length()==0){
|
||||||
|
setCommentReference(-1);
|
||||||
|
}else {
|
||||||
|
String old=getComment();
|
||||||
|
if(comment.equals(old)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ResXmlString xmlString = getOrCreateResXmlString(comment);
|
||||||
|
setCommentReference(xmlString.getIndex());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public ResXmlElement getParentResXmlElement(){
|
||||||
|
Block parent=getParent();
|
||||||
|
while (parent!=null){
|
||||||
|
if(parent instanceof ResXmlElement){
|
||||||
|
return (ResXmlElement)parent;
|
||||||
|
}
|
||||||
|
parent=parent.getParent();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onChunkRefreshed() {
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String toString(){
|
||||||
|
ChunkType chunkType=getHeaderBlock().getChunkType();
|
||||||
|
if(chunkType==null){
|
||||||
|
return super.toString();
|
||||||
|
}
|
||||||
|
StringBuilder builder=new StringBuilder();
|
||||||
|
builder.append(chunkType.toString());
|
||||||
|
builder.append(": line=");
|
||||||
|
builder.append(getLineNumber());
|
||||||
|
builder.append(" {");
|
||||||
|
builder.append(getName());
|
||||||
|
builder.append("}");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -13,13 +13,13 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.reandroid.lib.arsc.chunk.xml;
|
package com.reandroid.arsc.chunk.xml;
|
||||||
|
|
||||||
import com.reandroid.lib.arsc.array.ResXmlIDArray;
|
import com.reandroid.arsc.array.ResXmlIDArray;
|
||||||
import com.reandroid.lib.arsc.array.StringArray;
|
import com.reandroid.arsc.array.StringArray;
|
||||||
import com.reandroid.lib.arsc.item.ResXmlID;
|
import com.reandroid.arsc.item.ResXmlID;
|
||||||
import com.reandroid.lib.arsc.item.ResXmlString;
|
import com.reandroid.arsc.item.ResXmlString;
|
||||||
import com.reandroid.lib.arsc.pool.ResXmlStringPool;
|
import com.reandroid.arsc.pool.ResXmlStringPool;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
535
src/main/java/com/reandroid/arsc/chunk/xml/ResXmlAttribute.java
Executable file
535
src/main/java/com/reandroid/arsc/chunk/xml/ResXmlAttribute.java
Executable file
@ -0,0 +1,535 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 github.com/REAndroid
|
||||||
|
*
|
||||||
|
* 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 com.reandroid.arsc.chunk.xml;
|
||||||
|
|
||||||
|
import com.reandroid.arsc.array.ResXmlAttributeArray;
|
||||||
|
import com.reandroid.arsc.array.ResXmlIDArray;
|
||||||
|
import com.reandroid.arsc.base.Block;
|
||||||
|
import com.reandroid.arsc.container.FixedBlockContainer;
|
||||||
|
import com.reandroid.arsc.decoder.ValueDecoder;
|
||||||
|
import com.reandroid.arsc.group.EntryGroup;
|
||||||
|
import com.reandroid.arsc.item.*;
|
||||||
|
import com.reandroid.arsc.pool.ResXmlStringPool;
|
||||||
|
import com.reandroid.arsc.value.Value;
|
||||||
|
import com.reandroid.arsc.value.ValueType;
|
||||||
|
import com.reandroid.common.EntryStore;
|
||||||
|
import com.reandroid.json.JSONConvert;
|
||||||
|
import com.reandroid.json.JSONObject;
|
||||||
|
import com.reandroid.xml.XMLAttribute;
|
||||||
|
import com.reandroid.xml.XMLException;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class ResXmlAttribute extends FixedBlockContainer
|
||||||
|
implements Value, Comparable<ResXmlAttribute>, JSONConvert<JSONObject> {
|
||||||
|
private final IntegerItem mNamespaceReference;
|
||||||
|
private final IntegerItem mNameReference;
|
||||||
|
private final IntegerItem mValueStringReference;
|
||||||
|
private final ShortItem mNameType;
|
||||||
|
private final ByteItem mReserved;
|
||||||
|
private final ByteItem mValueTypeByte;
|
||||||
|
private final IntegerItem mData;
|
||||||
|
private final ByteArray extraBytes;
|
||||||
|
public ResXmlAttribute(int size) {
|
||||||
|
super(8);
|
||||||
|
mNamespaceReference = new IntegerItem(-1);
|
||||||
|
mNameReference = new IntegerItem(-1);
|
||||||
|
mValueStringReference = new IntegerItem(-1);
|
||||||
|
mNameType = new ShortItem((short) 0x0008);
|
||||||
|
mReserved = new ByteItem();
|
||||||
|
mValueTypeByte = new ByteItem();
|
||||||
|
mData = new IntegerItem();
|
||||||
|
extraBytes = new ByteArray();
|
||||||
|
addChild(0, mNamespaceReference);
|
||||||
|
addChild(1, mNameReference);
|
||||||
|
addChild(2, mValueStringReference);
|
||||||
|
addChild(3, mNameType);
|
||||||
|
addChild(4, mReserved);
|
||||||
|
addChild(5, mValueTypeByte);
|
||||||
|
addChild(6, mData);
|
||||||
|
addChild(7, extraBytes);
|
||||||
|
|
||||||
|
extraBytes.setSize(size-20);
|
||||||
|
}
|
||||||
|
public ResXmlAttribute(){
|
||||||
|
this(20);
|
||||||
|
}
|
||||||
|
public void setAttributesUnitSize(int size){
|
||||||
|
extraBytes.setSize(size-20);
|
||||||
|
IntegerItem integerItem = new IntegerItem(this.hashCode());
|
||||||
|
extraBytes.putByteArray(0, integerItem.getBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<ResXmlString> clearStringReferences(){
|
||||||
|
Set<ResXmlString> results= new HashSet<>();
|
||||||
|
ResXmlString xmlString;
|
||||||
|
xmlString=unLinkStringReference(mNamespaceReference);
|
||||||
|
if(xmlString!=null){
|
||||||
|
results.add(xmlString);
|
||||||
|
}
|
||||||
|
xmlString=unLinkStringReference(mNameReference);
|
||||||
|
if(xmlString!=null){
|
||||||
|
results.add(xmlString);
|
||||||
|
}
|
||||||
|
xmlString=unLinkStringReference(mValueStringReference);
|
||||||
|
if(xmlString!=null){
|
||||||
|
results.add(xmlString);
|
||||||
|
}
|
||||||
|
xmlString=unLinkStringReference(mData);
|
||||||
|
if(xmlString!=null){
|
||||||
|
results.add(xmlString);
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
public void linkStringReferences(){
|
||||||
|
linkStringReference(mNamespaceReference);
|
||||||
|
linkStringReference(mNameReference);
|
||||||
|
linkStringReference(mValueStringReference);
|
||||||
|
if(getValueType()==ValueType.STRING){
|
||||||
|
linkStringReference(mData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void linkStringReference(IntegerItem item){
|
||||||
|
ResXmlString xmlString = getResXmlString(item.get());
|
||||||
|
if(xmlString!=null){
|
||||||
|
xmlString.addReferenceIfAbsent(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private ResXmlString unLinkStringReference(IntegerItem item){
|
||||||
|
ResXmlString xmlString = getResXmlString(item.get());
|
||||||
|
if(xmlString!=null){
|
||||||
|
xmlString.removeReference(item);
|
||||||
|
}
|
||||||
|
return xmlString;
|
||||||
|
}
|
||||||
|
public String getUri(){
|
||||||
|
return getString(getNamespaceReference());
|
||||||
|
}
|
||||||
|
int getNamespaceReference(){
|
||||||
|
return mNamespaceReference.get();
|
||||||
|
}
|
||||||
|
public void setNamespaceReference(int ref){
|
||||||
|
mNamespaceReference.set(ref);
|
||||||
|
}
|
||||||
|
int getNameReference(){
|
||||||
|
return mNameReference.get();
|
||||||
|
}
|
||||||
|
void setNameReference(int ref){
|
||||||
|
mNameReference.set(ref);
|
||||||
|
}
|
||||||
|
int getValueStringReference(){
|
||||||
|
return mValueStringReference.get();
|
||||||
|
}
|
||||||
|
void setValueStringReference(int ref){
|
||||||
|
mValueStringReference.set(ref);
|
||||||
|
}
|
||||||
|
byte getValueTypeByte(){
|
||||||
|
return mValueTypeByte.get();
|
||||||
|
}
|
||||||
|
void setValueTypeByte(byte b){
|
||||||
|
mValueTypeByte.set(b);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int getData(){
|
||||||
|
return mData.get();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void setData(int val){
|
||||||
|
mData.set(val);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public ValueType getValueType(){
|
||||||
|
return ValueType.valueOf(getValueTypeByte());
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void setValueType(ValueType valueType){
|
||||||
|
byte b=0;
|
||||||
|
if(valueType!=null){
|
||||||
|
b=valueType.getByte();
|
||||||
|
}
|
||||||
|
setValueTypeByte(b);
|
||||||
|
}
|
||||||
|
public String getFullName(){
|
||||||
|
String name=getName();
|
||||||
|
if(name==null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String prefix=getNamePrefix();
|
||||||
|
if(prefix==null){
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
return prefix+":"+name;
|
||||||
|
}
|
||||||
|
public String getName(){
|
||||||
|
return getString(getNameReference());
|
||||||
|
}
|
||||||
|
public String getNamePrefix(){
|
||||||
|
ResXmlElement xmlElement=getParentResXmlElement();
|
||||||
|
if(xmlElement==null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
ResXmlStartNamespace startNamespace=xmlElement.getStartNamespaceByUriRef(getNamespaceReference());
|
||||||
|
if(startNamespace==null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return startNamespace.getPrefix();
|
||||||
|
}
|
||||||
|
public ResXmlStartNamespace getStartNamespace(){
|
||||||
|
ResXmlElement xmlElement=getParentResXmlElement();
|
||||||
|
if(xmlElement==null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return xmlElement.getStartNamespaceByUriRef(getNamespaceReference());
|
||||||
|
}
|
||||||
|
@Deprecated
|
||||||
|
public String getValueString(){
|
||||||
|
return getString(getValueStringReference());
|
||||||
|
}
|
||||||
|
public int getNameResourceID(){
|
||||||
|
return getResourceId(getNameReference());
|
||||||
|
}
|
||||||
|
public void setNameResourceID(int resourceId){
|
||||||
|
ResXmlIDMap xmlIDMap=getResXmlIDMap();
|
||||||
|
if(xmlIDMap==null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ResXmlID xmlID = xmlIDMap.getOrCreate(resourceId);
|
||||||
|
setNameReference(xmlID.getIndex());
|
||||||
|
}
|
||||||
|
public void setName(String name, int resourceId){
|
||||||
|
if(resourceId!=0){
|
||||||
|
setNameResourceID(resourceId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(name==null){
|
||||||
|
name="";
|
||||||
|
}
|
||||||
|
ResXmlIDMap xmlIDMap=getResXmlIDMap();
|
||||||
|
ResXmlStringPool stringPool=getStringPool();
|
||||||
|
if(stringPool==null || xmlIDMap==null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ResXmlString xmlString = stringPool.getOrCreateAttributeName(xmlIDMap.getResXmlIDArray().childesCount(), name);
|
||||||
|
setNameReference(xmlString.getIndex());
|
||||||
|
}
|
||||||
|
private int getResourceId(int ref){
|
||||||
|
if(ref<0){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ResXmlIDMap xmlIDMap=getResXmlIDMap();
|
||||||
|
if(xmlIDMap==null){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ResXmlIDArray xmlIDArray = xmlIDMap.getResXmlIDArray();
|
||||||
|
ResXmlID xmlID = xmlIDArray.get(ref);
|
||||||
|
if(xmlID!=null){
|
||||||
|
return xmlID.get();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getString(int ref){
|
||||||
|
if(ref<0){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
ResXmlString xmlString=getResXmlString(ref);
|
||||||
|
if(xmlString!=null){
|
||||||
|
return xmlString.getHtml();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
private ResXmlString getResXmlString(int ref){
|
||||||
|
ResXmlStringPool stringPool=getStringPool();
|
||||||
|
if(stringPool!=null){
|
||||||
|
return stringPool.get(ref);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
private ResXmlString getOrCreateResXmlString(String str){
|
||||||
|
ResXmlStringPool stringPool=getStringPool();
|
||||||
|
if(stringPool!=null){
|
||||||
|
return stringPool.getOrCreate(str);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
private ResXmlStringPool getStringPool(){
|
||||||
|
ResXmlElement xmlElement=getParentResXmlElement();
|
||||||
|
if(xmlElement!=null){
|
||||||
|
return xmlElement.getStringPool();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
private ResXmlIDMap getResXmlIDMap(){
|
||||||
|
ResXmlElement xmlElement=getParentResXmlElement();
|
||||||
|
if(xmlElement!=null){
|
||||||
|
return xmlElement.getResXmlIDMap();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public ResXmlElement getParentResXmlElement(){
|
||||||
|
Block parent=getParent();
|
||||||
|
while (parent!=null){
|
||||||
|
if(parent instanceof ResXmlElement){
|
||||||
|
return (ResXmlElement)parent;
|
||||||
|
}
|
||||||
|
parent=parent.getParent();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public String getValueAsString(){
|
||||||
|
int ref= getData();
|
||||||
|
ResXmlString xmlString=getResXmlString(ref);
|
||||||
|
if(xmlString==null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return xmlString.getHtml();
|
||||||
|
}
|
||||||
|
public boolean getValueAsBoolean(){
|
||||||
|
int ref= getData();
|
||||||
|
return ref!=0;
|
||||||
|
}
|
||||||
|
public void setValueAsString(String str){
|
||||||
|
setValueType(ValueType.STRING);
|
||||||
|
ResXmlString xmlString=getOrCreateResXmlString(str);
|
||||||
|
if(xmlString==null){
|
||||||
|
throw new IllegalStateException("ResXmlString is null, attribute must be added to parent element first");
|
||||||
|
}
|
||||||
|
int ref=xmlString.getIndex();
|
||||||
|
setData(ref);
|
||||||
|
setValueStringReference(ref);
|
||||||
|
}
|
||||||
|
public void setValueAsBoolean(boolean val){
|
||||||
|
setValueType(ValueType.INT_BOOLEAN);
|
||||||
|
int ref=val?0xffffffff:0;
|
||||||
|
setData(ref);
|
||||||
|
setValueStringReference(-1);
|
||||||
|
}
|
||||||
|
public boolean hasIntegerValue(){
|
||||||
|
ValueType valueType=getValueType();
|
||||||
|
return valueType==ValueType.INT_DEC;
|
||||||
|
}
|
||||||
|
public Integer getValueAsInteger(){
|
||||||
|
if(hasIntegerValue()){
|
||||||
|
return getData();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public void setValueAsInteger(int val){
|
||||||
|
setValueType(ValueType.INT_DEC);
|
||||||
|
setData(val);
|
||||||
|
setValueStringReference(-1);
|
||||||
|
}
|
||||||
|
private ResXmlAttributeArray getParentResXmlAttributeArray(){
|
||||||
|
Block parent=this;
|
||||||
|
while(parent!=null){
|
||||||
|
if(parent instanceof ResXmlAttributeArray){
|
||||||
|
return (ResXmlAttributeArray)parent;
|
||||||
|
}
|
||||||
|
parent=parent.getParent();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public void setValueAsIntegerDec(int val){
|
||||||
|
setValueType(ValueType.INT_DEC);
|
||||||
|
setData(val);
|
||||||
|
setValueStringReference(-1);
|
||||||
|
}
|
||||||
|
public void setValueAsHex(int val){
|
||||||
|
setValueType(ValueType.INT_HEX);
|
||||||
|
setData(val);
|
||||||
|
setValueStringReference(-1);
|
||||||
|
}
|
||||||
|
public void setValueAsFraction(float fraction){
|
||||||
|
int val=Float.floatToIntBits(fraction);
|
||||||
|
setValueAsFraction(val);
|
||||||
|
}
|
||||||
|
public void setValueAsFraction(int val){
|
||||||
|
setValueType(ValueType.FRACTION);
|
||||||
|
setData(val);
|
||||||
|
setValueStringReference(-1);
|
||||||
|
}
|
||||||
|
public void setValueAsResourceId(int resId){
|
||||||
|
setValueType(ValueType.REFERENCE);
|
||||||
|
setData(resId);
|
||||||
|
setValueStringReference(-1);
|
||||||
|
}
|
||||||
|
public void setValueAsAttributeId(int attrId){
|
||||||
|
setValueType(ValueType.ATTRIBUTE);
|
||||||
|
setData(attrId);
|
||||||
|
setValueStringReference(-1);
|
||||||
|
}
|
||||||
|
public void setValueAsColorRGB4(int val){
|
||||||
|
setValueType(ValueType.INT_COLOR_RGB4);
|
||||||
|
setData(val);
|
||||||
|
setValueStringReference(-1);
|
||||||
|
}
|
||||||
|
public void setValueAsColorRGB8(int val){
|
||||||
|
setValueType(ValueType.INT_COLOR_RGB8);
|
||||||
|
setData(val);
|
||||||
|
setValueStringReference(-1);
|
||||||
|
}
|
||||||
|
public void setValueAsColorARGB4(int val){
|
||||||
|
setValueType(ValueType.INT_COLOR_ARGB4);
|
||||||
|
setData(val);
|
||||||
|
setValueStringReference(-1);
|
||||||
|
}
|
||||||
|
public void setValueAsColorARGB8(int val){
|
||||||
|
setValueType(ValueType.INT_COLOR_ARGB8);
|
||||||
|
setData(val);
|
||||||
|
setValueStringReference(-1);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int compareTo(ResXmlAttribute other) {
|
||||||
|
int id1=getNameResourceID();
|
||||||
|
int id2=other.getNameResourceID();
|
||||||
|
if(id1==0 && id2!=0){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(id2==0 && id1!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(id1!=0){
|
||||||
|
return Integer.compare(id1, id2);
|
||||||
|
}
|
||||||
|
String name1=getName();
|
||||||
|
if(name1==null){
|
||||||
|
name1="";
|
||||||
|
}
|
||||||
|
String name2=other.getName();
|
||||||
|
if(name2==null){
|
||||||
|
name2="";
|
||||||
|
}
|
||||||
|
return name1.compareTo(name2);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public JSONObject toJson() {
|
||||||
|
JSONObject jsonObject= new JSONObject();
|
||||||
|
jsonObject.put(NAME_name, getName());
|
||||||
|
jsonObject.put(NAME_id, getNameResourceID());
|
||||||
|
jsonObject.put(NAME_namespace_uri, getUri());
|
||||||
|
ValueType valueType=getValueType();
|
||||||
|
jsonObject.put(NAME_value_type, valueType.name());
|
||||||
|
if(valueType==ValueType.STRING){
|
||||||
|
jsonObject.put(NAME_data, getValueAsString());
|
||||||
|
}else if(valueType==ValueType.INT_BOOLEAN){
|
||||||
|
jsonObject.put(NAME_data, getValueAsBoolean());
|
||||||
|
}else {
|
||||||
|
jsonObject.put(NAME_data, getData());
|
||||||
|
}
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void fromJson(JSONObject json) {
|
||||||
|
String name = json.optString(NAME_name, "");
|
||||||
|
int id = json.optInt(NAME_id, 0);
|
||||||
|
setName(name, id);
|
||||||
|
String uri= json.optString(NAME_namespace_uri, null);
|
||||||
|
if(uri!=null){
|
||||||
|
ResXmlStartNamespace ns = getParentResXmlElement().getStartNamespaceByUri(uri);
|
||||||
|
setNamespaceReference(ns.getUriReference());
|
||||||
|
}
|
||||||
|
ValueType valueType=ValueType.fromName(json.getString(NAME_value_type));
|
||||||
|
if(valueType==ValueType.STRING){
|
||||||
|
setValueAsString(json.optString(NAME_data, ""));
|
||||||
|
}else if(valueType==ValueType.INT_BOOLEAN){
|
||||||
|
setValueAsBoolean(json.getBoolean(NAME_data));
|
||||||
|
}else {
|
||||||
|
setValueType(valueType);
|
||||||
|
setData(json.getInt(NAME_data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public XMLAttribute decodeToXml(EntryStore entryStore, int currentPackageId) throws XMLException {
|
||||||
|
int resourceId=getNameResourceID();
|
||||||
|
String name;
|
||||||
|
if(resourceId==0){
|
||||||
|
name=getName();
|
||||||
|
}else {
|
||||||
|
EntryGroup group = entryStore.getEntryGroup(resourceId);
|
||||||
|
if(group==null){
|
||||||
|
//Lets ignore such error until XML encoder implemented
|
||||||
|
//throw new XMLException("Failed to decode attribute name: "
|
||||||
|
//+ String.format("@0x%08x", resourceId));
|
||||||
|
name=String.format("@0x%08x", resourceId);
|
||||||
|
}else {
|
||||||
|
name=group.getSpecName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String prefix = getNamePrefix();
|
||||||
|
if(prefix!=null){
|
||||||
|
name=prefix+":"+name;
|
||||||
|
}
|
||||||
|
ValueType valueType=getValueType();
|
||||||
|
int raw= getData();
|
||||||
|
String value;
|
||||||
|
if(valueType==ValueType.STRING){
|
||||||
|
value = ValueDecoder.escapeSpecialCharacter(getValueAsString());
|
||||||
|
}else {
|
||||||
|
value = ValueDecoder.decode(entryStore,
|
||||||
|
currentPackageId,
|
||||||
|
resourceId,
|
||||||
|
valueType,
|
||||||
|
raw);
|
||||||
|
}
|
||||||
|
XMLAttribute attribute = new XMLAttribute(name, value);
|
||||||
|
attribute.setNameId(resourceId);
|
||||||
|
if(valueType==ValueType.REFERENCE||valueType==ValueType.ATTRIBUTE){
|
||||||
|
attribute.setValueId(raw);
|
||||||
|
}
|
||||||
|
return attribute;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String toString(){
|
||||||
|
String fullName=getFullName();
|
||||||
|
if(fullName!=null ){
|
||||||
|
int id=getNameResourceID();
|
||||||
|
if(id>0){
|
||||||
|
fullName=fullName+"(@"+String.format("0x%08x",id)+")";
|
||||||
|
}
|
||||||
|
String valStr;
|
||||||
|
ValueType valueType=getValueType();
|
||||||
|
if(valueType==ValueType.STRING){
|
||||||
|
valStr=getValueAsString();
|
||||||
|
}else if (valueType==ValueType.INT_BOOLEAN){
|
||||||
|
valStr=String.valueOf(getValueAsBoolean());
|
||||||
|
}else {
|
||||||
|
valStr="["+valueType+"] "+ getData();
|
||||||
|
}
|
||||||
|
if(valStr!=null){
|
||||||
|
return fullName+"=\""+valStr+"\"";
|
||||||
|
}
|
||||||
|
return fullName+"["+valueType+"]=\""+ getData()+"\"";
|
||||||
|
}
|
||||||
|
StringBuilder builder= new StringBuilder();
|
||||||
|
builder.append(getClass().getSimpleName());
|
||||||
|
builder.append(": ");
|
||||||
|
builder.append(getIndex());
|
||||||
|
builder.append("{NamespaceReference=").append(getNamespaceReference());
|
||||||
|
builder.append(", NameReference=").append(getNameReference());
|
||||||
|
builder.append(", ValueStringReference=").append(getValueStringReference());
|
||||||
|
builder.append(", NameType=").append(mNameType.unsignedInt());
|
||||||
|
builder.append(", ReservedByte=").append(mReserved.unsignedInt());
|
||||||
|
builder.append(", ValueTypeByte=").append(getValueTypeByte());
|
||||||
|
builder.append(", RawValue=").append(getData());
|
||||||
|
builder.append("}");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
static final String NAME_id = "id";
|
||||||
|
public static final String NAME_value_type = "value_type";
|
||||||
|
public static final String NAME_name = "name";
|
||||||
|
public static final String NAME_namespace_uri = "namespace_uri";
|
||||||
|
public static final String NAME_data= "data";
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user