Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fab379ad authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Stop service when the work is done

parent 34167a59
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -72,6 +72,12 @@ class CustomCertManager(
                }
            }
        }

        fun resetCertificates(context: Context): Boolean {
            val intent = Intent(context, CustomCertService::class.java)
            intent.action = CustomCertService.CMD_RESET_CERTIFICATES
            return context.startService(intent) != null
        }
    }

    /** for sending requests to {@link CustomCertService} */
@@ -265,12 +271,6 @@ class CustomCertManager(

    fun hostnameVerifier(defaultVerifier: HostnameVerifier?) = CustomHostnameVerifier(defaultVerifier)

    fun resetCertificates() {
        val intent = Intent(context, CustomCertService::class.java)
        intent.action = CustomCertService.CMD_RESET_CERTIFICATES
        context.startService(intent)
    }


    // hostname verifier

+6 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ class CustomCertService: Service() {
    private val pendingDecisions = HashMap<X509Certificate, MutableList<ReplyInfo>>()

    override fun onCreate() {
        Constants.log.info("Creating CustomCertService")
        Constants.log.info("CustomCertService created")

        // initialize trustedKeyStore
        keyStoreFile = File(getDir(KEYSTORE_DIR, Context.MODE_PRIVATE), KEYSTORE_NAME)
@@ -87,6 +87,10 @@ class CustomCertService: Service() {
        customTrustManager = CertUtils.getTrustManager(trustedKeyStore)
    }

    override fun onDestroy() {
        Constants.log.info("CustomCertService destroyed")
    }

    private fun inTrustStore(cert: X509Certificate) =
        try {
            trustedKeyStore.getCertificateAlias(cert) != null
@@ -117,6 +121,7 @@ class CustomCertService: Service() {
                }
            }
        }
        stopSelf()
        return START_NOT_STICKY
    }