package com.gh.gamecenter.aidl

import android.app.Service
import android.content.Intent
import android.os.IBinder
import com.gh.vspace.VArchiveHelper
import com.gh.vspace.VHelper
import com.lg.vclient.interfaces.ICommunicationManager
import com.lg.vspace.remote.model.VGameInstallerResult
import com.lightgame.utils.Utils

class CommunicationService : Service() {

    private var mBinder: ICommunicationManager.Stub = object : ICommunicationManager.Stub() {
        override fun archiveUnzipCompleted(packageName: String, isSuccess: Boolean) {
            Utils.log(VHelper.LOG_TAG, "包名 $packageName 应用存档的结果是 $isSuccess")

            VArchiveHelper.onApplyGameArchiveFinished(packageName, isSuccess)
        }

        override fun archiveinPackageCompleted(packageName: String, isSuccess: Boolean) {
            Utils.log(VHelper.LOG_TAG, "包名 $packageName 保存存档的结果是 $isSuccess")

            VArchiveHelper.onSaveGameArchiveFinished(packageName, isSuccess)
        }

        override fun installGameCompleted(packageName: String, params: VGameInstallerResult) {
            Utils.log(VHelper.LOG_TAG, "包名 $packageName 安装的结果是 ${params.status}")

            VHelper.onInstallFinished(packageName, params.status)
        }

        override fun connectionCompleted() {
//            Utils.log(VHelper.LOG_TAG, "服务回调连接成功")
//
//            VHelper.onConnectionCompleted(shouldReconnect = true)
        }
    }

    override fun onBind(intent: Intent?): IBinder {
        return mBinder
    }

}