sdk_script.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import file_utils
  2. import xml_utils
  3. import os.path
  4. def execute(game, sdk, config):
  5. if not checkConfig(config):
  6. return 1
  7. subChannel = config['subChannel']
  8. createJmhyProperties(game, sdk, subChannel, config)
  9. changeApplicationAttr(game, sdk, subChannel, config)
  10. def checkConfig(config):
  11. '''
  12. 检查配置
  13. '''
  14. if 'properties' not in config:
  15. print('properties not exists in config')
  16. return False
  17. properties = config['properties']
  18. if 'agent' not in properties or 'version' not in properties:
  19. print('agent or version not exists in properties')
  20. return False
  21. '''if 'appid' not in config or 'appkey' not in config:
  22. print('appid or appkey not exists in config')
  23. return False'''
  24. return True
  25. def createJmhyProperties(game, sdk, subChannel, config):
  26. '''
  27. 创建jmhy.properties
  28. '''
  29. print('create jmhy.properties')
  30. propValue = config['properties']
  31. decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
  32. properties = os.path.join(decompliePath, 'assets', 'jmhy.properties')
  33. content = ''
  34. for key in propValue:
  35. content = '%s%s=%s\n' % (content, key, propValue[key])
  36. print('write properties : %s = %s' % (key, propValue[key]))
  37. file_utils.createFile(properties, content)
  38. return 0
  39. def changeApplicationAttr(game, sdk, subChannel, config):
  40. decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
  41. manifest = os.path.join(decompliePath, 'AndroidManifest.xml')
  42. xml_utils.addApplicationAttr(manifest, "networkSecurityConfig", "@xml/huosdk_network_security_config")