# -*- coding:utf-8 -*-
__author__ = 'ALIXie'

import os
import logging
import distutils.dir_util
import gw_apk_tool


def script_init(workspace_sdk_dir, extract_dir, channelSdkInfo, new_game_channel_info, game_info):
    return


def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
    logging.info('------------channelSdkInfo:' + str(channelSdkInfo))
    s1 = os.path.join(decompileDir, "smali","androidx")
    smali_classes2_dir = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(smali_classes2_dir,"androidx")
    list_package = ["interpolator","lifecycle","loader","savedstate","vectordrawable","versionedparcelable","viewpager"]
    if not os.path.exists(s3):
        distutils.dir_util.mkpath(s3)
    gw_apk_tool.move_package(s1, s3, list_package)

    s1 = os.path.join(decompileDir, "smali","androidx")
    smali_classes2_dir = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(smali_classes2_dir,"androidx")
    list_package = ["collection","core","cursoradapter","customview","drawerlayout","fragment"]
    if not os.path.exists(s3):
        distutils.dir_util.mkpath(s3)
    gw_apk_tool.move_package(s1, s3, list_package)

    s1 = os.path.join(decompileDir, "smali_classes2", "com")
    smali_classes2_dir = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(smali_classes2_dir,"com")
    list_package = ["mergeSdk","sdk","util"]
    if not os.path.exists(s3):
        distutils.dir_util.mkpath(s3)
    gw_apk_tool.move_package(s1, s3, list_package)

if __name__ == "__main__":
    ""
