def doAppendIcon(): #复制icons中的图片到game_icon中 if os.path.exists(os.path.dirname(file_utils.curDir) + '/icons'): file_utils.copy_files(os.path.dirname(file_utils.curDir) + '/icons', file_utils.getFullPath('_icon/game_icon')) configFile = file_utils.getFullPath("channels_config.xml") dom = xml.dom.minidom.parse(configFile) root = dom.documentElement channellist = root.getElementsByTagName('channel') #icon处理 for channel in channellist: #获取sdk_name和fs_app_id params = channel.getElementsByTagName("param") sdk_name = "" fs_app_id = "" for param in params: if "sdk_name" == param.getAttribute("name"): sdk_name = param.getAttribute("value") if "fs_app_id" == param.getAttribute("name"): fs_app_id = param.getAttribute("value") #判断是否有sdk对应的game icon if os.path.exists(file_utils.getFullPath("_icon/game_icon/" + fs_app_id + ".png")): #获取demo的res的path sdkDemoPath = channel.getAttribute('path') resDir = os.path.dirname(file_utils.curDir) + "/" + sdkDemoPath #合并icon并存到res中 if os.path.exists( resDir ): file_utils.printF("icon fusion : channel_icon:%s, game_icon:%s \r\n", fs_app_id, sdk_name) appendChannelIconMark(fs_app_id, sdk_name, resDir)
def handleWXPayActivity(channel, decompileDir, packageName, className, oldPackageName): sdkDir = decompileDir + '/../sdk/' + channel['sdk'] if not os.path.exists(sdkDir): file_utils.printF("The sdk temp folder is not exists. path:" + sdkDir) return 1 extraFilesPath = sdkDir + '/extraFiles' relatedJar = os.path.join(extraFilesPath, 'vivoUnionSDK.jar') relatedJar2 = os.path.join(extraFilesPath, 'libammsdk.jar') WXPayEntryActivity = os.path.join(extraFilesPath, className + '.java') file_utils.modifyFileContent(WXPayEntryActivity, oldPackageName, packageName + ".wxapi") splitdot = ';' if platform.system() == 'Darwin': splitdot = ':' cmd = '"%sjavac" -source 1.7 -target 1.7 "%s" -classpath "%s"%s"%s"%s"%s"' % ( file_utils.getJavaBinDir(), WXPayEntryActivity, relatedJar, splitdot, relatedJar2, splitdot, file_utils.getFullToolPath('android.jar')) ret = file_utils.execFormatCmd(cmd) if ret: return 1 packageDir = packageName.replace('.', '/') srcDir = sdkDir + '/tempDex' classDir = srcDir + '/' + packageDir + '/wxapi' if not os.path.exists(classDir): os.makedirs(classDir) sourceClassFilePath = os.path.join(extraFilesPath, className + '.class') targetClassFilePath = classDir + '/' + className + '.class' file_utils.copy_file(sourceClassFilePath, targetClassFilePath) targetDexPath = os.path.join(sdkDir, className + '.dex') dxTool = file_utils.getFullToolPath("/lib/dx.jar") cmd = file_utils.getJavaCMD( ) + ' -jar -Xmx512m -Xms512m "%s" --dex --output="%s" "%s"' % ( dxTool, targetDexPath, srcDir) ret = file_utils.execFormatCmd(cmd) if ret: return 1 ret = sdk_helper.dex2smali(targetDexPath, decompileDir + '/smali', "baksmali.jar") if ret: return 1 return 0
def main(): file_utils.printF("-------------------------icon fusion start------------------------") #检查并安装PIL installPIL(); #icon处理 doAppendIcon(); file_utils.printF("-------------------------icon fusion over------------------------\r\n\r\n")
def main(): file_utils.printF( "-------------------------all start------------------------\r\n") tool_encrypt.main() tool_icon.main() tool_splash.main() file_utils.printF( "-------------------------all over------------------------")
def generateNewChannelApk(sourceApkFile, empty_file, channelID): file_utils.printF("Now to generate channel %s", channelID) targetApk = file_utils.getFullPath("channels/u8-" + channelID + ".apk") file_utils.copy_file(sourceApkFile, targetApk) zipped = zipfile.ZipFile(targetApk, 'a', zipfile.ZIP_DEFLATED) emptyChannelFile = "META-INF/u8channel_{channel}".format(channel=channelID) zipped.write(empty_file, emptyChannelFile) zipped.close()
def generateNewChannelApk(sourceApkFile, empty_file, channelID): file_utils.printF("Now to generate channel %s", channelID) targetApk = file_utils.getFullPath("channels/u8-"+channelID+".apk") file_utils.copy_file(sourceApkFile, targetApk) zipped = zipfile.ZipFile(targetApk, 'a', zipfile.ZIP_DEFLATED) emptyChannelFile = "META-INF/u8channel_{channel}".format(channel=channelID) zipped.write(empty_file, emptyChannelFile) zipped.close()
def compileWXEntryActivity(channel, decompileDir, packageName): sdkDir = decompileDir + '/../sdk/' + channel['sdk'] if not os.path.exists(sdkDir): file_utils.printF("The sdk temp folder is not exists. path:"+sdkDir) return 1 extraFilesPath = sdkDir + '/extraFiles' relatedJar = os.path.join(extraFilesPath, 'MSDK_Android.jar') WXPayEntryActivity = os.path.join(extraFilesPath, 'WXEntryActivity.java') file_utils.modifyFileContent(WXPayEntryActivity, 'com.example.wegame.wxapi', packageName+".wxapi") splitdot = ';' if platform.system() == 'Darwin': splitdot = ':' cmd = '"%sjavac" -source 1.7 -target 1.7 "%s" -classpath "%s"%s"%s"' % (file_utils.getJavaBinDir(), WXPayEntryActivity, relatedJar, splitdot, file_utils.getFullToolPath('android.jar')) ret = file_utils.execFormatCmd(cmd) if ret: return 1 packageDir = packageName.replace('.', '/') srcDir = sdkDir + '/tempDex' classDir = srcDir + '/' + packageDir + '/wxapi' if not os.path.exists(classDir): os.makedirs(classDir) sourceClassFilePath = os.path.join(extraFilesPath, 'WXEntryActivity.class') targetClassFilePath = classDir + '/WXEntryActivity.class' file_utils.copy_file(sourceClassFilePath, targetClassFilePath) targetDexPath = os.path.join(sdkDir, 'WXEntryActivity.dex') dxTool = file_utils.getFullToolPath("/lib/dx.jar") cmd = file_utils.getJavaCMD() + ' -jar -Xmx512m -Xms512m "%s" --dex --output="%s" "%s"' % (dxTool, targetDexPath, srcDir) ret = file_utils.execFormatCmd(cmd) if ret: return 1 ret = apk_utils.dex2smali(targetDexPath, decompileDir+'/smali', "baksmali.jar") if ret: return 1
def main(): file_utils.printF("-------------------------encrypt config start------------------------") channels = config_utils.getAllChannels() # 循环获取每个channel,将每个channel的属性经过AzDG加密,输出为以channel_name为名的xml文件,并复制该xml文件到path属性下 for channel in channels: chnXml = config_utils.genChannelParamsXml(channel) sdkDemoPath = chnXml.getAttribute("path") chnXml.removeAttribute("path") ##不传递给sdk代码 azdg = AzDG.AzDG() jsonStr = config_utils.xmltojson(chnXml.toprettyxml().encode()) m = azdg.encode(jsonStr) # 存储加密后的json文本 fileDir = os.path.dirname(file_utils.curDir) + "\\" + sdkDemoPath if os.path.exists( fileDir ): path = fileDir + "\\assets\\" + "fssdk_config" file_utils.setFileContent(m, path) file_utils.printF("* save encrypt config : %s", sdkDemoPath + "\\assets\\") path = fileDir + "\\additional\\assets\\" + "fssdk_config" file_utils.setFileContent(m, path) file_utils.printF("* save encrypt config : %s", sdkDemoPath + "\\additional\\assets\\") # 解密 # content = azdg.decode(m) # file_utils.setFileContent(content, file_utils.curDir + "\\" + param.getAttribute("value") + ".txt") file_utils.printF("-------------------------encrypt config over------------------------\r\n\r\n")
def copyAndRenameImg(demoName, demoDir): splashDir = file_utils.curDir + '/_splashes/' + demoName demoResDir = demoDir + '/res/drawable-hdpi' #找图片,重命名,复制到destDir for i in range(1, 6): splashFullPath = demoResDir + '/' + 'game_splash_' + str(i) + '.png' if os.path.exists(splashFullPath): os.remove(splashFullPath) img_path = splashDir + '/' + str(i) + '.png' if os.path.exists(img_path): if not os.path.exists(demoResDir): os.makedirs(demoResDir) shutil.copy(img_path, splashFullPath) file_utils.printF("copy splash : %s", demoName + ': game_splash_' + str(i))
def modify(channels, sourceApkFile): sourceApkFile = sourceApkFile.replace('\\', '/') if not os.path.exists(sourceApkFile): file_utils.printF("The source apk file is not exists") return tempFolder = file_utils.getFullPath('temp') if not os.path.exists(tempFolder): os.makedirs(tempFolder) empty_file = os.path.join(tempFolder, "temp.txt") f = open(empty_file, 'w') f.close() for channel in channels: generateNewChannelApk(sourceApkFile, empty_file, channel) file_utils.del_file_folder(tempFolder)
def getAppIconName(dir): manifestFile = dir + "/AndroidManifest.xml" manifestFile = file_utils.getFullPath(manifestFile) ET.register_namespace('android', androidNS) tree = ET.parse(manifestFile) root = tree.getroot() applicationNode = root.find('application') if applicationNode is not None: return "icon" key = '{'+androidNS+'}icon' iconName = applicationNode.get(key) if not iconName: return "icon" name = iconName[10:] file_utils.printF("The game icon name is now %s", name) return name
def entry(): sourceApkFile = file_utils.getFullPath("u8source.apk") channelsFile = file_utils.getFullPath("channels.txt") if not os.path.exists(channelsFile): file_utils.printF("The channels.txt file is not exists.") return f = open(channelsFile) channelLines = f.readlines() f.close() channels = [] if channelLines != None and len(channelLines) > 0: for line in channelLines: targetChannel = line.strip() channels.append(targetChannel) else: file_utils.printF("There is no channel configed in channels.txt") modify(channels, sourceApkFile)
def main(): file_utils.printF("-------------------------copy splashes start------------------------") configFile = file_utils.getFullPath("channels_config.xml") dom = xml.dom.minidom.parse(configFile) root = dom.documentElement channellist = root.getElementsByTagName('channel') for channel in channellist: sdk_name = "" params = channel.getElementsByTagName("param") for param in params: if "sdk_name" == param.getAttribute("name"): sdk_name = param.getAttribute("value") break demoDir = os.path.dirname(file_utils.curDir) + "/" + channel.getAttribute('path') if os.path.exists( demoDir ): copyAndRenameImg(sdk_name, demoDir) #else: # file_utils.printF("can not find dir: %s", demoDir) file_utils.printF("-------------------------copy splashes over------------------------\r\n\r\n")
def main(): file_utils.printF( "-------------------------encrypt config start------------------------" ) channels = config_utils.getAllChannels() # 循环获取每个channel,将每个channel的属性经过AzDG加密,输出为以channel_name为名的xml文件,并复制该xml文件到path属性下 for channel in channels: chnXml = config_utils.genChannelParamsXml(channel) sdkDemoPath = chnXml.getAttribute("path") chnXml.removeAttribute("path") ##不传递给sdk代码 azdg = AzDG.AzDG() jsonStr = config_utils.xmltojson(chnXml.toprettyxml().encode()) m = azdg.encode(jsonStr) # 存储加密后的json文本 fileDir = os.path.dirname(file_utils.curDir) + "\\" + sdkDemoPath if os.path.exists(fileDir): path = fileDir + "\\assets\\" + "fssdk_config" file_utils.setFileContent(m, path) file_utils.printF("* save encrypt config : %s", sdkDemoPath + "\\assets\\") path = fileDir + "\\additional\\assets\\" + "fssdk_config" file_utils.setFileContent(m, path) file_utils.printF("* save encrypt config : %s", sdkDemoPath + "\\additional\\assets\\") # 解密 # content = azdg.decode(m) # file_utils.setFileContent(content, file_utils.curDir + "\\" + param.getAttribute("value") + ".txt") file_utils.printF( "-------------------------encrypt config over------------------------\r\n\r\n" )
def compileJava2Smali(channel, decompileDir, packageName, className, dependencyLibs): sdkDir = decompileDir + '/../sdk/' + channel['sdk'] if not os.path.exists(sdkDir): file_utils.printF("The sdk temp folder is not exists. path:" + sdkDir) return 1 extraFilesPath = sdkDir + '/extraFiles' # relatedJar = os.path.join(extraFilesPath, 'vivoUnionSDK.jar') # relatedJar2 = os.path.join(extraFilesPath, 'libammsdk.jar') if not os.path.exists(extraFilesPath): log_utils.error("compileJava2Smali failed. please put java file and related jars in extraFiles folder") return 1 javaFile = os.path.join(extraFilesPath, className + '.java') replaceJavaPackage(javaFile, packageName) splitdot = ';' if platform.system() == 'Darwin' or platform.system() == 'Linux': splitdot = ':' cmd = '"%sjavac" -source 1.7 -target 1.7 "%s" -classpath ' % (file_utils.getJavaBinDir(), javaFile) for lib in dependencyLibs: cmd = cmd + '"' + os.path.join(extraFilesPath, lib) + '"' + splitdot cmd = cmd + '"' + file_utils.getFullToolPath('android.jar') + '"' ret = file_utils.execFormatCmd(cmd) if ret: return 1 packageDir = packageName.replace('.', '/') srcDir = sdkDir + '/tempDex' classDir = srcDir + '/' + packageDir if not os.path.exists(classDir): os.makedirs(classDir) classFiles = file_utils.list_files_with_ext(extraFilesPath, [], '.class') for cf in classFiles: targetClassFilePath = os.path.join(classDir, os.path.basename(cf)) file_utils.copy_file(cf, targetClassFilePath) targetDexPath = os.path.join(sdkDir, className + '.dex') dxTool = file_utils.getFullToolPath("/lib/dx.jar") cmd = file_utils.getJavaCMD() + ' -jar -Xmx512m -Xms512m "%s" --dex --output="%s" "%s"' % ( dxTool, targetDexPath, srcDir) ret = file_utils.execFormatCmd(cmd) if ret: return 1 ret = dex2smali(targetDexPath, decompileDir + '/smali', "baksmali.jar") if ret: return 1 return 0
def execute(channel, decompileDir, packageName): sdkDir = decompileDir + '/../sdk/' + channel['sdk'] if not os.path.exists(sdkDir): file_utils.printF("The sdk temp folder is not exists. path:"+sdkDir) return 1 extraFilesPath = sdkDir + '/extraFiles' relatedJar = os.path.join(extraFilesPath, '360SDK.jar') WXPayEntryActivity = os.path.join(extraFilesPath, 'WXEntryActivity.java') file_utils.modifyFileContent(WXPayEntryActivity, 'com.u8.sdk.qh360.wxapi', packageName+".wxapi") splitdot = ';' if platform.system() == 'Darwin': splitdot = ':' cmd = '"%sjavac" -source 1.7 -target 1.7 "%s" -classpath "%s"%s"%s"' % (file_utils.getJavaBinDir(), WXPayEntryActivity, relatedJar, splitdot, file_utils.getFullToolPath('android.jar')) ret = file_utils.execFormatCmd(cmd) if ret: return 1 packageDir = packageName.replace('.', '/') srcDir = sdkDir + '/tempDex' classDir = srcDir + '/' + packageDir + '/wxapi' if not os.path.exists(classDir): os.makedirs(classDir) sourceClassFilePath = os.path.join(extraFilesPath, 'WXEntryActivity.class') targetClassFilePath = classDir + '/WXEntryActivity.class' file_utils.copy_file(sourceClassFilePath, targetClassFilePath) targetDexPath = os.path.join(sdkDir, 'WXEntryActivity.dex') dxTool = file_utils.getFullToolPath("/lib/dx.jar") cmd = file_utils.getJavaCMD() + ' -jar -Xmx512m -Xms512m "%s" --dex --output="%s" "%s"' % (dxTool, targetDexPath, srcDir) ret = file_utils.execFormatCmd(cmd) if ret: return 1 ret = apk_utils.dex2smali(targetDexPath, decompileDir+'/smali', "baksmali.jar") if ret: return 1 manifest = decompileDir + '/AndroidManifest.xml' ET.register_namespace('android', androidNS) name = '{' + androidNS + '}name' hostKey = '{'+androidNS+'}host' configChanges = '{' + androidNS + '}configChanges' exported = '{' + androidNS + '}exported' screenOrientation = '{' + androidNS + '}screenOrientation' tree = ET.parse(manifest) root = tree.getroot() appNode = root.find('application') if appNode is None: return 1 activityNode = SubElement(appNode, 'activity') activityNode.set(name, packageName + '.wxapi.WXEntryActivity') activityNode.set(configChanges, 'keyboardHidden|orientation') activityNode.set(exported, 'true') activityNode.set(screenOrientation, 'portrait') #append host activityNodeLst = appNode.findall('activity') if activityNodeLst is not None and len(activityNodeLst) > 0: for activityNode in activityNodeLst: activityName = activityNode.get(name) if activityName == 'com.qihoo.gamecenter.sdk.activity.ContainerActivity': intentNodeLst = activityNode.findall('intent-filter') find = False if intentNodeLst is not None: for itNode in intentNodeLst: dataNodeList = itNode.findall('data') for dataNode in dataNodeList : if dataNode.get(hostKey) == 'com.qihoo.gamecenter.sdk.demosp': dataNode.set(hostKey, packageName) find = True break if find: break tree.write(manifest, 'UTF-8') return 0
def execute(channel, decompileDir, packageName): sdkDir = decompileDir + '/../sdk/' + channel['sdk'] if not os.path.exists(sdkDir): file_utils.printF("The sdk temp folder is not exists. path:" + sdkDir) return 1 extraFilesPath = sdkDir + '/extraFiles' relatedJar = os.path.join(extraFilesPath, '360SDK.jar') WXPayEntryActivity = os.path.join(extraFilesPath, 'WXEntryActivity.java') file_utils.modifyFileContent(WXPayEntryActivity, 'com.u8.sdk.qh360.wxapi', packageName + ".wxapi") splitdot = ';' if platform.system() == 'Darwin': splitdot = ':' cmd = '"%sjavac" -source 1.7 -target 1.7 "%s" -classpath "%s"%s"%s"' % ( file_utils.getJavaBinDir(), WXPayEntryActivity, relatedJar, splitdot, file_utils.getFullToolPath('android.jar')) ret = file_utils.execFormatCmd(cmd) if ret: return 1 packageDir = packageName.replace('.', '/') srcDir = sdkDir + '/tempDex' classDir = srcDir + '/' + packageDir + '/wxapi' if not os.path.exists(classDir): os.makedirs(classDir) sourceClassFilePath = os.path.join(extraFilesPath, 'WXEntryActivity.class') targetClassFilePath = classDir + '/WXEntryActivity.class' file_utils.copy_file(sourceClassFilePath, targetClassFilePath) targetDexPath = os.path.join(sdkDir, 'WXEntryActivity.dex') dxTool = file_utils.getFullToolPath("/lib/dx.jar") cmd = file_utils.getJavaCMD( ) + ' -jar -Xmx512m -Xms512m "%s" --dex --output="%s" "%s"' % ( dxTool, targetDexPath, srcDir) ret = file_utils.execFormatCmd(cmd) if ret: return 1 ret = apk_utils.dex2smali(targetDexPath, decompileDir + '/smali') if ret: return 1 manifest = decompileDir + '/AndroidManifest.xml' ET.register_namespace('android', androidNS) name = '{' + androidNS + '}name' hostKey = '{' + androidNS + '}host' configChanges = '{' + androidNS + '}configChanges' exported = '{' + androidNS + '}exported' screenOrientation = '{' + androidNS + '}screenOrientation' authoritiesKey = '{' + androidNS + '}authorities' tree = ET.parse(manifest) root = tree.getroot() appNode = root.find('application') if appNode is None: return 1 activityNode = SubElement(appNode, 'activity') activityNode.set(name, packageName + '.wxapi.WXEntryActivity') activityNode.set(configChanges, 'keyboardHidden|orientation') activityNode.set(exported, 'true') activityNode.set(screenOrientation, 'portrait') # appkey = "" # if 'params' in channel: # params = channel['params'] # for param in params: # if param['name'] == 'QHOPENSDK_APPKEY': # appkey = param['value'] # break #append host activityNodeLst = appNode.findall('activity') if activityNodeLst is not None and len(activityNodeLst) > 0: for activityNode in activityNodeLst: activityName = activityNode.get(name) if activityName == 'com.qihoo.gamecenter.sdk.activity.ContainerActivity': intentNodeLst = activityNode.findall('intent-filter') if intentNodeLst is not None: for itNode in intentNodeLst: dataNode = SubElement(itNode, 'data') dataNode.set(hostKey, packageName) # elif activityName == 'com.qihoo.gamecenter.sdk.activity.QhDeepLinkActivity': # intentNodeLst = activityNode.findall('intent-filter') # if intentNodeLst is not None: # for itNode in intentNodeLst: # dataNodeLst = itNode.findall('data') # if dataNodeLst is not None: # for dNode in dataNodeLst: # dNode.set(hostKey, appkey) # break providerNodeLst = appNode.findall("provider") if providerNodeLst is not None and len(providerNodeLst) > 0: for pNode in providerNodeLst: pName = pNode.get(name) if pName == 'com.qihoo.pushsdk.keepalive.account.SyncProvider': pNode.set(authoritiesKey, packageName + ".cx.accounts.syncprovider") tree.write(manifest, 'UTF-8') #modify res/xml/qihoo_game_sdk_sync_adapter.xml resXml = decompileDir + '/res/xml/qihoo_game_sdk_sync_adapter.xml' if os.path.exists(resXml): file_utils.modifyFileContent( resXml, 'com.qihoo.gamecenter.sdk.demosp.cx.accounts.syncprovider', packageName + ".cx.accounts.syncprovider") return 0
def appendChannelIconMark(gameIconName, channelIconName, demoPath): from PIL import Image gameIconPath = file_utils.getFullPath('_icon/game_icon/' + gameIconName + '.png') if not os.path.exists(gameIconPath): file_utils.printF("Can not find game icon : %s", gameIconPath) return 1 gameIcon = Image.open(gameIconPath) rlImg = gameIcon channelIconPath = file_utils.getFullPath('_icon/channel_icon/' + channelIconName + '.png') if os.path.exists(channelIconPath): markIcon = Image.open(channelIconPath) rlImg = appendIconMark(gameIcon, markIcon, (0, 0)) # rlImg.show() drawbleSize = (48, 48) ldpiSize = (36, 36) mdpiSize = (48, 48) hdpiSize = (72, 72) xhdpiSize = (96, 96) xxhdpiSize = (144,144) drawbleIcon = rlImg.resize(drawbleSize, Image.ANTIALIAS) ldpiIcon = rlImg.resize(ldpiSize, Image.ANTIALIAS) mdpiIcon = rlImg.resize(mdpiSize, Image.ANTIALIAS) hdpiIcon = rlImg.resize(hdpiSize, Image.ANTIALIAS) xhdpiIcon = rlImg.resize(xhdpiSize, Image.ANTIALIAS) xxhdpiIcon = rlImg.resize(xxhdpiSize, Image.ANTIALIAS) sdkResPath = demoPath + '/res/' drawblePath = file_utils.getFullPath(sdkResPath + 'drawable') ldpiPath = file_utils.getFullPath(sdkResPath + 'drawable-ldpi') mdpiPath = file_utils.getFullPath(sdkResPath + 'drawable-mdpi') hdpiPath = file_utils.getFullPath(sdkResPath + 'drawable-hdpi') xhdpiPath = file_utils.getFullPath(sdkResPath + 'drawable-xhdpi') xxhdpiPath = file_utils.getFullPath(sdkResPath + 'drawable-xxhdpi') if not os.path.exists(drawblePath): os.makedirs(drawblePath) if not os.path.exists(ldpiPath): os.makedirs(ldpiPath) if not os.path.exists(mdpiPath): os.makedirs(mdpiPath) if not os.path.exists(hdpiPath): os.makedirs(hdpiPath) if not os.path.exists(xhdpiPath): os.makedirs(xhdpiPath) if not os.path.exists(xxhdpiPath): os.makedirs(xxhdpiPath) gameIconName = getAppIconName(demoPath) + '.png' drawbleIcon.save(os.path.join(drawblePath, gameIconName), 'PNG' ,quality = 95) ldpiIcon.save(os.path.join(ldpiPath, gameIconName), 'PNG' ,quality = 95) mdpiIcon.save(os.path.join(mdpiPath, gameIconName), 'PNG' ,quality = 95) hdpiIcon.save(os.path.join(hdpiPath, gameIconName), 'PNG' ,quality = 95) xhdpiIcon.save(os.path.join(xhdpiPath, gameIconName), 'PNG' ,quality = 95) xxhdpiIcon.save(os.path.join(xxhdpiPath, gameIconName), 'PNG' ,quality = 95) return 0
def generateWXEntryActivity(channel, pluginInfo, decompileDir, packageName): sdkDir = decompileDir + '/../plugins/' + pluginInfo['name'] if not os.path.exists(sdkDir): file_utils.printF("The plugin temp folder is not exists. path:" + sdkDir) return 1 extraFilesPath = sdkDir + '/extraFiles' relatedJar = os.path.join(extraFilesPath, 'ShareSDK-Wechat-Core.jar') WXPayEntryActivity = os.path.join(extraFilesPath, 'WXEntryActivity.java') file_utils.modifyFileContent(WXPayEntryActivity, 'cn.sharesdk.socialization.sample.wxapi', packageName + ".wxapi") splitdot = ';' if platform.system() == 'Darwin': splitdot = ':' cmd = '"%sjavac" -source 1.7 -target 1.7 "%s" -classpath "%s"%s"%s"' % ( file_utils.getJavaBinDir(), WXPayEntryActivity, relatedJar, splitdot, file_utils.getFullToolPath('android.jar')) ret = file_utils.execFormatCmd(cmd) if ret: return 1 packageDir = packageName.replace('.', '/') srcDir = sdkDir + '/tempDex' classDir = srcDir + '/' + packageDir + '/wxapi' if not os.path.exists(classDir): os.makedirs(classDir) sourceClassFilePath = os.path.join(extraFilesPath, 'WXEntryActivity.class') targetClassFilePath = classDir + '/WXEntryActivity.class' file_utils.copy_file(sourceClassFilePath, targetClassFilePath) targetDexPath = os.path.join(sdkDir, 'WXEntryActivity.dex') dxTool = file_utils.getFullToolPath("/lib/dx.jar") cmd = file_utils.getJavaCMD( ) + ' -jar -Xmx512m -Xms512m "%s" --dex --output="%s" "%s"' % ( dxTool, targetDexPath, srcDir) ret = file_utils.execFormatCmd(cmd) if ret: return 1 ret = apk_utils.dex2smali(targetDexPath, decompileDir + '/smali') if ret: return 1 manifest = decompileDir + '/AndroidManifest.xml' ET.register_namespace('android', androidNS) name = '{' + androidNS + '}name' theme = '{' + androidNS + '}theme' configChanges = '{' + androidNS + '}configChanges' exported = '{' + androidNS + '}exported' screenOrientation = '{' + androidNS + '}screenOrientation' tree = ET.parse(manifest) root = tree.getroot() appNode = root.find('application') if appNode is None: return 1 activityNode = SubElement(appNode, 'activity') activityNode.set(name, packageName + '.wxapi.WXEntryActivity') activityNode.set(theme, '@android:style/Theme.Translucent.NoTitleBar') activityNode.set(configChanges, 'keyboardHidden|orientation') activityNode.set(exported, 'true') activityNode.set(screenOrientation, 'portrait') tree.write(manifest, 'UTF-8') return 0