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

Commit 6d6da715 authored by Helen Qin's avatar Helen Qin
Browse files

Define the Request and Provider Info as part of the UI protocol.

The CredMan selector UI will expect request/provider info from the
launching intent. ProviderInfo contains metadata and entry info for a
single provider. RequestInfo contains metadata about the app request
that initiated this ui flow.

Test: deployed locally
Bug: 247855226
Change-Id: I3348ec582920d7d8019b272b8fc2b3c2d48404c6
parent 7c067f9e
Loading
Loading
Loading
Loading
+81 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 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.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.
 */

package android.credentials.ui;

import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;

import com.android.internal.util.AnnotationValidations;

/**
 * Holds metadata and credential entries for a single provider.
 *
 * @hide
 */
public class ProviderData implements Parcelable {

    /**
     * The intent extra key for the list of {@code ProviderData} when launching the UX
     * activities.
     */
    public static final String EXTRA_PROVIDER_DATA_LIST =
            "android.credentials.ui.extra.PROVIDER_DATA_LIST";

    // TODO: add entry data.

    @NonNull
    private final String mPackageName;

    public ProviderData(@NonNull String packageName) {
        mPackageName = packageName;
    }

    /** Returns the provider package name. */
    @NonNull
    public String getPackageName() {
        return mPackageName;
    }

    protected ProviderData(@NonNull Parcel in) {
        String packageName = in.readString8();
        mPackageName = packageName;
        AnnotationValidations.validate(NonNull.class, null, mPackageName);
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeString8(mPackageName);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final @NonNull Creator<ProviderData> CREATOR = new Creator<ProviderData>() {
        @Override
        public ProviderData createFromParcel(@NonNull Parcel in) {
            return new ProviderData(in);
        }

        @Override
        public ProviderData[] newArray(int size) {
            return new ProviderData[size];
        }
    };
}
+79 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 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.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.
 */

package android.credentials.ui;

import android.annotation.NonNull;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;

import com.android.internal.util.AnnotationValidations;

/**
 * Contains information about the request that initiated this UX flow.
 *
 * @hide
 */
public class RequestInfo implements Parcelable {

    /**
     * The intent extra key for the {@code RequestInfo} object when launching the UX
     * activities.
     */
    public static final String EXTRA_REQUEST_INFO = "android.credentials.ui.extra.REQUEST_INFO";

    @NonNull
    private final IBinder mToken;

    public RequestInfo(@NonNull IBinder token) {
        mToken = token;
    }

    /** Returns the request token matching the user request. */
    @NonNull
    public IBinder getToken() {
        return mToken;
    }

    protected RequestInfo(@NonNull Parcel in) {
        IBinder token = in.readStrongBinder();
        mToken = token;
        AnnotationValidations.validate(NonNull.class, null, mToken);
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeStrongBinder(mToken);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final @NonNull Creator<RequestInfo> CREATOR = new Creator<RequestInfo>() {
        @Override
        public RequestInfo createFromParcel(@NonNull Parcel in) {
            return new RequestInfo(in);
        }

        @Override
        public RequestInfo[] newArray(int size) {
            return new RequestInfo[size];
        }
    };
}