Merge branch 'hotfix-v4.5.0-250-crash' into 'release'
Hotfix v4.5.0 250 crash See merge request halo/assistant-android!44
This commit is contained in:
@ -118,7 +118,9 @@ class CertificationDialog(context: Context, private val authDialogEntity: AuthDi
|
||||
|
||||
//跳转登录页面
|
||||
private fun gotoLoginPage() {
|
||||
CheckLoginUtils.checkLogin(AppManager.getInstance().currentActivity() as AppCompatActivity,
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
CheckLoginUtils.checkLogin(currentActivity as AppCompatActivity,
|
||||
null, true, "实名认证弹窗") {
|
||||
if (UserManager.getInstance().isAuth) {
|
||||
listener.onConfirm()
|
||||
@ -129,7 +131,9 @@ class CertificationDialog(context: Context, private val authDialogEntity: AuthDi
|
||||
|
||||
//跳转实名认证页面
|
||||
private fun gotoAuthPage() {
|
||||
AvoidOnResultManager.getInstance(AppManager.getInstance().currentActivity() as AppCompatActivity)
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
AvoidOnResultManager.getInstance(currentActivity as AppCompatActivity)
|
||||
.startForResult(UserInfoEditActivity.getIntent(context, UserViewModel.TYPE_ID_CARD), object : Callback {
|
||||
override fun onActivityResult(resultCode: Int, data: Intent?) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
|
||||
@ -76,9 +76,10 @@ object DownloadObserver {
|
||||
// MtaHelper.onEventWithBasicDeviceInfo("下载失败弹窗",
|
||||
// "游戏", downloadEntity.name,
|
||||
// "平台", downloadEntity.platform)
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
DialogUtils.showAlertDialog(AppManager.getInstance().currentActivity(), "下载失败", "下载链接已失效,建议提交反馈", "立即反馈", "取消", {
|
||||
SuggestionActivity.startSuggestionActivity(AppManager.getInstance().currentActivity(),
|
||||
DialogUtils.showAlertDialog(currentActivity, "下载失败", "下载链接已失效,建议提交反馈", "立即反馈", "取消", {
|
||||
SuggestionActivity.startSuggestionActivity(currentActivity,
|
||||
SuggestType.gameQuestion, "notfound",
|
||||
StringUtils.buildString(downloadEntity.name, ",问题反馈:下载链接失效"),
|
||||
SimpleGameEntity(gameId, downloadEntity.name, ""))
|
||||
@ -141,7 +142,9 @@ object DownloadObserver {
|
||||
if (gameEntity?.simulator != null) {
|
||||
val isInstalled = PackageUtils.isInstalledFromAllPackage(HaloApp.getInstance().application, gameEntity.simulator!!.apk!!.packageName)
|
||||
if (!isInstalled) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(AppManager.getInstance().currentActivity(), gameEntity.simulator,
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(currentActivity, gameEntity.simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.id, gameEntity.name
|
||||
?: "", null)
|
||||
}
|
||||
|
||||
@ -41,7 +41,10 @@ object PackageInstaller {
|
||||
fun install(context: Context, downloadEntity: DownloadEntity, showUnzipToast: Boolean) {
|
||||
val pkgPath = downloadEntity.path
|
||||
val isXapk = XapkInstaller.XAPK_EXTENSION_NAME == pkgPath.getExtension()
|
||||
InstallPermissionDialogFragment.show(AppManager.getInstance().currentActivity() as AppCompatActivity, downloadEntity) {
|
||||
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
InstallPermissionDialogFragment.show(currentActivity as AppCompatActivity, downloadEntity) {
|
||||
// 取消状态栏下载完成的通知,若存在
|
||||
downloadEntity.meta[Constants.MARK_ALREADY_TRIGGERED_INSTALLATION] = "YES"
|
||||
DownloadNotificationHelper.addOrUpdateDownloadNotification(downloadEntity)
|
||||
|
||||
@ -61,7 +61,7 @@ object PackageRepository {
|
||||
val gameUpdateLiveData = MutableLiveData<List<GameUpdateEntity>>()
|
||||
val gameInstalledLiveData = MutableLiveData<List<GameInstall>>()
|
||||
|
||||
val gameInstalled = ArrayList<GameInstall>()
|
||||
val gameInstalled = Collections.synchronizedList(ArrayList<GameInstall>())
|
||||
val gameUpdate = ArrayList<GameUpdateEntity>()
|
||||
|
||||
init {
|
||||
@ -190,7 +190,7 @@ object PackageRepository {
|
||||
*
|
||||
* @param list 已安装的游戏包名集合
|
||||
*/
|
||||
private fun loadInstalledGameDigestAndNotifyData(list: ArrayList<String>) {
|
||||
private fun loadInstalledGameDigestAndNotifyData(list: ArrayList<String>, onWorkerThreadOnly: Boolean = false) {
|
||||
var isNotifyUpdate = false
|
||||
val latch = ObservableUtil.latch(list.size, {
|
||||
if (isNotifyUpdate || gameUpdateLiveData.value == null) notifyGameUpdateData()
|
||||
@ -199,33 +199,39 @@ object PackageRepository {
|
||||
|
||||
for (pkgName in list) {
|
||||
val filterQuery = UrlFilterUtils.getFilterQuery("package", pkgName)
|
||||
mSensitiveApi.loadGameDataByPackageName(filterQuery)
|
||||
|
||||
var observable = mSensitiveApi.loadGameDataByPackageName(filterQuery)
|
||||
.map(RegionSettingHelper.filterGame)
|
||||
.map(ApkActiveUtils.filterMapperList)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<List<GameEntity>>() {
|
||||
override fun onResponse(response: List<GameEntity>?) {
|
||||
if (response != null) {
|
||||
val gh_id = PackageUtils.getMetaData(HaloApp.getInstance().application, pkgName, "gh_id")
|
||||
for (game in response) {
|
||||
if (gh_id == null || gh_id == game.id) {
|
||||
gameInstalled.add(GameInstall.transformGameInstall(game, pkgName))
|
||||
val isCanPluggable = checkGamePlugin(game, pkgName)
|
||||
val isCanUpdate = checkGameUpdate(game)
|
||||
if (!isNotifyUpdate && isCanUpdate || isCanPluggable) {
|
||||
isNotifyUpdate = true
|
||||
}
|
||||
}
|
||||
|
||||
if (!onWorkerThreadOnly) {
|
||||
// 这里面的代码(根据包名获取签名?)或许是造成安装完成后的 ANR 和 startForegroundService did not then call startForeground 的原因
|
||||
// 为了避免影响其它地方,这里只处理安装完成后的调用
|
||||
observable = observable.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
observable.subscribe(object : Response<List<GameEntity>>() {
|
||||
override fun onResponse(response: List<GameEntity>?) {
|
||||
if (response != null) {
|
||||
val gh_id = PackageUtils.getMetaData(HaloApp.getInstance().application, pkgName, "gh_id")
|
||||
for (game in response) {
|
||||
if (gh_id == null || gh_id == game.id) {
|
||||
gameInstalled.add(GameInstall.transformGameInstall(game, pkgName))
|
||||
val isCanPluggable = checkGamePlugin(game, pkgName)
|
||||
val isCanUpdate = checkGameUpdate(game)
|
||||
if (!isNotifyUpdate && isCanUpdate || isCanPluggable) {
|
||||
isNotifyUpdate = true
|
||||
}
|
||||
}
|
||||
latch.countDown()
|
||||
}
|
||||
}
|
||||
latch.countDown()
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
latch.countDown()
|
||||
}
|
||||
})
|
||||
override fun onFailure(e: HttpException?) {
|
||||
latch.countDown()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,7 +309,7 @@ object PackageRepository {
|
||||
|
||||
val list = ArrayList<String>()
|
||||
list.add(pkgName)
|
||||
loadInstalledGameDigestAndNotifyData(list)
|
||||
loadInstalledGameDigestAndNotifyData(list, true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user