From 6cdff338ed0cd47fbc8fece5b2fbf91d97f67a05 Mon Sep 17 00:00:00 2001 From: chenjuntao Date: Mon, 19 May 2025 17:39:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B9=BF=E5=91=8A=E7=B3=BB=E7=BB=9F-?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B9=BF=E5=91=8A=E6=B8=B8=E6=88=8F=E7=9A=84?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E6=9D=A1=E4=BB=B6=20https://jira.shanqu.cc/b?= =?UTF-8?q?rowse/GHZSCY-8006?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../packagehelper/PackageRepository.kt | 19 ++++++++++++++++++- .../retrofit/service/ApiService.java | 7 +++++++ .../common/entity/InstalledPackagesAction.kt | 10 ++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 module_common/src/main/java/com/gh/gamecenter/common/entity/InstalledPackagesAction.kt diff --git a/app/src/main/java/com/gh/gamecenter/packagehelper/PackageRepository.kt b/app/src/main/java/com/gh/gamecenter/packagehelper/PackageRepository.kt index 807b21e103..67127c2783 100644 --- a/app/src/main/java/com/gh/gamecenter/packagehelper/PackageRepository.kt +++ b/app/src/main/java/com/gh/gamecenter/packagehelper/PackageRepository.kt @@ -9,15 +9,17 @@ import com.gh.common.filter.RegionSettingHelper import com.gh.common.util.GameUtils import com.gh.common.util.PackageHelper import com.gh.common.util.PackageUtils -import com.gh.gamecenter.R import com.gh.gamecenter.common.constant.Constants +import com.gh.gamecenter.common.entity.InstalledPackagesAction import com.gh.gamecenter.common.exposure.meta.MetaUtil import com.gh.gamecenter.common.loghub.LoghubUtils import com.gh.gamecenter.common.retrofit.BiResponse +import com.gh.gamecenter.common.retrofit.EmptyResponse import com.gh.gamecenter.common.retrofit.ObservableUtil import com.gh.gamecenter.common.retrofit.Response import com.gh.gamecenter.common.utils.secondOrNull import com.gh.gamecenter.common.utils.toArrayList +import com.gh.gamecenter.common.utils.toRequestBody import com.gh.gamecenter.common.utils.tryCatchInRelease import com.gh.gamecenter.core.runOnIoThread import com.gh.gamecenter.core.utils.SPUtils @@ -41,10 +43,12 @@ import io.reactivex.SingleObserver import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.Disposable import io.reactivex.schedulers.Schedulers +import okhttp3.ResponseBody import org.greenrobot.eventbus.EventBus import org.json.JSONException import org.json.JSONObject import java.util.* +import kotlin.collections.HashSet /** * 该类存储的是已安装的所有游戏(助手后台已收录的)和所有更新(包括插件化)数据 @@ -624,7 +628,20 @@ object PackageRepository { pkgSet.add(iterator.next()) } + postInstalledPackageList(pkgSet) + PackagesManager.initInstallPkgSet(pkgSet) } + private fun postInstalledPackageList(pkgSet: HashSet) { + val requestBody = InstalledPackagesAction( + action = "launch", + packages = pkgSet.toList() + ).toRequestBody() + + RetrofitManager.getInstance().newApi.postInstalledPackages(HaloApp.getInstance().gid, requestBody) + .subscribeOn(Schedulers.io()) + .subscribe(EmptyResponse()) + } + } \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java index 3302510d07..04dd31a6ac 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java +++ b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java @@ -3521,4 +3521,11 @@ public interface ApiService { @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("suggestions") Single uploadAcceleratorErrorLog(@Body RequestBody toRequestBody); + + /** + * 上传设备已安装的游戏 + */ + @POST("/devices/{device_id}/installed_games") + Single postInstalledPackages(@Path("device_id") String deviceId, @Body RequestBody body); + } \ No newline at end of file diff --git a/module_common/src/main/java/com/gh/gamecenter/common/entity/InstalledPackagesAction.kt b/module_common/src/main/java/com/gh/gamecenter/common/entity/InstalledPackagesAction.kt new file mode 100644 index 0000000000..8bd3f742c1 --- /dev/null +++ b/module_common/src/main/java/com/gh/gamecenter/common/entity/InstalledPackagesAction.kt @@ -0,0 +1,10 @@ +package com.gh.gamecenter.common.entity + +import android.os.Parcelable +import kotlinx.parcelize.Parcelize + +@Parcelize +class InstalledPackagesAction( + val action: String, + val packages: List, +): Parcelable \ No newline at end of file