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

Commit f6a0dadd authored by Android Build Merger (Role)'s avatar Android Build Merger (Role) Committed by Android (Google) Code Review
Browse files

Merge "Merge "Throw IAE when service add null AutofillIds on SaveInfo...

Merge "Merge "Throw IAE when service add null AutofillIds on SaveInfo methods." into oc-dev am: 6cde6875 am: a0a799f8" into oc-dr1-dev-plus-aosp
parents 364eb7bb 2d34d322
Loading
Loading
Loading
Loading
+25 −9
Original line number Original line Diff line number Diff line
@@ -273,13 +273,24 @@ public final class SaveInfo implements Parcelable {
         *
         *
         * <p>See {@link SaveInfo} for more info.
         * <p>See {@link SaveInfo} for more info.
         *
         *
         * @throws IllegalArgumentException if {@code requiredIds} is {@code null} or empty.
         * @throws IllegalArgumentException if {@code requiredIds} is {@code null} or empty, or if
         * it contains any {@code null} entry.
         */
         */
        public Builder(@SaveDataType int type, @NonNull AutofillId[] requiredIds) {
        public Builder(@SaveDataType int type, @NonNull AutofillId[] requiredIds) {
            Preconditions.checkArgument(requiredIds != null && requiredIds.length > 0,
            // TODO: add CTS unit tests (not integration) to assert the null cases
                    "must have at least one required id: " + Arrays.toString(requiredIds));
            mType = type;
            mType = type;
            mRequiredIds = requiredIds;
            mRequiredIds = assertValid(requiredIds);
        }

        private AutofillId[] assertValid(AutofillId[] ids) {
            Preconditions.checkArgument(ids != null && ids.length > 0,
                    "must have at least one id: " + Arrays.toString(ids));
            for (int i = 0; i < ids.length; i++) {
                final AutofillId id = ids[i];
                Preconditions.checkArgument(id != null,
                        "cannot have null id: " + Arrays.toString(ids));
            }
            return ids;
        }
        }


        /**
        /**
@@ -302,12 +313,14 @@ public final class SaveInfo implements Parcelable {
         *
         *
         * @param ids The ids of the optional views.
         * @param ids The ids of the optional views.
         * @return This builder.
         * @return This builder.
         *
         * @throws IllegalArgumentException if {@code ids} is {@code null} or empty, or if
         * it contains any {@code null} entry.
         */
         */
        public @NonNull Builder setOptionalIds(@Nullable AutofillId[] ids) {
        public @NonNull Builder setOptionalIds(@NonNull AutofillId[] ids) {
            // TODO: add CTS unit tests (not integration) to assert the null cases
            throwIfDestroyed();
            throwIfDestroyed();
            if (ids != null && ids.length != 0) {
            mOptionalIds = assertValid(ids);
                mOptionalIds = ids;
            }
            return this;
            return this;
        }
        }


@@ -421,7 +434,10 @@ public final class SaveInfo implements Parcelable {
            final Builder builder = new Builder(parcel.readInt(),
            final Builder builder = new Builder(parcel.readInt(),
                    parcel.readParcelableArray(null, AutofillId.class));
                    parcel.readParcelableArray(null, AutofillId.class));
            builder.setNegativeAction(parcel.readInt(), parcel.readParcelable(null));
            builder.setNegativeAction(parcel.readInt(), parcel.readParcelable(null));
            builder.setOptionalIds(parcel.readParcelableArray(null, AutofillId.class));
            final AutofillId[] optionalIds = parcel.readParcelableArray(null, AutofillId.class);
            if (optionalIds != null) {
                builder.setOptionalIds(optionalIds);
            }
            builder.setDescription(parcel.readCharSequence());
            builder.setDescription(parcel.readCharSequence());
            builder.setFlags(parcel.readInt());
            builder.setFlags(parcel.readInt());
            return builder.build();
            return builder.build();