ChannelReplace.py 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564
  1. # -*-coding:utf-8-*-
  2. import os
  3. import xml.etree.ElementTree as ET
  4. import re
  5. import hashlib
  6. import shutil
  7. import json
  8. from print_log import printlog
  9. import contants, file_utils, Replace, apk_tool
  10. from xml.etree.ElementTree import Element
  11. androidNS = 'http://schemas.android.com/apk/res/android'
  12. namespace = '{' + androidNS + '}'
  13. # 联想
  14. def LenovoReplace(prj_path, key, value):
  15. if key == "OPENAPPID":
  16. # 替换联想id
  17. replaceLeonovoIdShell = 'sed -i "1,\\$s/lenovo_id/%s/g" %s/AndroidManifest.xml ' % (value, prj_path)
  18. printlog("replaceLeonovoIdShell: %s" % replaceLeonovoIdShell)
  19. os.system(replaceLeonovoIdShell)
  20. manifestRootExt = r'<application android:networkSecurityConfig="@xml/network_security_config"'
  21. replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
  22. printlog("LenovoReplace replace add application root point shell: %s" % replacePkgNameShell)
  23. os.system(replacePkgNameShell)
  24. pass
  25. # 豌豆荚
  26. def WandoujiaReplace(prj_path, key, value):
  27. printlog("specail replace : wdj")
  28. if key == "APPKEY_ID":
  29. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  30. printlog("prj_am_path :%s" % prj_am_path)
  31. lines = open(prj_am_path).readlines()
  32. fp = open(prj_am_path, 'w')
  33. for s in lines:
  34. if s.find("Wandoujia-PaySdk-") != -1:
  35. printlog("replace Wandoujia-PaySdk-%s" % value)
  36. s = re.sub('Wandoujia-PaySdk-.*\"', 'Wandoujia-PaySdk-' + value + '\"', s)
  37. fp.write(s)
  38. fp.close()
  39. pass
  40. # 虫虫
  41. def ChongchongReplace(prj_path, key, value):
  42. printlog("specail replace : Chongchong")
  43. if key == "app_id":
  44. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  45. printlog("prj_am_path :%s" % prj_am_path)
  46. lines = open(prj_am_path).readlines()
  47. fp = open(prj_am_path, 'w')
  48. for s in lines:
  49. if s.find("qqPay") != -1:
  50. printlog("replace qqPay:%s" % value)
  51. s = re.sub('qqPay.*\"', 'qqPay' + value + '\"', s)
  52. fp.write(s)
  53. fp.close()
  54. # 360
  55. def QihuReplace(prj_path, key, value):
  56. global appkey
  57. printlog("specail replace : 360")
  58. if key == "QHOPENSDK_APPKEY":
  59. replacePkgNameShell = 'sed -i "s/qihu_appkey/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
  60. printlog("QihuReplace replace qihu_appkey shell: %s" % replacePkgNameShell)
  61. os.system(replacePkgNameShell)
  62. if key == "QHOPENSDK_APPSECRET":
  63. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  64. appsecret = value
  65. metadatas = ET.parse(prj_am_path).getroot().find("application").findall("meta-data")
  66. for meta in metadatas:
  67. if meta.attrib["{http://schemas.android.com/apk/res/android}name"] == "QHOPENSDK_APPKEY":
  68. appkey = meta.attrib["{http://schemas.android.com/apk/res/android}value"]
  69. printlog("prj_am_path:%s" % prj_am_path)
  70. m = hashlib.md5()
  71. printlog("appsecret :%s" % appsecret)
  72. printlog("appkey: %s" % appkey)
  73. md5value = "%s#%s" % (appsecret, appkey)
  74. printlog("md5value :%s" % md5value)
  75. m.update(md5value.encode('utf-8'))
  76. privatekey = m.hexdigest()
  77. printlog("privatekey:%s" % privatekey)
  78. file_utils.replace_manifest_meta_data(prj_am_path, 'QHOPENSDK_PRIVATEKEY', privatekey)
  79. manifestRootExt = r'<application android:networkSecurityConfig="@xml/network_security_config"'
  80. replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
  81. printlog("qihu360 replace add application root point shell: %s" % replacePkgNameShell)
  82. os.system(replacePkgNameShell)
  83. pass
  84. def OppoReplace(prj_path, key, value):
  85. printlog("specail replace : oppo")
  86. if key == "APPKEY":
  87. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  88. printlog("prj_am_path: %s" % prj_am_path)
  89. # 替换app_key
  90. file_utils.replace_manifest_meta_data(prj_am_path, 'app_key', value)
  91. printlog("appkey: %s" % value)
  92. pass
  93. def OppoMlReplace(prj_path, key, value):
  94. printlog("specail replace : oppoml")
  95. if key == "APPKEY":
  96. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  97. printlog("prj_am_path: %s" % prj_am_path)
  98. # 替换app_key
  99. file_utils.replace_manifest_meta_data(prj_am_path, 'app_key', value)
  100. printlog("appkey: %s" % value)
  101. pass
  102. def downjoyReplace(prj_path, key, value):
  103. printlog("specail replace : downjoy")
  104. if key == "APP_ID":
  105. splash_activity = "com.downjoy.activity.SdkLoadActivity"
  106. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  107. game_activity = Replace.replace_game_launch_activity_attribute_to_default(splash_activity, prj_am_path)
  108. printlog(game_activity)
  109. file_utils.replace_manifest_meta_data(prj_am_path, 'CP_ACTIVITY', game_activity)
  110. lines = open(prj_am_path).readlines()
  111. fp = open(prj_am_path, 'w')
  112. for s in lines:
  113. if s.find("dcnngsdk") != -1:
  114. printlog("replace dcnngsdk:%s" % value)
  115. s = re.sub('dcnngsdk.*\"', 'dcnngsdk' + value + '\"', s)
  116. fp.write(s)
  117. fp.close()
  118. pass
  119. def YYBReplace(prj_path, key, value):
  120. if key == "QQ_APP_ID":
  121. # 替换qq app id
  122. replaceQQAPPIDShell = 'sed -i "s/qq_app_id/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
  123. printlog("yingyongbao qq app id shell: %s" % replaceQQAPPIDShell)
  124. os.system(replaceQQAPPIDShell)
  125. # 替换ysdkconf.ini
  126. printlog("path ysdkconfig.ini:%s/assets/ysdkconf.ini" % prj_path)
  127. file_utils.replace_assets_param("%s/assets/ysdkconf.ini" % prj_path, key, value)
  128. file_utils.replace_assets_param("%s/assets/ysdkconf.ini" % prj_path, "OFFER_ID", value)
  129. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  130. game_activity = Replace.get_lauch_activity_name(prj_path)
  131. file_utils.replace_manifest_meta_data(prj_am_path, 'MAIN_ACTIVITY', game_activity)
  132. if key == "WX_APP_ID":
  133. replaceWXAPPIDShell = 'sed -i "s/wx_app_id/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
  134. printlog("yingyongbao wx app id shell: %s" % replaceWXAPPIDShell)
  135. os.system(replaceWXAPPIDShell)
  136. # 替换ysdkconf.ini
  137. file_utils.replace_assets_param("%s/assets/ysdkconf.ini" % prj_path, key, value)
  138. if key == "IS_SAND_BOX":
  139. ysdk_sand_url = "https://ysdktest.qq.com"
  140. ysdk_online_url = "https://ysdk.qq.com"
  141. if value == "1":
  142. ysdk_url = ysdk_sand_url
  143. else:
  144. ysdk_url = ysdk_online_url
  145. file_utils.replace_assets_param("%s/assets/ysdkconf.ini" % prj_path, "YSDK_URL", ysdk_url)
  146. pass
  147. def HuaweiReplace(prj_path, key, value):
  148. if key == "APP_ID":
  149. replaceAppidShell = '/bin/sed -i "s/APP_ID/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
  150. printlog("huawei replace appid shell: %s" % replaceAppidShell)
  151. os.system(replaceAppidShell)
  152. Replace.modify_R_id_smali(prj_path, "/smali/com/huawei/android/hms/app")
  153. Replace.modify_R_id_smali(prj_path, "/smali/com/huawei/android/hms/game")
  154. Replace.modify_R_id_smali(prj_path, "/smali/com/huawei/hms/base/hmscoreinstaller")
  155. if key == "PAY_ID":
  156. replacePayidShell = '/bin/sed -i "s/PAY_ID/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
  157. printlog("huawei replace payid shell: %s" % replacePayidShell)
  158. os.system(replacePayidShell)
  159. pass
  160. def AnzhiReplace(prj_path, key, value):
  161. printlog("specail replace : anzhi")
  162. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  163. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  164. if key == "APP_KEY":
  165. lines = open(prj_am_path).readlines()
  166. fp = open(prj_am_path, 'w')
  167. for s in lines:
  168. if s.find("packagename") != -1:
  169. s = re.sub('packagename', pkgName, s)
  170. fp.write(s)
  171. fp.close()
  172. pass
  173. def GuopanReplace(prj_path, key, value):
  174. printlog("specail replace : guopan")
  175. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  176. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  177. if key == "APP_ID":
  178. lines = open(prj_am_path).readlines()
  179. fp = open(prj_am_path, 'w')
  180. for s in lines:
  181. if s.find("gp_packagename") != -1:
  182. s = re.sub('gp_packagename', pkgName + ".StubContentProvider", s)
  183. fp.write(s)
  184. fp.close()
  185. pass
  186. def LeshiReplace(prj_path, key, value):
  187. printlog("specail replace : leshi")
  188. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  189. if key == "LEPAY_APPID":
  190. file_utils.replace_manifest_meta_data(prj_am_path, 'lepay_appid', value)
  191. if key == "LEPAY_APPKEY":
  192. file_utils.replace_manifest_meta_data(prj_am_path, 'lepay_appkey', value)
  193. pass
  194. def QuickReplace(prj_path, key, value):
  195. printlog("specail replace : Quick")
  196. if key == "PRODUCT_CODE":
  197. splashactivity = "com.yythird.sdk.SplashActivity"
  198. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  199. prj_param = "%s/assets/YyrhParam.cnf" % prj_path
  200. game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
  201. printlog("GAMEACTIVITY :%s" % game_activity)
  202. file_utils.replace_assets_param(prj_param, "GAMEACTIVITY", game_activity)
  203. if key == "SDK_TYPE":
  204. printlog("merge qitian Smali")
  205. if value == "qitian":
  206. printlog("merge qitian Smali")
  207. sdk_root_dir = contants.channel_sdk_path
  208. ret = 0
  209. ret = ret | Replace.mergeDir("%s/quick/quick/qitian_smali" % sdk_root_dir, "%s/smali" % prj_path)
  210. pass
  211. def LjsdkReplace(prj_path, key, value):
  212. printlog("specail replace : LjsdkReplace")
  213. if key == "XMGAME_PRODUCT_CODE":
  214. prj_param = "%s/assets/param.cnf" % prj_path
  215. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  216. splashactivity = "third.sdk.SplashActivity"
  217. game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
  218. printlog("GAMEACTIVITY :%s" % game_activity)
  219. file_utils.replace_assets_param(prj_param, "GAMEACTIVITY", game_activity)
  220. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  221. pkgLine = 'package="' + pkgName + '"'
  222. printlog("pkgValue :%s" % pkgLine)
  223. addPkgLine = ' xmlns:tools="http://schemas.android.com/tools" '
  224. addPerLine = ' tools:ignore="ProtectedPermissions" '
  225. permissionName = 'android:name="android.permission.PACKAGE_USAGE_STATS"'
  226. lines = open(prj_am_path).readlines()
  227. fp = open(prj_am_path, 'w')
  228. for s in lines:
  229. if s.find(pkgLine) != -1:
  230. s = re.sub(pkgLine, pkgLine + addPkgLine, s)
  231. printlog("pkgLine :%s" % s)
  232. if s.find(permissionName) != -1:
  233. s = re.sub(permissionName, permissionName + addPerLine, s)
  234. printlog("permissionName :%s" % s)
  235. fp.write(s)
  236. fp.close()
  237. pass
  238. def UcsdkReplace(prj_path, key, value):
  239. printlog("specail replace : UcsdkReplace")
  240. if key == "GAME_ID":
  241. replaceGidShell = 'sed -i "s/GAME_ID/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
  242. printlog("uc replace GAME_ID shell: %s" % replaceGidShell)
  243. os.system(replaceGidShell)
  244. pass
  245. def XiaomisdkReplace(prj_path, key, value):
  246. printlog("specail replace : XiaomisdkReplace")
  247. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  248. if key == "APP_ID":
  249. # 获取包名
  250. sdk_root_dir = contants.channel_sdk_path
  251. Replace.modifyRfileSmaliPath("xiaomi", prj_path)
  252. printlog(" xiaomi begin replace game package v4 smali -------------------------------")
  253. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  254. printlog("pkgV4Path:%s" % pkgV4Path)
  255. sdkV4Path = "%s/xiaomi/xiaomi/smali/android/support/v4" % sdk_root_dir
  256. printlog("sdkV4Path:%s" % sdkV4Path)
  257. if os.path.exists(pkgV4Path):
  258. Replace.copyAllFile(sdkV4Path, pkgV4Path)
  259. pkgAnnotation = "%s/smali/android/support/annotation" % prj_path
  260. printlog("pkgV4Path:%s" % pkgAnnotation)
  261. sdkAnnotation = "%s/xiaomi/xiaomi/smali/android/support/annotation" % sdk_root_dir
  262. if os.path.exists(pkgAnnotation):
  263. Replace.copyAllFile(sdkAnnotation, pkgAnnotation)
  264. app_value = "mi_%s" % value
  265. file_utils.replace_manifest_meta_data(prj_am_path, 'miGameAppId', app_value)
  266. if key == "APP_KEY":
  267. key_value = "mi_%s" % value
  268. file_utils.replace_manifest_meta_data(prj_am_path, 'miGameAppKey', key_value)
  269. pass
  270. # 圣本
  271. def ShengbensdkReplace(prj_path, key, value):
  272. printlog("specail replace : ShengbensdkReplace")
  273. if key == "AGENT":
  274. jsonFilePath = os.path.join(prj_path, 'assets', 'hnsb_config.json')
  275. printlog("path hnsb_config.json :%s" % jsonFilePath)
  276. with open(jsonFilePath, 'r') as fp:
  277. jsonData = json.load(fp)
  278. jsonData['sdk']["ver"] = value
  279. newJsonData = jsonData
  280. fp.close()
  281. with open(jsonFilePath, 'w') as fp:
  282. json.dump(newJsonData, fp)
  283. fp.close()
  284. if key == "APP_ID":
  285. jsonFilePath = os.path.join(prj_path, 'assets', 'hnsb_config.json')
  286. with open(jsonFilePath, 'r') as fp:
  287. jsonData = json.load(fp)
  288. jsonData['sdk']["appid"] = value
  289. newJsonData = jsonData
  290. fp.close()
  291. with open(jsonFilePath, 'w') as fp:
  292. json.dump(newJsonData, fp)
  293. fp.close()
  294. pass
  295. def JinkuosdkReplace(prj_path, key, value):
  296. printlog("specail replace : JinkuosdkReplace")
  297. printlog("path yy.properties :%s/assets/u8_developer_config.properties" % prj_path)
  298. file_utils.replace_assets_param("%s/assets/u8_developer_config.properties" % prj_path, key, value)
  299. pass
  300. def SamsungReplace(prj_path, key, value):
  301. printlog("specail replace : SamsungReplace")
  302. if key == "APPV_KEY":
  303. ptKey = value[0:99]
  304. pvData = value[99:len(value)]
  305. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  306. printlog("prj_am_path: %s" % prj_am_path)
  307. # 替换app_key
  308. file_utils.replace_manifest_meta_data(prj_am_path, 'ptKey', ptKey)
  309. prj_param = "%s/assets/YyrhParam.cnf" % prj_path
  310. file_utils.replace_assets_param(prj_param, "pvData", pvData)
  311. pass
  312. def TTReplace(prj_path, key, value):
  313. printlog("specail replace : TTReplace")
  314. if key == "GAME_ID":
  315. file_utils.replace_assets_param("%s/assets/tt_game_sdk_opt.properties" % prj_path, "gameId", value)
  316. if key == "GAME_KEY":
  317. replaceKeyShell = 'sed -i "s/@WSX3edc/%s/g" %s/assets/TTGameSDKConfig.cfg' % (value, prj_path)
  318. printlog("replaceMainLineShell:%s" % replaceKeyShell)
  319. os.system(replaceKeyShell)
  320. pass
  321. def YXFReplace(prj_path, key, value):
  322. printlog("specail replace : YXFReplace")
  323. if key == "YGAPPID":
  324. replacePkgNameShell = '/bin/sed -i "1,\\$s/YXFAPPID/%s/g" %s/AndroidManifest.xml' % (value, prj_path)
  325. printlog("replacePkgNameShell:%s" % replacePkgNameShell)
  326. os.system(replacePkgNameShell)
  327. manifestRootExt = r'<application android:usesCleartextTraffic="true"'
  328. replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
  329. printlog("youxiFan replace add application root point shell: %s" % replacePkgNameShell)
  330. os.system(replacePkgNameShell)
  331. if key == "screenOrientation":
  332. sdk_root_dir = contants.channel_sdk_path
  333. if value == "screenOrientation:0":
  334. splash = "%s/yxf/yxf/extension/sp_landscape.png" % sdk_root_dir
  335. apkres = "%s/res/drawable/crash_screen.png" % prj_path
  336. shutil.copy(splash, apkres)
  337. if value == "screenOrientation:1":
  338. splash = "%s/yxf/yxf/extension/sp_portrait.png" % sdk_root_dir
  339. apkres = "%s/res/drawable/crash_screen.png" % prj_path
  340. shutil.copy(splash, apkres)
  341. pass
  342. def VivosdkReplace(prj_path, key, value):
  343. printlog("specail replace : VivosdkReplace")
  344. if key == "APP_ID":
  345. printlog("path supplierconfig.json :%s/assets/supplierconfig.json" % prj_path)
  346. replaceConfigShell = '/bin/sed -i "1,\\$s/APP_ID/%s/g" %s/assets/supplierconfig.json' % (value, prj_path)
  347. printlog("replaceConfigShell APP_ID:%s" % replaceConfigShell)
  348. os.system(replaceConfigShell)
  349. jsonFilePath = os.path.join(prj_path, 'assets', 'supplierconfig.json')
  350. printlog("path supplierconfig.json :%s" % jsonFilePath)
  351. with open(jsonFilePath, 'r') as fp:
  352. jsonData = json.load(fp)
  353. jsonData['supplier']["vivo"]["appid"] = value
  354. newJsonData = jsonData
  355. fp.close()
  356. with open(jsonFilePath, 'w') as fp:
  357. json.dump(newJsonData, fp)
  358. fp.close()
  359. pass
  360. def XTsdkReplace(prj_path, key, value):
  361. printlog("specail replace : Xiantu3011sdkReplace")
  362. if key == "GAME_ID":
  363. # 获取包名
  364. Replace.modifyRfileSmaliPath("3011", prj_path)
  365. pass
  366. def DDTsdkReplace(prj_path, key, value):
  367. printlog("specail replace : DDTsdkReplace")
  368. if key == "APP_ID":
  369. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  370. splashactivity = "com.ddtsdk.ui.activity.MHPerActivity"
  371. game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
  372. printlog("GAMEACTIVITY :%s" % game_activity)
  373. file_utils.replace_manifest_meta_data(prj_am_path, "mainAct", game_activity)
  374. if key == "agent":
  375. file_utils.replace_assets_param("%s/assets/ddt.properties" % prj_path, key, value)
  376. pass
  377. def QiyuReplace(prj_path, key, value):
  378. if key == "APP_ID":
  379. manifestRootExt = r'<application android:usesCleartextTraffic="true"'
  380. replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
  381. printlog("QiyuReplace add application root point shell: %s" % replacePkgNameShell)
  382. os.system(replacePkgNameShell)
  383. pass
  384. def WankaReplace(prj_path, key, value):
  385. if key == "APPID":
  386. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  387. manifestRootExt = r'<application xmlns:tools="http://schemas.android.com/tools" tools:replace="android:theme,android:name"'
  388. replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
  389. printlog("WankaReplace replace add application root point shell: %s" % replacePkgNameShell)
  390. os.system(replacePkgNameShell)
  391. tree = ET.parse(prj_am_path)
  392. activitys = tree.getroot().find("application").findall("activity")
  393. for activity in activitys:
  394. filters = activity.findall('intent-filter')
  395. for filter in filters:
  396. categorys = filter.findall('category')
  397. for category in categorys:
  398. categoryname = category.attrib[namespace + "name"]
  399. if categoryname == "android.intent.category.LAUNCHER":
  400. element = Element('intent-filter')
  401. el1 = Element('action android:name="android.intent.action.VIEW"')
  402. el2 = Element('category android:name="android.intent.category.DEFAULT"')
  403. el3 = Element('category android:name="android.intent.category.BROWSABLE"')
  404. el4_value = 'data android:scheme="app%s"' % value
  405. el4 = Element(el4_value)
  406. element.append(el1)
  407. element.append(el2)
  408. element.append(el3)
  409. element.append(el4)
  410. activity.append(element)
  411. activity.set(namespace + 'launchMode', "singleTask")
  412. tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
  413. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  414. apk_tool.create_R_file(prj_path, pkgName)
  415. sdkRpath = "android/support/v7/appcompat"
  416. pkgRpath = pkgName.replace(".", "/")
  417. sdkAbsoluteRpath = "%s/smali/%s" % (prj_path, sdkRpath)
  418. pkgAbsoluteRpath = "%s/smali/%s" % (prj_path, pkgRpath)
  419. Replace.createRFile2Sdk(pkgAbsoluteRpath, sdkAbsoluteRpath, pkgRpath, sdkRpath)
  420. pass
  421. def DDDReplace(prj_path, key, value):
  422. if key == "channelId":
  423. file_utils.replace_assets_param("%s/assets/dingdd.properties" % prj_path, 'channelId', value)
  424. if key == "adId":
  425. file_utils.replace_assets_param("%s/assets/dingdd.properties" % prj_path, 'adId', value)
  426. if key == "adFlag":
  427. file_utils.replace_assets_param("%s/assets/dingdd.properties" % prj_path, 'adFlag', value)
  428. pass
  429. def LZYXReplace(prj_path, key, value):
  430. if key == "ML_Channel":
  431. file_utils.replace_assets_param("%s/assets/mlgame_developer_config.properties" % prj_path, 'ML_Channel', value)
  432. if key == "ML_APPKEY":
  433. file_utils.replace_assets_param("%s/assets/mlgame_developer_config.properties" % prj_path, 'ML_APPKEY', value)
  434. pass
  435. def WSReplace(prj_path, key, value):
  436. if key == "HS_APPID":
  437. manifestRootExt = r'<application android:networkSecurityConfig="@xml/huosdk_network_security_config"'
  438. replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
  439. printlog("qihu360 replace add application root point shell: %s" % replacePkgNameShell)
  440. os.system(replacePkgNameShell)
  441. pass
  442. def XBReplace(prj_path, key, value):
  443. if key == "GID":
  444. printlog("path gameshaiApp.ini :%s/assets/gameshaiApp.ini" % prj_path)
  445. file_utils.replace_assets_param("%s/assets/gameshaiApp.ini" % prj_path, 'gid', value)
  446. if key == "PID":
  447. printlog("path gameshaiApp.ini :%s/assets/gameshaiApp.ini" % prj_path)
  448. file_utils.replace_assets_param("%s/assets/gameshaiApp.ini" % prj_path, 'pid', value)
  449. pass
  450. def YoudianReplace(prj_path, key, value):
  451. if key == "APPID":
  452. apk_tool.create_R_file(prj_path, ET.parse("%s/AndroidManifest.xml" % prj_path).getroot().attrib["package"])
  453. pass
  454. def Xiao7Replace(prj_path, key, value):
  455. if key == "APPKEY":
  456. Replace.modify_R_id_smali(prj_path, "/smali_classes2/com/smwl/smsdk")
  457. printlog(" Xiao7Replace begin replace game package v4 smali -------------------------------")
  458. sdk_root_dir = contants.channel_sdk_path
  459. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  460. printlog("pkgV4Path:%s" % pkgV4Path)
  461. sdkV4Path = "%s/x7sy/x7sy/smali/android/support/v4" % sdk_root_dir
  462. printlog("sdkV4Path:%s" % sdkV4Path)
  463. if os.path.exists(pkgV4Path):
  464. Replace.copyAllFile(sdkV4Path, pkgV4Path)
  465. pkgName = ET.parse("%s/AndroidManifest.xml" % prj_path).getroot().attrib["package"]
  466. apk_tool.create_R_file(prj_path, pkgName)
  467. pkgName = "android.support.constraint"
  468. apk_tool.create_R_file(prj_path, pkgName)
  469. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  470. prj_param = "%s/assets/YyrhParam.cnf" % prj_path
  471. splashactivity = "com.yythird.sdk.SplashActivity"
  472. game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
  473. file_utils.replace_assets_param(prj_param, "GAME_ACTIVITY", game_activity)
  474. printlog("xiaoqi GAME_ACTIVITY :%s" % game_activity)
  475. pass
  476. def NwanKaReplace(prj_path, key, value):
  477. if key == "channelId":
  478. file_utils.replace_assets_param("%s/assets/wk.properties" % prj_path, 'channelId', value)
  479. if key == "adId":
  480. file_utils.replace_assets_param("%s/assets/wk.properties" % prj_path, 'adId', value)
  481. if key == "adFlag":
  482. file_utils.replace_assets_param("%s/assets/wk.properties" % prj_path, 'adFlag', value)
  483. manifestRootExt = r'<application xmlns:tools="http://schemas.android.com/tools" tools:replace="android:theme,android:name"'
  484. replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
  485. printlog("WankaReplace replace add application root point shell: %s" % replacePkgNameShell)
  486. os.system(replacePkgNameShell)
  487. pass
  488. def MBaiduReplace(prj_path, key, value):
  489. if key == "APP_ID":
  490. manifestRootExt = r'<application android:networkSecurityConfig="@xml/network_security_config"'
  491. replacePkgNameShell = "sed -i 's!<application!%s!g' %s/AndroidManifest.xml" % (manifestRootExt, prj_path)
  492. printlog("MbaiduReplace replace add application root point shell: %s" % replacePkgNameShell)
  493. os.system(replacePkgNameShell)
  494. Replace.modify_R_id_smali(prj_path, "/smali/com/baidu/passport/sapi2")
  495. pass
  496. def ShenshouReplace(prj_path, key, value):
  497. if key == "BALANCENAME":
  498. prj_style_path = os.path.join(prj_path, 'res', 'values-v28', 'styles.xml')
  499. printlog("prj_style_path: %s" % prj_style_path)
  500. Replace.safeFileDelete(prj_style_path)
  501. pass
  502. def DaYanReplace(prj_path, key, value):
  503. if key == "GD":
  504. filepath = "%s/assets/sdkchannel.txt" % prj_path
  505. replacePdShell = 'sed -i "s#%s#%s#g" %s' % ("PD", value, filepath)
  506. printlog(replacePdShell)
  507. os.system(replacePdShell)
  508. pass
  509. def DaLanReplace(prj_path, key, value):
  510. printlog("specail replace : DaLanReplace")
  511. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  512. if key == "DL_APPID":
  513. splashactivity = "com.dalan.dl_assembly.SplashScreenActivity"
  514. game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
  515. printlog("GAMEACTIVITY :%s" % game_activity)
  516. file_utils.replace_manifest_meta_data(prj_am_path, "dalan_union_main_activity", game_activity)
  517. pass
  518. def KSyxReplace(prj_path, key, value):
  519. if key == "kwai_app_id":
  520. file_utils.replace_assets_param("%s/assets/allin_developer_config.properties" % prj_path, 'kwai_app_id', value)
  521. printlog(" KSyxReplace begin replace game package v4 smali -------------------------------")
  522. sdk_root_dir = contants.channel_sdk_path
  523. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  524. printlog("pkgV4Path:%s" % pkgV4Path)
  525. sdkV4Path = "%s/ksyx/ksyx/smali/android/support/v4" % sdk_root_dir
  526. printlog("sdkV4Path:%s" % sdkV4Path)
  527. if os.path.exists(pkgV4Path):
  528. Replace.copyAllFile(sdkV4Path, pkgV4Path)
  529. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  530. Replace.replace_manifest_allow_backup(prj_am_path)
  531. pass
  532. def LlhyReplace(prj_path, key, value):
  533. printlog("specail replace : LlhyReplace")
  534. if key == "LLHY_APP_ID":
  535. metaKey = "unityplayer.SkipPermissionsDialog"
  536. file_utils.replace_manifest_meta_data("%s/AndroidManifest.xml" % prj_path, metaKey,
  537. "true")
  538. pass
  539. def HnqsReplace(prj_path, key, value):
  540. printlog("specail replace : HnqsReplace")
  541. if key == "agent":
  542. file_utils.replace_assets_param("%s/assets/jmhy.properties" % prj_path, 'agent', value)
  543. metaKey = "unityplayer.SkipPermissionsDialog"
  544. file_utils.replace_manifest_meta_data("%s/AndroidManifest.xml" % prj_path, metaKey,
  545. "true")
  546. sdk_root_dir = contants.channel_sdk_path
  547. sdk_smali_dir = "%s/hnqs/hnqs/extension/yyrh" % sdk_root_dir
  548. temp_old_smali_dir = "%s/smali/com/yyrh" % prj_path
  549. if os.path.exists(sdk_smali_dir):
  550. Replace.copyAllFile(sdk_smali_dir, temp_old_smali_dir)
  551. pass
  552. def SogouReplace(prj_path, key, value):
  553. if key == "GID":
  554. printlog(" SogouReplace begin replace game package v4 smali -------------------------------")
  555. sdk_root_dir = contants.channel_sdk_path
  556. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  557. printlog("pkgV4Path:%s" % pkgV4Path)
  558. sdkV4Path = "%s/sogou/sogou/smali/android/support/v4" % sdk_root_dir
  559. printlog("sdkV4Path:%s" % sdkV4Path)
  560. if os.path.exists(pkgV4Path):
  561. Replace.copyAllFile(sdkV4Path, pkgV4Path)
  562. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  563. Replace.replace_manifest_allow_backup(prj_am_path)
  564. pass
  565. def JinRiTouTiaoReplace(prj_path, key, value):
  566. jsonFilePath = os.path.join(prj_path, 'assets', 'config.json')
  567. if key == 'APP_ID':
  568. with open(jsonFilePath, 'r') as fp:
  569. jsonData = json.load(fp)
  570. jsonData['app']["app_id"] = value
  571. jsonData['app']['main_activity'] = Replace.get_lauch_activity_name(prj_path)
  572. orientation = Replace.get_lauch_activity_screen_orientation(prj_path)
  573. if orientation == "landscape" or orientation == "sensorLandscape":
  574. screen_orientation = "sensorLandscape"
  575. else:
  576. screen_orientation = "sensorPortrait"
  577. jsonData['app']['screen_orientation'] = screen_orientation
  578. newJsonData = jsonData
  579. fp.close()
  580. with open(jsonFilePath, 'w') as fp:
  581. json.dump(newJsonData, fp)
  582. fp.close()
  583. Replace.modify_R_id_smali(prj_path, "/smali/game_sdk/packers/rocket_sdk")
  584. Replace.modify_R_id_smali(prj_path, "/smali_classes2/game_sdk/packers/rocket_sdk")
  585. Replace.modify_R_id_smali(prj_path, "/smali/androidx/navigation/ui")
  586. Replace.modify_R_id_smali(prj_path, "/smali_classes3/android/support/design")
  587. Replace.modify_R_id_smali(prj_path, "/smali_classes3/android/support/v7/appcompat")
  588. sdk_root_dir = contants.channel_sdk_path
  589. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  590. printlog("pkgV4Path:%s" % pkgV4Path)
  591. sdkV4Path = "%s/jrtt/jrtt/smali_classes3/android/support/v4" % sdk_root_dir
  592. printlog("sdkV4Path:%s" % sdkV4Path)
  593. if os.path.exists(pkgV4Path):
  594. Replace.copyAllFile(sdkV4Path, pkgV4Path)
  595. modifyJrttV7ResIdSmali(prj_path)
  596. else:
  597. Replace.replace_json_value(jsonFilePath, "app", key, value)
  598. pass
  599. def modifyJrttV7ResIdSmali(prj_path):
  600. pkgV7AttrPath = "%s/smali_classes3/android/support/v7/appcompat/R$attr.smali" % prj_path
  601. if os.path.exists(pkgV7AttrPath):
  602. pkgV7StyleablePath = r"%s/smali_classes3/android/support/v7/appcompat/R\$styleable.smali" % prj_path
  603. data = ["windowActionBar:I", "windowActionBarOverlay:I", "windowActionModeOverlay:I",
  604. "windowFixedHeightMajor:I", "windowFixedHeightMinor:I", "windowFixedWidthMajor:I",
  605. "windowFixedWidthMinor:I", "windowMinWidthMajor:I", "windowMinWidthMinor:I", "windowNoTitle:I"]
  606. with open(pkgV7AttrPath, "r") as f:
  607. for line in f.readlines():
  608. if data[0] in line:
  609. value = line.split("=")
  610. replaceShell = 'sed -i "s/0x7f040245/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
  611. os.system(replaceShell)
  612. elif data[1] in line:
  613. value = line.split("=")
  614. replaceShell = 'sed -i "s/0x7f040246/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
  615. os.system(replaceShell)
  616. elif data[2] in line:
  617. value = line.split("=")
  618. replaceShell = 'sed -i "s/0x7f040247/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
  619. os.system(replaceShell)
  620. elif data[3] in line:
  621. value = line.split("=")
  622. replaceShell = 'sed -i "s/0x7f040248/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
  623. os.system(replaceShell)
  624. elif data[4] in line:
  625. value = line.split("=")
  626. replaceShell = 'sed -i "s/0x7f040249/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
  627. os.system(replaceShell)
  628. elif data[5] in line:
  629. value = line.split("=")
  630. replaceShell = 'sed -i "s/0x7f04024a/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
  631. os.system(replaceShell)
  632. elif data[6] in line:
  633. value = line.split("=")
  634. replaceShell = 'sed -i "s/0x7f04024b/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
  635. os.system(replaceShell)
  636. elif data[7] in line:
  637. value = line.split("=")
  638. replaceShell = 'sed -i "s/0x7f04024c/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
  639. os.system(replaceShell)
  640. elif data[8] in line:
  641. value = line.split("=")
  642. replaceShell = 'sed -i "s/0x7f04024d/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
  643. os.system(replaceShell)
  644. elif data[9] in line:
  645. value = line.split("=")
  646. replaceShell = 'sed -i "s/0x7f04024e/%s/g" %s' % (value[1].strip(), pkgV7StyleablePath)
  647. os.system(replaceShell)
  648. pass
  649. def FengQiReplace(prj_path, key, value):
  650. if key == "channelId" or key == "adId" or key == "adFlag":
  651. # 替换fq.properties
  652. printlog("path fq.properties:%s/assets/fq.properties" % prj_path)
  653. file_utils.replace_assets_param("%s/assets/fq.properties" % prj_path, key, value)
  654. pass
  655. pass
  656. def BlueStackReplace(prj_path, key, value):
  657. if key == "APP_ID":
  658. replaceBlueStackIdShell = 'sed -i "1,\\$s/APP_ID/%s/g" %s/assets/BSSDKConfig.xml ' % (value, prj_path)
  659. printlog("replaceBlueStackIdShell: %s" % replaceBlueStackIdShell)
  660. os.system(replaceBlueStackIdShell)
  661. pass
  662. # 司墨
  663. def SiMoReplace(prj_path, key, value):
  664. if key == "APP_ID":
  665. config_path = prj_path + '/assets/SIMgame_config.xml'
  666. tree = ET.parse(config_path)
  667. root = tree.getroot()
  668. for elem in root.iter('appid'):
  669. elem.text = value
  670. tree.write(config_path, "UTF-8", xml_declaration=True, method='xml')
  671. pass
  672. # 乘龙
  673. def ChenLongReplace(prj_path, key, value):
  674. if key == "CL_PID":
  675. file_utils.replace_assets_param("%s/assets/_cl_developer_config.properties" % prj_path, 'CL_PID', value)
  676. if key == "CL_KEY":
  677. file_utils.replace_assets_param("%s/assets/_cl_developer_config.properties" % prj_path, 'CL_KEY', value)
  678. if key == "CL_DEBUG_GD":
  679. file_utils.replace_assets_param("%s/assets/_cl_developer_config.properties" % prj_path, 'CL_DEBUG_GD', value)
  680. pass
  681. def JiuZiReplace(prj_path, key, value):
  682. printlog("specail replace : JiuZiReplace")
  683. if key == "gid":
  684. prj_param = "%s/assets/YyrhParam.cnf" % prj_path
  685. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  686. splash_activity = "com.yythird.sdk.SplashActivity"
  687. game_activity = Replace.replace_game_launch_activity_attribute_to_default(splash_activity, prj_am_path)
  688. printlog("GAMEACTIVITY :%s" % game_activity)
  689. file_utils.replace_assets_param(prj_param, "GAMEACTIVITY", game_activity)
  690. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  691. apk_tool.create_R_file(prj_path, pkgName)
  692. Replace.modify_R_id_smali(prj_path, "/smali/com/jzyx/sdk")
  693. pass
  694. def BingNiaoReplace(prj_path, key, value):
  695. printlog("specail replace : DaLanReplace")
  696. if key == "YH_GAME_ID":
  697. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  698. splashactivity = "prj.iyinghun.platform.sdk.SplashScreenActivity"
  699. game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
  700. printlog("GAMEACTIVITY :%s" % game_activity)
  701. file_utils.replace_manifest_meta_data(prj_am_path, "prj.chameleon.intent.main", game_activity)
  702. pass
  703. def BingChengReplace(prj_path, key, value):
  704. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  705. ET.register_namespace('android', androidNS)
  706. if key == "BC_GAME_ID":
  707. tree = ET.parse(prj_am_path)
  708. pkgName = tree.getroot().attrib["package"]
  709. activitys = tree.getroot().find("application").findall("activity")
  710. for activity in activitys:
  711. filters = activity.findall('intent-filter')
  712. for filter in filters:
  713. categorys = filter.findall('category')
  714. for category in categorys:
  715. categoryname = category.attrib[namespace + "name"]
  716. if categoryname == "android.intent.category.LAUNCHER":
  717. element = Element('intent-filter')
  718. el1 = Element('action android:name="android.intent.action.VIEW"')
  719. el2 = Element('category android:name="android.intent.category.DEFAULT"')
  720. el3 = Element('category android:name="android.intent.category.BROWSABLE"')
  721. el4_value = 'data android:host="%s" android:scheme="%s"' % (value, pkgName)
  722. el4 = Element(el4_value)
  723. element.append(el1)
  724. element.append(el2)
  725. element.append(el3)
  726. element.append(el4)
  727. activity.append(element)
  728. tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
  729. def SuixingHuYuReplace(prj_path, key, value):
  730. if key == "game_id":
  731. file_utils.replace_assets_param("%s/assets/suixin/suixin_sdk.ini" % prj_path, key, value)
  732. if key == "pid":
  733. file_utils.replace_assets_param("%s/assets/suixin/suixin_sdk.ini" % prj_path, key, value)
  734. if key == "is_land":
  735. file_utils.replace_assets_param("%s/assets/suixin/suixin_sdk.ini" % prj_path, key, value)
  736. pass
  737. def ShouQuReplace(prj_path, key, value):
  738. config_path = "%s/assets/sqsdk_config" % prj_path
  739. with open(config_path, "r") as f:
  740. content = f.read()
  741. json_data = json.loads(content)
  742. json_data[key] = value
  743. with open(config_path, "w") as f:
  744. f.write(json.dumps(json_data))
  745. if key == "app_key":
  746. manifest_path = os.path.join(prj_path, 'AndroidManifest.xml')
  747. param_cnf = "%s/assets/YyrhParam.cnf" % prj_path
  748. splash_activity = "com.yythird.sdk.SplashActivity"
  749. game_activity = Replace.replace_game_launch_activity_attribute_to_default(splash_activity, manifest_path)
  750. file_utils.replace_assets_param(param_cnf, "GAMEACTIVITY", game_activity)
  751. printlog("GAMEACTIVITY :%s" % game_activity)
  752. def HaiNanQiJingReplace(prj_path, key, value):
  753. if key == "PACKAGE_TAG":
  754. sdk_root_dir = contants.channel_sdk_path
  755. sdkSmaliPath = "%s/hnqj/hnqj/smali/com" % sdk_root_dir
  756. pkgSmaliPath = "%s/smali/com" % prj_path
  757. printlog("sdkSmaliPath :%s" % sdkSmaliPath)
  758. printlog("pkgSmaliPath :%s" % pkgSmaliPath)
  759. if os.path.exists(pkgSmaliPath):
  760. Replace.copyAllFile(sdkSmaliPath, pkgSmaliPath)
  761. if contants.isTestEnvironment():
  762. key = "https://fxsy.qijinghao.com"
  763. value = "http://testsdkapi.yyxxgame.com"
  764. file = "%s/smali/com/yyrh/c/a.smali" % prj_path
  765. Replace.replaceKeyword(key, value, file)
  766. file = "%s/smali/com/yyrh/ui/a.smali" % prj_path
  767. Replace.replaceKeyword(key, value, file)
  768. file = "%s/smali/com/yyrh/a/d.smali" % prj_path
  769. Replace.replaceKeyword(key, value, file)
  770. file = "%s/smali/com/yyrh/sdk/SDKEntry.smali" % prj_path
  771. Replace.replaceKeyword(key, value, file)
  772. pass
  773. def HongGuoReplace(prj_path, key, value):
  774. config_path = "%s/assets/gameInfo.json" % prj_path
  775. with open(config_path, "r") as f:
  776. content = f.read()
  777. json_data = json.loads(content)
  778. json_data[key] = value
  779. with open(config_path, "w") as f:
  780. f.write(json.dumps(json_data))
  781. if key == "game_id":
  782. manifest_path = os.path.join(prj_path, 'AndroidManifest.xml')
  783. param_cnf = "%s/assets/YyrhParam.cnf" % prj_path
  784. splash_activity = "com.yythird.sdk.SplashActivity"
  785. game_activity = Replace.replace_game_launch_activity_attribute_to_default(splash_activity, manifest_path)
  786. file_utils.replace_assets_param(param_cnf, "GAMEACTIVITY", game_activity)
  787. sdk_root_dir = contants.channel_sdk_path
  788. printlog(" HongGuoReplace begin replace game package v4 smali -------------------------------")
  789. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  790. printlog("pkgV4Path:%s" % pkgV4Path)
  791. sdkV4Path = "%s/hg/hg/smali/android/support/v4" % sdk_root_dir
  792. printlog("sdkV4Path:%s" % sdkV4Path)
  793. if os.path.exists(pkgV4Path):
  794. Replace.copyAllFile(sdkV4Path, pkgV4Path)
  795. pass
  796. def BaizeReplace(prj_path, key, value):
  797. if key == "APP_ID":
  798. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  799. param_cnf = "%s/assets/YyrhParam.cnf" % prj_path
  800. splashactivity = "com.yythird.sdk.SplashActivity"
  801. game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
  802. printlog("GAMEACTIVITY :%s" % game_activity)
  803. file_utils.replace_assets_param(param_cnf, "GAMEACTIVITY", game_activity)
  804. pass
  805. def YanXinReplace(prj_path, key, value):
  806. if key == "ProductCode":
  807. Replace.modifyRfileSmaliPath("yx", prj_path)
  808. pass
  809. def ZhangShangHuYuReplace(prj_path, key, value):
  810. file_utils.replace_assets_param("%s/assets/yy.properties" % prj_path, key, value)
  811. if key == "channelId":
  812. sdk_root_dir = contants.channel_sdk_path
  813. printlog(" ZhangShangHuYuReplace begin replace game package v4 smali -------------------------------")
  814. pkgV4Path = "%s/smali/android/support/v7" % prj_path
  815. printlog("pkgV4Path:%s" % pkgV4Path)
  816. sdkV4Path = "%s/zshy/zshy/smali/android/support/v7" % sdk_root_dir
  817. printlog("sdkV4Path:%s" % sdkV4Path)
  818. if os.path.exists(pkgV4Path):
  819. Replace.copyAllFile(sdkV4Path, pkgV4Path)
  820. Replace.modify_R_id_smali(prj_path, "/smali/android/support/v7/cardview")
  821. printlog(" HongGuoReplace begin replace game package v4 smali -------------------------------")
  822. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  823. printlog("pkgV4Path:%s" % pkgV4Path)
  824. sdkV4Path = "%s/zshy/zshy/smali/android/support/v4" % sdk_root_dir
  825. printlog("sdkV4Path:%s" % sdkV4Path)
  826. if os.path.exists(pkgV4Path):
  827. Replace.copyAllFile(sdkV4Path, pkgV4Path)
  828. Replace.modify_R_id_smali(prj_path, "/smali/com/zshy/zshysdk")
  829. Replace.modifyRfileSmaliPath("zshy", prj_path)
  830. pass
  831. def XiYouWangReplace(prj_path, key, value):
  832. file_utils.replace_assets_param("%s/assets/xy_developer_config.properties" % prj_path, key, value)
  833. if key == "XY_APP_ID":
  834. splash_activity = "com.xiyou.sdk.XiYouSplashActivity"
  835. manifest_path = os.path.join(prj_path, 'AndroidManifest.xml')
  836. game_activity = Replace.replace_game_launch_activity_attribute_to_default(splash_activity, manifest_path)
  837. file_utils.replace_manifest_meta_data(manifest_path, 'XY_GAME_MAIN_ACTIVITY_NAME', game_activity)
  838. sdk_root_dir = contants.channel_sdk_path
  839. printlog(" xiyouwang begin replace game package v4 smali -------------------------------")
  840. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  841. printlog("pkgV4Path:%s" % pkgV4Path)
  842. sdkV4Path = "%s/xiyou/xiyou/smali/android/support/v4" % sdk_root_dir
  843. printlog("sdkV4Path:%s" % sdkV4Path)
  844. if os.path.exists(pkgV4Path):
  845. Replace.copyAllFile(sdkV4Path, pkgV4Path)
  846. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  847. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  848. apk_tool.create_R_file(prj_path, pkgName)
  849. pass
  850. def XunLeiReplace(prj_path, key, value):
  851. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  852. ET.register_namespace('android', androidNS)
  853. if key == "schemeCallback":
  854. tree = ET.parse(prj_am_path)
  855. activitys = tree.getroot().find("application").findall("activity")
  856. for activity in activitys:
  857. activityName = activity.attrib[namespace + "name"]
  858. printlog("activityName:%s" % activityName)
  859. if activityName == "com.xovs.common.auth.processor.XLAuthBackActivity":
  860. filters = activity.findall('intent-filter')
  861. for filter in filters:
  862. datas = filter.findall('data')
  863. for data in datas:
  864. printlog("data:%s" % data)
  865. data.set(namespace + "scheme", value)
  866. tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
  867. pass
  868. def CanLongReplace(prj_path, key, value):
  869. if key == "PRODUCT_CODE":
  870. Replace.modifyRfileSmaliPath("canlong", prj_path)
  871. pass
  872. def ShangHaiXiYuanReplace(prj_path, key, value):
  873. if key == "PACKAGE_TAG":
  874. sdk_root_dir = contants.channel_sdk_path
  875. sdkSmaliPath = "%s/shxy/shxy/smali/com/yyrh" % sdk_root_dir
  876. pkgSmaliPath = "%s/smali/com/yyrh" % prj_path
  877. printlog("sdkSmaliPath :%s" % sdkSmaliPath)
  878. printlog("pkgSmaliPath :%s" % pkgSmaliPath)
  879. if os.path.exists(pkgSmaliPath):
  880. Replace.copyAllFile(sdkSmaliPath, pkgSmaliPath)
  881. if contants.isTestEnvironment():
  882. key = "https://sdkapi.bklinok.com"
  883. value = "http://testsdkapi.yyxxgame.com"
  884. file = "%s/smali/com/yyrh/c/a.smali" % prj_path
  885. Replace.replaceKeyword(key, value, file)
  886. file = "%s/smali/com/yyrh/a/d.smali" % prj_path
  887. Replace.replaceKeyword(key, value, file)
  888. file = "%s/smali/com/yyrh/sdk/SDKEntry.smali" % prj_path
  889. Replace.replaceKeyword(key, value, file)
  890. pass
  891. def YuanYouRongHeReplace(prj_path, key, value):
  892. if key == "PACKAGE_TAG":
  893. sdk_root_dir = contants.channel_sdk_path
  894. sdkSmaliPath = "%s/mixsdk/mixsdk/smali/com/yyrh" % sdk_root_dir
  895. pkgSmaliPath = "%s/smali/com/yyrh" % prj_path
  896. printlog("sdkSmaliPath :%s" % sdkSmaliPath)
  897. printlog("pkgSmaliPath :%s" % pkgSmaliPath)
  898. if os.path.exists(pkgSmaliPath):
  899. Replace.copyAllFile(sdkSmaliPath, pkgSmaliPath)
  900. sdkSmaliPath = "%s/mixsdk/mixsdk/smali/com/yythird/base" % sdk_root_dir
  901. pkgSmaliPath = "%s/smali/com/yythird/base" % prj_path
  902. printlog("sdkSmaliPath :%s" % sdkSmaliPath)
  903. printlog("pkgSmaliPath :%s" % pkgSmaliPath)
  904. if os.path.exists(pkgSmaliPath):
  905. Replace.copyAllFile(sdkSmaliPath, pkgSmaliPath)
  906. if contants.isTestEnvironment():
  907. key = "https://sdkapi.yyxxgame.com"
  908. value = "http://testsdkapi.yyxxgame.com"
  909. file = "%s/smali/com/yyrh/c/a.smali" % prj_path
  910. Replace.replaceKeyword(key, value, file)
  911. file = "%s/smali/com/yyrh/sdk/SDKEntry.smali" % prj_path
  912. Replace.replaceKeyword(key, value, file)
  913. pass
  914. def BaLeReplace(prj_path, key, value):
  915. if key == "CHANNEL_ID":
  916. Replace.modify_R_id_smali(prj_path, "/smali/com/sdk/douyou")
  917. pass
  918. def QiPaReplace(prj_path, key, value):
  919. if key == "Super_Game_ID":
  920. splash_activity = "com.supersdk.application.MySplashActivity"
  921. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  922. game_activity = Replace.replace_game_launch_activity_attribute_to_default(splash_activity, prj_am_path)
  923. tree = ET.parse(prj_am_path)
  924. activitys = tree.getroot().find("application").findall("activity")
  925. for activity in activitys:
  926. xml_activity_name = activity.attrib[namespace + "name"]
  927. if xml_activity_name == game_activity:
  928. filter = activity.find('intent-filter')
  929. el1 = Element('action android:name="com.super.sdk.MAIN"')
  930. filter.append(el1)
  931. tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
  932. pass
  933. def DouyinReplace(prj_path, key, value):
  934. jsonFilePath = os.path.join(prj_path, 'assets', 'config.json')
  935. if key == 'app_id':
  936. with open(jsonFilePath, 'r') as fp:
  937. jsonData = json.load(fp)
  938. jsonData["app_id"] = value
  939. jsonData['screen_orientation'] = Replace.get_lauch_activity_name(prj_path)
  940. orientation = Replace.get_lauch_activity_screen_orientation(prj_path)
  941. if orientation == "landscape" or orientation == "sensorLandscape":
  942. screen_orientation = "sensorLandscape"
  943. else:
  944. screen_orientation = "sensorPortrait"
  945. jsonData['screen_orientation'] = screen_orientation
  946. newJsonData = jsonData
  947. fp.close()
  948. with open(jsonFilePath, 'w') as fp:
  949. json.dump(newJsonData, fp)
  950. fp.close()
  951. printlog(" douyin begin replace game package v4 smali -------------------------------")
  952. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  953. printlog("pkgV4Path:%s" % pkgV4Path)
  954. Replace.del_file(pkgV4Path)
  955. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  956. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  957. apk_tool.create_R_file(prj_path, pkgName)
  958. sdkRpath = "android/support/v7/appcompat"
  959. pkgRpath = pkgName.replace(".", "/")
  960. sdkAbsoluteRpath = "%s/smali_classes3/%s" % (prj_path, sdkRpath)
  961. pkgAbsoluteRpath = "%s/smali/%s" % (prj_path, pkgRpath)
  962. Replace.createRFile2Sdk(pkgAbsoluteRpath, sdkAbsoluteRpath, pkgRpath, sdkRpath)
  963. pass
  964. def MoMoYuReplace(prj_path, key, value):
  965. xml_path = "%s/res/values/strings.xml" % prj_path
  966. Replace.replace_xml_value(xml_path, key, value)
  967. pass
  968. def QuxuanReplace(prj_path, key, value):
  969. if key == "app_id":
  970. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  971. value = "Qdazzle_%s" % value
  972. file_utils.replace_manifest_meta_data(prj_am_path, "CommonSDK_AppID", value)
  973. Replace.modify_R_id_smali(prj_path, "/smali/com/qdazzle/sdk")
  974. if key == "app_key":
  975. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  976. value = "Qdazzle_%s" % value
  977. file_utils.replace_manifest_meta_data(prj_am_path, "CommonSDK_AppKey", value)
  978. pass
  979. def MuMuReplace(prj_path, key, value):
  980. if key == "YOFUN_APP_ID":
  981. printlog("specail replace : MuMuReplace")
  982. splashactivity = "com.yythird.sdk.SplashActivity"
  983. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  984. prj_param = "%s/assets/YyrhParam.cnf" % prj_path
  985. game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
  986. printlog("GAMEACTIVITY :%s" % game_activity)
  987. file_utils.replace_assets_param(prj_param, "GAMEACTIVITY", game_activity)
  988. pass
  989. def HeFengReplace(prj_path, key, value):
  990. if key == "ver":
  991. printlog("specail replace : HeFengReplace")
  992. printlog("path hf.properties :%s/assets/hf.properties" % prj_path)
  993. file_utils.replace_assets_param("%s/assets/hf.properties" % prj_path, "agent", value)
  994. pass
  995. def ShengBenFuliReplace(prj_path, key, value):
  996. if key == "appid":
  997. printlog("specail replace : ShengBenFuliReplace")
  998. splash_activity = "com.fysdk.activity.FyGuideActivity"
  999. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  1000. ET.register_namespace('android', androidNS)
  1001. tree = ET.parse(prj_am_path)
  1002. activitys = tree.getroot().find("application").findall("activity")
  1003. for activity in activitys:
  1004. filters = activity.findall('intent-filter')
  1005. for filter in filters:
  1006. categorys = filter.findall('category')
  1007. actions = filter.findall('action')
  1008. for category in categorys:
  1009. category_name = category.attrib[namespace + "name"]
  1010. if category_name == "android.intent.category.LAUNCHER":
  1011. action_name = activity.attrib[namespace + "name"]
  1012. if action_name != splash_activity:
  1013. printlog("delete :%s" % category_name)
  1014. category.attrib[namespace + "name"] = "android.intent.category.DEFAULT"
  1015. printlog("LAUNCHER replace DEFAULT :%s" % category.attrib[namespace + "name"])
  1016. for action in actions:
  1017. action_name = action.attrib[namespace + "name"]
  1018. if action_name == "android.intent.action.MAIN":
  1019. printlog("delete :%s" % action_name)
  1020. action.attrib[namespace + "name"] = "game.MAIN"
  1021. tree.write(prj_am_path, "UTF-8", xml_declaration=True, method='xml')
  1022. pass
  1023. def MuXueReplace(prj_path, key, value):
  1024. printlog("specail replace : MuXueReplace")
  1025. file_utils.replace_assets_param("%s/assets/gs.properties" % prj_path, key, value)
  1026. pass
  1027. def QiYouReplace(prj_path, key, value):
  1028. if key == "blgame_gameid":
  1029. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  1030. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  1031. sdk_root_dir = contants.channel_sdk_path()
  1032. pkgV4Path = "%s/smali/android/support/design" % prj_path
  1033. printlog("pkgV4Path:%s" % pkgV4Path)
  1034. sdkV4Path = "%s/7you/7you/smali/android/support/design" % sdk_root_dir
  1035. printlog("sdkV4Path:%s" % sdkV4Path)
  1036. if os.path.exists(pkgV4Path):
  1037. Replace.copyAllFile(sdkV4Path, pkgV4Path)
  1038. apk_tool.create_R_file(prj_path, pkgName)
  1039. Replace.modify_R_id_smali(prj_path, "/smali/android/support/v7/appcompat")
  1040. Replace.modify_R_id_smali(prj_path, "/smali/android/support/design")
  1041. Replace.modify_R_id_smali(prj_path, "/smali/android/support/v7/cardview")
  1042. pass
  1043. def YueWanReplace(prj_path, key, value):
  1044. printlog("specail replace : YueWanReplace")
  1045. if key == "J_GAME_ID":
  1046. sdk_root_dir = contants.channel_sdk_path
  1047. printlog(" YueWanReplace begin replace game package v4 smali -------------------------------")
  1048. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  1049. printlog("pkgV4Path:%s" % pkgV4Path)
  1050. sdkV4Path = "%s/yuewan/yuewan/smali/android/support/v4" % sdk_root_dir
  1051. printlog("sdkV4Path:%s" % sdkV4Path)
  1052. if os.path.exists(pkgV4Path):
  1053. Replace.copyAllFile(sdkV4Path, pkgV4Path)
  1054. pass
  1055. def ShengYueReplace(prj_path, key, value):
  1056. printlog("specail replace : ShengYueReplace")
  1057. os.path.join(prj_path, 'assets', 'UUConfig.json')
  1058. jsonFilePath = os.path.join(prj_path, 'assets', 'UUConfig.json')
  1059. Replace.replace_json_value(jsonFilePath, "", key, value)
  1060. pass
  1061. def JiZhiHuiReplace(prj_path, key, value):
  1062. printlog("specail replace : JiZhiHuiReplace")
  1063. config_path = "%s/assets/xggameinfo.txt" % prj_path
  1064. with open(config_path, "r") as f:
  1065. content = f.read()
  1066. json_data = json.loads(content)
  1067. json_data[key] = value
  1068. with open(config_path, "w") as f:
  1069. f.write(json.dumps(json_data))
  1070. def JiMiReplace(prj_path, key, value):
  1071. file_utils.replace_assets_param("%s/assets/jmhy.properties" % prj_path, key, value)
  1072. def DangLesdkReplace(prj_path, key, value):
  1073. printlog("specail replace : DangLesdkReplace")
  1074. if key == "RH_APPID":
  1075. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  1076. splashactivity = "com.rhsdk.SplashActivity"
  1077. game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
  1078. printlog("GAMEACTIVITY :%s" % game_activity)
  1079. file_utils.replace_manifest_meta_data(prj_am_path, "RH_GAME_ACTIVITY", game_activity)
  1080. rh_developer_config = "%s/assets/rh_developer_config.xml" % prj_path
  1081. tree = ET.parse(rh_developer_config)
  1082. metadatas = tree.getroot().findall("param")
  1083. for meta in metadatas:
  1084. if meta.attrib["name"] == key:
  1085. meta.attrib["value"] = value
  1086. tree.write(rh_developer_config, "UTF-8", xml_declaration=True, method='xml')
  1087. elif key == "RH_APPKEY":
  1088. rh_developer_config = "%s/assets/rh_developer_config.xml" % prj_path
  1089. tree = ET.parse(rh_developer_config)
  1090. metadatas = tree.getroot().findall("param")
  1091. for meta in metadatas:
  1092. if meta.attrib["name"] == key:
  1093. meta.attrib["value"] = value
  1094. tree.write(rh_developer_config, "UTF-8", xml_declaration=True, method='xml')
  1095. pass
  1096. def PinBangsdkReplace(prj_path, key, value):
  1097. if key == 'xggameinfo.txt':
  1098. if os.path.exists(value):
  1099. printlog('replace pinbang xggameinfo.txt:%s' % value)
  1100. pb_sdk_config_path = os.path.join(prj_path, 'assets', key)
  1101. printlog('replace pinbang pb_sdk_config_path:%s' % pb_sdk_config_path)
  1102. shutil.copy(value, pb_sdk_config_path)
  1103. pass
  1104. def JianDaoReplace(prj_path, key, value):
  1105. if key == "JIANDAO_GAMEID":
  1106. splashactivity = "com.yythird.sdk.SplashActivity"
  1107. prj_param = "%s/assets/YyrhParam.cnf" % prj_path
  1108. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  1109. game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
  1110. file_utils.replace_assets_param(prj_param, "GAME_ACTIVITY", game_activity)
  1111. printlog("JianDaoReplace GAME_ACTIVITY :%s" % game_activity)
  1112. sdk_root_dir = contants.channel_sdk_path
  1113. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  1114. printlog("pkgV4Path:%s" % pkgV4Path)
  1115. sdkV4Path = "%s/jiandao/jiandao/smali/android/support/v4" % sdk_root_dir
  1116. printlog("sdkV4Path:%s" % sdkV4Path)
  1117. if os.path.exists(pkgV4Path):
  1118. Replace.copyAllFile(sdkV4Path, pkgV4Path)
  1119. def MengHuReplace(prj_path, key, value):
  1120. if key == "appid":
  1121. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  1122. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  1123. apk_tool.create_R_file(prj_path, pkgName)
  1124. pass
  1125. def MengHu2Replace(prj_path, key, value):
  1126. if key == "appid":
  1127. prj_am_path = "%s/AndroidManifest.xml" % prj_path
  1128. pkgName = ET.parse(prj_am_path).getroot().attrib["package"]
  1129. apk_tool.create_R_file(prj_path, pkgName)
  1130. def MengHu3Replace(prj_path, key, value):
  1131. config_path = "%s/assets/cd_super_sdk.json" % prj_path
  1132. with open(config_path, "r") as f:
  1133. content = f.read()
  1134. json_data = json.loads(content)
  1135. json_data[key] = value
  1136. with open(config_path, "w") as f:
  1137. f.write(json.dumps(json_data))
  1138. def baUReplace(prj_path, key, value):
  1139. if key == "appid":
  1140. splashactivity = "com.yythird.sdk.SplashActivity"
  1141. prj_param = "%s/assets/YyrhParam.cnf" % prj_path
  1142. prj_am_path = os.path.join(prj_path, 'AndroidManifest.xml')
  1143. game_activity = Replace.replace_game_launch_activity_attribute_to_default(splashactivity, prj_am_path)
  1144. file_utils.replace_assets_param(prj_param, "GAME_ACTIVITY", game_activity)
  1145. printlog("baUReplace GAME_ACTIVITY :%s" % game_activity)
  1146. pass
  1147. def ZhongXingReplace(prj_path, key, value):
  1148. if key == 'Gamble_cfg':
  1149. printlog('replace ZhongXing Gamble_cfg')
  1150. config_path = os.path.join(prj_path, 'assets', key)
  1151. shutil.copy(value, config_path)
  1152. pass
  1153. def YouXiYouReplace(prj_path, key, value):
  1154. jsonFilePath = os.path.join(prj_path, 'assets', 'youxiyougameinfo.txt')
  1155. printlog('replace YouXiYouReplace youxiyougameinfo.txt ,value:%s' % key)
  1156. with open(jsonFilePath, 'r') as fp:
  1157. jsonData = json.load(fp)
  1158. jsonData[key] = value
  1159. newJsonData = jsonData
  1160. fp.close()
  1161. with open(jsonFilePath, 'w') as fp:
  1162. json.dump(newJsonData, fp, ensure_ascii=False)
  1163. fp.close()
  1164. pass
  1165. def SiLangReplace(prj_path, key, value):
  1166. if key == "SL_PARAMS_channelID":
  1167. Replace.modify_R_id_smali(prj_path, "/smali/com/silang/slsdk")
  1168. printlog(" SiLangReplace begin replace game package v4 smali -------------------------------")
  1169. sdk_root_dir = contants.channel_sdk_path
  1170. pkgV4Path = "%s/smali/android/support/v4" % prj_path
  1171. printlog("pkgV4Path:%s" % pkgV4Path)
  1172. sdkV4Path = "%s/sl/sl/smali/android/support/v4" % sdk_root_dir
  1173. printlog("sdkV4Path:%s" % sdkV4Path)
  1174. if os.path.exists(pkgV4Path):
  1175. Replace.copyAllFile(sdkV4Path, pkgV4Path)
  1176. pass
  1177. specialReplace = {
  1178. "lenovo": LenovoReplace,
  1179. "wandoujia": WandoujiaReplace,
  1180. "qh360": QihuReplace,
  1181. "oppo": OppoReplace,
  1182. "oppoml": OppoMlReplace,
  1183. "chongchong": ChongchongReplace,
  1184. "yingyongbao": YYBReplace,
  1185. "downjoy": downjoyReplace,
  1186. "huawei": HuaweiReplace,
  1187. "anzhi": AnzhiReplace,
  1188. "leshi": LeshiReplace,
  1189. "quick": QuickReplace,
  1190. "guopan": GuopanReplace,
  1191. "ljsdk": LjsdkReplace,
  1192. "uc": UcsdkReplace,
  1193. "xiaomi": XiaomisdkReplace,
  1194. "hnshengben": ShengbensdkReplace,
  1195. "jk": JinkuosdkReplace,
  1196. "samsung": SamsungReplace,
  1197. "ttyy": TTReplace,
  1198. "yxf": YXFReplace,
  1199. "vivo": VivosdkReplace,
  1200. "3011": XTsdkReplace,
  1201. "ddt": DDTsdkReplace,
  1202. "wanka": WankaReplace,
  1203. "ddd": DDDReplace,
  1204. "lzyx": LZYXReplace,
  1205. "ws": WSReplace,
  1206. "xb": XBReplace,
  1207. "youdian": YoudianReplace,
  1208. "x7sy": Xiao7Replace,
  1209. "nwanka": NwanKaReplace,
  1210. "mbaidu": MBaiduReplace,
  1211. "shenshou": ShenshouReplace,
  1212. "dyyx": DaYanReplace,
  1213. "dl": DaLanReplace,
  1214. "ksyx": KSyxReplace,
  1215. "llhy": LlhyReplace,
  1216. "hnqs": HnqsReplace,
  1217. "sogou": SogouReplace,
  1218. "jrtt": JinRiTouTiaoReplace,
  1219. "fq": FengQiReplace,
  1220. "bs": BlueStackReplace,
  1221. "simo": SiMoReplace,
  1222. "cl": ChenLongReplace,
  1223. "qianmian": JinRiTouTiaoReplace,
  1224. "jiuzi": JiuZiReplace,
  1225. "bingniao": BingNiaoReplace,
  1226. "bingcheng": BingChengReplace,
  1227. "sxhy": SuixingHuYuReplace,
  1228. "shouqu": ShouQuReplace,
  1229. "hnqj": HaiNanQiJingReplace,
  1230. "hg": HongGuoReplace,
  1231. "baize": BaizeReplace,
  1232. "yx": YanXinReplace,
  1233. "zshy": ZhangShangHuYuReplace,
  1234. "xiyou": XiYouWangReplace,
  1235. "xunlei": XunLeiReplace,
  1236. "canlong": CanLongReplace,
  1237. "shxy": ShangHaiXiYuanReplace,
  1238. "mixsdk": YuanYouRongHeReplace,
  1239. "bale": BaLeReplace,
  1240. "7pa": QiPaReplace,
  1241. "dymmy": MoMoYuReplace,
  1242. "dyly": DouyinReplace,
  1243. "qx": QuxuanReplace,
  1244. "wymumu": MuMuReplace,
  1245. "hf": HeFengReplace,
  1246. "sbfl": ShengBenFuliReplace,
  1247. "muxue": MuXueReplace,
  1248. "7you": QiYouReplace,
  1249. "yuewan": YueWanReplace,
  1250. "shengyue": ShengYueReplace,
  1251. "jzh": JiZhiHuiReplace,
  1252. "jmhy": JiMiReplace,
  1253. "dangle": DangLesdkReplace,
  1254. "pinbang": PinBangsdkReplace,
  1255. "jiandao": JianDaoReplace,
  1256. "menghu": MengHuReplace,
  1257. "8uyx": baUReplace,
  1258. "menghu2": MengHu2Replace,
  1259. "menghu3": MengHu3Replace,
  1260. "zx": ZhongXingReplace,
  1261. "yxy": YouXiYouReplace,
  1262. "sl": SiLangReplace
  1263. }
  1264. def getSpecilReplace(sdk_name):
  1265. if sdk_name in specialReplace:
  1266. return specialReplace[sdk_name]
  1267. else:
  1268. return None
  1269. pass