script_old.py 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. import distutils.dir_util
  10. import os
  11. import gw_apk_tool
  12. import gw_file_system
  13. def script(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  14. logging.info('------------channelSdkInfo:' + str(channelSdkInfo))
  15. if channelSdkInfo['id'] == '597':
  16. logging.info("remove_navigate")
  17. remove_navigate(decompileDir)
  18. def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
  19. logging.info('------------channelSdkInfo:' + str(channelSdkInfo))
  20. if channelSdkInfo['id'] == "549" or channelSdkInfo['id'] == "597":
  21. s1 = os.path.join(decompileDir, "smali_classes11/com")
  22. if os.path.exists(s1):
  23. smali_classes_new = create_mutil_smali(decompileDir)
  24. s3 = os.path.join(decompileDir, smali_classes_new)
  25. list_package = ["bytedance"]
  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_classes17/com/bytedance/ttgame/module")
  30. if os.path.exists(s1):
  31. smali_classes_new = create_mutil_smali(decompileDir)
  32. s3 = os.path.join(decompileDir, smali_classes_new)
  33. list_package = ["usercenter","voice","vtranslate","webview"]
  34. if not os.path.exists(s3):
  35. distutils.dir_util.mkpath(s3)
  36. move_package(s1, s3, list_package)
  37. s1 = os.path.join(decompileDir, "smali_classes40/com/bytedance/ttgame")
  38. if os.path.exists(s1):
  39. smali_classes_new = create_mutil_smali(decompileDir)
  40. s3 = os.path.join(decompileDir, smali_classes_new)
  41. list_package = ["core"]
  42. if not os.path.exists(s3):
  43. distutils.dir_util.mkpath(s3)
  44. move_package(s1, s3, list_package)
  45. def move_package(s1, s3, list_package):
  46. for d in list_package:
  47. src = os.path.join(s1, d)
  48. if os.path.exists(src):
  49. dst = os.path.join(s3, d)
  50. distutils.dir_util.copy_tree(src, dst)
  51. distutils.dir_util.remove_tree(src)
  52. def create_mutil_smali(decompileDir):
  53. f_idx = 2
  54. while True:
  55. tmp = gw_file_system.get_full_path(os.path.join(decompileDir, 'smali_classes%d' % f_idx))
  56. tmp = tmp.replace('\\', '/')
  57. tmp = re.sub('/+', '/', tmp)
  58. if os.path.exists(tmp):
  59. f_idx += 1
  60. else:
  61. smali_classes2_dir = tmp
  62. break
  63. # endwhile
  64. os.mkdir(smali_classes2_dir)
  65. return smali_classes2_dir
  66. def remove_navigate(decompileDir):
  67. tmp_res = os.path.join(decompileDir, "res", "navigation")
  68. tmp_public_xml = os.path.join(decompileDir, "res", "values", "public.xml")
  69. if os.path.exists(tmp_res):
  70. distutils.dir_util.remove_tree(tmp_res)
  71. if os.path.exists(tmp_public_xml):
  72. os.remove(tmp_public_xml)
  73. if __name__ == '__main__':
  74. # del_qihoo("C:\\Users\\Administrator\\Desktop\\zt")
  75. remove_navigate("G:\\autopack2.0_kuaifa\\tool\\workspace\\lrs360\\13651\\extract")