script.py 5.2 KB

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