|
@@ -7,6 +7,7 @@ import DownloadItem
|
7
|
7
|
import android.Manifest
|
8
|
8
|
import android.annotation.SuppressLint
|
9
|
9
|
import android.app.ActivityManager
|
|
10
|
+import android.content.ComponentName
|
10
|
11
|
import android.content.Context
|
11
|
12
|
import android.content.Intent
|
12
|
13
|
import android.content.IntentFilter
|
|
@@ -17,6 +18,7 @@ import android.graphics.drawable.Drawable
|
17
|
18
|
import android.net.ConnectivityManager
|
18
|
19
|
import android.os.Build
|
19
|
20
|
import android.provider.Settings
|
|
21
|
+import android.view.MotionEvent
|
20
|
22
|
import android.view.View
|
21
|
23
|
import android.widget.Button
|
22
|
24
|
import android.widget.EditText
|
|
@@ -60,6 +62,7 @@ import com.xhly.manageapp.bean.app.AppModel
|
60
|
62
|
import com.xhly.manageapp.bean.log.LogPushBean
|
61
|
63
|
import com.xhly.manageapp.bean.log.LogdOperateBean
|
62
|
64
|
import com.xhly.manageapp.bean.log.UpdateBean
|
|
65
|
+import com.xhly.manageapp.bean.scheme.AutoAppBean
|
63
|
66
|
import com.xhly.manageapp.bean.school.SchoolDeviceSetBean
|
64
|
67
|
import com.xhly.manageapp.bean.strategy.StrategyBean
|
65
|
68
|
import com.xhly.manageapp.bean.user.UserBean
|
|
@@ -110,6 +113,9 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
110
|
113
|
private var accountDialog:CustomDialog?=null
|
111
|
114
|
//创建应用卸载集合,方便获得应用信息
|
112
|
115
|
private val unInstallAppList= arrayListOf<AppInfo>()
|
|
116
|
+
|
|
117
|
+ //标记是否可以点击啊
|
|
118
|
+ private var canClickFlag=false
|
113
|
119
|
override fun getBinding() = ActivityMainBinding.inflate(layoutInflater)
|
114
|
120
|
|
115
|
121
|
@SuppressLint("CheckResult")
|
|
@@ -206,32 +212,6 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
206
|
212
|
FileUtils.deleteCurrentFlie(it)
|
207
|
213
|
}
|
208
|
214
|
val file = getExternalFilesDir(null)
|
209
|
|
- /* viewModel.viewModelScope.launch {
|
210
|
|
- modelList.forEach { app ->
|
211
|
|
- try {
|
212
|
|
- //获得已安装的应用判断版本,未安装的则直接静默安装。
|
213
|
|
- val filter =
|
214
|
|
- appList.filter { it.packageName.equals(app.appPackage) }
|
215
|
|
- //列表中不存在,或者版本较低则更新
|
216
|
|
- val apkPath = app.apkPath
|
217
|
|
- val appName = app.appName
|
218
|
|
- if (filter.isNotEmpty()) {
|
219
|
|
- val currentApp = filter[0]
|
220
|
|
- if (app.versionNum > currentApp.versionNum) {
|
221
|
|
- //版本低则更新安装。
|
222
|
|
- //AppDownLoadUtils.addToDownloadQueue(apkPath, appName,app.appPackage)
|
223
|
|
- DownLoadUtils.addDownload(apkPath,appName,File(file.toString(), "$appName.apk").toString(),app.appPackage)
|
224
|
|
- }
|
225
|
|
- } else {
|
226
|
|
- //不存在,直接下载安装。
|
227
|
|
- //AppDownLoadUtils.addToDownloadQueue(apkPath, appName,app.appPackage)
|
228
|
|
- DownLoadUtils.addDownload(apkPath,appName,File(file.toString(), "$appName.apk").toString(),app.appPackage)
|
229
|
|
- }
|
230
|
|
- } catch (e: Exception) {
|
231
|
|
- LogShow("问题" + e.toString())
|
232
|
|
- }
|
233
|
|
- }
|
234
|
|
- }*/
|
235
|
215
|
modelList.forEach { app ->
|
236
|
216
|
try {
|
237
|
217
|
//获得已安装的应用判断版本,未安装的则直接静默安装。
|
|
@@ -408,7 +388,33 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
408
|
388
|
viewModel.autoAppData.observe(this){
|
409
|
389
|
//连接不为空,并且应用已安装则跳转应用
|
410
|
390
|
if (it.authUrl!=null&&AppUtils.isAppInstalled(this,it.appPackage)){
|
411
|
|
- ZJAPPUtils.openApk(this,it.appPackage)
|
|
391
|
+ spUtils.saveJson(Const.AUTOAPPKEY,it)
|
|
392
|
+ val launchIntent = Intent()
|
|
393
|
+ launchIntent.setComponent(
|
|
394
|
+ ComponentName(
|
|
395
|
+ it.appPackage!!,
|
|
396
|
+ it.authUrl!!
|
|
397
|
+ )
|
|
398
|
+ )
|
|
399
|
+ startActivity(launchIntent)
|
|
400
|
+ }else{
|
|
401
|
+ try {
|
|
402
|
+ val autoAppBean = spUtils.getFromJson(Const.AUTOAPPKEY, AutoAppBean().javaClass) as AutoAppBean
|
|
403
|
+ if (it.authUrl!=null&&AppUtils.isAppInstalled(this,it.appPackage)){
|
|
404
|
+ val launchIntent = Intent()
|
|
405
|
+ launchIntent.setComponent(
|
|
406
|
+ ComponentName(
|
|
407
|
+ autoAppBean.appPackage!!,
|
|
408
|
+ autoAppBean.authUrl!!
|
|
409
|
+ )
|
|
410
|
+ )
|
|
411
|
+ startActivity(launchIntent)
|
|
412
|
+ }else{
|
|
413
|
+ canClickFlag=true
|
|
414
|
+ }
|
|
415
|
+ }catch (e:Exception){
|
|
416
|
+ canClickFlag=true
|
|
417
|
+ }
|
412
|
418
|
}
|
413
|
419
|
}
|
414
|
420
|
startWorkManager()
|
|
@@ -1266,6 +1272,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
1266
|
1272
|
timer?.cancel()
|
1267
|
1273
|
timer = null
|
1268
|
1274
|
}
|
|
1275
|
+ AppSocket.onDestroy()
|
1269
|
1276
|
DownLoadUtils.removeCallback(this)
|
1270
|
1277
|
mMyInstallReceiver?.let {
|
1271
|
1278
|
unregisterReceiver(it)
|
|
@@ -1307,4 +1314,12 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
1307
|
1314
|
override fun onLoading(downItem: DownloadItem) {
|
1308
|
1315
|
|
1309
|
1316
|
}
|
|
1317
|
+
|
|
1318
|
+ override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
|
|
1319
|
+ return if (canClickFlag){
|
|
1320
|
+ super.dispatchTouchEvent(ev)
|
|
1321
|
+ }else{
|
|
1322
|
+ true
|
|
1323
|
+ }
|
|
1324
|
+ }
|
1310
|
1325
|
}
|