script.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. 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/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. def move_package(s1, s3, list_package):
  40. for d in list_package:
  41. src = os.path.join(s1, d)
  42. if os.path.exists(src):
  43. dst = os.path.join(s3, d)
  44. distutils.dir_util.copy_tree(src, dst)
  45. distutils.dir_util.remove_tree(src)
  46. def create_mutil_smali(decompileDir):
  47. f_idx = 2
  48. while True:
  49. tmp = gw_file_system.get_full_path(os.path.join(decompileDir, 'smali_classes%d' % f_idx))
  50. tmp = tmp.replace('\\', '/')
  51. tmp = re.sub('/+', '/', tmp)
  52. if os.path.exists(tmp):
  53. files = os.listdir(tmp)
  54. if len(files) == 0:
  55. smali_classes2_dir = tmp
  56. break
  57. f_idx += 1
  58. else:
  59. smali_classes2_dir = tmp
  60. break
  61. # endwhile
  62. if not os.path.exists(smali_classes2_dir):
  63. os.mkdir(smali_classes2_dir)
  64. return smali_classes2_dir
  65. def handle_public_xml_param(public_xml_path, remove_node):
  66. if not os.path.exists(public_xml_path):
  67. logging.info('public_xml is null: ' + public_xml_path)
  68. return
  69. new_lines = []
  70. with open(public_xml_path, 'r+') as f:
  71. for line in f.readlines():
  72. # l = line.strip()
  73. if line.find(remove_node) > -1:
  74. continue
  75. new_lines.append(line)
  76. f.seek(0)
  77. f.truncate()
  78. f.writelines(new_lines)
  79. return
  80. def handle_public_xml(public_xml_path):
  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("offline_banners") > -1 or line.find("outfit7") > -1 or line.find(
  89. "countries") > -1 or line.find(
  90. "county_codes") > -1 or line.find("felis_error_reporting_files") > -1:
  91. continue
  92. new_lines.append(line)
  93. f.seek(0)
  94. f.truncate()
  95. f.writelines(new_lines)
  96. return
  97. def remove_navigate(decompileDir):
  98. tmp_res = os.path.join(decompileDir, "res", "navigation")
  99. tmp_public_xml = os.path.join(decompileDir, "res", "values", "public.xml")
  100. if os.path.exists(tmp_res):
  101. distutils.dir_util.remove_tree(tmp_res)
  102. if os.path.exists(tmp_public_xml):
  103. os.remove(tmp_public_xml)
  104. if __name__ == '__main__':
  105. script_last("/tmp/ss", "G:/autopack2.0_kuaifa/tool/workspace/wdajl/15957/extract/", {"id": "309"}, "", "")
  106. # xml_path = "E:/apk/youhua/jingmenfengyue_216122/res/values/public.xml"
  107. # handle_public_xml(xml_path)
  108. # hideSplash("/mnt/share/yanghuang/python_test/cr")