# coding:utf8

__author__ = '极无双'

import os
from xml.etree import ElementTree as ET


def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
    fix_fake_recharge_screen_orientation_portrait(decompileDir)


def fix_fake_recharge_screen_orientation_portrait(decompile_dir_path):
    for dirpath, dirnames, filenames in os.walk(decompile_dir_path):
        if r'com\youzu\gamexy' in dirpath and 'Game.smali' in filenames:
            smali_path = os.path.join(dirpath, 'Game.smali')
            print(smali_path)
            f = open(smali_path, 'r')
            smali_str_arr = f.readlines()
            f.close()
            for line in smali_str_arr:
                if 'invoke-static {p0}, Lcom/youzu/gamexy/Game;->Init(Landroid/content/Context;)V' in line:
                    smali_str_arr[smali_str_arr.index(
                        line)] = '\t#invoke-static {p0}, Lcom/youzu/gamexy/Game;->Init(Landroid/content/Context;)V\n'
            f = open(smali_path, 'w')
            f.write(''.join(smali_str_arr))
            f.close()

    developer_path = os.path.join(decompile_dir_path, 'assets', 'developer.properties')
    print(developer_path)
    f = open(developer_path, 'r')
    smali_str_arr = f.readlines()
    f.close()

    for line in smali_str_arr:
        if 'isRealname' in line:
            smali_str_arr[smali_str_arr.index(line)] = line.replace('1', '0')
            break

    f = open(developer_path, 'w')
    f.write(''.join(smali_str_arr))
    f.close()

if __name__ == '__main__':
    ""
