script.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # coding:utf8
  2. __author__ = '极无双'
  3. import os
  4. import logging
  5. import xml.dom.minidom
  6. import re
  7. import shutil
  8. import glob
  9. ANDROID_NS = 'http://schemas.android.com/apk/res/android'
  10. from xml.etree import ElementTree as ET
  11. def script(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  12. # modify_manifest(decompileDir)
  13. modify_manifest_common(decompileDir, "allowNativeHeapPointerTagging")
  14. def modify_manifest(decompileDir):
  15. ET.register_namespace('android', ANDROID_NS)
  16. xmlparse = os.path.join(decompileDir, 'AndroidManifest.xml')
  17. root_node = ET.parse(xmlparse)
  18. root = root_node.getroot()
  19. name = '{' + ANDROID_NS + '}name'
  20. authorities = '{' + ANDROID_NS + '}foregroundServiceType'
  21. authoritiesTwo = '{' + ANDROID_NS + '}requestLegacyExternalStorage'
  22. package_name = root.attrib.get('package')
  23. if package_name == None:
  24. return
  25. providers = root.findall('./application/service')
  26. if providers != None:
  27. for provider in providers:
  28. providerName = provider.attrib.get(name)
  29. if 'com.hbisoft.hbrecorder.ScreenRecordService' == providerName:
  30. try:
  31. del provider.attrib[authorities]
  32. # del provider.attrib[authoritiesTwo]
  33. except:
  34. ""
  35. root_node.write(xmlparse, 'utf-8')
  36. def modify_manifest_common(decompileDir, removeKey):
  37. ET.register_namespace('android', ANDROID_NS)
  38. xmlparse = os.path.join(decompileDir, 'AndroidManifest.xml')
  39. logging.info(xmlparse)
  40. root_node = ET.parse(xmlparse)
  41. root = root_node.getroot()
  42. name = '{' + ANDROID_NS + '}name'
  43. authorities = '{' + ANDROID_NS + '}' + removeKey
  44. package_name = root.attrib.get('package')
  45. if package_name == None:
  46. return
  47. providers = root.findall('./application')
  48. if providers != None:
  49. for provider in providers:
  50. try:
  51. del provider.attrib[authorities]
  52. except:
  53. ""
  54. root_node.write(xmlparse, 'utf-8')
  55. if __name__ == '__main__':
  56. ""