# coding:utf8

__author__ = 'd'

import os
import logging
import xml.dom.minidom
import re
import shutil
import glob
from xml.etree.ElementTree import ElementTree, Element
import distutils.dir_util
import gw_file_system
import gw_data_center
from xml.etree import ElementTree as ET

ANDROID_NS = 'http://schemas.android.com/apk/res/android'


def script_init(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
    sdk_id = channel_sdk_info['id']
    if sdk_id == "512":
        gw_data_center.pack_small = False
        logging.info('script_init: ' + str(channel_sdk_info))


def script_first(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
    logging.info("-----debug exec first func-----")
    game_apk = decompileDir + "/../game.apk"
    if os.path.exists(game_apk):
        gw_file_system.delete_apk_file_by_aapt(game_apk, "assets/39285EFA.dex")
    logging.info("-----debug-----")


def script(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
    dex = decompileDir + "../39285EFA.dex"
    asserts = os.path.join(decompileDir, "assets/39285EFA.dex")
    if os.path.exists(asserts) and os.path.exists(os.path.join(dex)):
        distutils.dir_util.copy_tree(dex, asserts)
    logging.info("-----debug-----")
