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

Commit 3fedc79f authored by Reema Bajwa's avatar Reema Bajwa
Browse files

Navigate directly to second page from pinned entry

Bug: 318503000
Test: Deployed and tested locally

Change-Id: I57e2bb6c1dbb76468b04d255ecb9f0be697c51c2
parent 2e0beb06
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -29,6 +29,13 @@ public class Constants {
    public static final String EXTRA_RESULT_RECEIVER =
            "android.credentials.ui.extra.RESULT_RECEIVER";

    /**
     * The intent extra key for indicating whether the bottom sheet should be started directly
     * on the 'All Options' screen.
     */
    public static final String EXTRA_REQ_FOR_ALL_OPTIONS =
            "android.credentials.ui.extra.REQ_FOR_ALL_OPTIONS";

    /** The intent action for when the enabled Credential Manager providers has been updated. */
    public static final String CREDMAN_ENABLED_PROVIDERS_UPDATED =
            "android.credentials.ui.action.CREDMAN_ENABLED_PROVIDERS_UPDATED";
+25 −0
Original line number Diff line number Diff line
@@ -35,6 +35,31 @@ import java.util.ArrayList;
 */
@TestApi
public class IntentFactory {

    /**
     * Generate a new launch intent to the Credential Selector UI.
     *
     * @hide
     */
    @NonNull
    public static Intent createCredentialSelectorIntent(
            @NonNull RequestInfo requestInfo,
            @SuppressLint("ConcreteCollection") // Concrete collection needed for marshalling.
            @NonNull
            ArrayList<ProviderData> enabledProviderDataList,
            @SuppressLint("ConcreteCollection") // Concrete collection needed for marshalling.
            @NonNull
            ArrayList<DisabledProviderData> disabledProviderDataList,
            @NonNull ResultReceiver resultReceiver,
            boolean isRequestForAllOptions) {

        Intent intent = createCredentialSelectorIntent(requestInfo, enabledProviderDataList,
                disabledProviderDataList, resultReceiver);
        intent.putExtra(Constants.EXTRA_REQ_FOR_ALL_OPTIONS, isRequestForAllOptions);

        return intent;
    }

    /** Generate a new launch intent to the Credential Selector UI. */
    @NonNull
    public static Intent createCredentialSelectorIntent(
+15 −4
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ class CredentialManagerRepo(
    isNewActivity: Boolean,
) {
    val requestInfo: RequestInfo?
    var isReqForAllOptions: Boolean = false
    private val providerEnabledList: List<ProviderData>
    private val providerDisabledList: List<DisabledProviderData>?
    val resultReceiver: ResultReceiver?
@@ -102,6 +103,11 @@ class CredentialManagerRepo(
            ResultReceiver::class.java
        )

        isReqForAllOptions = intent.getBooleanExtra(
                Constants.EXTRA_REQ_FOR_ALL_OPTIONS,
                /*defaultValue=*/ false
        )

        val cancellationRequest = getCancelUiRequest(intent)
        val cancelUiRequestState = cancellationRequest?.let {
            CancelUiRequestState(getAppLabel(context.getPackageManager(), it.appPackageName))
@@ -141,7 +147,8 @@ class CredentialManagerRepo(
                )
            }
            RequestInfo.TYPE_GET -> {
                val getCredentialInitialUiState = getCredentialInitialUiState(originName)!!
                val getCredentialInitialUiState = getCredentialInitialUiState(originName,
                        isReqForAllOptions)!!
                val autoSelectEntry =
                    findAutoSelectEntry(getCredentialInitialUiState.providerDisplayInfo)
                UiState(
@@ -216,14 +223,18 @@ class CredentialManagerRepo(
    }

    // IMPORTANT: new invocation should be mindful that this method can throw.
    private fun getCredentialInitialUiState(originName: String?): GetCredentialUiState? {
    private fun getCredentialInitialUiState(
            originName: String?,
            isReqForAllOptions: Boolean
    ): GetCredentialUiState? {
        val providerEnabledList = GetFlowUtils.toProviderList(
            providerEnabledList as List<GetCredentialProviderData>, context
        )
        val requestDisplayInfo = GetFlowUtils.toRequestDisplayInfo(requestInfo, context, originName)
        return GetCredentialUiState(
                isReqForAllOptions,
                providerEnabledList,
            requestDisplayInfo ?: return null,
                requestDisplayInfo ?: return null
        )
    }

+7 −2
Original line number Diff line number Diff line
@@ -26,10 +26,12 @@ import com.android.credentialmanager.model.get.RemoteEntryInfo
import com.android.internal.util.Preconditions

data class GetCredentialUiState(
        val isRequestForAllOptions: Boolean,
    val providerInfoList: List<ProviderInfo>,
    val requestDisplayInfo: RequestDisplayInfo,
    val providerDisplayInfo: ProviderDisplayInfo = toProviderDisplayInfo(providerInfoList),
    val currentScreenState: GetScreenState = toGetScreenState(providerDisplayInfo),
    val currentScreenState: GetScreenState = toGetScreenState(
            providerDisplayInfo, isRequestForAllOptions),
    val activeEntry: EntryInfo? = toActiveEntry(providerDisplayInfo),
    val isNoAccount: Boolean = false,
)
@@ -184,7 +186,8 @@ private fun toActiveEntry(
}

private fun toGetScreenState(
    providerDisplayInfo: ProviderDisplayInfo
    providerDisplayInfo: ProviderDisplayInfo,
    isRequestForAllOptions: Boolean
): GetScreenState {
    return if (providerDisplayInfo.sortedUserNameToCredentialEntryList.isEmpty() &&
        providerDisplayInfo.remoteEntry == null &&
@@ -194,6 +197,8 @@ private fun toGetScreenState(
        providerDisplayInfo.authenticationEntryList.isEmpty() &&
        providerDisplayInfo.remoteEntry != null)
        GetScreenState.REMOTE_ONLY
    else if (isRequestForAllOptions)
        GetScreenState.ALL_SIGN_IN_OPTIONS
    else GetScreenState.PRIMARY_SELECTION
}

+1 −1
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
                            PermissionUtils.hasPermission(mContext, mClientAppInfo.getPackageName(),
                                    Manifest.permission.CREDENTIAL_MANAGER_SET_ALLOWED_PROVIDERS),
                            /*defaultProviderId=*/flattenedPrimaryProviders),
                    providerDataList);
                    providerDataList, /*isRequestForAllOptions=*/ false);
            mClientCallback.onPendingIntent(mPendingIntent);
        } catch (RemoteException e) {
            mRequestSessionMetric.collectUiReturnedFinalPhase(/*uiReturned=*/ false);
Loading