sdk_script.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import file_utils
  2. import xml_utils
  3. import common_utils
  4. import os.path
  5. def execute(game, sdk, config):
  6. if not checkConfig(config):
  7. return 1
  8. subChannel = config['subChannel']
  9. createJmhyProperties(game, sdk, subChannel, config)
  10. createQytxProperties(game, sdk, subChannel, config)
  11. common_utils.changeApplication(game, sdk, subChannel, config, 'com.cy.common.CYApplication')
  12. return 0
  13. def checkConfig(config):
  14. '''
  15. 检查配置
  16. '''
  17. if 'properties' not in config:
  18. print('properties not exists in config')
  19. return False
  20. if 'qytx' not in config:
  21. print('qytx not exists in config')
  22. return False
  23. properties = config['properties']
  24. if 'agent' not in properties or 'version' not in properties:
  25. print('agent or version not exists in properties')
  26. return False
  27. '''if 'appid' not in config or 'appkey' not in config:
  28. print('appid or appkey not exists in config')
  29. return False'''
  30. return True
  31. def createJmhyProperties(game, sdk, subChannel, config):
  32. '''
  33. 创建jmhy.properties
  34. '''
  35. print('create jmhy.properties')
  36. propValue = config['properties']
  37. decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
  38. properties = os.path.join(decompliePath, 'assets', 'jmhy.properties')
  39. content = ''
  40. for key in propValue:
  41. content = '%s%s=%s\n' % (content, key, propValue[key])
  42. file_utils.createFile(properties, content)
  43. return 0
  44. def copyWechatCode(game, sdk, subChannel, config):
  45. '''
  46. 拷贝微信sdk的代码
  47. '''
  48. print('copy WXPayEntryActivity.smali')
  49. sdkPath = file_utils.getFullSDKPath(sdk)
  50. WXPayEntryActivity = 'WXPayEntryActivity.smali'
  51. wxFile = os.path.join(sdkPath, 'smali', WXPayEntryActivity)
  52. decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
  53. smaliPath = os.path.join(decompliePath, 'smali')
  54. targetPath = file_utils.getPackagePath(smaliPath, config['packageName'])
  55. targetFile = os.path.join(targetPath, 'wxapi', WXPayEntryActivity)
  56. ret = file_utils.copyFile(wxFile, targetFile)
  57. if ret:
  58. return ret
  59. file_utils.replaceContent(targetFile, '${packageName}', config['packageName'].replace('.', '/'))
  60. return 0
  61. def createQytxProperties(game, sdk, subChannel, config):
  62. '''
  63. 创建qytx.properties
  64. '''
  65. print('create cy.properties')
  66. propValue = config['qytx']
  67. decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
  68. properties = os.path.join(decompliePath, 'assets', 'cy.properties')
  69. content = ''
  70. for key in propValue:
  71. content = '%s%s=%s\n' % (content, key, propValue[key])
  72. file_utils.createFile(properties, content)
  73. return 0