|
@@ -127,12 +127,19 @@ def pack(game, sdk, config):
|
|
|
if ret:
|
|
|
return ret
|
|
|
|
|
|
+
|
|
|
# log sdk
|
|
|
if 'logSdk' in config:
|
|
|
for log in config['logSdk']:
|
|
|
ret = addLogSdk(game, sdk, subChannel, config, log)
|
|
|
if ret:
|
|
|
return ret
|
|
|
+
|
|
|
+ # oaid sdk
|
|
|
+ ret = addOaidSdk(game, sdk, subChannel, config, "1.0.10")
|
|
|
+ if ret:
|
|
|
+ return ret
|
|
|
+
|
|
|
# 生成R文件
|
|
|
'''ret = generateNewRFile(game, sdk, subChannel, config)
|
|
|
if ret:
|
|
@@ -744,6 +751,52 @@ def addLogSdk(game, sdk, subChannel, config, logSdk):
|
|
|
|
|
|
return packLogJar(game, sdk, subChannel, config, logSdk)
|
|
|
|
|
|
+
|
|
|
+def addOaidSdk(game, sdk, subChannel, config, oaidVersion):
|
|
|
+
|
|
|
+ sdkPath = file_utils.getFullOaidSDKPath(oaidVersion)
|
|
|
+ decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
|
|
|
+
|
|
|
+ # 拷贝assets
|
|
|
+ print('copy oaid assets...')
|
|
|
+ assetsPath = file_utils.getFullPath(sdkPath, 'assets')
|
|
|
+ decomplieAssetsPath = file_utils.getFullPath(decompliePath, 'assets')
|
|
|
+ if os.path.exists(assetsPath):
|
|
|
+ ret = file_utils.copyFileAllDir(assetsPath, decomplieAssetsPath)
|
|
|
+ if ret:
|
|
|
+ return ret
|
|
|
+
|
|
|
+
|
|
|
+ # 拷贝jniLibs
|
|
|
+
|
|
|
+ print('copy oaid jniLibs...')
|
|
|
+ jniPath = file_utils.getFullPath(sdkPath, 'jniLibs')
|
|
|
+ decomplieJniPath = file_utils.getFullPath(decompliePath, 'lib')
|
|
|
+ abiFilters = []
|
|
|
+ if os.path.exists(decomplieJniPath):
|
|
|
+ for abi in os.listdir(decomplieJniPath):
|
|
|
+ if abi == 'armeabi-v7a' or abi == 'armeabi':
|
|
|
+ abiFilters.append(abi)
|
|
|
+ else:
|
|
|
+ abiFilters = ['armeabi-v7a']
|
|
|
+
|
|
|
+ if os.path.exists(jniPath):
|
|
|
+ ret = file_utils.copyFileAllDir(jniPath, decomplieJniPath, False, abiFilters)
|
|
|
+ if ret:
|
|
|
+ return ret
|
|
|
+
|
|
|
+ print('merge oaid AndroidManifest...')
|
|
|
+ libManifest = file_utils.getFullPath(sdkPath, 'manifest.xml')
|
|
|
+ if os.path.exists(libManifest):
|
|
|
+ manifest = os.path.join(decompliePath, 'AndroidManifest.xml')
|
|
|
+ ret = xml_utils.mergeManifestRes(manifest, libManifest)
|
|
|
+ if ret:
|
|
|
+ return ret
|
|
|
+
|
|
|
+ return packOaidJar(game, sdk, subChannel, config, oaidVersion)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
def generateNewRFile(game, sdk, subChannel, config):
|
|
|
'''
|
|
|
生成新的R文件
|
|
@@ -981,7 +1034,69 @@ def packLogJar(game, sdk, subChannel, config, logSdk):
|
|
|
return 0
|
|
|
|
|
|
|
|
|
+def packOaidJar(game, sdk, subChannel, config, oaidVerion):
|
|
|
+ '''
|
|
|
+ 打包oaid jar
|
|
|
+ '''
|
|
|
+ decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
|
|
|
+ outPath = file_utils.getFullPath(decompliePath, 'gen')
|
|
|
+
|
|
|
+ if not os.path.exists(outPath):
|
|
|
+ os.makedirs(outPath)
|
|
|
|
|
|
+ if config['aapt2disable']:
|
|
|
+ dx = file_utils.getDxPath()
|
|
|
+ dexCmd = '--dex --multi-dex --no-warning --output="%s"' % outPath
|
|
|
+ else:
|
|
|
+ dx = file_utils.getD8Path()
|
|
|
+ androidPlatforms = file_utils.getAndroidCompileToolPath()
|
|
|
+ dexCmd = '--lib "%s" --output "%s"' % (androidPlatforms, outPath)
|
|
|
+
|
|
|
+ # 找到所有lib依赖
|
|
|
+ sdkPath = file_utils.getFullOaidSDKPath(oaidVerion)
|
|
|
+ libs = os.path.join(sdkPath, 'libs')
|
|
|
+ libConfig = os.path.join(libs, 'config.json')
|
|
|
+
|
|
|
+ # 存在配置文件
|
|
|
+ # if os.path.exists(libConfig):
|
|
|
+ # jsonText = file_utils.readFile(libConfig)
|
|
|
+ # libList = json.loads(jsonText)
|
|
|
+ # for jar in libList:
|
|
|
+ # if not jar.endswith('.jar'):
|
|
|
+ # continue
|
|
|
+ # dexCmd += ' ' + os.path.join(libs, jar)
|
|
|
+ # else:
|
|
|
+ # for jar in os.listdir(libs):
|
|
|
+ # if not jar.endswith('.jar'):
|
|
|
+ # continue
|
|
|
+ # dexCmd += ' ' + os.path.join(libs, jar)
|
|
|
+
|
|
|
+ # sdk实现类
|
|
|
+ print('packageing oaid jar ...')
|
|
|
+ dexCmd += ' ' + os.path.join(libs, 'miit_mdid_%s.jar' % oaidVerion)
|
|
|
+ ret = file_utils.execJarCmd(dx, dexCmd)
|
|
|
+ if ret:
|
|
|
+ return ret
|
|
|
+
|
|
|
+ # 反向dex生成smali
|
|
|
+ # 存放在out目录
|
|
|
+ print('baksmali classes.dex ...')
|
|
|
+ outDex = os.path.join(outPath, 'classes.dex')
|
|
|
+ baksmaliPath = file_utils.getBaksmaliPath()
|
|
|
+ outPath = file_utils.getFullPath(decompliePath, 'out')
|
|
|
+
|
|
|
+ ret = file_utils.execJarCmd(baksmaliPath, 'd "%s" -o "%s"' % (outDex, outPath))
|
|
|
+ if ret:
|
|
|
+ return ret
|
|
|
+
|
|
|
+ # 将生成的文件拷贝到目标目录
|
|
|
+ print('copy all log smali ...')
|
|
|
+ smaliPath = file_utils.getFullPath(decompliePath, 'smali')
|
|
|
+ ret = file_utils.copyFileAllDir(outPath, smaliPath, True)
|
|
|
+ if ret:
|
|
|
+ return ret
|
|
|
+
|
|
|
+ return 0
|
|
|
|
|
|
|
|
|
def splitDex(game, sdk, subChannel, config):
|