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

Commit 173df1cf authored by Gustavo Pagani's avatar Gustavo Pagani Committed by Android (Google) Code Review
Browse files

Merge "Improvements to MVP: address TODOs to move code to shared module." into main

parents 016e056c ed687dc7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ fun Intent.parse(
    packageManager: PackageManager,
    previousIntent: Intent? = null,
): Request {
    this.toRequestClose(packageManager, previousIntent)?.let { closeRequest ->
    this.toRequestClose(previousIntent)?.let { closeRequest ->
        return closeRequest
    }

+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0N
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.credentialmanager.ktx

import androidx.activity.result.IntentSenderRequest
import com.android.credentialmanager.IS_AUTO_SELECTED_KEY
import com.android.credentialmanager.model.Password

fun Password.getIntentSenderRequest(
    isAutoSelected: Boolean = false
): IntentSenderRequest {
    val entryIntent = entry.frameworkExtrasIntent
    entryIntent?.putExtra(IS_AUTO_SELECTED_KEY, isAutoSelected)

    return IntentSenderRequest.Builder(
        pendingIntent = passwordCredentialEntry.pendingIntent
    ).setFillInIntent(entryIntent).build()
}
+1 −4
Original line number Diff line number Diff line
@@ -31,9 +31,6 @@ fun Intent.toRequestCancel(packageManager: PackageManager): Request.Cancel? =
            Log.d(TAG, "Received UI cancel request with an invalid package name.")
            null
        } else {
            Request.Cancel(
                showCancellationUi = cancelUiRequest.shouldShowCancellationUi(),
                appName = appLabel
            )
            Request.Cancel(appName = appLabel)
        }
    }
+16 −14
Original line number Diff line number Diff line
@@ -17,18 +17,17 @@
package com.android.credentialmanager.mapper

import android.content.Intent
import android.content.pm.PackageManager
import com.android.credentialmanager.ktx.cancelUiRequest
import com.android.credentialmanager.ktx.requestInfo
import com.android.credentialmanager.model.Request

fun Intent.toRequestClose(
    packageManager: PackageManager,
    previousIntent: Intent? = null,
): Request.Close? {
    // Close request comes as "Cancel" request from Credential Manager API
    val currentRequest = toRequestCancel(packageManager = packageManager) ?: return null
    this.cancelUiRequest?.let { cancelUiRequest ->

    if (currentRequest.showCancellationUi) {
        if (cancelUiRequest.shouldShowCancellationUi()) {
            // Current request is to Cancel and not to Close
            return null
        }
@@ -45,3 +44,6 @@ fun Intent.toRequestClose(

        return Request.Close
    }

    return null
}
 No newline at end of file
+0 −1
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ sealed class Request {
     * Request to close the app, displaying a message to the user.
     */
    data class Cancel(
        val showCancellationUi: Boolean,
        val appName: String
    ) : Request()

Loading