Fix potential IllegalArgumentException from the auto-select flow.

AutoSelect flow animate the bottom sheet directly into empty sheet
because it will then immediately launch the provider activity. However,
there's a native compose bug that throws IllegalArgumentException when
the sheet is animated from/to an empty sheet. The fix was submitted to
late for us to merge into our U release b/ 281791945 so we need a temporary solution:
for now we'd keep a 1 pixel transparent bar when this could happen; it
won't be noticeable.

Bug: 281791945
Test: manual
Change-Id: I668af5316fa795cf833d0907481373d86bb24ed1
This commit is contained in:
Helen Qin
2023-05-10 07:33:21 +00:00
parent c58528f3f4
commit 35c3307f7d
2 changed files with 28 additions and 0 deletions

View File

@@ -43,6 +43,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.core.graphics.drawable.toBitmap
import com.android.credentialmanager.CredentialSelectorViewModel
@@ -50,6 +51,7 @@ import com.android.credentialmanager.R
import com.android.credentialmanager.common.BaseEntry
import com.android.credentialmanager.common.CredentialType
import com.android.credentialmanager.common.ProviderActivityState
import com.android.credentialmanager.common.material.ModalBottomSheetDefaults
import com.android.credentialmanager.common.ui.ActionButton
import com.android.credentialmanager.common.ui.BodyMediumText
import com.android.credentialmanager.common.ui.BodySmallText
@@ -148,6 +150,13 @@ fun CreateCredentialScreen(
}
}
ProviderActivityState.READY_TO_LAUNCH -> {
// This is a native bug from ModalBottomSheet. For now, use the temporary
// solution of not having an empty state.
if (viewModel.uiState.isAutoSelectFlow) {
Divider(
thickness = Dp.Hairline, color = ModalBottomSheetDefaults.scrimColor
)
}
// Launch only once per providerActivityState change so that the provider
// UI will not be accidentally launched twice.
LaunchedEffect(viewModel.uiState.providerActivityState) {
@@ -158,6 +167,11 @@ fun CreateCredentialScreen(
.CREDMAN_CREATE_CRED_PROVIDER_ACTIVITY_READY_TO_LAUNCH)
}
ProviderActivityState.PENDING -> {
if (viewModel.uiState.isAutoSelectFlow) {
Divider(
thickness = Dp.Hairline, color = ModalBottomSheetDefaults.scrimColor
)
}
// Hide our content when the provider activity is active.
viewModel.uiMetrics.log(
CreateCredentialEvent.CREDMAN_CREATE_CRED_PROVIDER_ACTIVITY_PENDING)

View File

@@ -43,6 +43,7 @@ import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextLayoutResult
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.core.graphics.drawable.toBitmap
import com.android.credentialmanager.CredentialSelectorViewModel
@@ -50,6 +51,7 @@ import com.android.credentialmanager.R
import com.android.credentialmanager.common.BaseEntry
import com.android.credentialmanager.common.CredentialType
import com.android.credentialmanager.common.ProviderActivityState
import com.android.credentialmanager.common.material.ModalBottomSheetDefaults
import com.android.credentialmanager.common.ui.ActionButton
import com.android.credentialmanager.common.ui.ActionEntry
import com.android.credentialmanager.common.ui.ConfirmButton
@@ -132,6 +134,13 @@ fun GetCredentialScreen(
}
}
ProviderActivityState.READY_TO_LAUNCH -> {
// This is a native bug from ModalBottomSheet. For now, use the temporary
// solution of not having an empty state.
if (viewModel.uiState.isAutoSelectFlow) {
Divider(
thickness = Dp.Hairline, color = ModalBottomSheetDefaults.scrimColor
)
}
// Launch only once per providerActivityState change so that the provider
// UI will not be accidentally launched twice.
LaunchedEffect(viewModel.uiState.providerActivityState) {
@@ -141,6 +150,11 @@ fun GetCredentialScreen(
.CREDMAN_GET_CRED_PROVIDER_ACTIVITY_READY_TO_LAUNCH)
}
ProviderActivityState.PENDING -> {
if (viewModel.uiState.isAutoSelectFlow) {
Divider(
thickness = Dp.Hairline, color = ModalBottomSheetDefaults.scrimColor
)
}
// Hide our content when the provider activity is active.
viewModel.uiMetrics.log(GetCredentialEvent
.CREDMAN_GET_CRED_PROVIDER_ACTIVITY_PENDING)