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

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

Merge "Implement cancellation request." into main

parents d38ef87d e10140ee
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "frameworks_base_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["frameworks_base_license"],
}

android_library {
    name: "CredentialManagerShared",
    manifest: "AndroidManifest.xml",
    srcs: ["src/**/*.kt"],
    static_libs: [
        "androidx.core_core-ktx",
        "androidx.credentials_credentials",
    ],
}
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
 * Copyright (c) 2023 Google Inc.
 *
 * 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.0
 *
 * 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.
 */
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.credentialmanager">

</manifest>
+42 −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.ui

import android.content.Intent
import android.credentials.ui.RequestInfo
import com.android.credentialmanager.ui.ktx.cancelUiRequest
import com.android.credentialmanager.ui.ktx.requestInfo
import com.android.credentialmanager.ui.mapper.toCancel
import com.android.credentialmanager.ui.model.Request

fun Intent.parse(): Request {
    cancelUiRequest?.let {
        return it.toCancel()
    }

    return when (requestInfo?.type) {
        RequestInfo.TYPE_CREATE -> {
            Request.Create
        }
        RequestInfo.TYPE_GET -> {
            Request.Get
        }
        else -> {
            throw IllegalStateException("Unrecognized request type: ${requestInfo?.type}")
        }
    }
}
+19 −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.ui

const val TAG = "CredentialSelector"
+33 −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.ui.ktx

import android.content.Intent
import android.credentials.ui.CancelUiRequest
import android.credentials.ui.RequestInfo

val Intent.cancelUiRequest: CancelUiRequest?
    get() = this.extras?.getParcelable(
        CancelUiRequest.EXTRA_CANCEL_UI_REQUEST,
        CancelUiRequest::class.java
    )

val Intent.requestInfo: RequestInfo?
    get() = this.extras?.getParcelable(
        RequestInfo.EXTRA_REQUEST_INFO,
        RequestInfo::class.java
    )
 No newline at end of file
Loading