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

Commit b57080eb authored by Felipe Leme's avatar Felipe Leme
Browse files

Changed FillResponse so it can have only a client state.

Test: atest CtsAutoFillServiceTestCases#FillResponseTest
Fixes: 69568694

Change-Id: I72ebb280c68db82f28d1ecb651d645eb028bafbe
parent 253063a7
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -319,6 +319,7 @@ public final class FillResponse implements Parcelable {
         */
        public Builder setClientState(@Nullable Bundle clientState) {
            throwIfDestroyed();
            throwIfDisableAutofillCalled();
            mClientState = clientState;
            return this;
        }
@@ -385,8 +386,9 @@ public final class FillResponse implements Parcelable {
         *
         * @throws IllegalArgumentException if {@code duration} is not a positive number.
         * @throws IllegalStateException if either {@link #addDataset(Dataset)},
         *       {@link #setAuthentication(AutofillId[], IntentSender, RemoteViews)}, or
         *       {@link #setSaveInfo(SaveInfo)} was already called.
         *       {@link #setAuthentication(AutofillId[], IntentSender, RemoteViews)},
         *       {@link #setSaveInfo(SaveInfo)}, or {@link #setClientState(Bundle)}
         *       was already called.
         */
        public Builder disableAutofill(long duration) {
            throwIfDestroyed();
@@ -394,7 +396,7 @@ public final class FillResponse implements Parcelable {
                throw new IllegalArgumentException("duration must be greater than 0");
            }
            if (mAuthentication != null || mDatasets != null || mSaveInfo != null
                    || mFieldsDetection != null) {
                    || mFieldsDetection != null || mClientState != null) {
                throw new IllegalStateException("disableAutofill() must be the only method called");
            }

@@ -410,7 +412,8 @@ public final class FillResponse implements Parcelable {
         *   <li>{@link #build()} was already called.
         *   <li>No call was made to {@link #addDataset(Dataset)},
         *       {@link #setAuthentication(AutofillId[], IntentSender, RemoteViews)},
         *       {@link #setSaveInfo(SaveInfo)}, or {@link #disableAutofill(long)}.
         *       {@link #setSaveInfo(SaveInfo)}, {@link #disableAutofill(long)},
         *       or {@link #setClientState(Bundle)}.
         * </ol>
         *
         * @return A built response.
@@ -418,10 +421,10 @@ public final class FillResponse implements Parcelable {
        public FillResponse build() {
            throwIfDestroyed();
            if (mAuthentication == null && mDatasets == null && mSaveInfo == null
                    && mDisableDuration == 0 && mFieldsDetection == null) {
                    && mDisableDuration == 0 && mFieldsDetection == null && mClientState == null) {
                throw new IllegalStateException("need to provide: at least one DataSet, or a "
                        + "SaveInfo, or an authentication with a presentation, "
                        + "or a FieldsDetection, or disable autofill");
                        + "or a FieldsDetection, or a client state, or disable autofill");
            }
            mDestroyed = true;
            return new FillResponse(this);