script.py 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. s1 = os.path.join(decompileDir, "smali/androidx")
  21. if channelSdkInfo['id']=="597" and os.path.exists(s1):
  22. s1 = os.path.join(decompileDir, "smali/androidx")
  23. smali_classes2_dir = create_mutil_smali(decompileDir)
  24. s3 = os.path.join(smali_classes2_dir, "androidx")
  25. list_package = ["documentfile","drawerlayout","fragment","interpolator","legacy","lifecycle","loader","localbroadcastmanager","multidex"]
  26. if not os.path.exists(s3):
  27. distutils.dir_util.mkpath(s3)
  28. move_package(s1, s3, list_package)
  29. smali_classes2_dir = create_mutil_smali(decompileDir)
  30. s3 = os.path.join(smali_classes2_dir, "androidx")
  31. list_package = ["preference", "print", "recyclerview", "room", "savedstate", "slidingpanelayout", "sqlite",
  32. "swiperefreshlayout", "vectordrawable", "versionedparcelable", "viewpager", "work"]
  33. if not os.path.exists(s3):
  34. distutils.dir_util.mkpath(s3)
  35. move_package(s1, s3, list_package)
  36. s1 = os.path.join(decompileDir, "smali/androidx")
  37. smali_classes2_dir = create_mutil_smali(decompileDir)
  38. s3 = os.path.join(smali_classes2_dir, "androidx")
  39. list_package = ["activity", "appcompat", "asynclayoutinflater", "constraintlayout", "core", "customview",
  40. "drawerlayout", "fragment", "interpolator", "lifecycle", "localbroadcastmanager", "multidex",
  41. "annotation", "arch", "collection", "coordinatorlayout", "cursoradapter", "documentfile",
  42. "exifinterface", "inspection", "legacy", "loader", " media"]
  43. if not os.path.exists(s3):
  44. distutils.dir_util.mkpath(s3)
  45. move_package(s1, s3, list_package)
  46. if channelSdkInfo['id']=="549" or channelSdkInfo['id']=="591":
  47. s1 = os.path.join(decompileDir, "smali_classes4/com")
  48. smali_classes2_dir = create_mutil_smali(decompileDir)
  49. s3 = os.path.join(smali_classes2_dir, "com")
  50. list_package = ["uc","umeng","unity3d","yasirkula","yulong","zy"]
  51. if not os.path.exists(s3):
  52. distutils.dir_util.mkpath(s3)
  53. move_package(s1, s3, list_package)
  54. def move_package(s1, s3, list_package):
  55. for d in list_package:
  56. src = os.path.join(s1, d)
  57. if os.path.exists(src):
  58. dst = os.path.join(s3, d)
  59. distutils.dir_util.copy_tree(src, dst)
  60. distutils.dir_util.remove_tree(src)
  61. def create_mutil_smali(decompileDir):
  62. f_idx = 2
  63. while True:
  64. tmp = gw_file_system.get_full_path(os.path.join(decompileDir, 'smali_classes%d' % f_idx))
  65. tmp = tmp.replace('\\', '/')
  66. tmp = re.sub('/+', '/', tmp)
  67. if os.path.exists(tmp):
  68. files = os.listdir(tmp)
  69. if len(files) == 0:
  70. smali_classes2_dir = tmp
  71. break
  72. f_idx += 1
  73. else:
  74. smali_classes2_dir = tmp
  75. break
  76. # endwhile
  77. if not os.path.exists(smali_classes2_dir):
  78. os.mkdir(smali_classes2_dir)
  79. return smali_classes2_dir
  80. def handle_public_xml_param(public_xml_path, remove_node):
  81. if not os.path.exists(public_xml_path):
  82. logging.info('public_xml is null: ' + public_xml_path)
  83. return
  84. new_lines = []
  85. with open(public_xml_path, 'r+') as f:
  86. for line in f.readlines():
  87. # l = line.strip()
  88. if line.find(remove_node) > -1:
  89. continue
  90. new_lines.append(line)
  91. f.seek(0)
  92. f.truncate()
  93. f.writelines(new_lines)
  94. return
  95. def handle_public_xml(public_xml_path):
  96. if not os.path.exists(public_xml_path):
  97. logging.info('public_xml is null: ' + public_xml_path)
  98. return
  99. new_lines = []
  100. with open(public_xml_path, 'r+') as f:
  101. for line in f.readlines():
  102. # l = line.strip()
  103. if line.find("offline_banners") > -1 or line.find("outfit7") > -1 or line.find(
  104. "countries") > -1 or line.find(
  105. "county_codes") > -1 or line.find("felis_error_reporting_files") > -1:
  106. continue
  107. new_lines.append(line)
  108. f.seek(0)
  109. f.truncate()
  110. f.writelines(new_lines)
  111. return
  112. def remove_navigate(decompileDir):
  113. tmp_res = os.path.join(decompileDir, "res", "navigation")
  114. tmp_public_xml = os.path.join(decompileDir, "res", "values", "public.xml")
  115. if os.path.exists(tmp_res):
  116. distutils.dir_util.remove_tree(tmp_res)
  117. if os.path.exists(tmp_public_xml):
  118. os.remove(tmp_public_xml)
  119. if __name__ == '__main__':
  120. script_last("/tmp/ss", "G:/autopack2.0_kuaifa/tool/workspace/wdajl/15957/extract/", {"id": "309"}, "", "")
  121. # xml_path = "E:/apk/youhua/jingmenfengyue_216122/res/values/public.xml"
  122. # handle_public_xml(xml_path)
  123. # hideSplash("/mnt/share/yanghuang/python_test/cr")