diff --git a/.gitignore b/.gitignore index 98d8864bd4..ae637c2a1b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ build/ release-app/ test-app/ scripts/apk-channel/ -app/src/test/java/com/gh/gamecenter \ No newline at end of file +app/src/test/java/com/gh/gamecenter +app/src/main/assets-debug/ +app/src/main/assets-release/ \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 3e9004104b..ffb5a1e4c0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -8,3 +8,6 @@ [submodule "ndownload"] path = ndownload url = ../../../android/ndownload.git +[submodule "vasdk"] + path = vasdk + url = ../../../sdg/android/vasdk.git diff --git a/app/build.gradle b/app/build.gradle index 97c481893b..e5d8d6de60 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -75,7 +75,7 @@ android { versionName rootProject.ext.versionName applicationId rootProject.ext.applicationId - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-fresco.txt' + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-fresco.txt', rootProject.ext.va_proguard_rules String CORE_EVENT_GAME_CATEGORY = "" @@ -164,6 +164,15 @@ android { flavorDimensions("env", "region") sourceSets { + + debug { + assets.srcDirs += 'src/main/assets-debug' + } + + release { + assets.srcDirs += 'src/main/assets-release' + } + publish { java.srcDirs = ['src/main/java', "src/default/java"] } @@ -368,7 +377,7 @@ dependencies { kapt "com.alibaba:arouter-compiler:$arouterVersion" implementation project(':ndownload') - implementation project(':vspace-bridge:vspace') + implementation project(':vspace-bridge') implementation (project(':module_common')) { exclude group: 'androidx.swiperefreshlayout' @@ -416,6 +425,17 @@ dependencies { // implementation(pushProject) { // exclude group: 'androidx.swiperefreshlayout' // } + + implementation(project(":va-lib")) + implementation(project(':va-main')) { + exclude group: 'androidx.swiperefreshlayout' + } + debugImplementation "com.bytedance.tools.codelocator:codelocator-core:2.0.3" + compileOnly project(":va-core") + compileOnly project(":va-plugin-host-lib") + implementation project(":va-plugin-host") + implementation project(":va-archive") + } File propFile = file('sign.properties') diff --git a/app/src/internal/java/com/gh/vspace/ExternalGameUsage.kt b/app/src/internal/java/com/gh/vspace/ExternalGameUsage.kt index 584c697d1e..bc880b14be 100644 --- a/app/src/internal/java/com/gh/vspace/ExternalGameUsage.kt +++ b/app/src/internal/java/com/gh/vspace/ExternalGameUsage.kt @@ -1,32 +1,79 @@ package com.gh.vspace import android.content.Intent +import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.annotation.Keep import com.gh.gamecenter.R +import com.gh.gamecenter.core.utils.ToastUtils import com.gh.gamecenter.databinding.LayoutPersonalOtherItemBinding import com.gh.vspace.installexternalgames.InstallExternalGameActivity +import com.lg.vspace.VaApp +import com.lg.vspace.plugin.host.PluginHelper +import com.lightgame.utils.Utils +import com.lightgame.utils.toast.ToastHelper +import com.lody.virtual.client.core.VirtualCore +import java.io.File @Keep -class ExternalGameUsage : IExternalGamesUsage { - override fun addInstallExternalGameButton(viewParent: ViewGroup) { +class ExternalGameUsage : ITestCase { + + private fun buttonTemplate(viewParent: ViewGroup, id: Int, fn: (LayoutPersonalOtherItemBinding) -> Unit) { val context = viewParent.context - viewParent.findViewById(R.id.install_game_from_external) ?: run { + viewParent.findViewById(id) ?: run { val binding = LayoutPersonalOtherItemBinding.inflate(LayoutInflater.from(context)).apply { - root.id = R.id.install_game_from_external - titleTv.text = context.getString(R.string.title_install_external_game) - iconIv.setImageResource(R.drawable.ic_personal_my_game) - root.setOnClickListener { - VHelper.connectService { - context.startActivity( - InstallExternalGameActivity.getIntent(context) - .apply { flags = flags or Intent.FLAG_ACTIVITY_NEW_TASK }) - } - } + root.id = id + fn(this) } viewParent.addView(binding.root, 0) } } + + override fun addInstallExternalGameButton(viewParent: ViewGroup) { + val context = viewParent.context + buttonTemplate(viewParent, R.id.install_game_from_external) { + it.titleTv.text = context.getString(R.string.title_install_external_game) + it.iconIv.setImageResource(R.drawable.ic_personal_my_game) + it.root.setOnClickListener { + VHelper.connectService { + context.startActivity( + InstallExternalGameActivity.getIntent(context) + .apply { flags = flags or Intent.FLAG_ACTIVITY_NEW_TASK }) + } + } + } + } + + override fun addInstallPluginButton(viewParent: ViewGroup) { + buttonTemplate(viewParent, R.id.install_plugin) { + it.titleTv.text = "安装64位插件" + it.root.setOnClickListener { + val file = File("/data/local/tmp/gh-plugins/artifacts.zip") + if (file.exists()) { + Utils.log(VHelper.LOG_TAG, "有本地更新文件: 64位插件") + // TODO: 补充debug插件更新 + ToastUtils.showToast("暂未实现debug功能") + } else { + ToastUtils.showToast("data/local/tmp没有push文件") + } + } + } + } + + override fun addInstallPlugin32Button(viewParent: ViewGroup) { + buttonTemplate(viewParent, R.id.install_plugin_32) { + it.titleTv.text = "安装32位插件" + it.root.setOnClickListener { + val file = File("/data/local/tmp/gh-plugins/artifacts32.zip") + if (file.exists()) { + // TODO: 补充debug插件更新 + ToastUtils.showToast("暂未实现debug功能") + } else { + ToastUtils.showToast("data/local/tmp没有push文件") + } + } + } + } } \ No newline at end of file diff --git a/app/src/internal/java/com/gh/vspace/installexternalgames/ExternalGameAdapter.kt b/app/src/internal/java/com/gh/vspace/installexternalgames/ExternalGameAdapter.kt index 534b51a36a..61b9c5ec44 100644 --- a/app/src/internal/java/com/gh/vspace/installexternalgames/ExternalGameAdapter.kt +++ b/app/src/internal/java/com/gh/vspace/installexternalgames/ExternalGameAdapter.kt @@ -25,6 +25,11 @@ class ExternalGameAdapter(private val games: List, private 路径:${item.apkPath} """.trimIndent() } + + holder.update.setOnClickListener { + onItemClickListener.onItemClick(item, OnItemClickListener.ClickType.CLICK_INSTALL) + } + holder.install.goneIf(item.isInstalled) { holder.install.setOnClickListener { onItemClickListener.onItemClick(item, OnItemClickListener.ClickType.CLICK_INSTALL) diff --git a/app/src/internal/java/com/gh/vspace/installexternalgames/ExternalGameViewHolder.kt b/app/src/internal/java/com/gh/vspace/installexternalgames/ExternalGameViewHolder.kt index 3a339b0088..9ab762e115 100644 --- a/app/src/internal/java/com/gh/vspace/installexternalgames/ExternalGameViewHolder.kt +++ b/app/src/internal/java/com/gh/vspace/installexternalgames/ExternalGameViewHolder.kt @@ -8,4 +8,5 @@ class ExternalGameViewHolder(binding: LayoutExternalGameItemBinding) : RecyclerV val install = binding.btnInstall val uninstall = binding.btnUninstall val start = binding.btnStart + val update = binding.btnUpdate } \ No newline at end of file diff --git a/app/src/internal/java/com/gh/vspace/installexternalgames/InstallExternalGameFragment.kt b/app/src/internal/java/com/gh/vspace/installexternalgames/InstallExternalGameFragment.kt index 9b9e3499c9..26d16ac40a 100644 --- a/app/src/internal/java/com/gh/vspace/installexternalgames/InstallExternalGameFragment.kt +++ b/app/src/internal/java/com/gh/vspace/installexternalgames/InstallExternalGameFragment.kt @@ -16,6 +16,7 @@ import com.gh.gamecenter.databinding.FragmentInstallExternalGamesBinding import com.gh.vspace.VHelper import com.halo.assistant.HaloApp import com.lg.vspace.VirtualAppManager +import com.lightgame.download.DownloadEntity import io.reactivex.Single import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.Disposable @@ -105,6 +106,15 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener { private fun install(externalGameUiState: ExternalGameUiState) { val bit = externalGameUiState.externalGameEntity.cpuAbi.let { if (it.size == 1 && it.contains("armeabi-v7a")) "32" else "64" } + + VHelper.install(requireContext(), DownloadEntity().apply { + externalGameUiState.externalGameEntity.apply { + packageName = apkPackageName + path = apkPath + } + }, true) + + if (VHelper.showDialogIfVSpaceIsNeeded( requireContext(), "", @@ -144,7 +154,9 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener { com.gh.gamecenter.BuildConfig.VERSION_NAME, HaloApp.getInstance().channel, "", - "" + "", + com.lg.core.BuildConfig.VERSION_NAME, + HaloApp.getInstance().oaid ) requireActivity().startActivity(intent) } diff --git a/app/src/internal/res/layout/layout_external_game_item.xml b/app/src/internal/res/layout/layout_external_game_item.xml index 066c698eec..a623ca3c24 100644 --- a/app/src/internal/res/layout/layout_external_game_item.xml +++ b/app/src/internal/res/layout/layout_external_game_item.xml @@ -24,6 +24,14 @@ android:visibility="gone" tools:visibility="visible" /> +