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

Commit da413daa authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

chore: small tunings to make it works

parent 5d9bbe79
Loading
Loading
Loading
Loading
Loading
+8 −12
Original line number Diff line number Diff line
@@ -87,9 +87,13 @@ class ReLoginWithOidcActivity : AppCompatActivity() {
    private fun loginAccount(accountType: String) {

        val callback: (AliasFuture) -> Unit = { future ->
            val intent = getIntentFromFuture(future)
            intent?.let(::startActivity)
            Logger.log.info("Vincent: callback for login account. Intent started. About to finish ${this.javaClass}")
            val accountName = future.result?.getString(KEY_ACCOUNT_NAME)
            if (accountName != null) {
                Logger.log.info("Account $accountName logged again")
            } else {
                Logger.log.warning("No new account relogged")
            }


            Handler(Looper.getMainLooper()).post {
                finishAndRemoveTask()
@@ -97,21 +101,13 @@ class ReLoginWithOidcActivity : AppCompatActivity() {
        }

        try {
            accountManager.addAccount(accountType,null, null, null, null, callback, null)
            accountManager.addAccount(accountType,null, null, null, this, callback, null)
        } catch (exception: Exception) {
            Logger.log.warning("${exception.javaClass}: can't add account: ${exception.message}")
            finishAndRemoveTask()
        }
    }

    private fun getIntentFromFuture(future: AliasFuture): Intent? {
        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            future.result?.getParcelable(KEY_INTENT, Intent::class.java)
        } else {
            future.result?.getParcelable(KEY_INTENT)
        }
    }

    companion object {
        private var isAccountRemoved = false
    }