Loading packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorActivity.kt +15 −11 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import androidx.activity.ComponentActivity import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.compose.setContent import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.viewModels import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect Loading @@ -43,17 +44,6 @@ class CredentialSelectorActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) Log.d(Constants.LOG_TAG, "Creating new CredentialSelectorActivity") init(intent) } override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) setIntent(intent) Log.d(Constants.LOG_TAG, "Existing activity received new intent") init(intent) } fun init(intent: Intent) { try { val userConfigRepo = UserConfigRepo(this) val credManRepo = CredentialManagerRepo(this, intent, userConfigRepo) Loading @@ -70,6 +60,20 @@ class CredentialSelectorActivity : ComponentActivity() { } } override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) setIntent(intent) Log.d(Constants.LOG_TAG, "Existing activity received new intent") try { val userConfigRepo = UserConfigRepo(this) val credManRepo = CredentialManagerRepo(this, intent, userConfigRepo) val viewModel: CredentialSelectorViewModel by viewModels() viewModel.onNewCredentialManagerRepo(credManRepo) } catch (e: Exception) { onInitializationError(e, intent) } } @ExperimentalMaterialApi @Composable fun CredentialManagerBottomSheet( Loading packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorViewModel.kt +3 −1 Original line number Diff line number Diff line Loading @@ -104,7 +104,9 @@ class CredentialSelectorViewModel( entry.providerId, entry.entryKey, entry.entrySubkey, resultCode, resultData, ) if (entry.shouldTerminateUiUponSuccessfulProviderResult) { uiState = uiState.copy(dialogState = DialogState.COMPLETE) } } else { Log.w(Constants.LOG_TAG, "Illegal state: received a provider result but found no matching entry.") Loading packages/CredentialManager/src/com/android/credentialmanager/common/BaseEntry.kt +1 −0 Original line number Diff line number Diff line Loading @@ -25,4 +25,5 @@ open class BaseEntry ( val entrySubkey: String, val pendingIntent: PendingIntent?, val fillInIntent: Intent?, val shouldTerminateUiUponSuccessfulProviderResult: Boolean, ) No newline at end of file packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateModel.kt +16 −2 Original line number Diff line number Diff line Loading @@ -69,7 +69,14 @@ class CreateOptionInfo( val totalCredentialCount: Int?, val lastUsedTime: Instant?, val footerDescription: String?, ) : BaseEntry(providerId, entryKey, entrySubkey, pendingIntent, fillInIntent) ) : BaseEntry( providerId, entryKey, entrySubkey, pendingIntent, fillInIntent, shouldTerminateUiUponSuccessfulProviderResult = true, ) class RemoteInfo( providerId: String, Loading @@ -77,7 +84,14 @@ class RemoteInfo( entrySubkey: String, pendingIntent: PendingIntent?, fillInIntent: Intent?, ) : BaseEntry(providerId, entryKey, entrySubkey, pendingIntent, fillInIntent) ) : BaseEntry( providerId, entryKey, entrySubkey, pendingIntent, fillInIntent, shouldTerminateUiUponSuccessfulProviderResult = true, ) data class RequestDisplayInfo( val title: String, Loading packages/CredentialManager/src/com/android/credentialmanager/getflow/GetModel.kt +183 −154 Original line number Diff line number Diff line Loading @@ -74,7 +74,14 @@ class CredentialEntryInfo( val displayName: String?, val icon: Drawable?, val lastUsedTimeMillis: Instant?, ) : BaseEntry(providerId, entryKey, entrySubkey, pendingIntent, fillInIntent) ) : BaseEntry( providerId, entryKey, entrySubkey, pendingIntent, fillInIntent, shouldTerminateUiUponSuccessfulProviderResult = true, ) class AuthenticationEntryInfo( providerId: String, Loading @@ -84,7 +91,13 @@ class AuthenticationEntryInfo( fillInIntent: Intent?, val title: String, val icon: Drawable, ) : BaseEntry(providerId, entryKey, entrySubkey, pendingIntent, fillInIntent) ) : BaseEntry( providerId, entryKey, entrySubkey, pendingIntent, fillInIntent, shouldTerminateUiUponSuccessfulProviderResult = false, ) class RemoteEntryInfo( providerId: String, Loading @@ -92,7 +105,14 @@ class RemoteEntryInfo( entrySubkey: String, pendingIntent: PendingIntent?, fillInIntent: Intent?, ) : BaseEntry(providerId, entryKey, entrySubkey, pendingIntent, fillInIntent) ) : BaseEntry( providerId, entryKey, entrySubkey, pendingIntent, fillInIntent, shouldTerminateUiUponSuccessfulProviderResult = true, ) class ActionEntryInfo( providerId: String, Loading @@ -103,7 +123,14 @@ class ActionEntryInfo( val title: String, val icon: Drawable, val subTitle: String?, ) : BaseEntry(providerId, entryKey, entrySubkey, pendingIntent, fillInIntent) ) : BaseEntry( providerId, entryKey, entrySubkey, pendingIntent, fillInIntent, shouldTerminateUiUponSuccessfulProviderResult = false, ) data class RequestDisplayInfo( val appName: String, Loading @@ -123,8 +150,10 @@ data class PerUserNameCredentialEntryList( enum class GetScreenState { /** The primary credential selection page. */ PRIMARY_SELECTION, /** The secondary credential selection page, where all sign-in options are listed. */ ALL_SIGN_IN_OPTIONS, /** The snackbar only page when there's no account but only a remoteEntry. */ REMOTE_ONLY, } Loading Loading
packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorActivity.kt +15 −11 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import androidx.activity.ComponentActivity import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.compose.setContent import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.viewModels import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect Loading @@ -43,17 +44,6 @@ class CredentialSelectorActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) Log.d(Constants.LOG_TAG, "Creating new CredentialSelectorActivity") init(intent) } override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) setIntent(intent) Log.d(Constants.LOG_TAG, "Existing activity received new intent") init(intent) } fun init(intent: Intent) { try { val userConfigRepo = UserConfigRepo(this) val credManRepo = CredentialManagerRepo(this, intent, userConfigRepo) Loading @@ -70,6 +60,20 @@ class CredentialSelectorActivity : ComponentActivity() { } } override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) setIntent(intent) Log.d(Constants.LOG_TAG, "Existing activity received new intent") try { val userConfigRepo = UserConfigRepo(this) val credManRepo = CredentialManagerRepo(this, intent, userConfigRepo) val viewModel: CredentialSelectorViewModel by viewModels() viewModel.onNewCredentialManagerRepo(credManRepo) } catch (e: Exception) { onInitializationError(e, intent) } } @ExperimentalMaterialApi @Composable fun CredentialManagerBottomSheet( Loading
packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorViewModel.kt +3 −1 Original line number Diff line number Diff line Loading @@ -104,7 +104,9 @@ class CredentialSelectorViewModel( entry.providerId, entry.entryKey, entry.entrySubkey, resultCode, resultData, ) if (entry.shouldTerminateUiUponSuccessfulProviderResult) { uiState = uiState.copy(dialogState = DialogState.COMPLETE) } } else { Log.w(Constants.LOG_TAG, "Illegal state: received a provider result but found no matching entry.") Loading
packages/CredentialManager/src/com/android/credentialmanager/common/BaseEntry.kt +1 −0 Original line number Diff line number Diff line Loading @@ -25,4 +25,5 @@ open class BaseEntry ( val entrySubkey: String, val pendingIntent: PendingIntent?, val fillInIntent: Intent?, val shouldTerminateUiUponSuccessfulProviderResult: Boolean, ) No newline at end of file
packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateModel.kt +16 −2 Original line number Diff line number Diff line Loading @@ -69,7 +69,14 @@ class CreateOptionInfo( val totalCredentialCount: Int?, val lastUsedTime: Instant?, val footerDescription: String?, ) : BaseEntry(providerId, entryKey, entrySubkey, pendingIntent, fillInIntent) ) : BaseEntry( providerId, entryKey, entrySubkey, pendingIntent, fillInIntent, shouldTerminateUiUponSuccessfulProviderResult = true, ) class RemoteInfo( providerId: String, Loading @@ -77,7 +84,14 @@ class RemoteInfo( entrySubkey: String, pendingIntent: PendingIntent?, fillInIntent: Intent?, ) : BaseEntry(providerId, entryKey, entrySubkey, pendingIntent, fillInIntent) ) : BaseEntry( providerId, entryKey, entrySubkey, pendingIntent, fillInIntent, shouldTerminateUiUponSuccessfulProviderResult = true, ) data class RequestDisplayInfo( val title: String, Loading
packages/CredentialManager/src/com/android/credentialmanager/getflow/GetModel.kt +183 −154 Original line number Diff line number Diff line Loading @@ -74,7 +74,14 @@ class CredentialEntryInfo( val displayName: String?, val icon: Drawable?, val lastUsedTimeMillis: Instant?, ) : BaseEntry(providerId, entryKey, entrySubkey, pendingIntent, fillInIntent) ) : BaseEntry( providerId, entryKey, entrySubkey, pendingIntent, fillInIntent, shouldTerminateUiUponSuccessfulProviderResult = true, ) class AuthenticationEntryInfo( providerId: String, Loading @@ -84,7 +91,13 @@ class AuthenticationEntryInfo( fillInIntent: Intent?, val title: String, val icon: Drawable, ) : BaseEntry(providerId, entryKey, entrySubkey, pendingIntent, fillInIntent) ) : BaseEntry( providerId, entryKey, entrySubkey, pendingIntent, fillInIntent, shouldTerminateUiUponSuccessfulProviderResult = false, ) class RemoteEntryInfo( providerId: String, Loading @@ -92,7 +105,14 @@ class RemoteEntryInfo( entrySubkey: String, pendingIntent: PendingIntent?, fillInIntent: Intent?, ) : BaseEntry(providerId, entryKey, entrySubkey, pendingIntent, fillInIntent) ) : BaseEntry( providerId, entryKey, entrySubkey, pendingIntent, fillInIntent, shouldTerminateUiUponSuccessfulProviderResult = true, ) class ActionEntryInfo( providerId: String, Loading @@ -103,7 +123,14 @@ class ActionEntryInfo( val title: String, val icon: Drawable, val subTitle: String?, ) : BaseEntry(providerId, entryKey, entrySubkey, pendingIntent, fillInIntent) ) : BaseEntry( providerId, entryKey, entrySubkey, pendingIntent, fillInIntent, shouldTerminateUiUponSuccessfulProviderResult = false, ) data class RequestDisplayInfo( val appName: String, Loading @@ -123,8 +150,10 @@ data class PerUserNameCredentialEntryList( enum class GetScreenState { /** The primary credential selection page. */ PRIMARY_SELECTION, /** The secondary credential selection page, where all sign-in options are listed. */ ALL_SIGN_IN_OPTIONS, /** The snackbar only page when there's no account but only a remoteEntry. */ REMOTE_ONLY, } Loading