From 469693ff766929004fc235f7b36be7baed66b88a Mon Sep 17 00:00:00 2001 From: Tim Strazzere Date: Wed, 7 Aug 2024 11:43:13 -0700 Subject: [PATCH] (feature) add protection level parsing closes #5 --- .../content/res/chunk/types/Attribute.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/main/java/android/content/res/chunk/types/Attribute.java b/src/main/java/android/content/res/chunk/types/Attribute.java index 94b8a85..917611b 100644 --- a/src/main/java/android/content/res/chunk/types/Attribute.java +++ b/src/main/java/android/content/res/chunk/types/Attribute.java @@ -33,6 +33,16 @@ */ public class Attribute implements Chunk { + public static class Permission { + public static final int PROTECTION_MASK_BASE = 0xF; + + public static final int PROTECTION_NORMAL = 0; + public static final int PROTECTION_DANGEROUS = 1; + public static final int PROTECTION_SIGNATURE = 2; + public static final int PROTECTION_SIGNATURE_OR_SYSTEM = 3; + public static final int PROTECTION_INTERNAL = 4; + } + private int uri; private int name; private int stringData; @@ -133,6 +143,9 @@ public String toXML(StringSection stringSection, ResourceSection resourceSection } buffer.append(stringSection.getString(name)); + if (stringSection.getString(name).equals("protectionLevel")) { + boolean derp = true; + } buffer.append("=\""); @@ -153,6 +166,8 @@ public String toXML(StringSection stringSection, ResourceSection resourceSection } else { buffer.append("ERROR"); } + } else if (attributeType == AttributeType.FLAGS.getIntType()) { + buffer.append(getProtectionString(data)); } buffer.append("\""); @@ -160,6 +175,23 @@ public String toXML(StringSection stringSection, ResourceSection resourceSection return buffer.toString(); } + private String getProtectionString(int level) { + switch (level & Permission.PROTECTION_MASK_BASE) { + case Permission.PROTECTION_DANGEROUS: + return "dangerous"; + case Permission.PROTECTION_NORMAL: + return "normal"; + case Permission.PROTECTION_SIGNATURE: + return "signature"; + case Permission.PROTECTION_SIGNATURE_OR_SYSTEM: + return "signatureOrSystem"; + case Permission.PROTECTION_INTERNAL: + return "internal"; + default: + return "????"; + } + } + /* * (non-Javadoc) *