Loading core/java/android/view/contentcapture/ContentCaptureContext.java +20 −6 Original line number Original line Diff line number Diff line Loading @@ -86,7 +86,6 @@ public final class ContentCaptureContext implements Parcelable { private final @Nullable Uri mUri; private final @Nullable Uri mUri; // Fields below are set by server when the session starts // Fields below are set by server when the session starts // TODO(b/111276913): create new object for taskId + componentName / reuse on other places private final @Nullable ComponentName mComponentName; private final @Nullable ComponentName mComponentName; private final int mTaskId; private final int mTaskId; private final int mDisplayId; private final int mDisplayId; Loading Loading @@ -213,6 +212,7 @@ public final class ContentCaptureContext implements Parcelable { public static final class Builder { public static final class Builder { private Bundle mExtras; private Bundle mExtras; private Uri mUri; private Uri mUri; private boolean mDestroyed; /** /** * Sets extra options associated with this context. * Sets extra options associated with this context. Loading @@ -221,11 +221,13 @@ public final class ContentCaptureContext implements Parcelable { * * * @param extras extra options. * @param extras extra options. * @return this builder. * @return this builder. * * @throws IllegalStateException if {@link #build()} was already called. */ */ @NonNull @NonNull public Builder setExtras(@NonNull Bundle extras) { public Builder setExtras(@NonNull Bundle extras) { // TODO(b/111276913): check build just once / throw exception / test / document mExtras = Preconditions.checkNotNull(extras); mExtras = Preconditions.checkNotNull(extras); throwIfDestroyed(); return this; return this; } } Loading @@ -236,23 +238,35 @@ public final class ContentCaptureContext implements Parcelable { * * * @param uri URI associated with this context. * @param uri URI associated with this context. * @return this builder. * @return this builder. * * @throws IllegalStateException if {@link #build()} was already called. */ */ @NonNull @NonNull public Builder setUri(@NonNull Uri uri) { public Builder setUri(@NonNull Uri uri) { // TODO(b/111276913): check build just once / throw exception / test / document mUri = Preconditions.checkNotNull(uri); mUri = Preconditions.checkNotNull(uri); throwIfDestroyed(); return this; return this; } } /** /** * Builds the {@link ContentCaptureContext}. * Builds the {@link ContentCaptureContext}. * * @throws IllegalStateException if {@link #build()} was already called or no call to either * {@link #setExtras(Bundle)} or {@link #setUri(Uri)} was made. * * @return the built {@code ContentCaptureContext} */ */ public ContentCaptureContext build() { public ContentCaptureContext build() { // TODO(b/111276913): check build just once / throw exception / test / document throwIfDestroyed(); // TODO(b/111276913): make sure it at least one property (uri / extras) / test / Preconditions.checkState(mExtras != null || mUri != null, "Must call setUri() " // throw exception / documment + "or setExtras() before calling build()"); mDestroyed = true; return new ContentCaptureContext(this); return new ContentCaptureContext(this); } } private void throwIfDestroyed() { Preconditions.checkState(!mDestroyed, "Already called #build()"); } } } /** /** Loading core/tests/coretests/src/android/view/contentcapture/ContentCaptureSessionTest.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -31,7 +31,7 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner; /** /** * Unit test for {@link ContentCaptureSessionTest}. * Unit tests for {@link ContentCaptureSession}. * * * <p>To run it: * <p>To run it: * {@code atest FrameworksCoreTests:android.view.contentcapture.ContentCaptureSessionTest} * {@code atest FrameworksCoreTests:android.view.contentcapture.ContentCaptureSessionTest} Loading core/tests/coretests/src/android/view/contentcapture/ViewNodeTest.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -42,7 +42,7 @@ import org.mockito.junit.MockitoJUnitRunner; import java.util.Locale; import java.util.Locale; /** /** * Unit test for {@link ViewNode}. * Unit tests for {@link ViewNode}. * * * <p>To run it: {@code atest FrameworksCoreTests:android.view.contentcapture.ViewNodeTest} * <p>To run it: {@code atest FrameworksCoreTests:android.view.contentcapture.ViewNodeTest} */ */ Loading Loading
core/java/android/view/contentcapture/ContentCaptureContext.java +20 −6 Original line number Original line Diff line number Diff line Loading @@ -86,7 +86,6 @@ public final class ContentCaptureContext implements Parcelable { private final @Nullable Uri mUri; private final @Nullable Uri mUri; // Fields below are set by server when the session starts // Fields below are set by server when the session starts // TODO(b/111276913): create new object for taskId + componentName / reuse on other places private final @Nullable ComponentName mComponentName; private final @Nullable ComponentName mComponentName; private final int mTaskId; private final int mTaskId; private final int mDisplayId; private final int mDisplayId; Loading Loading @@ -213,6 +212,7 @@ public final class ContentCaptureContext implements Parcelable { public static final class Builder { public static final class Builder { private Bundle mExtras; private Bundle mExtras; private Uri mUri; private Uri mUri; private boolean mDestroyed; /** /** * Sets extra options associated with this context. * Sets extra options associated with this context. Loading @@ -221,11 +221,13 @@ public final class ContentCaptureContext implements Parcelable { * * * @param extras extra options. * @param extras extra options. * @return this builder. * @return this builder. * * @throws IllegalStateException if {@link #build()} was already called. */ */ @NonNull @NonNull public Builder setExtras(@NonNull Bundle extras) { public Builder setExtras(@NonNull Bundle extras) { // TODO(b/111276913): check build just once / throw exception / test / document mExtras = Preconditions.checkNotNull(extras); mExtras = Preconditions.checkNotNull(extras); throwIfDestroyed(); return this; return this; } } Loading @@ -236,23 +238,35 @@ public final class ContentCaptureContext implements Parcelable { * * * @param uri URI associated with this context. * @param uri URI associated with this context. * @return this builder. * @return this builder. * * @throws IllegalStateException if {@link #build()} was already called. */ */ @NonNull @NonNull public Builder setUri(@NonNull Uri uri) { public Builder setUri(@NonNull Uri uri) { // TODO(b/111276913): check build just once / throw exception / test / document mUri = Preconditions.checkNotNull(uri); mUri = Preconditions.checkNotNull(uri); throwIfDestroyed(); return this; return this; } } /** /** * Builds the {@link ContentCaptureContext}. * Builds the {@link ContentCaptureContext}. * * @throws IllegalStateException if {@link #build()} was already called or no call to either * {@link #setExtras(Bundle)} or {@link #setUri(Uri)} was made. * * @return the built {@code ContentCaptureContext} */ */ public ContentCaptureContext build() { public ContentCaptureContext build() { // TODO(b/111276913): check build just once / throw exception / test / document throwIfDestroyed(); // TODO(b/111276913): make sure it at least one property (uri / extras) / test / Preconditions.checkState(mExtras != null || mUri != null, "Must call setUri() " // throw exception / documment + "or setExtras() before calling build()"); mDestroyed = true; return new ContentCaptureContext(this); return new ContentCaptureContext(this); } } private void throwIfDestroyed() { Preconditions.checkState(!mDestroyed, "Already called #build()"); } } } /** /** Loading
core/tests/coretests/src/android/view/contentcapture/ContentCaptureSessionTest.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -31,7 +31,7 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner; /** /** * Unit test for {@link ContentCaptureSessionTest}. * Unit tests for {@link ContentCaptureSession}. * * * <p>To run it: * <p>To run it: * {@code atest FrameworksCoreTests:android.view.contentcapture.ContentCaptureSessionTest} * {@code atest FrameworksCoreTests:android.view.contentcapture.ContentCaptureSessionTest} Loading
core/tests/coretests/src/android/view/contentcapture/ViewNodeTest.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -42,7 +42,7 @@ import org.mockito.junit.MockitoJUnitRunner; import java.util.Locale; import java.util.Locale; /** /** * Unit test for {@link ViewNode}. * Unit tests for {@link ViewNode}. * * * <p>To run it: {@code atest FrameworksCoreTests:android.view.contentcapture.ViewNodeTest} * <p>To run it: {@code atest FrameworksCoreTests:android.view.contentcapture.ViewNodeTest} */ */ Loading