|
@@ -10,6 +10,7 @@ import android.content.Intent
|
|
|
import android.os.Build
|
|
|
import android.util.Log
|
|
|
import androidx.annotation.RequiresApi
|
|
|
+import com.common.lib_base.common.async.ThreadPoolManager
|
|
|
import com.common.lib_base.utils.log.AppLogUtils
|
|
|
import com.hh.hhomc.keeplive.LocalService
|
|
|
import com.hh.hhomc.keeplive.RemoteService
|
|
@@ -53,45 +54,52 @@ class MyJobService :JobService(){
|
|
|
|
|
|
override fun onStartJob(params: JobParameters?): Boolean {
|
|
|
AppLogUtils.i("开启job")
|
|
|
+ ThreadPoolManager.getInstance().executeIOTask {
|
|
|
+ try {
|
|
|
|
|
|
- //如果7.0以上 轮训
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
|
- StartJob(this)
|
|
|
- }
|
|
|
- val isLocalRun: Boolean = Utils.isRunningService(
|
|
|
- this,
|
|
|
- LocalService::class.java.name
|
|
|
- )
|
|
|
- val isRemoteRun: Boolean = Utils.isRunningService(
|
|
|
- this,
|
|
|
- RemoteService::class.java.name
|
|
|
- )
|
|
|
-
|
|
|
- val isBackgroundServiceRun: Boolean = Utils.isRunningService(
|
|
|
- this,
|
|
|
- BackgroundService::class.java.name
|
|
|
- )
|
|
|
-
|
|
|
- //只有其中任何一个服务被干掉了,则进行start
|
|
|
- if (!isLocalRun || !isRemoteRun || !isBackgroundServiceRun) {
|
|
|
-
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
- // 8.0
|
|
|
- startForegroundService(Intent(this, LocalService::class.java));
|
|
|
- startForegroundService(Intent(this, RemoteService::class.java));
|
|
|
- startForegroundService(Intent(this, BackgroundService::class.java));
|
|
|
- }else{
|
|
|
- startService(Intent(this, LocalService::class.java))
|
|
|
- startService(Intent(this, RemoteService::class.java))
|
|
|
-
|
|
|
- startService(Intent(this, BackgroundService::class.java))
|
|
|
- }
|
|
|
+ val isLocalRun: Boolean = Utils.isRunningService(
|
|
|
+ this,
|
|
|
+ LocalService::class.java.name
|
|
|
+ )
|
|
|
+ val isRemoteRun: Boolean = Utils.isRunningService(
|
|
|
+ this,
|
|
|
+ RemoteService::class.java.name
|
|
|
+ )
|
|
|
|
|
|
+ val isBackgroundServiceRun: Boolean = Utils.isRunningService(
|
|
|
+ this,
|
|
|
+ BackgroundService::class.java.name
|
|
|
+ )
|
|
|
|
|
|
+ //只有其中任何一个服务被干掉了,则进行start
|
|
|
+ if (!isLocalRun || !isRemoteRun || !isBackgroundServiceRun) {
|
|
|
|
|
|
- }
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
+ // 8.0
|
|
|
+ startForegroundService(Intent(this, LocalService::class.java));
|
|
|
+ startForegroundService(Intent(this, RemoteService::class.java));
|
|
|
+ startForegroundService(Intent(this, BackgroundService::class.java));
|
|
|
+ } else {
|
|
|
+ startService(Intent(this, LocalService::class.java))
|
|
|
+ startService(Intent(this, RemoteService::class.java))
|
|
|
+
|
|
|
+ startService(Intent(this, BackgroundService::class.java))
|
|
|
+ }
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } catch (e: java.lang.Exception) {
|
|
|
+
|
|
|
+ } finally {
|
|
|
+ //如果7.0以上 轮训
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
|
+ StartJob(this)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
return false
|