|
@@ -309,56 +309,56 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
309
|
309
|
}
|
310
|
310
|
}
|
311
|
311
|
}
|
312
|
|
-
|
313
|
312
|
viewModel.viewModelScope.launch {
|
314
|
313
|
viewModel.forceListAppData.collect { modelList ->
|
315
|
314
|
modelList?.let {
|
316
|
|
- //获得必装应用,未安装或者版本较低则更新,先删除目录中的文件
|
317
|
|
- val rxPermissions = RxPermissions(this@MainActivity)
|
318
|
|
- rxPermissions.request(Manifest.permission.REQUEST_INSTALL_PACKAGES)
|
319
|
|
- .subscribe { granted ->
|
320
|
|
- if (granted || ModelNameUtils.IS_LianxX505f()||ModelNameUtils.IS_LianxX6e6f()) {
|
321
|
|
- // 权限已授予,执行安装操作
|
322
|
|
- val appList = AppUtils.GetAppList(this@MainActivity)
|
323
|
|
- getExternalFilesDir(null)?.let {
|
324
|
|
- FileUtils.deleteCurrentFlie(it)
|
325
|
|
- }
|
326
|
|
- val file = getExternalFilesDir(null)
|
327
|
|
- modelList.forEach { app ->
|
328
|
|
- try {
|
329
|
|
- //获得已安装的应用判断版本,未安装的则直接静默安装。
|
330
|
|
- val filter =
|
331
|
|
- appList.filter { it.packageName.equals(app.appPackage) }
|
332
|
|
- //列表中不存在,或者版本较低则更新
|
333
|
|
- val apkPath = app.apkPath
|
334
|
|
- val appName = app.appName
|
335
|
|
- if (filter.isNotEmpty()||app.appPackage.equals(packageName)) {
|
336
|
|
- val appversion=if (app.appPackage.equals(packageName)){
|
337
|
|
- SystemUtil.getAppVersionCode(this@MainActivity,packageName)
|
338
|
|
- }else{
|
339
|
|
- filter[0].versionNum
|
340
|
|
- }
|
341
|
|
- if (app.versionNum > appversion) {
|
342
|
|
- //版本低则更新安装。
|
|
315
|
+ //如果已经进入商店则不显示
|
|
316
|
+ if (!Const.startAppStoreFlag){
|
|
317
|
+ //获得必装应用,未安装或者版本较低则更新,先删除目录中的文件
|
|
318
|
+ val rxPermissions = RxPermissions(this@MainActivity)
|
|
319
|
+ rxPermissions.request(Manifest.permission.REQUEST_INSTALL_PACKAGES)
|
|
320
|
+ .subscribe { granted ->
|
|
321
|
+ if (granted || ModelNameUtils.IS_LianxX505f()||ModelNameUtils.IS_LianxX6e6f()) {
|
|
322
|
+ // 权限已授予,执行安装操作
|
|
323
|
+ val appList = AppUtils.GetAppList(this@MainActivity)
|
|
324
|
+ getExternalFilesDir(null)?.let {
|
|
325
|
+ FileUtils.deleteCurrentFlie(it)
|
|
326
|
+ }
|
|
327
|
+ val file = getExternalFilesDir(null)
|
|
328
|
+ modelList.forEach { app ->
|
|
329
|
+ try {
|
|
330
|
+ //获得已安装的应用判断版本,未安装的则直接静默安装。
|
|
331
|
+ val filter =
|
|
332
|
+ appList.filter { it.packageName.equals(app.appPackage) }
|
|
333
|
+ //列表中不存在,或者版本较低则更新
|
|
334
|
+ val apkPath = app.apkPath
|
|
335
|
+ val appName = app.appName
|
|
336
|
+ if (filter.isNotEmpty()||app.appPackage.equals(packageName)) {
|
|
337
|
+ val appversion=if (app.appPackage.equals(packageName)){
|
|
338
|
+ SystemUtil.getAppVersionCode(this@MainActivity,packageName)
|
|
339
|
+ }else{
|
|
340
|
+ filter[0].versionNum
|
|
341
|
+ }
|
|
342
|
+ if (app.versionNum > appversion) {
|
|
343
|
+ //版本低则更新安装。
|
|
344
|
+ //AppDownLoadUtils.addToDownloadQueue(apkPath, appName,app.appPackage)
|
|
345
|
+ DownLoadUtils.addDownload(apkPath,app.appPackage,File(file.toString(), "$appName.apk").toString(),app.appPackage,appName)
|
|
346
|
+ }
|
|
347
|
+ } else {
|
|
348
|
+ //不存在,直接下载安装。
|
343
|
349
|
//AppDownLoadUtils.addToDownloadQueue(apkPath, appName,app.appPackage)
|
344
|
350
|
DownLoadUtils.addDownload(apkPath,app.appPackage,File(file.toString(), "$appName.apk").toString(),app.appPackage,appName)
|
345
|
351
|
}
|
346
|
|
- } else {
|
347
|
|
- //不存在,直接下载安装。
|
348
|
|
- //AppDownLoadUtils.addToDownloadQueue(apkPath, appName,app.appPackage)
|
349
|
|
- DownLoadUtils.addDownload(apkPath,app.appPackage,File(file.toString(), "$appName.apk").toString(),app.appPackage,appName)
|
|
352
|
+ } catch (e: Exception) {
|
|
353
|
+ LogShow("问题" + e.toString())
|
350
|
354
|
}
|
351
|
|
- } catch (e: Exception) {
|
352
|
|
- LogShow("问题" + e.toString())
|
353
|
355
|
}
|
|
356
|
+ } else {
|
|
357
|
+ // 用户拒绝了安装权限,处理相应逻辑
|
|
358
|
+ viewModel.getAppList()
|
354
|
359
|
}
|
355
|
|
- } else {
|
356
|
|
- // 用户拒绝了安装权限,处理相应逻辑
|
357
|
|
- viewModel.getAppList()
|
358
|
360
|
}
|
359
|
|
-
|
360
|
|
- }
|
361
|
|
-
|
|
361
|
+ }
|
362
|
362
|
}
|
363
|
363
|
}
|
364
|
364
|
|
|
@@ -795,6 +795,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
795
|
795
|
}
|
796
|
796
|
|
797
|
797
|
})*/
|
|
798
|
+ Const.startAppStoreFlag=false
|
798
|
799
|
updateNetErrorAppRv()
|
799
|
800
|
updateResumeStrategy()
|
800
|
801
|
/* userBean?.let {
|
|
@@ -1856,7 +1857,10 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
1856
|
1857
|
|
1857
|
1858
|
override fun onSuccess(downItem: DownloadItem) {
|
1858
|
1859
|
/* ManageApplication.installPackage(downItem.savepath)*/
|
1859
|
|
- InstallUtils.addInstall(downItem.savepath,downItem.pkgName,downItem.appName)
|
|
1860
|
+ //进入应用商店才安装
|
|
1861
|
+ if (!Const.startAppStoreFlag){
|
|
1862
|
+ InstallUtils.addInstall(downItem.savepath,downItem.pkgName,downItem.appName)
|
|
1863
|
+ }
|
1860
|
1864
|
}
|
1861
|
1865
|
|
1862
|
1866
|
override fun onFailure(downItem: DownloadItem, errMsg: String) {
|