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

Commit 094fa910 authored by Omer Ozer's avatar Omer Ozer
Browse files

Add sessions to requestsession

Update the matching logic within CredentialService
and add ProviderRegistryGetSession to GetRequestSession.

Bug: 272649023
Test: manual

Change-Id: Ied7bedb9afb813279f90f7bb5c0c1f765d374bc6
parent 1ce0d2cf
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -221,12 +221,12 @@ public class CredentialDescriptionRegistry {
        return false;
    }

    private static boolean checkForMatch(Set<String> registeredUnflattenedStrings,
    static boolean checkForMatch(Set<String> registeredUnflattenedStrings,
            Set<String> requestedUnflattenedString) {
        return registeredUnflattenedStrings.containsAll(requestedUnflattenedString);
    }

    private static Set<String> flatStringToSet(String flatString) {
    static Set<String> flatStringToSet(String flatString) {
        return new HashSet<>(Arrays
                .asList(flatString.split(FLAT_STRING_SPLIT_REGEX)));
    }
+17 −11
Original line number Diff line number Diff line
@@ -291,14 +291,15 @@ public final class CredentialManagerService
        List<ProviderSession> providerSessions = new ArrayList<>();
        for (Pair<CredentialOption, CredentialDescriptionRegistry.FilterResult> result :
                activeCredentialContainers) {
            providerSessions.add(
                    ProviderRegistryGetSession.createNewSession(
            ProviderSession providerSession = ProviderRegistryGetSession.createNewSession(
                    mContext,
                    UserHandle.getCallingUserId(),
                    session,
                    session.mClientAppInfo,
                    result.second.mPackageName,
                            result.first));
                    result.first);
            providerSessions.add(providerSession);
            session.addProviderSession(providerSession.getComponentName(), providerSession);
        }
        return providerSessions;
    }
@@ -328,10 +329,15 @@ public final class CredentialManagerService
                new HashSet<>();

        for (CredentialDescriptionRegistry.FilterResult filterResult : filterResults) {
            Set<String> registeredUnflattenedStrings = CredentialDescriptionRegistry
                    .flatStringToSet(filterResult.mFlattenedRequest);
            for (CredentialOption credentialOption : options) {
                if (filterResult.mFlattenedRequest.equals(credentialOption
                Set<String> requestedUnflattenedStrings = CredentialDescriptionRegistry
                        .flatStringToSet(credentialOption
                                .getCredentialRetrievalData()
                        .getString(CredentialOption.FLATTENED_REQUEST))) {
                                .getString(CredentialOption.FLATTENED_REQUEST));
                if (CredentialDescriptionRegistry.checkForMatch(registeredUnflattenedStrings,
                        requestedUnflattenedStrings)) {
                    result.add(new Pair<>(credentialOption, filterResult));
                }
            }
+4 −0
Original line number Diff line number Diff line
@@ -128,6 +128,10 @@ abstract class RequestSession<T, U> implements CredentialManagerUi.CredentialMan
        this.mInitialPhaseMetric.setCountRequestClassType(requestClassType);
    }

    public void addProviderSession(ComponentName componentName, ProviderSession providerSession) {
        mProviders.put(componentName.flattenToString(), providerSession);
    }

    // UI callbacks

    @Override // from CredentialManagerUiCallbacks