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

Commit f6bd8b06 authored by Helen Qin's avatar Helen Qin
Browse files

Report user_cancellation when the user back scroll from the UI activity

Bug: 280518183
Test: manual (see bug for recording)
Change-Id: I243b32a23fa01d79038582f4dc1ddbd4c2e66703
parent e28675e2
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.os.Bundle
import android.os.ResultReceiver
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.OnBackPressedCallback
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.compose.setContent
import androidx.activity.viewModels
@@ -48,11 +49,12 @@ import com.android.credentialmanager.ui.theme.PlatformTheme
class CredentialSelectorActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.d(Constants.LOG_TAG, "Creating new CredentialSelectorActivity")
        overrideActivityTransition(Activity.OVERRIDE_TRANSITION_OPEN,
            0, 0)
        overrideActivityTransition(Activity.OVERRIDE_TRANSITION_CLOSE,
            0, 0)
        Log.d(Constants.LOG_TAG, "Creating new CredentialSelectorActivity")

        try {
            val (isCancellationRequest, shouldShowCancellationUi, _) =
                maybeCancelUIUponRequest(intent)
@@ -61,6 +63,18 @@ class CredentialSelectorActivity : ComponentActivity() {
            }
            val userConfigRepo = UserConfigRepo(this)
            val credManRepo = CredentialManagerRepo(this, intent, userConfigRepo)

            val backPressedCallback = object : OnBackPressedCallback(
                true // default to enabled
            ) {
                override fun handleOnBackPressed() {
                    credManRepo.onUserCancel()
                    Log.d(Constants.LOG_TAG, "Activity back triggered: finish the activity.")
                    this@CredentialSelectorActivity.finish()
                }
            }
            onBackPressedDispatcher.addCallback(this, backPressedCallback)

            setContent {
                PlatformTheme {
                    CredentialManagerBottomSheet(