RestartReceiver.kt 600 B

123456789101112131415161718
  1. package com.github.kr328.clash
  2. import android.content.BroadcastReceiver
  3. import android.content.Context
  4. import android.content.Intent
  5. import com.github.kr328.clash.service.StatusProvider
  6. import com.github.kr328.clash.util.startClashService
  7. class RestartReceiver : BroadcastReceiver() {
  8. override fun onReceive(context: Context, intent: Intent) {
  9. when (intent.action) {
  10. Intent.ACTION_BOOT_COMPLETED, Intent.ACTION_MY_PACKAGE_REPLACED -> {
  11. if (StatusProvider.shouldStartClashOnBoot)
  12. context.startClashService()
  13. }
  14. }
  15. }
  16. }