# 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):
    namespace = '{http://schemas.android.com/apk/res/android}'
    ET._namespace_map['android'] = 'http://schemas.android.com/apk/res/android'

    manifest_path = os.path.join(decompile_dir_path, 'AndroidManifest.xml')
    xml_tree = ET.parse(manifest_path)
    xml_root = xml_tree.getroot()
    activity_nodes = xml_root.findall('.//activity')
    print activity_nodes
    for activity_node in activity_nodes:
        print activity_node.attrib
        activity_name = activity_node.get(namespace + 'name')
        print activity_name
        if 'com.cccolyun.sdkkit.gameplatform.paysdk.view.activity.CoolPaySDKActivity' == activity_name:
            activity_node.set(namespace + 'screenOrientation', 'portrait')
            xml_tree.write(manifest_path, encoding=u'utf-8', xml_declaration=True)
            break


if __name__ == '__main__':
    ""
