Class ResXmlPatcher

java.lang.Object
brut.androlib.res.xml.ResXmlPatcher

public final class ResXmlPatcher extends Object
  • Constructor Details

    • ResXmlPatcher

      public ResXmlPatcher()
  • Method Details

    • removeApplicationDebugTag

      public static void removeApplicationDebugTag(File file) throws AndrolibException
      Removes "debug" tag from file
      Parameters:
      file - AndroidManifest file
      Throws:
      AndrolibException - Error reading Manifest file
    • setApplicationDebugTagTrue

      public static void setApplicationDebugTagTrue(File file)
      Sets "debug" tag in the file to true
      Parameters:
      file - AndroidManifest file
    • setNetworkSecurityConfig

      public static void setNetworkSecurityConfig(File file)
      Sets the value of the network security config in the AndroidManifest file
      Parameters:
      file - AndroidManifest file
    • modNetworkSecurityConfig

      public static void modNetworkSecurityConfig(File file) throws ParserConfigurationException, TransformerException, IOException, SAXException
      Creates a modified network security config file that is more permissive
      Parameters:
      file - network security config file
      Throws:
      TransformerException - XML file could not be edited
      IOException - XML file could not be located
      SAXException - XML file could not be read
      ParserConfigurationException - XML nodes could be written
    • fixingPublicAttrsInProviderAttributes

      public static void fixingPublicAttrsInProviderAttributes(File file)
      Any @string reference in a provider value in AndroidManifest.xml will break on build, thus preventing the application from installing. This is from a bug/error in AOSP where public resources cannot be part of an authorities attribute within a provider tag.

      This finds any reference and replaces it with the literal value found in the res/values/strings.xml file.

      Parameters:
      file - File for AndroidManifest.xml
    • pullValueFromStrings

      public static String pullValueFromStrings(File directory, String key)
      Finds key in strings.xml file and returns text value
      Parameters:
      directory - Root directory of apk
      key - String reference (ie @string/foo)
      Returns:
      String|null
    • pullValueFromIntegers

      public static String pullValueFromIntegers(File directory, String key)
      Finds key in integers.xml file and returns text value
      Parameters:
      directory - Root directory of apk
      key - Integer reference (ie @integer/foo)
      Returns:
      String|null
    • removeManifestVersions

      public static void removeManifestVersions(File file)
      Removes attributes like "versionCode" and "versionName" from file.
      Parameters:
      file - File representing AndroidManifest.xml
    • renameManifestPackage

      public static void renameManifestPackage(File file, String packageOriginal)
      Replaces package value with passed packageOriginal string
      Parameters:
      file - File for AndroidManifest.xml
      packageOriginal - Package name to replace