package com.gh.gamecenter.provider

import android.app.Activity
import android.app.Application
import android.text.TextUtils
import com.gh.gamecenter.common.constant.Config
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.utils.PackageFlavorHelper
import com.gh.gamecenter.core.provider.IFlavorProvider
import com.gh.gamecenter.core.utils.SPUtils
import com.tencent.vasdolly.helper.ChannelReaderUtil

class FlavorProviderImp : IFlavorProvider {
    override fun getChannelStr(application: Application): String {
        var channel = ChannelReaderUtil.getChannel(application)
        if (channel == null || TextUtils.isEmpty(channel.trim())) {
            channel = if (PackageFlavorHelper.IS_TEST_FLAVOR) {
                Config.DEFAULT_CHANNEL
            } else {
                Config.DEFAULT_CHANNEL_FOR_RELEASE
            }
        }
        if (PackageFlavorHelper.IS_TEST_FLAVOR) {
            channel = SPUtils.getString(Constants.SP_TEST_FLAVOR_CHANNEL, channel)
        }
        return channel
    }

    override fun init(application: Application, activity: Activity, activateRatio: Int) {
        // do nothing
    }

    override fun logEvent(content: String) {
        // do nothing
    }

    override fun logCoreEvent() {
        // do nothing
    }
}