script.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. # coding:utf8
  2. import os
  3. import logging
  4. import re
  5. import glob
  6. import shutil
  7. import xml.etree.ElementTree as ET
  8. import distutils.dir_util
  9. import gw_file_system
  10. ANDROID_NS = 'http://schemas.android.com/apk/res/android'
  11. def script(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
  12. return
  13. def script_second(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
  14. logging.info('script_second: ' + str(channel_sdk_info))
  15. return
  16. def script_pre(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
  17. return
  18. def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  19. logging.info('------------channelSdkInfo:' + str(channelSdkInfo))
  20. if not os.path.exists(os.path.join(decompileDir, "smali_classes3/androidx")):
  21. return
  22. s1 = os.path.join(decompileDir, "smali_classes3")
  23. smali_classes2_dir = create_mutil_smali(decompileDir)
  24. s3 = smali_classes2_dir
  25. list_package = ["androidx"]
  26. if not os.path.exists(s3):
  27. distutils.dir_util.mkpath(s3)
  28. move_package(s1, s3, list_package)
  29. def move_package(s1, s3, list_package):
  30. for d in list_package:
  31. src = os.path.join(s1, d)
  32. if os.path.exists(src):
  33. dst = os.path.join(s3, d)
  34. distutils.dir_util.copy_tree(src, dst)
  35. distutils.dir_util.remove_tree(src)
  36. def create_mutil_smali(decompileDir):
  37. f_idx = 2
  38. while True:
  39. tmp = gw_file_system.get_full_path(os.path.join(decompileDir, 'smali_classes%d' % f_idx))
  40. tmp = tmp.replace('\\', '/')
  41. tmp = re.sub('/+', '/', tmp)
  42. if os.path.exists(tmp):
  43. files = os.listdir(tmp)
  44. if len(files) == 0:
  45. smali_classes2_dir = tmp
  46. break
  47. f_idx += 1
  48. else:
  49. smali_classes2_dir = tmp
  50. break
  51. # endwhile
  52. if not os.path.exists(smali_classes2_dir):
  53. os.mkdir(smali_classes2_dir)
  54. return smali_classes2_dir
  55. def handle_public_xml_param(public_xml_path, remove_node):
  56. if not os.path.exists(public_xml_path):
  57. logging.info('public_xml is null: ' + public_xml_path)
  58. return
  59. new_lines = []
  60. with open(public_xml_path, 'r+') as f:
  61. for line in f.readlines():
  62. # l = line.strip()
  63. if line.find(remove_node) > -1:
  64. continue
  65. new_lines.append(line)
  66. f.seek(0)
  67. f.truncate()
  68. f.writelines(new_lines)
  69. return
  70. def handle_public_xml(public_xml_path):
  71. if not os.path.exists(public_xml_path):
  72. logging.info('public_xml is null: ' + public_xml_path)
  73. return
  74. new_lines = []
  75. with open(public_xml_path, 'r+') as f:
  76. for line in f.readlines():
  77. # l = line.strip()
  78. if line.find("offline_banners") > -1 or line.find("outfit7") > -1 or line.find(
  79. "countries") > -1 or line.find(
  80. "county_codes") > -1 or line.find("felis_error_reporting_files") > -1:
  81. continue
  82. new_lines.append(line)
  83. f.seek(0)
  84. f.truncate()
  85. f.writelines(new_lines)
  86. return
  87. def remove_navigate(decompileDir):
  88. tmp_res = os.path.join(decompileDir, "res", "navigation")
  89. tmp_public_xml = os.path.join(decompileDir, "res", "values", "public.xml")
  90. if os.path.exists(tmp_res):
  91. distutils.dir_util.remove_tree(tmp_res)
  92. if os.path.exists(tmp_public_xml):
  93. os.remove(tmp_public_xml)
  94. if __name__ == '__main__':
  95. script_last("/tmp/ss", "G:/autopack2.0_kuaifa/tool/workspace/wdajl/15957/extract/", {"id": "309"}, "", "")
  96. # xml_path = "E:/apk/youhua/jingmenfengyue_216122/res/values/public.xml"
  97. # handle_public_xml(xml_path)
  98. # hideSplash("/mnt/share/yanghuang/python_test/cr")