package com.ch.jedge.demo.glm;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

import com.ch.jedge.demo.glm.asserts.QAssetsCopyer;
import com.ch.jedge.demo.glm.service.BaseJedgeService;
import com.ch.jedge.demo.glm.service.JBotService;
import com.ch.jedge.demo.glm.service.JGlmService;
import com.ch.jedge.demo.glm.service.MgsService;
import com.ch.jedge.demo.glm.service.TVAgentService;
import com.changhong.qlib.util.file.FileUtils;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        String service = "services";
        String cfg_dir = "cfg";
        String jedgeBasePath = QAssetsCopyer.getLocalCachePath(this, service);
        String jedgeCfgPath = QAssetsCopyer.getLocalCachePath(this, cfg_dir);
        if(!QAssetsCopyer.copyAssetFolder(getAssets(), cfg_dir, jedgeCfgPath)) {
            Log.e("JEDGE","Fail to copy service files : " + service);
        }
        String dir = FileUtils.contactPath(jedgeBasePath, "mgs");

        BaseJedgeService.startJedgeService(this , dir, jedgeBasePath, "mgs", MgsService.class);
        BaseJedgeService.startJedgeService(this , dir, jedgeBasePath, "jbot", JBotService.class);
        BaseJedgeService.startJedgeService(this , dir, jedgeBasePath, "llm", JGlmService.class);
        BaseJedgeService.startJedgeService(this , dir, jedgeBasePath, "tvass", TVAgentService.class);
    }
}