12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406 |
- # -*-coding:utf-8-*-
- import os
- import xml.etree.ElementTree as ET
- import re
- import hashlib
- import shutil
- import json
- from V1.PrintLog import printlog
- from V1 import Contants, File, GeneralModifySmali, Replace, Aapt_Util, apk_utils
- from xml.etree.ElementTree import Element
- # 联想
- def LenovoReplace(prj_path, dir_split, key, value):
- if (key == "OPENAPPID"):
- # 替换联想id
- replaceLeonovoIdShell = 'sed -i "1,\\$s/lenovo_id/%s/g" %s/AndroidManifest.xml ' % (value, prj_path)
- printlog("replaceLeonovoIdShell: %s" % replaceLeonovoIdShell)
- os.system(replaceLeonovoIdShell)
- manifestRootExt = r'<application android:networkSecurityConfig="@xml/network_security_config"'
- replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
- printlog("LenovoReplace replace add application root point shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- pass
- # 豌豆荚
- def WandoujiaReplace(prj_path, dir_split, key, value):
- printlog("specail replace : wdj")
- if (key == "APPKEY_ID"):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- printlog("prj_am_path :%s" % prj_am_path)
- lines = open(prj_am_path).readlines()
- fp = open(prj_am_path, 'w')
- for s in lines:
- if (s.find("Wandoujia-PaySdk-") != -1):
- printlog("replace Wandoujia-PaySdk-%s" % value)
- s = re.sub('Wandoujia-PaySdk-.*\"', 'Wandoujia-PaySdk-' + value + '\"', s)
- fp.write(s)
- fp.close()
- pass
- # 虫虫
- def ChongchongReplace(prj_path, dir_split, key, value):
- printlog("specail replace : Chongchong")
- if (key == "app_id"):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- printlog("prj_am_path :%s" % prj_am_path)
- lines = open(prj_am_path).readlines()
- fp = open(prj_am_path, 'w')
- for s in lines:
- if (s.find("qqPay") != -1):
- printlog("replace qqPay:%s" % value)
- s = re.sub('qqPay.*\"', 'qqPay' + value + '\"', s);
- fp.write(s)
- fp.close()
- # 360
- def QihuReplace(prj_path, dir_split, key, value):
- global appkey
- printlog("specail replace : 360")
- if (key == "QHOPENSDK_APPKEY"):
- replacePkgNameShell = 'sed -i "s/qihu_appkey/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
- printlog("QihuReplace replace qihu_appkey shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- if (key == "QHOPENSDK_APPSECRET"):
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- appsecret = value
- metadatas = ET.parse(prj_am_path).getroot().find("application").findall("meta-data")
- for meta in metadatas:
- if (meta.attrib["{http://schemas.android.com/apk/res/android}name"] == "QHOPENSDK_APPKEY"):
- appkey = meta.attrib["{http://schemas.android.com/apk/res/android}value"]
- printlog("prj_am_path:%s" % prj_am_path)
- m = hashlib.md5()
- printlog("appsecret :%s" % appsecret)
- printlog("appkey: %s" % appkey)
- md5value = "%s#%s" % (appsecret, appkey)
- printlog("md5value :%s" % md5value)
- m.update(md5value)
- privatekey = m.hexdigest()
- printlog("privatekey:%s" % privatekey)
- Replace.replaceAM_Meta_data(prj_am_path, 'QHOPENSDK_PRIVATEKEY', privatekey)
- manifestRootExt = r'<application android:networkSecurityConfig="@xml/network_security_config"'
- replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
- printlog("qihu360 replace add application root point shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- pass
- def OppoReplace(prj_path, dir_split, key, value):
- printlog("specail replace : oppo")
- if (key == "APPKEY"):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- printlog("prj_am_path: %s" % prj_am_path)
- # 替换app_key
- Replace.replaceAM_Meta_data(prj_am_path, 'app_key', value)
- printlog("appkey: %s" % value)
- pass
- def OppoMlReplace(prj_path, dir_split, key, value):
- printlog("specail replace : oppoml")
- if (key == "APPKEY"):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- printlog("prj_am_path: %s" % prj_am_path)
- # 替换app_key
- Replace.replaceAM_Meta_data(prj_am_path, 'app_key', value)
- printlog("appkey: %s" % value)
- pass
- def downjoyReplace(prj_path, dir_split, key, value):
- printlog("specail replace : downjoy")
- if (key == "APP_ID"):
- splash_activity = "com.downjoy.activity.SdkLoadActivity"
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, prj_am_path)
- printlog(game_activity)
- Replace.replaceAM_Meta_data(prj_am_path, 'CP_ACTIVITY', game_activity)
- lines = open(prj_am_path).readlines()
- fp = open(prj_am_path, 'w')
- for s in lines:
- if (s.find("dcnngsdk") != -1):
- printlog("replace dcnngsdk:%s" % value)
- s = re.sub('dcnngsdk.*\"', 'dcnngsdk' + value + '\"', s)
- fp.write(s)
- fp.close()
- pass
- def YYBReplace(prj_path, dir_split, key, value):
- if (key == "QQ_APP_ID"):
- # 替换qq app id
- replaceQQAPPIDShell = 'sed -i "s/qq_app_id/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
- printlog("yingyongbao qq app id shell: %s" % replaceQQAPPIDShell)
- os.system(replaceQQAPPIDShell)
- # 替换ysdkconf.ini
- printlog("path ysdkconfig.ini:%s/assets/ysdkconf.ini" % prj_path)
- Replace.replaceAssets_Param("%s/assets/ysdkconf.ini" % prj_path, key, value)
- Replace.replaceAssets_Param("%s/assets/ysdkconf.ini" % prj_path, "OFFER_ID", value)
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- game_activity = Replace.getLauchActivityName(prj_path)
- Replace.replaceAM_Meta_data(prj_am_path, 'MAIN_ACTIVITY', game_activity)
- if (key == "WX_APP_ID"):
- replaceWXAPPIDShell = 'sed -i "s/wx_app_id/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
- printlog("yingyongbao wx app id shell: %s" % replaceWXAPPIDShell)
- os.system(replaceWXAPPIDShell)
- # 替换ysdkconf.ini
- Replace.replaceAssets_Param("%s/assets/ysdkconf.ini" % prj_path, key, value)
- if (key == "IS_SAND_BOX"):
- ysdk_sand_url = "https://ysdktest.qq.com"
- ysdk_online_url = "https://ysdk.qq.com"
- if value == "1":
- ysdk_url = ysdk_sand_url
- else:
- ysdk_url = ysdk_online_url
- Replace.replaceAssets_Param("%s/assets/ysdkconf.ini" % prj_path, "YSDK_URL", ysdk_url)
- pass
- def HuaweiReplace(prj_path, dir_split, key, value):
- if (key == "APP_ID"):
- replaceAppidShell = '/bin/sed -i "s/APP_ID/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
- printlog("huawei replace appid shell: %s" % replaceAppidShell)
- os.system(replaceAppidShell)
- if (key == "PAY_ID"):
- replacePayidShell = '/bin/sed -i "s/PAY_ID/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
- printlog("huawei replace payid shell: %s" % replacePayidShell)
- os.system(replacePayidShell)
- pass
- def AnzhiReplace(prj_path, dir_split, key, value):
- printlog("specail replace : anzhi")
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- if (key == "APP_KEY"):
- lines = open(prj_am_path).readlines()
- fp = open(prj_am_path, 'w')
- for s in lines:
- if (s.find("packagename") != -1):
- s = re.sub('packagename', pkgName, s);
- fp.write(s)
- fp.close()
- pass
- def GuopanReplace(prj_path, dir_split, key, value):
- printlog("specail replace : guopan")
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- if (key == "APP_ID"):
- lines = open(prj_am_path).readlines()
- fp = open(prj_am_path, 'w')
- for s in lines:
- if (s.find("gp_packagename") != -1):
- s = re.sub('gp_packagename', pkgName + ".StubContentProvider", s);
- fp.write(s)
- fp.close()
- pass
- def LeshiReplace(prj_path, dir_split, key, value):
- printlog("specail replace : leshi")
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- if (key == "LEPAY_APPID"):
- Replace.replaceAM_Meta_data(prj_am_path, 'lepay_appid', value)
- if (key == "LEPAY_APPKEY"):
- Replace.replaceAM_Meta_data(prj_am_path, 'lepay_appkey', value)
- pass
- def QuickReplace(prj_path, dir_split, key, value):
- printlog("specail replace : Quick")
- if (key == "PRODUCT_CODE"):
- splashactivity = "com.yythird.sdk.SplashActivity"
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- Replace.replaceAssets_Param(prj_param, "GAMEACTIVITY", game_activity)
- if (key == "SDK_TYPE"):
- printlog("merge qitian Smali")
- if value == "qitian":
- printlog("merge qitian Smali")
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- ret = 0
- ret = ret | File.mergeDir("%s/quick/quick/qitian_smali" % sdk_root_dir, "%s/smali" % prj_path)
- pass
- def LjsdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : LjsdkReplace")
- if (key == "XMGAME_PRODUCT_CODE"):
- prj_param = "%s/assets/param.cnf" % prj_path
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- splashactivity = "third.sdk.SplashActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- Replace.replaceAssets_Param(prj_param, "GAMEACTIVITY", game_activity)
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- pkgLine = 'package="' + pkgName + '"'
- printlog("pkgValue :%s" % pkgLine)
- addPkgLine = ' xmlns:tools="http://schemas.android.com/tools" '
- addPerLine = ' tools:ignore="ProtectedPermissions" '
- permissionName = 'android:name="android.permission.PACKAGE_USAGE_STATS"'
- lines = open(prj_am_path).readlines()
- fp = open(prj_am_path, 'w')
- for s in lines:
- if (s.find(pkgLine) != -1):
- s = re.sub(pkgLine, pkgLine + addPkgLine, s);
- printlog("pkgLine :%s" % s)
- if (s.find(permissionName) != -1):
- s = re.sub(permissionName, permissionName + addPerLine, s);
- printlog("permissionName :%s" % s)
- fp.write(s)
- fp.close()
- pass
- def UcsdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : UcsdkReplace")
- if (key == "GAME_ID"):
- replaceGidShell = 'sed -i "s/GAME_ID/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
- printlog("uc replace GAME_ID shell: %s" % replaceGidShell)
- os.system(replaceGidShell)
- # GeneralModifySmali.modifyLauchSmali(prj_path)
- pass
- def XiaomisdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : XiaomisdkReplace")
- if (key == "APP_ID"):
- # 获取包名
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- Replace.modifyRfileSmaliPath("xiaomi", prj_path);
- printlog(" xiaomi begin replace game package v4 smali -------------------------------")
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/xiaomi/xiaomi/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- pkgAnnotation = "%s/smali/android/support/annotation" % prj_path
- printlog("pkgV4Path:%s" % pkgAnnotation)
- sdkAnnotation = "%s/xiaomi/xiaomi/smali/android/support/annotation" % sdk_root_dir
- if os.path.exists(pkgAnnotation):
- File.copyAllFile(sdkAnnotation, pkgAnnotation)
- pass
- # 百度
- def BaiduReplace(prj_path, dir_split, key, value):
- printlog("specail replace : baidu")
- if (key == "APP_ID"):
- GeneralModifySmali.modifyLauchSmali(prj_path)
- pass
- # 圣本
- def ShengbensdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : ShengbensdkReplace")
- if (key == "AGENT"):
- jsonFilePath = prj_path + dir_split + "assets" + dir_split + "hnsb_config.json"
- printlog("path hnsb_config.json :%s" % jsonFilePath)
- with open(jsonFilePath, 'r') as fp:
- jsonData = json.load(fp)
- jsonData['sdk']["ver"] = value
- newJsonData = jsonData
- fp.close()
- with open(jsonFilePath, 'w') as fp:
- json.dump(newJsonData, fp)
- fp.close()
- if (key == "APP_ID"):
- jsonFilePath = prj_path + dir_split + "assets" + dir_split + "hnsb_config.json"
- with open(jsonFilePath, 'r') as fp:
- jsonData = json.load(fp)
- jsonData['sdk']["appid"] = value
- newJsonData = jsonData
- fp.close()
- with open(jsonFilePath, 'w') as fp:
- json.dump(newJsonData, fp)
- fp.close()
- pass
- def JinkuosdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : JinkuosdkReplace")
- printlog("path yy.properties :%s/assets/u8_developer_config.properties" % prj_path)
- Replace.replaceAssets_Param("%s/assets/u8_developer_config.properties" % prj_path, key, value)
- pass
- def HdhdsdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : HdhdsdkReplace")
- if (key == "APP_ID"):
- GeneralModifySmali.modifyLauchSmali(prj_path)
- pass
- def SamsungReplace(prj_path, dir_split, key, value):
- printlog("specail replace : SamsungReplace")
- if (key == "APPV_KEY"):
- ptKey = value[0:99]
- pvData = value[99:len(value)]
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- printlog("prj_am_path: %s" % prj_am_path)
- # 替换app_key
- Replace.replaceAM_Meta_data(prj_am_path, 'ptKey', ptKey)
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- Replace.replaceAssets_Param(prj_param, "pvData", pvData)
- pass
- def TTReplace(prj_path, dir_split, key, value):
- printlog("specail replace : TTReplace")
- if (key == "GAME_ID"):
- Replace.replaceAssets_Param("%s/assets/tt_game_sdk_opt.properties" % prj_path, "gameId", value)
- if (key == "GAME_KEY"):
- replaceKeyShell = 'sed -i "s/@WSX3edc/%s/g" %s/assets/TTGameSDKConfig.cfg' % (value, prj_path)
- printlog("replaceMainLineShell:%s" % replaceKeyShell)
- os.system(replaceKeyShell)
- pass
- def YXFReplace(prj_path, dir_split, key, value):
- printlog("specail replace : YXFReplace")
- if (key == "YGAPPID"):
- replacePkgNameShell = '/bin/sed -i "1,\\$s/YXFAPPID/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
- printlog("replacePkgNameShell:%s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- manifestRootExt = r'<application android:usesCleartextTraffic="true"'
- replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
- printlog("youxiFan replace add application root point shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- if (key == "IS_SPLASH"):
- if (value == "0"):
- GeneralModifySmali.modifyYXFLauchSmali(prj_path)
- if (key == "screenOrientation"):
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- if (value == "screenOrientation:0"):
- splash = "%s/yxf/yxf/extension/sp_landscape.png" % sdk_root_dir
- apkres = "%s/res/drawable/crash_screen.png" % prj_path
- shutil.copy(splash, apkres)
- if (value == "screenOrientation:1"):
- splash = "%s/yxf/yxf/extension/sp_portrait.png" % sdk_root_dir
- apkres = "%s/res/drawable/crash_screen.png" % prj_path
- shutil.copy(splash, apkres)
- pass
- def VivosdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : VivosdkReplace")
- if (key == "APP_ID"):
- printlog("path supplierconfig.json :%s/assets/supplierconfig.json" % prj_path)
- replaceConfigShell = '/bin/sed -i "1,\\$s/APP_ID/%s/g" %s/assets/supplierconfig.json' % (value, prj_path)
- printlog("replaceConfigShell APP_ID:%s" % replaceConfigShell)
- os.system(replaceConfigShell)
- jsonFilePath = prj_path + dir_split + "assets" + dir_split + "supplierconfig.json"
- printlog("path supplierconfig.json :%s" % jsonFilePath)
- with open(jsonFilePath, 'r') as fp:
- jsonData = json.load(fp)
- jsonData['supplier']["vivo"]["appid"] = value
- newJsonData = jsonData
- fp.close()
- with open(jsonFilePath, 'w') as fp:
- json.dump(newJsonData, fp)
- fp.close()
- pass
- def XTsdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : Xiantu3011sdkReplace")
- if (key == "GAME_ID"):
- # 获取包名
- Replace.modifyRfileSmaliPath("3011", prj_path);
- pass
- def DDTsdkReplace(prj_path, dir_split, key, value):
- printlog("specail replace : DDTsdkReplace")
- if (key == "APP_ID"):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- splashactivity = "com.ddtsdk.ui.activity.MHPerActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- Replace.replaceAM_Meta_data(prj_am_path, "mainAct", game_activity)
- if (key == "agent"):
- Replace.replaceAssets_Param("%s/assets/ddt.properties" % prj_path, key, value)
- pass
- def QiyuReplace(prj_path, dir_split, key, value):
- if (key == "APP_ID"):
- manifestRootExt = r'<application android:usesCleartextTraffic="true"'
- replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
- printlog("QiyuReplace add application root point shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- pass
- def WankaReplace(prj_path, dir_split, key, value):
- if (key == "APPID"):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- namespace = '{http://schemas.android.com/apk/res/android}'
- manifestRootExt = r'<application xmlns:tools="http://schemas.android.com/tools" tools:replace="android:theme,android:name"'
- replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
- printlog("WankaReplace replace add application root point shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- tree = ET.parse(prj_am_path)
- activitys = tree.getroot().find("application").findall("activity")
- for activity in activitys:
- filters = activity.findall('intent-filter')
- for filter in filters:
- categorys = filter.findall('category')
- for category in categorys:
- categoryname = category.attrib[namespace + "name"]
- if (categoryname == "android.intent.category.LAUNCHER"):
- element = Element('intent-filter')
- el1 = Element('action android:name="android.intent.action.VIEW"')
- el2 = Element('category android:name="android.intent.category.DEFAULT"')
- el3 = Element('category android:name="android.intent.category.BROWSABLE"')
- el4_value = 'data android:scheme="app%s"' % value
- el4 = Element(el4_value)
- element.append(el1)
- element.append(el2)
- element.append(el3)
- element.append(el4)
- activity.append(element)
- activity.set(namespace + 'launchMode', "singleTask")
- tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- Aapt_Util.createRFile(prj_path, False, pkgName)
- sdkRpath = "android/support/v7/appcompat"
- pkgRpath = pkgName.replace(".", "/")
- sdkAbsoluteRpath = "%s/smali/%s" % (prj_path, sdkRpath)
- pkgAbsoluteRpath = "%s/smali/%s" % (prj_path, pkgRpath)
- Replace.createRFile2Sdk(pkgAbsoluteRpath, sdkAbsoluteRpath, pkgRpath, sdkRpath)
- pass
- def DDDReplace(prj_path, dir_split, key, value):
- if (key == "channelId"):
- Replace.replaceAssets_Param("%s/assets/dingdd.properties" % prj_path, 'channelId', value)
- if (key == "adId"):
- Replace.replaceAssets_Param("%s/assets/dingdd.properties" % prj_path, 'adId', value)
- if (key == "adFlag"):
- Replace.replaceAssets_Param("%s/assets/dingdd.properties" % prj_path, 'adFlag', value)
- pass
- def LZYXReplace(prj_path, dir_split, key, value):
- if (key == "ML_Channel"):
- Replace.replaceAssets_Param("%s/assets/mlgame_developer_config.properties" % prj_path, 'ML_Channel', value)
- if (key == "ML_APPKEY"):
- Replace.replaceAssets_Param("%s/assets/mlgame_developer_config.properties" % prj_path, 'ML_APPKEY', value)
- pass
- def WSReplace(prj_path, dir_split, key, value):
- if (key == "HS_APPID"):
- manifestRootExt = r'<application android:networkSecurityConfig="@xml/huosdk_network_security_config"'
- replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
- printlog("qihu360 replace add application root point shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- pass
- def XBReplace(prj_path, dir_split, key, value):
- if (key == "GID"):
- printlog("path gameshaiApp.ini :%s/assets/gameshaiApp.ini" % prj_path)
- Replace.replaceAssets_Param("%s/assets/gameshaiApp.ini" % prj_path, 'gid', value)
- if (key == "PID"):
- printlog("path gameshaiApp.ini :%s/assets/gameshaiApp.ini" % prj_path)
- Replace.replaceAssets_Param("%s/assets/gameshaiApp.ini" % prj_path, 'pid', value)
- pass
- def YoudianReplace(prj_path, dir_split, key, value):
- if (key == "APPID"):
- apkPkgDir = ET.parse("%s/AndroidManifest.xml" % prj_path).getroot().attrib["package"].replace(".", "/")
- apkRfilePath = "%s/smali/%s" % (prj_path, apkPkgDir)
- Replace.modifyRfileSmaliPath("youdian", prj_path);
- publicXml = "%s/res/values/public.xml" % prj_path
- sdk_jar_dir = apk_utils.getToolsJarHome()
- jarPath = "%s/MergeSamli.jar" % sdk_jar_dir
- javaMerCm = 'java -jar %s %s %s' % (jarPath, publicXml, apkRfilePath)
- printlog("javaMerCm:%s" % javaMerCm)
- os.system(javaMerCm)
- pass
- def Xiao7Replace(prj_path, dir_split, key, value):
- if (key == "APPKEY"):
- apkRfilePath = "%s/smali_classes2/com/smwl/smsdk" % prj_path
- publicXml = "%s/res/values/public.xml" % prj_path
- sdk_jar_dir = apk_utils.getToolsJarHome()
- jarPath = "%s/MergeSamli.jar" % sdk_jar_dir
- javaMerCm = 'java -jar %s %s %s' % (jarPath, publicXml, apkRfilePath)
- printlog("javaMerCm:%s" % javaMerCm)
- os.system(javaMerCm)
- printlog(" Xiao7Replace begin replace game package v4 smali -------------------------------")
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/x7sy/x7sy/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- pkgName = ET.parse("%s/AndroidManifest.xml" % prj_path).getroot().attrib["package"]
- Aapt_Util.createRFile(prj_path, False, pkgName)
- pkgName = "android.support.constraint"
- Aapt_Util.createRFile(prj_path, False, pkgName)
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- splashactivity = "com.yythird.sdk.SplashActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- Replace.replaceAssets_Param(prj_param, "GAME_ACTIVITY", game_activity)
- printlog("xiaoqi GAME_ACTIVITY :%s" % game_activity)
- pass
- def NwanKaReplace(prj_path, dir_split, key, value):
- if (key == "channelId"):
- Replace.replaceAssets_Param("%s/assets/wk.properties" % prj_path, 'channelId', value)
- if (key == "adId"):
- Replace.replaceAssets_Param("%s/assets/wk.properties" % prj_path, 'adId', value)
- if (key == "adFlag"):
- Replace.replaceAssets_Param("%s/assets/wk.properties" % prj_path, 'adFlag', value)
- manifestRootExt = r'<application xmlns:tools="http://schemas.android.com/tools" tools:replace="android:theme,android:name"'
- replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
- printlog("WankaReplace replace add application root point shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- pass
- def MBaiduReplace(prj_path, dir_split, key, value):
- if (key == "APP_ID"):
- manifestRootExt = r'<application android:networkSecurityConfig="@xml/network_security_config"'
- replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
- printlog("MbaiduReplace replace add application root point shell: %s" % replacePkgNameShell)
- os.system(replacePkgNameShell)
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/com/baidu/passport/sapi2")
- pass
- def ShenshouReplace(prj_path, dir_split, key, value):
- if (key == "BALANCENAME"):
- prj_style_path = prj_path + dir_split + "res/values-v28/styles.xml"
- printlog("prj_style_path: %s" % prj_style_path)
- File.safeFileDelete(prj_style_path)
- pass
- def DaYanReplace(prj_path, dir_split, key, value):
- if (key == "GD"):
- filepath = "%s/assets/sdkchannel.txt" % prj_path
- replacePdShell = 'sed -i "s#%s#%s#g" %s' % ("PD", value, filepath)
- printlog(replacePdShell)
- os.system(replacePdShell)
- pass
- def DaLanReplace(prj_path, dir_split, key, value):
- printlog("specail replace : DaLanReplace")
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- if (key == "DL_APPID"):
- splashactivity = "com.dalan.dl_assembly.SplashScreenActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- Replace.replaceAM_Meta_data(prj_am_path, "dalan_union_main_activity", game_activity)
- pass
- def KSyxReplace(prj_path, dir_split, key, value):
- if (key == "kwai_app_id"):
- Replace.replaceAssets_Param("%s/assets/allin_developer_config.properties" % prj_path, 'kwai_app_id', value)
- printlog(" KSyxReplace begin replace game package v4 smali -------------------------------")
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/ksyx/ksyx/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- Replace.replaceAM_AllowBackup(prj_am_path)
- pass
- def LlhyReplace(prj_path, dir_split, key, value):
- printlog("specail replace : LlhyReplace")
- if (key == "LLHY_APP_ID"):
- metaKey = "unityplayer.SkipPermissionsDialog"
- Replace.replaceAM_Meta_data("%s/AndroidManifest.xml" % prj_path, metaKey,
- "true")
- pass
- def HnqsReplace(prj_path, dir_split, key, value):
- printlog("specail replace : HnqsReplace")
- if (key == "agent"):
- Replace.replaceAssets_Param("%s/assets/jmhy.properties" % prj_path, 'agent', value)
- metaKey = "unityplayer.SkipPermissionsDialog"
- Replace.replaceAM_Meta_data("%s/AndroidManifest.xml" % prj_path, metaKey,
- "true")
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- sdk_smali_dir = "%s/hnqs/hnqs/extension/yyrh" % sdk_root_dir
- temp_old_smali_dir = "%s/smali/com/yyrh" % prj_path
- if os.path.exists(sdk_smali_dir):
- File.copyAllFile(sdk_smali_dir, temp_old_smali_dir)
- pass
- def SogouReplace(prj_path, dir_split, key, value):
- if (key == "GID"):
- printlog(" SogouReplace begin replace game package v4 smali -------------------------------")
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/sogou/sogou/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- Replace.replaceAM_AllowBackup(prj_am_path)
- pass
- def JinRiTouTiaoReplace(prj_path, dir_split, key, value):
- jsonFilePath = prj_path + dir_split + "assets" + dir_split + "config.json"
- if key == 'APP_ID':
- with open(jsonFilePath, 'r') as fp:
- jsonData = json.load(fp)
- jsonData['app']["app_id"] = value
- jsonData['app']['main_activity'] = GeneralModifySmali.getLauchActivityName(prj_path)
- orientation = GeneralModifySmali.getLauchActivityScreenOrientation(prj_path)
- if orientation == "landscape" or orientation == "sensorLandscape":
- screen_orientation = "sensorLandscape"
- else:
- screen_orientation = "sensorPortrait"
- jsonData['app']['screen_orientation'] = screen_orientation
- newJsonData = jsonData
- fp.close()
- with open(jsonFilePath, 'w') as fp:
- json.dump(newJsonData, fp)
- fp.close()
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/game_sdk/packers/rocket_sdk")
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali_classes2/game_sdk/packers/rocket_sdk")
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/androidx/navigation/ui")
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali_classes3/android/support/design")
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali_classes3/android/support/v7/appcompat")
- # GeneralModifySmali.replaceSdkV4Smali(prj_path,"jrtt/jrtt/smali/android/support/v4")
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/jrtt/jrtt/smali_classes3/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- GeneralModifySmali.modifyJrttV7ResIdSmali(prj_path)
- else:
- Replace.replaceJsonValue(jsonFilePath, "app", key, value)
- pass
- def FengQiReplace(prj_path, dir_split, key, value):
- if (key == "channelId") or (key == "adId") or (key == "adFlag"):
- # 替换fq.properties
- printlog("path fq.properties:%s/assets/fq.properties" % prj_path)
- Replace.replaceAssets_Param("%s/assets/fq.properties" % prj_path, key, value)
- pass
- pass
- def BlueStackReplace(prj_path, dir_split, key, value):
- if key == "APP_ID":
- replaceBlueStackIdShell = 'sed -i "1,\\$s/APP_ID/%s/g" %s/assets/BSSDKConfig.xml ' % (value, prj_path)
- printlog("replaceBlueStackIdShell: %s" % replaceBlueStackIdShell)
- os.system(replaceBlueStackIdShell)
- pass
- # 司墨
- def SiMoReplace(prj_path, dir_split, key, value):
- if key == "APP_ID":
- config_path = prj_path + '/assets/SIMgame_config.xml'
- tree = ET.parse(config_path)
- root = tree.getroot()
- for elem in root.iter('appid'):
- elem.text = value
- tree.write(config_path, "UTF-8", xml_declaration=True, method='xml')
- pass
- # 乘龙
- def ChenLongReplace(prj_path, dir_split, key, value):
- if key == "CL_PID":
- Replace.replaceAssets_Param("%s/assets/_cl_developer_config.properties" % prj_path, 'CL_PID', value)
- if key == "CL_KEY":
- Replace.replaceAssets_Param("%s/assets/_cl_developer_config.properties" % prj_path, 'CL_KEY', value)
- if key == "CL_DEBUG_GD":
- Replace.replaceAssets_Param("%s/assets/_cl_developer_config.properties" % prj_path, 'CL_DEBUG_GD', value)
- pass
- def JiuZiReplace(prj_path, dir_split, key, value):
- printlog("specail replace : JiuZiReplace")
- if (key == "gid"):
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- splash_activity = "com.yythird.sdk.SplashActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- Replace.replaceAssets_Param(prj_param, "GAMEACTIVITY", game_activity)
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- Aapt_Util.createRFile(prj_path, False, pkgName)
- apkRfilePath = "%s/smali/com/jzyx/sdk" % prj_path
- printlog("apkRfilePath:%s" % apkRfilePath)
- publicXml = "%s/res/values/public.xml" % prj_path
- sdk_jar_dir = apk_utils.getToolsJarHome()
- jarPath = "%s/MergeSamli.jar" % sdk_jar_dir
- javaMerCm = 'java -jar %s %s %s' % (jarPath, publicXml, apkRfilePath)
- printlog("javaMerCm:%s" % javaMerCm)
- os.system(javaMerCm)
- pass
- def BingNiaoReplace(prj_path, dir_split, key, value):
- printlog("specail replace : DaLanReplace")
- if (key == "YH_GAME_ID"):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- splashactivity = "prj.iyinghun.platform.sdk.SplashScreenActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- Replace.replaceAM_Meta_data(prj_am_path, "prj.chameleon.intent.main", game_activity)
- pass
- def BingChengReplace(prj_path, dir_split, key, value):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- namespace = '{http://schemas.android.com/apk/res/android}'
- ET.register_namespace('android', "http://schemas.android.com/apk/res/android")
- if (key == "BC_GAME_ID"):
- tree = ET.parse(prj_am_path)
- pkgName = tree.getroot().attrib["package"]
- activitys = tree.getroot().find("application").findall("activity")
- for activity in activitys:
- filters = activity.findall('intent-filter')
- for filter in filters:
- categorys = filter.findall('category')
- for category in categorys:
- categoryname = category.attrib[namespace + "name"]
- if (categoryname == "android.intent.category.LAUNCHER"):
- element = Element('intent-filter')
- el1 = Element('action android:name="android.intent.action.VIEW"')
- el2 = Element('category android:name="android.intent.category.DEFAULT"')
- el3 = Element('category android:name="android.intent.category.BROWSABLE"')
- el4_value = 'data android:host="%s" android:scheme="%s"' % (value, pkgName)
- el4 = Element(el4_value)
- element.append(el1)
- element.append(el2)
- element.append(el3)
- element.append(el4)
- activity.append(element)
- tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
- def SuixingHuYuReplace(prj_path, dir_split, key, value):
- if (key == "game_id"):
- Replace.replaceAssets_Param("%s/assets/suixin/suixin_sdk.ini" % prj_path, key, value)
- if (key == "pid"):
- Replace.replaceAssets_Param("%s/assets/suixin/suixin_sdk.ini" % prj_path, key, value)
- if (key == "is_land"):
- Replace.replaceAssets_Param("%s/assets/suixin/suixin_sdk.ini" % prj_path, key, value)
- pass
- def ShouQuReplace(prj_path, dir_split, key, value):
- config_path = "%s/assets/sqsdk_config" % prj_path
- with open(config_path, "r") as f:
- content = f.read()
- json_data = json.loads(content)
- json_data[key] = value
- with open(config_path, "w") as f:
- f.write(json.dumps(json_data))
- if key == "app_key":
- manifest_path = prj_path + dir_split + "AndroidManifest.xml"
- param_cnf = "%s/assets/YyrhParam.cnf" % prj_path
- splash_activity = "com.yythird.sdk.SplashActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, manifest_path)
- Replace.replaceAssets_Param(param_cnf, "GAMEACTIVITY", game_activity)
- printlog("GAMEACTIVITY :%s" % game_activity)
- def HaiNanQiJingReplace(prj_path, dir_split, key, value):
- if key == "PACKAGE_TAG":
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- sdkSmaliPath = "%s/hnqj/hnqj/smali/com" % sdk_root_dir
- pkgSmaliPath = "%s/smali/com" % prj_path
- printlog("sdkSmaliPath :%s" % sdkSmaliPath)
- printlog("pkgSmaliPath :%s" % pkgSmaliPath)
- if os.path.exists(pkgSmaliPath):
- File.copyAllFile(sdkSmaliPath, pkgSmaliPath)
- if Contants.isTestEnvironment():
- key = "https://fxsy.qijinghao.com"
- value = "http://testsdkapi.yyxxgame.com"
- file = "%s/smali/com/yyrh/c/a.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- file = "%s/smali/com/yyrh/ui/a.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- file = "%s/smali/com/yyrh/a/d.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- file = "%s/smali/com/yyrh/sdk/SDKEntry.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- pass
- def HongGuoReplace(prj_path, dir_split, key, value):
- config_path = "%s/assets/gameInfo.json" % prj_path
- with open(config_path, "r") as f:
- content = f.read()
- json_data = json.loads(content)
- json_data[key] = value
- with open(config_path, "w") as f:
- f.write(json.dumps(json_data))
- if key == "game_id":
- manifest_path = prj_path + dir_split + "AndroidManifest.xml"
- param_cnf = "%s/assets/YyrhParam.cnf" % prj_path
- splash_activity = "com.yythird.sdk.SplashActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, manifest_path)
- Replace.replaceAssets_Param(param_cnf, "GAMEACTIVITY", game_activity)
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- printlog(" HongGuoReplace begin replace game package v4 smali -------------------------------")
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/hg/hg/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- pass
- def BaizeReplace(prj_path, dir_split, key, value):
- if key == "APP_ID":
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- param_cnf = "%s/assets/YyrhParam.cnf" % prj_path
- splashactivity = "com.yythird.sdk.SplashActivity"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- Replace.replaceAssets_Param(param_cnf, "GAMEACTIVITY", game_activity)
- pass
- def YanXinReplace(prj_path, dir_split, key, value):
- if key == "ProductCode":
- Replace.modifyRfileSmaliPath("yx", prj_path)
- pass
- def ZhangShangHuYuReplace(prj_path, dir_split, key, value):
- Replace.replaceAssets_Param("%s/assets/yy.properties" % prj_path, key, value)
- if key == "channelId":
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- printlog(" ZhangShangHuYuReplace begin replace game package v4 smali -------------------------------")
- pkgV4Path = "%s/smali/android/support/v7" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/zshy/zshy/smali/android/support/v7" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/android/support/v7/cardview")
- printlog(" HongGuoReplace begin replace game package v4 smali -------------------------------")
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/zshy/zshy/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- apkRfilePath = "%s/smali/com/zshy/zshysdk" % prj_path
- printlog("apkRfilePath:%s" % apkRfilePath)
- publicXml = "%s/res/values/public.xml" % prj_path
- sdk_jar_dir = apk_utils.getToolsJarHome()
- jarPath = "%s/MergeSamli.jar" % sdk_jar_dir
- javaMerCm = 'java -jar %s %s %s' % (jarPath, publicXml, apkRfilePath)
- printlog("javaMerCm:%s" % javaMerCm)
- os.system(javaMerCm)
- Replace.modifyRfileSmaliPath("zshy", prj_path);
- pass
- def XiYouWangReplace(prj_path, dir_split, key, value):
- Replace.replaceAssets_Param("%s/assets/xy_developer_config.properties" % prj_path, key, value)
- if key == "XY_APP_ID":
- splash_activity = "com.xiyou.sdk.XiYouSplashActivity"
- manifest_path = prj_path + dir_split + "AndroidManifest.xml"
- game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, manifest_path)
- Replace.replaceAM_Meta_data(manifest_path, 'XY_GAME_MAIN_ACTIVITY_NAME', game_activity)
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- printlog(" xiyouwang begin replace game package v4 smali -------------------------------")
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/xiyou/xiyou/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- Aapt_Util.createRFile(prj_path, False, pkgName)
- pass
- def XunLeiReplace(prj_path, dir_split, key, value):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- namespace = '{http://schemas.android.com/apk/res/android}'
- ET.register_namespace('android', "http://schemas.android.com/apk/res/android")
- if (key == "schemeCallback"):
- tree = ET.parse(prj_am_path)
- activitys = tree.getroot().find("application").findall("activity")
- for activity in activitys:
- activityName = activity.attrib[namespace + "name"]
- printlog("activityName:%s" % activityName)
- if (activityName == "com.xovs.common.auth.processor.XLAuthBackActivity"):
- filters = activity.findall('intent-filter')
- for filter in filters:
- datas = filter.findall('data')
- for data in datas:
- printlog("data:%s" % data)
- data.set(namespace + "scheme", value)
- tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
- pass
- def CanLongReplace(prj_path, dir_split, key, value):
- if key == "PRODUCT_CODE":
- Replace.modifyRfileSmaliPath("canlong", prj_path);
- pass
- def ShangHaiXiYuanReplace(prj_path, dir_split, key, value):
- if key == "PACKAGE_TAG":
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- sdkSmaliPath = "%s/shxy/shxy/smali/com/yyrh" % sdk_root_dir
- pkgSmaliPath = "%s/smali/com/yyrh" % prj_path
- printlog("sdkSmaliPath :%s" % sdkSmaliPath)
- printlog("pkgSmaliPath :%s" % pkgSmaliPath)
- if os.path.exists(pkgSmaliPath):
- File.copyAllFile(sdkSmaliPath, pkgSmaliPath)
- if Contants.isTestEnvironment():
- key = "https://sdkapi.bklinok.com"
- value = "http://testsdkapi.yyxxgame.com"
- file = "%s/smali/com/yyrh/c/a.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- file = "%s/smali/com/yyrh/a/d.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- file = "%s/smali/com/yyrh/sdk/SDKEntry.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- pass
- def YuanYouRongHeReplace(prj_path, dir_split, key, value):
- if key == "PACKAGE_TAG":
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- sdkSmaliPath = "%s/mixsdk/mixsdk/smali/com/yyrh" % sdk_root_dir
- pkgSmaliPath = "%s/smali/com/yyrh" % prj_path
- printlog("sdkSmaliPath :%s" % sdkSmaliPath)
- printlog("pkgSmaliPath :%s" % pkgSmaliPath)
- if os.path.exists(pkgSmaliPath):
- File.copyAllFile(sdkSmaliPath, pkgSmaliPath)
- sdkSmaliPath = "%s/mixsdk/mixsdk/smali/com/yythird/base" % sdk_root_dir
- pkgSmaliPath = "%s/smali/com/yythird/base" % prj_path
- printlog("sdkSmaliPath :%s" % sdkSmaliPath)
- printlog("pkgSmaliPath :%s" % pkgSmaliPath)
- if os.path.exists(pkgSmaliPath):
- File.copyAllFile(sdkSmaliPath, pkgSmaliPath)
- if Contants.isTestEnvironment():
- key = "https://sdkapi.yyxxgame.com"
- value = "http://testsdkapi.yyxxgame.com"
- file = "%s/smali/com/yyrh/c/a.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- file = "%s/smali/com/yyrh/sdk/SDKEntry.smali" % prj_path
- Replace.replaceKeyword(key, value, file)
- pass
- def BaLeReplace(prj_path, dir_split, key, value):
- if key == "CHANNEL_ID":
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/com/sdk/douyou")
- pass
- def QiPaReplace(prj_path, dir_split, key, value):
- if key == "Super_Game_ID":
- splash_activity = "com.supersdk.application.MySplashActivity"
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- game_activity = Replace.replaceGameActivityLaunchAttribute(splash_activity, prj_am_path)
- tree = ET.parse(prj_am_path)
- activitys = tree.getroot().find("application").findall("activity")
- for activity in activitys:
- namespace = '{http://schemas.android.com/apk/res/android}'
- xml_activity_name = activity.attrib[namespace + "name"]
- if xml_activity_name == game_activity:
- filter = activity.find('intent-filter')
- el1 = Element('action android:name="com.super.sdk.MAIN"')
- filter.append(el1)
- tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
- pass
- def DouyinReplace(prj_path, dir_split, key, value):
- jsonFilePath = prj_path + dir_split + "assets" + dir_split + "config.json"
- if key == 'app_id':
- with open(jsonFilePath, 'r') as fp:
- jsonData = json.load(fp)
- jsonData["app_id"] = value
- jsonData['screen_orientation'] = GeneralModifySmali.getLauchActivityName(prj_path)
- orientation = GeneralModifySmali.getLauchActivityScreenOrientation(prj_path)
- if orientation == "landscape" or orientation == "sensorLandscape":
- screen_orientation = "sensorLandscape"
- else:
- screen_orientation = "sensorPortrait"
- jsonData['screen_orientation'] = screen_orientation
- newJsonData = jsonData
- fp.close()
- with open(jsonFilePath, 'w') as fp:
- json.dump(newJsonData, fp)
- fp.close()
- printlog(" douyin begin replace game package v4 smali -------------------------------")
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- File.del_file(pkgV4Path)
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- Aapt_Util.createRFile(prj_path, False, pkgName)
- sdkRpath = "android/support/v7/appcompat"
- pkgRpath = pkgName.replace(".", "/")
- sdkAbsoluteRpath = "%s/smali_classes3/%s" % (prj_path, sdkRpath)
- pkgAbsoluteRpath = "%s/smali/%s" % (prj_path, pkgRpath)
- Replace.createRFile2Sdk(pkgAbsoluteRpath, sdkAbsoluteRpath, pkgRpath, sdkRpath)
- pass
- def MoMoYuReplace(prj_path, dir_split, key, value):
- xml_path = "%s/res/values/strings.xml" % prj_path
- Replace.replaceXmlValue(xml_path, key, value)
- pass
- def QuxuanReplace(prj_path, dir_split, key, value):
- if key == "app_id":
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- value = "Qdazzle_%s" % value
- Replace.replaceAM_Meta_data(prj_am_path, "CommonSDK_AppID", value)
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/com/qdazzle/sdk")
- if key == "app_key":
- prj_am_path = "%s/AndroidManifest.xml" % prj_path
- value = "Qdazzle_%s" % value
- Replace.replaceAM_Meta_data(prj_am_path, "CommonSDK_AppKey", value)
- pass
- def MuMuReplace(prj_path, dir_split, key, value):
- if key == "YOFUN_APP_ID":
- printlog("specail replace : MuMuReplace")
- splashactivity = "com.yythird.sdk.SplashActivity"
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- prj_param = "%s/assets/YyrhParam.cnf" % prj_path
- game_activity = Replace.replaceGameActivityLaunchAttribute(splashactivity, prj_am_path)
- printlog("GAMEACTIVITY :%s" % game_activity)
- Replace.replaceAssets_Param(prj_param, "GAMEACTIVITY", game_activity)
- pass
- def HeFengReplace(prj_path, dir_split, key, value):
- if key == "ver":
- printlog("specail replace : HeFengReplace")
- printlog("path hf.properties :%s/assets/hf.properties" % prj_path)
- Replace.replaceAssets_Param("%s/assets/hf.properties" % prj_path, "agent", value)
- pass
- def ShengBenFuliReplace(prj_path, dir_split, key, value):
- if key == "appid":
- printlog("specail replace : ShengBenFuliReplace")
- splash_activity = "com.fysdk.activity.FyGuideActivity"
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- namespace = '{http://schemas.android.com/apk/res/android}'
- ET.register_namespace('android', "http://schemas.android.com/apk/res/android")
- tree = ET.parse(prj_am_path)
- activitys = tree.getroot().find("application").findall("activity")
- for activity in activitys:
- filters = activity.findall('intent-filter')
- for filter in filters:
- categorys = filter.findall('category')
- actions = filter.findall('action')
- for category in categorys:
- category_name = category.attrib[namespace + "name"]
- if category_name == "android.intent.category.LAUNCHER":
- action_name = activity.attrib[namespace + "name"]
- if action_name != splash_activity:
- printlog("delete :%s" % category_name)
- category.attrib[namespace + "name"] = "android.intent.category.DEFAULT"
- printlog("LAUNCHER replace DEFAULT :%s" % category.attrib[namespace + "name"])
- for action in actions:
- action_name = action.attrib[namespace + "name"]
- if action_name == "android.intent.action.MAIN":
- printlog("delete :%s" % action_name)
- action.attrib[namespace + "name"] = "game.MAIN"
- tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
- pass
- def MuXueReplace(prj_path, dir_split, key, value):
- printlog("specail replace : MuXueReplace")
- Replace.replaceAssets_Param("%s/assets/gs.properties" % prj_path, key, value)
- pass
- def QiYouReplace(prj_path, dir_split, key, value):
- if (key == "blgame_gameid"):
- prj_am_path = prj_path + dir_split + "AndroidManifest.xml"
- pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- pkgV4Path = "%s/smali/android/support/design" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/7you/7you/smali/android/support/design" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- Aapt_Util.createRFile(prj_path, False, pkgName)
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/android/support/v7/appcompat")
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/android/support/design")
- GeneralModifySmali.modifyRfileIdSmali(prj_path, "/smali/android/support/v7/cardview")
- pass
- def YueWanReplace(prj_path, dir_split, key, value):
- printlog("specail replace : YueWanReplace")
- if (key == "J_GAME_ID"):
- sdk_root_dir = apk_utils.getCutSdkRootHome()
- printlog(" YueWanReplace begin replace game package v4 smali -------------------------------")
- pkgV4Path = "%s/smali/android/support/v4" % prj_path
- printlog("pkgV4Path:%s" % pkgV4Path)
- sdkV4Path = "%s/yuewan/yuewan/smali/android/support/v4" % sdk_root_dir
- printlog("sdkV4Path:%s" % sdkV4Path)
- if os.path.exists(pkgV4Path):
- File.copyAllFile(sdkV4Path, pkgV4Path)
- pass
- def ShengYueReplace(prj_path, dir_split, key, value):
- printlog("specail replace : ShengYueReplace")
- jsonFilePath = prj_path + dir_split + "assets" + dir_split + "UUConfig.json"
- Replace.replaceJsonValue(jsonFilePath, "", key, value)
- pass
- def JiZhiHuiReplace(prj_path, dir_split, key, value):
- printlog("specail replace : JiZhiHuiReplace")
- config_path = "%s/assets/xggameinfo.txt" % prj_path
- with open(config_path, "r") as f:
- content = f.read()
- json_data = json.loads(content)
- json_data[key] = value
- with open(config_path, "w") as f:
- f.write(json.dumps(json_data))
- def JiMiReplace(prj_path, dir_split, key, value):
- Replace.replaceAssets_Param("%s/assets/jmhy.properties" % prj_path, key, value)
- specialReplace = {
- "lenovo": LenovoReplace,
- "baidu": BaiduReplace,
- "wandoujia": WandoujiaReplace,
- "qh360": QihuReplace,
- "oppo": OppoReplace,
- "oppoml": OppoMlReplace,
- "chongchong": ChongchongReplace,
- "yingyongbao": YYBReplace,
- "downjoy": downjoyReplace,
- "huawei": HuaweiReplace,
- "anzhi": AnzhiReplace,
- "leshi": LeshiReplace,
- "quick": QuickReplace,
- "guopan": GuopanReplace,
- "ljsdk": LjsdkReplace,
- "uc": UcsdkReplace,
- "xiaomi": XiaomisdkReplace,
- "hnshengben": ShengbensdkReplace,
- "jk": JinkuosdkReplace,
- "hd": HdhdsdkReplace,
- "samsung": SamsungReplace,
- "ttyy": TTReplace,
- "yxf": YXFReplace,
- "vivo": VivosdkReplace,
- "3011": XTsdkReplace,
- "ddt": DDTsdkReplace,
- "wanka": WankaReplace,
- "ddd": DDDReplace,
- "lzyx": LZYXReplace,
- "ws": WSReplace,
- "xb": XBReplace,
- "youdian": YoudianReplace,
- "x7sy": Xiao7Replace,
- "nwanka": NwanKaReplace,
- "mbaidu": MBaiduReplace,
- "shenshou": ShenshouReplace,
- "dyyx": DaYanReplace,
- "dl": DaLanReplace,
- "ksyx": KSyxReplace,
- "llhy": LlhyReplace,
- "hnqs": HnqsReplace,
- "sogou": SogouReplace,
- "jrtt": JinRiTouTiaoReplace,
- "fq": FengQiReplace,
- "bs": BlueStackReplace,
- "simo": SiMoReplace,
- "cl": ChenLongReplace,
- "qianmian": JinRiTouTiaoReplace,
- "jiuzi": JiuZiReplace,
- "bingniao": BingNiaoReplace,
- "bingcheng": BingChengReplace,
- "sxhy": SuixingHuYuReplace,
- "shouqu": ShouQuReplace,
- "hnqj": HaiNanQiJingReplace,
- "hg": HongGuoReplace,
- "baize": BaizeReplace,
- "yx": YanXinReplace,
- "zshy": ZhangShangHuYuReplace,
- "xiyou": XiYouWangReplace,
- "xunlei": XunLeiReplace,
- "canlong": CanLongReplace,
- "shxy": ShangHaiXiYuanReplace,
- "mixsdk": YuanYouRongHeReplace,
- "bale": BaLeReplace,
- "7pa": QiPaReplace,
- "dymmy": MoMoYuReplace,
- "dyly": DouyinReplace,
- "qx": QuxuanReplace,
- "wymumu": MuMuReplace,
- "hf": HeFengReplace,
- "sbfl": ShengBenFuliReplace,
- "muxue": MuXueReplace,
- "7you": QiYouReplace,
- "yuewan": YueWanReplace,
- "shengyue": ShengYueReplace,
- "jzh": JiZhiHuiReplace,
- "jmhy": JiMiReplace
- }
- def getSpecilReplace(sdk_name):
- if sdk_name in specialReplace:
- return specialReplace[sdk_name]
- else:
- return None
- pass
|