script.py 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. ANDROID_NS = 'http://schemas.android.com/apk/res/android'
  13. def script_init(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
  14. # gw_data_center.pack_small=True
  15. return
  16. def script_second(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
  17. logging.info('script_second: ' + str(channel_sdk_info))
  18. # 逆向渠道id
  19. if channel_sdk_info['id'] == '549':
  20. # public_xml = os.path.join(extract_dir, "res/values/public.xml")
  21. # handle_public_xml(public_xml, "abc_list_pressed_holo_dark")
  22. #
  23. #
  24. # public_xml = os.path.join(extract_dir, "res/values/public.xml")
  25. # handle_public_xml(public_xml, "abc_list_selector_disabled_holo_dark")
  26. # public_xml = os.path.join(extract_dir, "res/layout/design_bottom_sheet_dialog.xml")
  27. # handle_public_xml(public_xml, "attr-private")
  28. public_xml = os.path.join(extract_dir, "../sdk/smallsheep/ForRes/values/public.xml")
  29. handle_public_xml(public_xml, "abc_list_pressed_holo_dark")
  30. #
  31. #
  32. public_xml = os.path.join(extract_dir, "../sdk/smallsheep/ForRes/values/public.xml")
  33. handle_public_xml(public_xml, "abc_list_selector_disabled_holo_dark")
  34. public_xml = os.path.join(extract_dir, "../sdk/smallsheep/ForRes/values/public.xml")
  35. handle_public_xml(public_xml, "abc_list_selector_background_transition_holo_dark")
  36. public_xml = os.path.join(extract_dir, "../sdk/smallsheep/ForRes/values/public.xml")
  37. handle_public_xml(public_xml, "abc_list_selector_holo_dark")
  38. public_xml = os.path.join(extract_dir, "../sdk/smallsheep/ForRes/values/public.xml")
  39. handle_public_xml(public_xml, "abc_item_background_holo_dark")
  40. public_xml = os.path.join(extract_dir, "../sdk/smallsheep/ForRes/values/styles.xml")
  41. handle_public_xml(public_xml, "abc_list_selector_holo_dark")
  42. public_xml = os.path.join(extract_dir, "../sdk/smallsheep/ForRes/values/styles.xml")
  43. handle_public_xml(public_xml, "abc_item_background_holo_dark")
  44. public_xml = os.path.join(extract_dir, "../sdk/smallsheep/ForRes/drawable/abc_item_background_holo_dark.xml")
  45. if os.path.exists(public_xml):
  46. os.remove(public_xml)
  47. public_xml = os.path.join(extract_dir,
  48. "../sdk/smallsheep/ForRes/drawable/abc_list_selector_background_transition_holo_dark.xml")
  49. if os.path.exists(public_xml):
  50. os.remove(public_xml)
  51. public_xml = os.path.join(extract_dir, "../sdk/smallsheep/ForRes/drawable/abc_list_selector_holo_dark.xml")
  52. if os.path.exists(public_xml):
  53. os.remove(public_xml)
  54. public_xml = os.path.join(extract_dir,
  55. "../sdk/smallsheep/ForRes/drawable-mdpi/abc_list_pressed_holo_dark.9.png")
  56. logging.info("public_xml:" + public_xml)
  57. if os.path.exists(public_xml):
  58. os.remove(public_xml)
  59. public_xml = os.path.join(extract_dir,
  60. "../sdk/smallsheep/ForRes/drawable-hdpi/abc_list_pressed_holo_dark.9.png")
  61. if os.path.exists(public_xml):
  62. os.remove(public_xml)
  63. public_xml = os.path.join(extract_dir,
  64. "../sdk/smallsheep/ForRes/drawable-xhdpi/abc_list_pressed_holo_dark.9.png")
  65. if os.path.exists(public_xml):
  66. os.remove(public_xml)
  67. public_xml = os.path.join(extract_dir,
  68. "../sdk/smallsheep/ForRes/drawable-xxhdpi/abc_list_pressed_holo_dark.9.png")
  69. if os.path.exists(public_xml):
  70. os.remove(public_xml)
  71. public_xml = os.path.join(extract_dir,
  72. "../sdk/smallsheep/ForRes/drawable-mdpi/abc_list_selector_disabled_holo_dark.9.png")
  73. if os.path.exists(public_xml):
  74. os.remove(public_xml)
  75. public_xml = os.path.join(extract_dir,
  76. "../sdk/smallsheep/ForRes/drawable-hdpi/abc_list_selector_disabled_holo_dark.9.png")
  77. if os.path.exists(public_xml):
  78. os.remove(public_xml)
  79. public_xml = os.path.join(extract_dir,
  80. "../sdk/smallsheep/ForRes/drawable-xhdpi/abc_list_selector_disabled_holo_dark.9.png")
  81. if os.path.exists(public_xml):
  82. os.remove(public_xml)
  83. public_xml = os.path.join(extract_dir,
  84. "../sdk/smallsheep/ForRes/drawable-xxhdpi/abc_list_selector_disabled_holo_dark.9.png")
  85. if os.path.exists(public_xml):
  86. os.remove(public_xml)
  87. return
  88. def handle_public_xml(public_xml_path, remove_node):
  89. if not os.path.exists(public_xml_path):
  90. logging.info('public_xml is null: ' + public_xml_path)
  91. return
  92. new_lines = []
  93. with open(public_xml_path, 'r+') as f:
  94. for line in f.readlines():
  95. # l = line.strip()
  96. if line.find(remove_node) > -1:
  97. continue
  98. new_lines.append(line)
  99. f.seek(0)
  100. f.truncate()
  101. f.writelines(new_lines)
  102. return
  103. def script_after(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
  104. if channel_sdk_info['id'] == '549':
  105. logging.info("-----after info-----")
  106. public_xml = os.path.join(extract_dir, "res/values/public.xml")
  107. handle_public_xml(public_xml, "abc_list_pressed_holo_dark")
  108. #
  109. #
  110. public_xml = os.path.join(extract_dir, "res/values/public.xml")
  111. handle_public_xml(public_xml, "abc_list_selector_disabled_holo_dark")
  112. logging.info("-----debug-----")
  113. def script(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  114. logging.info("-----debug-----")
  115. def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  116. return
  117. if __name__ == '__main__':
  118. # replace_super_application("D:\work\wzdq")
  119. ""