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

This commit is contained in:
Helen Qin
2022-10-03 21:52:48 +00:00
committed by Android (Google) Code Review
2 changed files with 160 additions and 0 deletions

View File

@@ -0,0 +1,81 @@
/*
* 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];
}
};
}

View File

@@ -0,0 +1,79 @@
/*
* 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];
}
};
}