|
@@ -22,6 +22,9 @@ import sys
|
|
import importlib
|
|
import importlib
|
|
import uuid
|
|
import uuid
|
|
|
|
|
|
|
|
+from xml.etree import ElementTree as ET
|
|
|
|
+from xml.etree.ElementTree import SubElement
|
|
|
|
+
|
|
def pack(game, sdk, config):
|
|
def pack(game, sdk, config):
|
|
config['cache'] = uuid.uuid1()
|
|
config['cache'] = uuid.uuid1()
|
|
subChannel = config['subChannel']
|
|
subChannel = config['subChannel']
|
|
@@ -78,6 +81,8 @@ def pack(game, sdk, config):
|
|
ret = addConfig(game, sdk, subChannel, config)
|
|
ret = addConfig(game, sdk, subChannel, config)
|
|
if ret:
|
|
if ret:
|
|
return ret
|
|
return ret
|
|
|
|
+ #保存旧包名
|
|
|
|
+ config['oldPackageName'] = getPackageName(game, sdk, subChannel, config)
|
|
# 更改包名
|
|
# 更改包名
|
|
if 'packageName' in config and config['packageName'] != '':
|
|
if 'packageName' in config and config['packageName'] != '':
|
|
ret = changePackageName(game, sdk, subChannel, config)
|
|
ret = changePackageName(game, sdk, subChannel, config)
|
|
@@ -110,6 +115,10 @@ def pack(game, sdk, config):
|
|
return ret
|
|
return ret
|
|
# 乐变sdk的特殊处理
|
|
# 乐变sdk的特殊处理
|
|
ret = game_utils.sdkLebianChange(game, sdk, config)
|
|
ret = game_utils.sdkLebianChange(game, sdk, config)
|
|
|
|
+ if ret:
|
|
|
|
+ return ret
|
|
|
|
+ # 复制EntryActivity文件
|
|
|
|
+ ret = copyEntryActivityCode(game, sdk, subChannel, config)
|
|
if ret:
|
|
if ret:
|
|
return ret
|
|
return ret
|
|
# 游戏脚本处理
|
|
# 游戏脚本处理
|
|
@@ -224,6 +233,7 @@ def copyRes(game, sdk, subChannel, config):
|
|
ret = file_utils.copyFileAllDir(jniPath, decomplieJniPath, False, abiFilters)
|
|
ret = file_utils.copyFileAllDir(jniPath, decomplieJniPath, False, abiFilters)
|
|
if ret:
|
|
if ret:
|
|
return ret
|
|
return ret
|
|
|
|
+
|
|
return 0
|
|
return 0
|
|
|
|
|
|
def mergeDrawableRes(game, sdk, subChannel, config):
|
|
def mergeDrawableRes(game, sdk, subChannel, config):
|
|
@@ -982,9 +992,11 @@ def apksignerApk(game, sdk, subChannel, config):
|
|
os.makedirs(config['outPath'])
|
|
os.makedirs(config['outPath'])
|
|
|
|
|
|
signedApk = os.path.join(config['outPath'], config['outName'] + '.apk')
|
|
signedApk = os.path.join(config['outPath'], config['outName'] + '.apk')
|
|
|
|
+ print('signedApk = ' + signedApk)
|
|
elif 'outName' in config:
|
|
elif 'outName' in config:
|
|
signedApk = file_utils.getRenameApkPath(game, sdk, config['cache'], config['outName'])
|
|
signedApk = file_utils.getRenameApkPath(game, sdk, config['cache'], config['outName'])
|
|
-
|
|
|
|
|
|
+ print('signedApk = ' + signedApk)
|
|
|
|
+
|
|
# java -jar apksigner.jar sign --ks key.jks --ks-key-alias releasekey --ks-pass pass:pp123456 --key-pass pass:pp123456 --out output.apk input.apk
|
|
# java -jar apksigner.jar sign --ks key.jks --ks-key-alias releasekey --ks-pass pass:pp123456 --key-pass pass:pp123456 --out output.apk input.apk
|
|
v2disable = ''
|
|
v2disable = ''
|
|
if 'v2disable' in config and config['v2disable']:
|
|
if 'v2disable' in config and config['v2disable']:
|
|
@@ -1109,4 +1121,47 @@ def packConsole(game, sdk, subChannel):
|
|
|
|
|
|
print('success %d, failure %d' % (successCount, failureCount))
|
|
print('success %d, failure %d' % (successCount, failureCount))
|
|
|
|
|
|
- return 0
|
|
|
|
|
|
+ return 0
|
|
|
|
+
|
|
|
|
+def copyEntryActivityCode(game, sdk, subChannel, config):
|
|
|
|
+ '''
|
|
|
|
+ 拷贝代码
|
|
|
|
+ '''
|
|
|
|
+ print('copy EntryActivity.smali')
|
|
|
|
+ sdkPath = file_utils.getFullSDKPath(sdk)
|
|
|
|
+ EntryActivity = 'EntryActivity.smali'
|
|
|
|
+ entryFile = os.path.join(sdkPath, 'smali', EntryActivity)
|
|
|
|
+ decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
|
|
|
|
+ smaliPath = os.path.join(decompliePath, 'smali')
|
|
|
|
+ targetPath = file_utils.getPackagePath(smaliPath, config['packageName'])
|
|
|
|
+ targetFile = os.path.join(targetPath, EntryActivity)
|
|
|
|
+ ret = file_utils.copyFile(entryFile, targetFile)
|
|
|
|
+ if ret:
|
|
|
|
+ return ret
|
|
|
|
+ writeActivityToManifest(os.path.join(decompliePath, 'AndroidManifest.xml'),config)
|
|
|
|
+ oldText = 'com/jmhy/floatsdk/sample/EntryActivity'
|
|
|
|
+ newText = config['packageName'].replace('.', '/') + "/EntryActivity"
|
|
|
|
+ print("EntryActivity.smali change '{}' to '{}' ...".format(oldText,newText))
|
|
|
|
+ file_utils.replaceContent(targetFile, oldText, newText)
|
|
|
|
+ return 0
|
|
|
|
+
|
|
|
|
+def writeActivityToManifest(targetManifest, config):
|
|
|
|
+ androidNS = 'http://schemas.android.com/apk/res/android'
|
|
|
|
+ ET.register_namespace('android', androidNS)
|
|
|
|
+ targetTree = ET.parse(targetManifest)
|
|
|
|
+ targetRoot = targetTree.getroot()
|
|
|
|
+ appNode = targetRoot.find('application')
|
|
|
|
+ activitys = appNode.findall('activity')
|
|
|
|
+ keyName = "{0}{1}{2}name".format("{",androidNS,"}")
|
|
|
|
+ for activity in activitys:
|
|
|
|
+ activityName = activity.get(keyName)
|
|
|
|
+ if activityName.find('.EntryActivity')>=0:
|
|
|
|
+ oldName = activityName;
|
|
|
|
+ newName = config['packageName'] + ".EntryActivity"
|
|
|
|
+ activity.set(keyName,newName)
|
|
|
|
+ print("EntryActivity change '{}' to '{}' ...".format(oldName, newName))
|
|
|
|
+ targetTree.write(targetManifest, 'UTF-8')
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|