# coding:utf8

__author__ = 'dong'

import os
import logging
import xml.dom.minidom
import re
import shutil
import glob
import distutils.dir_util
import os
import gw_apk_tool
import gw_data_center


def script(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
    # if channelSdkInfo['id'] == '597':
    #     gw_data_center.pack_small = True
    return


def script_second(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
    return


def script(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
    # logging.info('------------channelSdkInfo:' + str(channelSdkInfo))
    # if channelSdkInfo['id'] == '597':
    #     logging.info("remove_navigate")
    #     remove_navigate(decompileDir)
    return


def script_last(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
    logging.info('------------channelSdkInfo:' + str(channelSdkInfo))
    if channelSdkInfo['id'] == '597':
       return
    else:
        move_224_bytedance(decompileDir)


def move(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes10/com")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com")
    list_package = ["facebook"]
    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_classes11/com")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com")
    list_package = ["facebook", "feiyu", "google", "hermes"]
    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_classes11/com")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com")
    list_package = ["sedna", "service", "sina"]
    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_classes11/com")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com")
    list_package = ["heytap", "huawei", "hw", "ixigua", "just", "loc", "luck"]
    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_classes11/com")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com")
    list_package = ["squareup", "ss", "swmansion"]
    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_classes12/androidx")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "androidx")
    list_package = ["activity", "annotation", "appcompat", "arch", "asynclayoutinflater", "cardview", "collection",
                    "concurrent", "constraintlayout", "coordinatorlayout"]
    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_classes12/androidx")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "androidx")
    list_package = ["print", "room", "sqlite", "tracing", "versionedparcelable", "viewpager2", "recyclerview",
                    "savedstate", "startup", "transition", "viewbinding", "window", "resourceinspection",
                    "slidingpanelayout", "swiperefreshlayout", "vectordrawable", "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_classes12/androidx")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "androidx")
    list_package = ["core", "customview", "drawerlayout", "emoji2", "fragment", "legacy", "loader", "media",
                    "navigation", "cursoradapter", "documentfile", "dynamicanimation", "exifinterface", "interpolator",
                    "lifecycle", "localbroadcastmanager", "multidex"]
    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_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com")
    list_package = ["swmansion", "sxd3", "taptap", "tds", "tencent", "ttnet", "unicom", "unity3d", "uodis", "vivo",
                    "volcengine", "vv", "weibo", "xiaomi", "xm", "yqritc"]
    if not os.path.exists(s3):
        distutils.dir_util.mkpath(s3)
    gw_apk_tool.move_package(s1, s3, list_package)


def remove_navigate(decompileDir):
    tmp_res = os.path.join(decompileDir, "res", "navigation")
    tmp_public_xml = os.path.join(decompileDir, "res", "values", "public.xml")
    if os.path.exists(tmp_res):
        distutils.dir_util.remove_tree(tmp_res)
    if os.path.exists(tmp_public_xml):
        os.remove(tmp_public_xml)


def move_10_bytedance(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes10/com/bytedance")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance")
    list_package = ["ttgame"]
    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_classes10/com/bytedance")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance")
    list_package = ["ttnet"]
    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_classes10/com/bytedance")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance")
    list_package = ["ug"]
    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_classes10/com/bytedance")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance")
    list_package = ["unbridge"]
    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_classes10/com/bytedance")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance")
    list_package = ["usergrowth"]
    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_classes10/com/bytedance")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance")
    list_package = ["watson"]
    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_classes19/com")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com")
    list_package = ["ixigua", "just", "loc", "luck"]
    if not os.path.exists(s3):
        distutils.dir_util.mkpath(s3)
    gw_apk_tool.move_package(s1, s3, list_package)


def move_11_bytedance(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes10/com/bytedance")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance")
    list_package = ["rocketapi", "wrapper_account", "wrapper_alog", "wrapper_appcloud", "wrapper_applog"]
    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_classes10/com/bytedance")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance")
    list_package = ["wrapper_download", "wrapper_encrypt", "wrapper_jsbridge", "wrapper_librarian", "wrapper_net"]
    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_classes10/com/bytedance")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance")
    list_package = ["wrapper_pangolinsdk", "wrapper_push", "wrapper_sdk_monitor", "wrapper_service_manager",
                    "wrapper_setting_manager"]
    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_classes10/com/bytedance")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance")
    list_package = ["wrapper_share", "wrapper_smartrouter", "wrapper_utility"]
    if not os.path.exists(s3):
        distutils.dir_util.mkpath(s3)
    gw_apk_tool.move_package(s1, s3, list_package)


def move_4_bytedance(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes4/com/bytedance")
    list_b = ["android", "apm6", "article", "bdinstall", "boost_multidex", "cloudplay", "crash", "ttgame",
              "apkidentity", "apmsdk", "bdauditsdk", "bdlocation", "boringssl", "common", "crashthanos", "apm",
              "applog", "bdauditsdkbase", "bdturing", "channelmigrator", "constants2", "frameworks"]
    for a in list_b:
        smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
        s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance")
        list_package = [a]
        if not os.path.exists(s3):
            distutils.dir_util.mkpath(s3)
        gw_apk_tool.move_package(s1, s3, list_package)


def move_5_bytedance(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes5/com/bytedance")
    list_b = ["frameworks", "gamerecord", "lynx", "perf", "reader_apk", "shadowhook", "thanos", "framwork", "geckox",
              "mira", "permissions", "remote", "share_channel_douyin", "tpssdk", "frankie", "grecorder", "monitor",
              "pipeline", "retrofit2", "share_channel_weibo", "tracing", "frankie_sohotfix_util", "gumiho", "mpaas",
              "platform", "robust", "share_image_token", "ttgame", "frankie_sohotfix_util_emulator", "hidden_watermark",
              "msgsdk", "praisedialoglib", "router", "share_qq", "fresco", "ies", "news", "push", "sdk", "share_ui",
              "game", "keva", "notification", "react", "security", "share_wechat", "gameprotect", "librarian", "pangle",
              "reactnative", "services", "sync"]
    for a in list_b:
        smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
        s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance")
        list_package = [a]
        if not os.path.exists(s3):
            distutils.dir_util.mkpath(s3)
        gw_apk_tool.move_package(s1, s3, list_package)


def move_6_bytedance(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes6/com/bytedance/ttgame")
    list_b = ["account", "base", "core", "framework", "glog", "gsdk_base_common_ui", "gsdk_base_utils", "library",
              "module", "audio", "channel", "engine", "gecko", "gsdk", "gsdk_base_sdk_config", "gsdksync", "main"]
    for a in list_b:
        smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
        s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame")
        list_package = [a]
        if not os.path.exists(s3):
            distutils.dir_util.mkpath(s3)
        gw_apk_tool.move_package(s1, s3, list_package)


def move_60_ss(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes60/com/ss/android")
    list_b = ["account", "applog", "bytedcert", "deviceregister", "downloadad", "downloadlib", "newmedia",
              "push_3rd_module", "pushmanager", "token", "ug", "agilelogger", "article", "common", "download",
              "downloadapi", "message", "push", "push_common_lib", "socialbase", "ttmd5", "ugc"]
    for a in list_b:
        smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
        s3 = os.path.join(decompileDir, smali_classes_new, "com/ss/android")
        list_package = [a]
        if not os.path.exists(s3):
            distutils.dir_util.mkpath(s3)
        gw_apk_tool.move_package(s1, s3, list_package)


def move_64_bytedance(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes64/com/bytedance/ttgame")
    list_b = ["rocket", "rocketapi", "sdk", "tps", "unity"]
    for a in list_b:
        smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
        s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame")
        list_package = [a]
        if not os.path.exists(s3):
            distutils.dir_util.mkpath(s3)
        gw_apk_tool.move_package(s1, s3, list_package)


def move_7_bytedance(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes7/com/bytedance/ttgame/module")
    list_b = ["compliance", "crash", "deeplink", "download", "fileupload", "gameinfo", "gameprotect", "compress",
              "database", "demo", "dynamic", "friendchain", "gamelivesdk"]
    for a in list_b:
        smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
        s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame/module")
        list_package = [a]
        if not os.path.exists(s3):
            distutils.dir_util.mkpath(s3)
        gw_apk_tool.move_package(s1, s3, list_package)


def move_8_bytedance(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes8/com/bytedance/ttgame/module")
    list_b = ["location", "log", "mediaupload", "netdiagnose", "pay", "push", "rn", "rnengine", "screenrecord",
              "loccom", "main", "monitor", "notice", "privacy", "rating", "rncore"]
    for a in list_b:
        smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
        s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame/module")
        list_package = [a]
        if not os.path.exists(s3):
            distutils.dir_util.mkpath(s3)
        gw_apk_tool.move_package(s1, s3, list_package)


def move_9_bytedance(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes9/com/bytedance/ttgame/module")
    list_b = ["screenrecord", "share", "thanos", "unitelive"]
    for a in list_b:
        smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
        s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame/module")
        list_package = [a]
        if not os.path.exists(s3):
            distutils.dir_util.mkpath(s3)
        gw_apk_tool.move_package(s1, s3, list_package)


def move_37_bytedance(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes37/com/bytedance/apm6")
    list_b = ["foundation", "hub", "memory", "monitor", "perf", "service", "util"]
    # for a in list_b:
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/apm6")
    list_package = list_b
    if not os.path.exists(s3):
        distutils.dir_util.mkpath(s3)
    gw_apk_tool.move_package(s1, s3, list_package)


def move_49_bytedance(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes49/com/bytedance/common")
    list_b = ["perf_block", "process", "profilesdk", "push", "support", "util", "utility", "wschannel"]
    # for a in list_b:
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/common")
    list_package = list_b
    if not os.path.exists(s3):
        distutils.dir_util.mkpath(s3)
    gw_apk_tool.move_package(s1, s3, list_package)


def move_103_bytedance(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes103/com/bytedance/sdk")
    list_b = ["bridge", "account", "open", "openadsdk"]
    for a in list_b:
        smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
        s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/sdk")
        list_package = [a]
        if not os.path.exists(s3):
            distutils.dir_util.mkpath(s3)
        gw_apk_tool.move_package(s1, s3, list_package)


def move_125_bytedance(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes125/com/bytedance/ttgame/module")
    list_b = ["abtest", "account", "apimonitor", "asr", "boost", "bridge", "cdkey", "cloud", "cloudgame", "common",
              "compliance", "gpm", "location"]
    for a in list_b:
        smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
        s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame/module")
        list_package = [a]
        if not os.path.exists(s3):
            distutils.dir_util.mkpath(s3)
        gw_apk_tool.move_package(s1, s3, list_package)


def move_158_bytedance(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes158/com/bytedance/ttgame/sdk/module")
    list_b = ["entity", "location", "pojo", "skin", "ui", "utils"]
    # for a in list_b:
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame/sdk/module")
    list_package = list_b
    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_classes158/com/bytedance/ttgame/sdk/module")
    list_b = ["account", "bridge"]
    # for a in list_b:
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame/sdk/module")
    list_package = list_b
    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_classes161/com/bytedance/ttgame/module/compliance")
    list_b = ["bridge"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame/module/compliance")
    list_package = list_b
    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_classes190/com/bytedance/ttgame/module/screenrecord")
    list_b = ["bridge", "download", "impl", "interceptor", "lib", "log", "net"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame/module/screenrecord")
    list_package = list_b
    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_classes191/com/bytedance/ttgame/module/share")
    list_b = ["bridge", "api", "impl"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame/module/share")
    list_package = list_b
    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_classes197/com/bytedance/sdk/account")
    list_b = ["api", "bpea", "constants", "extra"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/sdk/account")
    list_package = list_b
    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_classes197/com/bytedance/sdk/account")
    list_b = ["impl", "information", "mobile", "network"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/sdk/account")
    list_package = list_b
    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_classes197/com/bytedance/sdk/account")
    list_b = ["save", "sso", "user", "bdopen", "common"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/sdk/account")
    list_package = list_b
    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_classes197/com/bytedance/sdk/account")
    list_b = ["execute", "helper", "induce", "job", "monitor"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/sdk/account")
    list_package = list_b
    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_classes197/com/bytedance/sdk/account")
    list_b = ["response", "special", "third", "utils"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/sdk/account")
    list_package = list_b
    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_classes197/com/bytedance/sdk/account")
    list_b = ["param", "platform_china"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/sdk/account")
    list_package = list_b
    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_classes197/com/bytedance/sdk/account")
    list_b = ["platform", "open"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/sdk/account")
    list_package = list_b
    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_classes210/com/bytedance/ttgame/module/compliance")
    list_b = ["bridge"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame/module/compliance")
    list_package = list_b
    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_classes214/com/bytedance/ttgame/sdk/module/account")
    list_b = ["api", "login"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame/sdk/module/account")
    list_package = list_b
    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_classes214/com/bytedance/ttgame/sdk/module/account")
    list_b = ["pojo"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame/sdk/module/account")
    list_package = list_b
    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_classes214/com/bytedance/ttgame/sdk/module/account")
    list_b = ["platform"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame/sdk/module/account")
    list_package = list_b
    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_classes216/com/bytedance/ttgame/module/screenrecord")
    list_b = ["bridge"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame/module/screenrecord")
    list_package = list_b
    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_classes217/com/bytedance/ttgame/module/share")
    list_b = ["bridge"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame/module/share")
    list_package = list_b
    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_classes217/com/bytedance/ttgame/module/share")
    list_b = ["api"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame/module/share")
    list_package = list_b
    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_classes228/com/bytedance/ttgame/sdk/module/account/platform")
    list_b = ["api", "douyin", "huoshan", "onekey"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame/sdk/module/account/platform")
    list_package = list_b
    if not os.path.exists(s3):
        distutils.dir_util.mkpath(s3)
    gw_apk_tool.move_package(s1, s3, list_package)

def move_224_bytedance(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes2")
    list_b = ["androidx"]
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new)
    list_package = list_b
    if not os.path.exists(s3):
        distutils.dir_util.mkpath(s3)
    gw_apk_tool.move_package(s1, s3, list_package)



def move_2(decompileDir):
    s1 = os.path.join(decompileDir, "smali_classes23/com")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com")
    list_package = ["ixigua", "just", "loc", "luck"]
    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_classes24/com/ss")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/ss")
    list_package = ["bduploader", "cgpa", "mediakit"]
    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_classes24/com/ss")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/ss")
    list_package = ["android"]
    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_classes26/androidx")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/androidx")
    list_package = ["tracing", "transition", "vectordrawable", "versionedparcelable", "viewbinding", "viewpager",
                    "viewpager2", "window"]
    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_classes27/androidx")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/androidx")
    list_package = ["interpolator", "legacy", "lifecycle", "loader"]
    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_classes27/androidx")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/androidx")
    list_package = ["localbroadcastmanager", "media", "multidex", "navigation"]
    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_classes29/com/bytedance/ttgame")
    smali_classes_new = gw_apk_tool.create_mutil_smali(decompileDir)
    s3 = os.path.join(decompileDir, smali_classes_new, "com/bytedance/ttgame")
    list_package = ["rocket", "rocketapi", "sdk", "tps", "unity"]
    if not os.path.exists(s3):
        distutils.dir_util.mkpath(s3)
    gw_apk_tool.move_package(s1, s3, list_package)

def handle_public_xml(public_xml_path, remove_node):
    if not os.path.exists(public_xml_path):
        logging.info('public_xml is null: ' + public_xml_path)
        return
    new_lines = []
    with open(public_xml_path, 'r+') as f:
        for line in f.readlines():
            # l = line.strip()
            if line.find(remove_node) > -1:
                continue
            new_lines.append(line)
        f.seek(0)
        f.truncate()
        f.writelines(new_lines)
    return

if __name__ == '__main__':
    # del_qihoo("C:\\Users\\Administrator\\Desktop\\zt")
    remove_navigate("G:\\autopack2.0_kuaifa\\tool\\workspace\\lrs360\\13651\\extract")
