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

Commit 52845fdf authored by Milton Wu's avatar Milton Wu
Browse files

Fix biometric activities launched twice

Save launched state

Bug: 401461494
Test: After pressing Done in biometric confirmation page, intro page
      don not show again
Flag: EXEMPT bug fix
Change-Id: I7dfca8e2a6752a20de0429b61f8d9885fdd12e47
parent 744ed220
Loading
Loading
Loading
Loading
+30 −11
Original line number Original line Diff line number Diff line
@@ -23,7 +23,6 @@ import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatActivity
import com.android.settings.biometrics.BiometricEnrollBase.RESULT_FINISHED
import com.android.settings.biometrics.BiometricEnrollBase.RESULT_FINISHED
import com.android.settings.biometrics.combination.CombinedBiometricStatusUtils
import com.android.settings.biometrics.combination.CombinedBiometricStatusUtils

import com.android.settings.overlay.FeatureFactory.Companion.featureFactory
import com.android.settings.overlay.FeatureFactory.Companion.featureFactory


class FaceEnroll: AppCompatActivity() {
class FaceEnroll: AppCompatActivity() {
@@ -39,9 +38,16 @@ class FaceEnroll: AppCompatActivity() {
    private val enrollActivityProvider: FaceEnrollActivityClassProvider
    private val enrollActivityProvider: FaceEnrollActivityClassProvider
        get() = featureFactory.faceFeatureProvider.enrollActivityClassProvider
        get() = featureFactory.faceFeatureProvider.enrollActivityClassProvider


    private var isLaunched = false

    override fun onCreate(savedInstanceState: Bundle?) {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        super.onCreate(savedInstanceState)


        if (savedInstanceState != null) {
            isLaunched = savedInstanceState.getBoolean(KEY_IS_LAUNCHED, isLaunched)
        }

        if (!isLaunched) {
            /**
            /**
             *  Logs the next activity to be launched, creates an intent for that activity,
             *  Logs the next activity to be launched, creates an intent for that activity,
             *  adds flags to forward the result, includes any existing extras from the current intent,
             *  adds flags to forward the result, includes any existing extras from the current intent,
@@ -51,6 +57,14 @@ class FaceEnroll: AppCompatActivity() {
            val nextIntent = Intent(this, nextActivityClass)
            val nextIntent = Intent(this, nextActivityClass)
            nextIntent.putExtras(intent)
            nextIntent.putExtras(intent)
            startActivityForResult(nextIntent, 0)
            startActivityForResult(nextIntent, 0)

            isLaunched = true
        }
    }

    override fun onSaveInstanceState(outState: Bundle) {
        outState.putBoolean(KEY_IS_LAUNCHED, isLaunched)
        super.onSaveInstanceState(outState)
    }
    }


    override fun onActivityResult(
    override fun onActivityResult(
@@ -60,6 +74,7 @@ class FaceEnroll: AppCompatActivity() {
        caller: ComponentCaller
        caller: ComponentCaller
    ) {
    ) {
        super.onActivityResult(requestCode, resultCode, data, caller)
        super.onActivityResult(requestCode, resultCode, data, caller)
        isLaunched = false
        if (intent.getBooleanExtra(
        if (intent.getBooleanExtra(
                CombinedBiometricStatusUtils.EXTRA_LAUNCH_FROM_SAFETY_SOURCE_ISSUE, false)
                CombinedBiometricStatusUtils.EXTRA_LAUNCH_FROM_SAFETY_SOURCE_ISSUE, false)
            && resultCode != RESULT_FINISHED) {
            && resultCode != RESULT_FINISHED) {
@@ -68,4 +83,8 @@ class FaceEnroll: AppCompatActivity() {
        setResult(resultCode, data)
        setResult(resultCode, data)
        finish()
        finish()
    }
    }

    private companion object {
        const val KEY_IS_LAUNCHED = "isLaunched"
    }
}
}
+29 −9
Original line number Original line Diff line number Diff line
@@ -62,9 +62,16 @@ open class FingerprintEnroll: AppCompatActivity() {
    protected val enrollActivityProvider: FingerprintEnrollActivityClassProvider
    protected val enrollActivityProvider: FingerprintEnrollActivityClassProvider
        get() = featureFactory.fingerprintFeatureProvider.getEnrollActivityClassProvider(this)
        get() = featureFactory.fingerprintFeatureProvider.getEnrollActivityClassProvider(this)


    private var isLaunched = false

    override fun onCreate(savedInstanceState: Bundle?) {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        super.onCreate(savedInstanceState)


        if (savedInstanceState != null) {
            isLaunched = savedInstanceState.getBoolean(KEY_IS_LAUNCHED, isLaunched)
        }

        if (!isLaunched) {
            /**
            /**
             *  Logs the next activity to be launched, creates an intent for that activity,
             *  Logs the next activity to be launched, creates an intent for that activity,
             *  adds flags to forward the result, includes any existing extras from the current intent,
             *  adds flags to forward the result, includes any existing extras from the current intent,
@@ -74,6 +81,14 @@ open class FingerprintEnroll: AppCompatActivity() {
            val nextIntent = Intent(this, nextActivityClass)
            val nextIntent = Intent(this, nextActivityClass)
            nextIntent.putExtras(intent)
            nextIntent.putExtras(intent)
            startActivityForResult(nextIntent, 0)
            startActivityForResult(nextIntent, 0)

            isLaunched = true
        }
    }

    override fun onSaveInstanceState(outState: Bundle) {
        outState.putBoolean(KEY_IS_LAUNCHED, isLaunched)
        super.onSaveInstanceState(outState)
    }
    }


    override fun onActivityResult(
    override fun onActivityResult(
@@ -83,6 +98,7 @@ open class FingerprintEnroll: AppCompatActivity() {
        caller: ComponentCaller
        caller: ComponentCaller
    ) {
    ) {
        super.onActivityResult(requestCode, resultCode, data, caller)
        super.onActivityResult(requestCode, resultCode, data, caller)
        isLaunched = false
        if (intent.getBooleanExtra(
        if (intent.getBooleanExtra(
                CombinedBiometricStatusUtils.EXTRA_LAUNCH_FROM_SAFETY_SOURCE_ISSUE, false)
                CombinedBiometricStatusUtils.EXTRA_LAUNCH_FROM_SAFETY_SOURCE_ISSUE, false)
            && resultCode != BiometricEnrollBase.RESULT_FINISHED
            && resultCode != BiometricEnrollBase.RESULT_FINISHED
@@ -92,4 +108,8 @@ open class FingerprintEnroll: AppCompatActivity() {
        setResult(resultCode, data)
        setResult(resultCode, data)
        finish()
        finish()
    }
    }

    private companion object {
        const val KEY_IS_LAUNCHED = "isLaunched"
    }
}
}
 No newline at end of file