script.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # coding:utf8
  2. __author__ = 'dong'
  3. import os
  4. import logging
  5. import xml.dom.minidom
  6. import re
  7. import shutil
  8. import glob
  9. from xml.etree.ElementTree import ElementTree, Element
  10. import distutils.dir_util
  11. from xml.etree import ElementTree as ET
  12. import gw_file_system
  13. ANDROID_NS = 'http://schemas.android.com/apk/res/android'
  14. def script_second(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
  15. logging.info('script_second: ' + str(channel_sdk_info))
  16. # 逆向渠道id
  17. if channel_sdk_info['id'] == '597':
  18. public_xml = os.path.join(extract_dir, "res/values/public.xml")
  19. handle_public_xml(public_xml, "attr-private")
  20. public_xml = os.path.join(extract_dir, "res/layout/mtrl_layout_snackbar.xml")
  21. os.remove(public_xml)
  22. public_xml = os.path.join(extract_dir, "res/layout-sw600dp/mtrl_layout_snackbar.xml")
  23. os.remove(public_xml)
  24. public_xml = os.path.join(extract_dir, "res/values/public.xml")
  25. handle_public_xml(public_xml, "mtrl_layout_snackbar")
  26. public_xml = os.path.join(extract_dir, "res/layout/mtrl_layout_snackbar_include.xml")
  27. handle_public_xml(public_xml, "attr-private")
  28. public_xml = os.path.join(extract_dir, "res/layout/design_bottom_sheet_dialog.xml")
  29. handle_public_xml(public_xml, "attr-private")
  30. public_xml = os.path.join(extract_dir, "res/values/styles.xml")
  31. handle_public_xml(public_xml, "attr-private")
  32. public_xml = os.path.join(extract_dir, "res/values-v21/styles.xml")
  33. handle_public_xml(public_xml, "attr-private")
  34. return
  35. def script(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  36. logging.info("-----debug-----")
  37. def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  38. return
  39. def handle_public_xml(public_xml_path, remove_node):
  40. if not os.path.exists(public_xml_path):
  41. logging.info('public_xml is null: ' + public_xml_path)
  42. return
  43. new_lines = []
  44. with open(public_xml_path, 'r+') as f:
  45. for line in f.readlines():
  46. # l = line.strip()
  47. if line.find(remove_node) > -1:
  48. continue
  49. new_lines.append(line)
  50. f.seek(0)
  51. f.truncate()
  52. f.writelines(new_lines)
  53. return
  54. if __name__ == '__main__':
  55. # replace_super_application("D:\work\wzdq")
  56. ""