Add remote credential entry to GET and CREATE responses
Test: Built & deployed locally Bug: 253155223 Change-Id: I11e8210af107d725520f8cb4ecc86acb09048842
This commit is contained in:
@@ -35,18 +35,22 @@ import java.util.Objects;
|
||||
public final class CreateCredentialResponse implements Parcelable {
|
||||
private final @Nullable CharSequence mHeader;
|
||||
private final @NonNull List<SaveEntry> mSaveEntries;
|
||||
private final @Nullable Action mRemoteSaveEntry;
|
||||
//TODO : Add actions if needed
|
||||
|
||||
private CreateCredentialResponse(@NonNull Parcel in) {
|
||||
mHeader = in.readCharSequence();
|
||||
List<SaveEntry> saveEntries = new ArrayList<>();
|
||||
in.readTypedList(saveEntries, SaveEntry.CREATOR);
|
||||
mSaveEntries = saveEntries;
|
||||
mRemoteSaveEntry = in.readTypedObject(Action.CREATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
||||
dest.writeCharSequence(mHeader);
|
||||
dest.writeTypedList(mSaveEntries);
|
||||
dest.writeTypedObject(mRemoteSaveEntry, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,11 +73,13 @@ public final class CreateCredentialResponse implements Parcelable {
|
||||
|
||||
/* package-private */ CreateCredentialResponse(
|
||||
@Nullable CharSequence header,
|
||||
@NonNull List<SaveEntry> saveEntries) {
|
||||
@NonNull List<SaveEntry> saveEntries,
|
||||
@Nullable Action remoteSaveEntry) {
|
||||
this.mHeader = header;
|
||||
this.mSaveEntries = saveEntries;
|
||||
com.android.internal.util.AnnotationValidations.validate(
|
||||
NonNull.class, null, mSaveEntries);
|
||||
this.mRemoteSaveEntry = remoteSaveEntry;
|
||||
}
|
||||
|
||||
/** Returns the header to be displayed on the UI. */
|
||||
@@ -86,6 +92,11 @@ public final class CreateCredentialResponse implements Parcelable {
|
||||
return mSaveEntries;
|
||||
}
|
||||
|
||||
/** Returns the remote save entry to be displayed on the UI. */
|
||||
public @NonNull Action getRemoteSaveEntry() {
|
||||
return mRemoteSaveEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder for {@link CreateCredentialResponse}
|
||||
*/
|
||||
@@ -94,6 +105,7 @@ public final class CreateCredentialResponse implements Parcelable {
|
||||
|
||||
private @Nullable CharSequence mHeader;
|
||||
private @NonNull List<SaveEntry> mSaveEntries = new ArrayList<>();
|
||||
private @Nullable Action mRemoteSaveEntry;
|
||||
|
||||
/** Sets the header to be displayed on the UI. */
|
||||
public @NonNull Builder setHeader(@Nullable CharSequence header) {
|
||||
@@ -125,6 +137,14 @@ public final class CreateCredentialResponse implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a remote save entry to be shown on the UI.
|
||||
*/
|
||||
public @NonNull Builder setRemoteSaveEntry(@Nullable Action remoteSaveEntry) {
|
||||
mRemoteSaveEntry = remoteSaveEntry;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the instance.
|
||||
*
|
||||
@@ -135,7 +155,8 @@ public final class CreateCredentialResponse implements Parcelable {
|
||||
+ "not be empty");
|
||||
return new CreateCredentialResponse(
|
||||
mHeader,
|
||||
mSaveEntries);
|
||||
mSaveEntries,
|
||||
mRemoteSaveEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,12 +43,17 @@ public final class CredentialsDisplayContent implements Parcelable {
|
||||
/** List of provider actions to be displayed on the UI. */
|
||||
private final @NonNull List<Action> mActions;
|
||||
|
||||
/** Remote credential entry to get the response from a different device. */
|
||||
private final @Nullable Action mRemoteCredentialEntry;
|
||||
|
||||
private CredentialsDisplayContent(@Nullable CharSequence header,
|
||||
@NonNull List<CredentialEntry> credentialEntries,
|
||||
@NonNull List<Action> actions) {
|
||||
@NonNull List<Action> actions,
|
||||
@Nullable Action remoteCredentialEntry) {
|
||||
mHeader = header;
|
||||
mCredentialEntries = credentialEntries;
|
||||
mActions = actions;
|
||||
mRemoteCredentialEntry = remoteCredentialEntry;
|
||||
}
|
||||
|
||||
private CredentialsDisplayContent(@NonNull Parcel in) {
|
||||
@@ -59,6 +64,7 @@ public final class CredentialsDisplayContent implements Parcelable {
|
||||
List<Action> actions = new ArrayList<>();
|
||||
in.readTypedList(actions, Action.CREATOR);
|
||||
mActions = actions;
|
||||
mRemoteCredentialEntry = in.readTypedObject(Action.CREATOR);
|
||||
}
|
||||
|
||||
public static final @NonNull Creator<CredentialsDisplayContent> CREATOR =
|
||||
@@ -84,6 +90,7 @@ public final class CredentialsDisplayContent implements Parcelable {
|
||||
dest.writeCharSequence(mHeader);
|
||||
dest.writeTypedList(mCredentialEntries, flags);
|
||||
dest.writeTypedList(mActions, flags);
|
||||
dest.writeTypedObject(mRemoteCredentialEntry, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,13 +114,21 @@ public final class CredentialsDisplayContent implements Parcelable {
|
||||
return mActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the remote credential entry to be displayed on the UI.
|
||||
*/
|
||||
public @Nullable Action getRemoteCredentialEntry() {
|
||||
return mRemoteCredentialEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an instance of {@link CredentialsDisplayContent}.
|
||||
*/
|
||||
public static final class Builder {
|
||||
private CharSequence mHeader = null;
|
||||
private CharSequence mHeader;
|
||||
private List<CredentialEntry> mCredentialEntries = new ArrayList<>();
|
||||
private List<Action> mActions = new ArrayList<>();
|
||||
private Action mRemoteCredentialEntry;
|
||||
|
||||
/**
|
||||
* Sets the header to be displayed on the UI.
|
||||
@@ -123,6 +138,14 @@ public final class CredentialsDisplayContent implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the remote credential entry to be displayed on the UI.
|
||||
*/
|
||||
public @NonNull Builder setRemoteCredentialEntry(@Nullable Action remoteCredentialEntry) {
|
||||
mRemoteCredentialEntry = remoteCredentialEntry;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a {@link CredentialEntry} to the list of entries to be displayed on
|
||||
* the UI.
|
||||
@@ -185,7 +208,8 @@ public final class CredentialsDisplayContent implements Parcelable {
|
||||
throw new IllegalStateException("credentialEntries and actions must not both "
|
||||
+ "be empty");
|
||||
}
|
||||
return new CredentialsDisplayContent(mHeader, mCredentialEntries, mActions);
|
||||
return new CredentialsDisplayContent(mHeader, mCredentialEntries, mActions,
|
||||
mRemoteCredentialEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user