예제 #1
0
def copySplashToUnityResFolder(workDir, channel, decompileDir):

    splashPath = file_utils.getSplashPath()
    resPath = workDir + "/sdk/" + channel['name'] + "/splash/" + channel['splash'] + "/%s/u8_splash.png"
    resTargetPath = decompileDir + "/assets/bin/Data/splash.png"

    paths = ['drawable', 'drawable-hdpi', 'drawable-ldpi', 'drawable-mdpi', 'drawable-xhdpi']

    bFound = False
    for path in paths:
        imgPath = resPath % path
        if os.path.exists(imgPath):
            resPath = imgPath
            bFound = True
            break

    if not bFound:
        log_utils.error("the u8_splash is not found.path:%s", resPath)
        return 1

    if not os.path.exists(resTargetPath):
        log_utils.error("the unity splash is not exists. path:%s", resTargetPath)
        return 1

    file_utils.copy_file(resPath, resTargetPath)

    return 0
예제 #2
0
def addSplashScreen(workDir, channel, decompileDir):

    """
        if the splash attrib is not zero ,then set the splash activity
        if the splash_copy_to_unity attrib is set, then copy the splash img to unity res fold ,replace the default splash.png.

    """

    if channel['splash'] =='0':
        return 0

    if channel['splash_copy_to_unity'] == '1':
        return copySplashToUnityResFolder(workDir, channel, decompileDir)

    splashPath = file_utils.getSplashPath()
    smaliPath = splashPath + "/smali"
    smaliTargetPath = decompileDir + "/smali"

    copyResToApk(smaliPath, smaliTargetPath)

    splashLayoutPath = splashPath + "/u8_splash.xml"
    splashTargetPath = decompileDir + "/res/layout/u8_splash.xml"
    file_utils.copy_file(splashLayoutPath, splashTargetPath)

    resPath = workDir + "/sdk/" + channel['name'] + "/splash/" + channel['splash']
    resTargetPath = decompileDir + "/res"
    copyResToApk(resPath, resTargetPath)

    #remove original launcher activity of the game
    activityName = removeStartActivity(decompileDir)

    #append the launcher activity with the splash activity
    appendSplashActivity(decompileDir, channel['splash'])

    splashActivityPath = smaliTargetPath + "/com/u8/sdk/SplashActivity.smali"
    f = open(splashActivityPath, 'r+')
    content = str(f.read())
    f.close()

    replaceTxt = '{U8SDK_Game_Activity}'

    idx = content.find(replaceTxt)
    if idx == -1:
        log_utils.error("modify splash file failed.the {U8SDK_Game_Activity} not found in SplashActivity.smali")
        return 1

    content = content[:idx] + activityName + content[(idx + len(replaceTxt)):]
    f2 = open(splashActivityPath, 'w')
    f2.write(content)
    f2.close()

    log_utils.info("modify splash file success.")
    return 0