Bug 1474450 - 3. Fix javadoc; r=jchen a=lizzard
authorJim Chen <nchen@mozilla.com>
Tue, 10 Jul 2018 13:12:56 -0400
changeset 477957 7f495a6969c5
parent 477956 94e6d8bb45e5
child 477958 fb31b6425bf7
push id9475
push userarchaeopteryx@coole-files.de
push date2018-07-13 21:33 +0000
treeherdermozilla-beta@d7ab2f3df084 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen, lizzard
bugs1474450
milestone62.0
Bug 1474450 - 3. Fix javadoc; r=jchen a=lizzard 1) Add some missing javadoc and fix existing javadoc warnings. 2) Expand the GeckoResult javadoc with some examples. 3) Make @IntDef/@StringDef interfaces package-private, so they don't show up in javadoc as empty stubs. MozReview-Commit-ID: JzvlLzTMgAQ
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoResult.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoResult.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoResult.java
@@ -4,17 +4,143 @@ import org.mozilla.gecko.util.ThreadUtil
 
 import android.os.Looper;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
 
 import java.util.ArrayList;
 
 /**
- * GeckoResult is a class that represents an asynchronous result.
+ * GeckoResult is a class that represents an asynchronous result. The result is initially pending,
+ * and at a later time, the result may be completed with {@link #complete a value} or {@link
+ * #completeExceptionally an exception} depending on the outcome of the asynchronous operation. For
+ * example,<pre>
+ * public GeckoResult&lt;Integer&gt; divide(final int dividend, final int divisor) {
+ *     final GeckoResult&lt;Integer&gt; result = new GeckoResult&lt;&gt;();
+ *     (new Thread(() -&gt; {
+ *         if (divisor != 0) {
+ *             result.complete(dividend / divisor);
+ *         } else {
+ *             result.completeExceptionally(new ArithmeticException("Dividing by zero"));
+ *         }
+ *     })).start();
+ *     return result;
+ * }</pre>
+ * <p>
+ * To retrieve the completed value or exception, use one of the {@link #then} methods to register
+ * listeners on the result. All listeners are run on the application main thread. For example, to
+ * retrieve a completed value,<pre>
+ * divide(42, 2).then(new GeckoResult.OnValueListener&lt;Integer, Void&gt;() {
+ *     &#64;Override
+ *     public GeckoResult&lt;Void&gt; onValue(final Integer value) {
+ *         // value == 21
+ *     }
+ * }, new GeckoResult.OnExceptionListener&lt;Void&gt;() {
+ *     &#64;Override
+ *     public GeckoResult&lt;Void&gt; onException(final Throwable exception) {
+ *         // Not called
+ *     }
+ * });</pre>
+ * <p>
+ * And to retrieve a completed exception,<pre>
+ * divide(42, 0).then(new GeckoResult.OnValueListener&lt;Integer, Void&gt;() {
+ *     &#64;Override
+ *     public GeckoResult&lt;Void&gt; onValue(final Integer value) {
+ *         // Not called
+ *     }
+ * }, new GeckoResult.OnExceptionListener&lt;Void&gt;() {
+ *     &#64;Override
+ *     public GeckoResult&lt;Void&gt; onException(final Throwable exception) {
+ *         // exception instanceof ArithmeticException
+ *     }
+ * });</pre>
+ * <p>
+ * {@link #then} calls may be chained to complete multiple asynchonous operations in sequence.
+ * This example takes an integer, converts it to a String, and appends it to another String,<pre>
+ * divide(42, 2).then(new GeckoResult.OnValueListener&lt;Integer, String&gt;() {
+ *     &#64;Override
+ *     public GeckoResult&lt;String&gt; onValue(final Integer value) {
+ *         return GeckoResult.fromValue(value.toString());
+ *     }
+ * }).then(new GeckoResult.OnValueListener&lt;String, String&gt;() {
+ *     &#64;Override
+ *     public GeckoResult&lt;String&gt; onValue(final String value) {
+ *         return GeckoResult.fromValue("42 / 2 = " + value);
+ *     }
+ * }).then(new GeckoResult.OnValueListener&lt;String, Void&gt;() {
+ *     &#64;Override
+ *     public GeckoResult&lt;Void&gt; onValue(final String value) {
+ *         // value == "42 / 2 = 21"
+ *         return null;
+ *     }
+ * });</pre>
+ * <p>
+ * Chaining works with exception listeners as well. For example,<pre>
+ * divide(42, 0).then(new GeckoResult.OnExceptionListener&lt;String&gt;() {
+ *     &#64;Override
+ *     public GeckoResult&lt;Void&gt; onException(final Throwable exception) {
+ *         return "foo";
+ *     }
+ * }).then(new GeckoResult.OnValueListener&lt;String, Void&gt;() {
+ *     &#64;Override
+ *     public GeckoResult&lt;Void&gt; onValue(final String value) {
+ *         // value == "foo"
+ *     }
+ * });</pre>
+ * <p>
+ * A completed value/exception will propagate down the chain even if an intermediate step does not
+ * have a value/exception listener. For example,<pre>
+ * divide(42, 0).then(new GeckoResult.OnValueListener&lt;Integer, String&gt;() {
+ *     &#64;Override
+ *     public GeckoResult&lt;String&gt; onValue(final Integer value) {
+ *         // Not called
+ *     }
+ * }).then(new GeckoResult.OnExceptionListener&lt;Void&gt;() {
+ *     &#64;Override
+ *     public GeckoResult&lt;Void&gt; onException(final Throwable exception) {
+ *         // exception instanceof ArithmeticException
+ *     }
+ * });</pre>
+ * <p>
+ * However, any propagated value will be coerced to null. For example,<pre>
+ * divide(42, 2).then(new GeckoResult.OnExceptionListener&lt;String&gt;() {
+ *     &#64;Override
+ *     public GeckoResult&lt;String&gt; onException(final Throwable exception) {
+ *         // Not called
+ *     }
+ * }).then(new GeckoResult.OnValueListener&lt;String, Void&gt;() {
+ *     &#64;Override
+ *     public GeckoResult&lt;Void&gt; onValue(final String value) {
+ *         // value == null
+ *     }
+ * });</pre>
+ * <p>
+ * Any exception thrown by a listener are automatically used to complete the result. At the end of
+ * every chain, there is an implicit exception listener that rethrows any uncaught and unhandled
+ * exception as {@link UncaughtException}. The following example will cause {@link
+ * UncaughtException} to be thrown because {@code BazException} is uncaught and unhandled at the
+ * end of the chain,<pre>
+ * GeckoResult.fromValue(42).then(new GeckoResult.OnValueListener&lt;Integer, Void&gt;() {
+ *     &#64;Override
+ *     public GeckoResult&lt;Void&gt; onValue(final Integer value) throws FooException {
+ *         throw new FooException();
+ *     }
+ * }).then(new GeckoResult.OnExceptionListener&lt;Void&gt;() {
+ *     &#64;Override
+ *     public GeckoResult&lt;Void&gt; onException(final Throwable exception) throws Exception {
+ *         // exception instanceof FooException
+ *         throw new BarException();
+ *     }
+ * }).then(new GeckoResult.OnExceptionListener&lt;Void&gt;() {
+ *     &#64;Override
+ *     public GeckoResult&lt;Void&gt; onException(final Throwable exception) throws Throwable {
+ *         // exception instanceof BarException
+ *         return new BazException();
+ *     }
+ * });</pre>
  *
  * @param <T> The type of the value delivered via the GeckoResult.
  */
 public class GeckoResult<T> {
     private static final String LOGTAG = "GeckoResult";
 
     public static final class UncaughtException extends RuntimeException {
         public UncaughtException(final Throwable cause) {
@@ -24,51 +150,53 @@ public class GeckoResult<T> {
 
     private boolean mComplete;
     private T mValue;
     private Throwable mError;
     private boolean mIsUncaughtError;
     private ArrayList<Runnable> mListeners;
 
     /**
-     * This constructs an incomplete GeckoResult. Call {@link #complete(Object)} or
+     * Construct an incomplete GeckoResult. Call {@link #complete(Object)} or
      * {@link #completeExceptionally(Throwable)} in order to fulfill the result.
      */
     public GeckoResult() {
     }
 
     /**
-     * This constructs a result from another result. Listeners are not copied.
+     * Construct a result from another result. Listeners are not copied.
      *
       * @param from The {@link GeckoResult} to copy.
      */
     public GeckoResult(GeckoResult<T> from) {
         this();
         mComplete = from.mComplete;
         mValue = from.mValue;
         mError = from.mError;
     }
 
     /**
-     * This constructs a result that is completed with the specified value.
+     * Construct a result that is completed with the specified value.
      *
      * @param value The value used to complete the newly created result.
+     * @param <U> Type for the result.
      * @return The completed {@link GeckoResult}
      */
     public static @NonNull <U> GeckoResult<U> fromValue(@Nullable final U value) {
         final GeckoResult<U> result = new GeckoResult<>();
         result.complete(value);
         return result;
     }
 
     /**
-     * This constructs a result that is completed with the specified {@link Throwable}.
+     * Construct a result that is completed with the specified {@link Throwable}.
      * May not be null.
      *
      * @param error The exception used to complete the newly created result.
+     * @param <T> Type for the result if the result had been completed without exception.
      * @return The completed {@link GeckoResult}
      */
     public static @NonNull <T> GeckoResult<T> fromException(@NonNull final Throwable error) {
         final GeckoResult<T> result = new GeckoResult<>();
         result.completeExceptionally(error);
         return result;
     }
 
@@ -98,46 +226,47 @@ public class GeckoResult<T> {
         return false;
     }
 
     /**
      * Convenience method for {@link #then(OnValueListener, OnExceptionListener)}.
      *
      * @param valueListener An instance of {@link OnValueListener}, called when the
      *                      {@link GeckoResult} is completed with a value.
-     * @param <U>
-     * @return
+     * @param <U> Type of the new result that is returned by the listener.
+     * @return A new {@link GeckoResult} that the listener will complete.
      */
     public @NonNull <U> GeckoResult<U> then(@NonNull final OnValueListener<T, U> valueListener) {
         return then(valueListener, null);
     }
 
     /**
      * Convenience method for {@link #then(OnValueListener, OnExceptionListener)}.
      *
      * @param exceptionListener An instance of {@link OnExceptionListener}, called when the
      *                          {@link GeckoResult} is completed with an {@link Exception}.
-     * @param <U> The type contained in the returned {@link GeckoResult}
-     * @return
+     * @param <U> Type of the new result that is returned by the listener.
+     * @return A new {@link GeckoResult} that the listener will complete.
      */
     public @NonNull <U> GeckoResult<U> then(@NonNull final OnExceptionListener<U> exceptionListener) {
         return then(null, exceptionListener);
     }
 
     /**
      * Adds listeners to be called when the {@link GeckoResult} is completed either with
      * a value or {@link Throwable}. Listeners will be invoked on the main thread. If the
      * result is already complete when this method is called, listeners will be invoked in
      * a future {@link Looper} iteration.
      *
      * @param valueListener An instance of {@link OnValueListener}, called when the
      *                      {@link GeckoResult} is completed with a value.
      * @param exceptionListener An instance of {@link OnExceptionListener}, called when the
      *                          {@link GeckoResult} is completed with an {@link Throwable}.
-     * @param <U> The type contained in the returned {@link GeckoResult}
+     * @param <U> Type of the new result that is returned by the listeners.
+     * @return A new {@link GeckoResult} that the listeners will complete.
      */
     public @NonNull <U> GeckoResult<U> then(@Nullable final OnValueListener<T, U> valueListener,
                                             @Nullable final OnExceptionListener<U> exceptionListener) {
         if (valueListener == null && exceptionListener == null) {
             throw new IllegalArgumentException("At least one listener should be non-null");
         }
 
         final GeckoResult<U> result = new GeckoResult<U>();
@@ -237,39 +366,39 @@ public class GeckoResult<T> {
                     mIsUncaughtError = other.mIsUncaughtError;
                     completeExceptionally(other.mError);
                 }
             }
         });
     }
 
     /**
-     * This completes the result with the specified value. IllegalStateException is thrown
+     * Complete the result with the specified value. IllegalStateException is thrown
      * if the result is already complete.
      *
      * @param value The value used to complete the result.
-     * @throws IllegalStateException
+     * @throws IllegalStateException If the result is already completed.
      */
     public synchronized void complete(final T value) {
         if (mComplete) {
             throw new IllegalStateException("result is already complete");
         }
 
         mValue = value;
         mComplete = true;
 
         dispatchLocked();
     }
 
     /**
-     * This completes the result with the specified {@link Throwable}. IllegalStateException is thrown
+     * Complete the result with the specified {@link Throwable}. IllegalStateException is thrown
      * if the result is already complete.
      *
      * @param exception The {@link Throwable} used to complete the result.
-     * @throws IllegalStateException
+     * @throws IllegalStateException If the result is already completed.
      */
     public synchronized void completeExceptionally(@NonNull final Throwable exception) {
         if (mComplete) {
             throw new IllegalStateException("result is already complete");
         }
 
         if (exception == null) {
             throw new IllegalArgumentException("Throwable must not be null");
@@ -278,38 +407,46 @@ public class GeckoResult<T> {
         mError = exception;
         mComplete = true;
 
         dispatchLocked();
     }
 
     /**
      * An interface used to deliver values to listeners of a {@link GeckoResult}
-     * @param <T> This is the type of the value delivered via {@link #onValue(Object)}
-     * @param <U> This is the type of the value for the result returned from {@link #onValue(Object)}
+     * @param <T> Type of the value delivered via {@link #onValue(Object)}
+     * @param <U> Type of the value for the result returned from {@link #onValue(Object)}
      */
     public interface OnValueListener<T, U> {
         /**
-         * Called when a {@link GeckoResult} is completed with a value. This will be
-         * called on the same thread in which the result was completed.
+         * Called when a {@link GeckoResult} is completed with a value. Will be
+         * called on the main thread.
          *
          * @param value The value of the {@link GeckoResult}
-         * @return A new {@link GeckoResult}, used for chaining results together.
-         *         May be null.
+         * @return Result used to complete the next result in the chain. May be null.
+         * @throws Throwable Exception used to complete next result in the chain.
          */
-        GeckoResult<U> onValue(T value) throws Throwable;
+        @Nullable GeckoResult<U> onValue(@Nullable T value) throws Throwable;
     }
 
     /**
      * An interface used to deliver exceptions to listeners of a {@link GeckoResult}
      *
-     * @param <V> This is the type of the vale for the result returned from {@link #onException(Throwable)}
+     * @param <V> Type of the vale for the result returned from {@link #onException(Throwable)}
      */
     public interface OnExceptionListener<V> {
-        GeckoResult<V> onException(Throwable exception) throws Throwable;
+        /**
+         * Called when a {@link GeckoResult} is completed with an exception. Will be
+         * called on the main thread.
+         *
+         * @param exception Exception that completed the result.
+         * @return Result used to complete the next result in the chain. May be null.
+         * @throws Throwable Exception used to complete next result in the chain.
+         */
+        @Nullable GeckoResult<V> onException(@NonNull Throwable exception) throws Throwable;
     }
 
     private boolean haveValue() {
         return mComplete && mError == null;
     }
 
     private boolean haveError() {
         return mComplete && mError != null;
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
@@ -236,18 +236,20 @@ public final class GeckoRuntime implemen
         }
         return mTelemetry;
 
     }
 
     /**
      * Get the profile directory for this runtime. This is where Gecko stores
      * internal data.
+     *
+     * @return Profile directory
      */
-    public File getProfileDir() {
+    @NonNull public File getProfileDir() {
         return GeckoThread.getActiveProfile().getDir();
     }
 
     @Override // Parcelable
     public int describeContents() {
         return 0;
     }
 
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
@@ -429,17 +429,18 @@ public final class GeckoRuntimeSettings 
      * @return True if the pause is enabled.
      */
     public boolean getPauseForDebuggerEnabled() { return mDebugPause; }
 
     // Sync values with nsICookieService.idl.
     @Retention(RetentionPolicy.SOURCE)
     @IntDef({ COOKIE_ACCEPT_ALL, COOKIE_ACCEPT_FIRST_PARTY,
               COOKIE_ACCEPT_NONE, COOKIE_ACCEPT_VISITED })
-    public @interface CookieBehavior {}
+    /* package */ @interface CookieBehavior {}
+
     /**
      * Accept first-party and third-party cookies and site data.
      */
     public static final int COOKIE_ACCEPT_ALL = 0;
     /**
      * Accept only first-party cookies and site data to block cookies which are
      * not associated with the domain of the visited site.
      */
@@ -475,17 +476,18 @@ public final class GeckoRuntimeSettings 
         mCookieBehavior.set(behavior);
         return this;
     }
 
     // Sync values with nsICookieService.idl.
     @Retention(RetentionPolicy.SOURCE)
     @IntDef({ COOKIE_LIFETIME_NORMAL, COOKIE_LIFETIME_RUNTIME,
               COOKIE_LIFETIME_DAYS })
-    public @interface CookieLifetime {}
+    /* package */ @interface CookieLifetime {}
+
     /**
      * Accept default cookie lifetime.
      */
     public static final int COOKIE_LIFETIME_NORMAL = 0;
     /**
      * Downgrade cookie lifetime to this runtime's lifetime.
      */
     public static final int COOKIE_LIFETIME_RUNTIME = 2;
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
@@ -871,17 +871,17 @@ public class GeckoSession extends LayerS
             mAccessibility = new SessionAccessibility(this);
         }
         return mAccessibility;
     }
 
     @IntDef(flag = true,
             value = { LOAD_FLAGS_NONE, LOAD_FLAGS_BYPASS_CACHE, LOAD_FLAGS_BYPASS_PROXY,
                       LOAD_FLAGS_EXTERNAL, LOAD_FLAGS_ALLOW_POPUPS })
-    public @interface LoadFlags {}
+    /* package */ @interface LoadFlags {}
 
     // These flags follow similarly named ones in Gecko's nsIWebNavigation.idl
     // https://searchfox.org/mozilla-central/source/docshell/base/nsIWebNavigation.idl
     //
     // We do not use the same values directly in order to insulate ourselves from
     // changes in Gecko. Instead, the flags are converted in GeckoViewNavigation.jsm.
 
     /**
@@ -1754,23 +1754,23 @@ public class GeckoSession extends LayerS
 
     public interface ProgressDelegate {
         /**
          * Class representing security information for a site.
          */
         public class SecurityInformation {
             @IntDef({SECURITY_MODE_UNKNOWN, SECURITY_MODE_IDENTIFIED,
                      SECURITY_MODE_VERIFIED})
-            public @interface SecurityMode {}
+            /* package */ @interface SecurityMode {}
             public static final int SECURITY_MODE_UNKNOWN = 0;
             public static final int SECURITY_MODE_IDENTIFIED = 1;
             public static final int SECURITY_MODE_VERIFIED = 2;
 
             @IntDef({CONTENT_UNKNOWN, CONTENT_BLOCKED, CONTENT_LOADED})
-            public @interface ContentType {}
+            /* package */ @interface ContentType {}
             public static final int CONTENT_UNKNOWN = 0;
             public static final int CONTENT_BLOCKED = 1;
             public static final int CONTENT_LOADED = 2;
             /**
              * Indicates whether or not the site is secure.
              */
             public final boolean isSecure;
             /**
@@ -1911,17 +1911,17 @@ public class GeckoSession extends LayerS
             contentLength = message.getLong("contentLength");
             filename = message.getString("filename");
         }
     }
 
     public interface ContentDelegate {
         @IntDef({ELEMENT_TYPE_NONE, ELEMENT_TYPE_IMAGE, ELEMENT_TYPE_VIDEO,
                  ELEMENT_TYPE_AUDIO})
-        public @interface ElementType {}
+        /* package */ @interface ElementType {}
         static final int ELEMENT_TYPE_NONE = 0;
         static final int ELEMENT_TYPE_IMAGE = 1;
         static final int ELEMENT_TYPE_VIDEO = 2;
         static final int ELEMENT_TYPE_AUDIO = 3;
 
         /**
         * A page title was discovered in the content or updated after the content
         * loaded.
@@ -1992,17 +1992,17 @@ public class GeckoSession extends LayerS
          * @param session The GeckoSession that crashed.
          */
         void onCrash(GeckoSession session);
     }
 
     public interface SelectionActionDelegate {
         @IntDef(flag = true, value = {FLAG_IS_COLLAPSED,
                                       FLAG_IS_EDITABLE})
-        @interface Flag {}
+        /* package */ @interface Flag {}
 
         /**
          * The selection is collapsed at a single position.
          */
         final int FLAG_IS_COLLAPSED = 1;
         /**
          * The selection is inside editable content such as an input element or
          * contentEditable node.
@@ -2016,17 +2016,17 @@ public class GeckoSession extends LayerS
         @StringDef({ACTION_CUT,
                     ACTION_COPY,
                     ACTION_DELETE,
                     ACTION_PASTE,
                     ACTION_SELECT_ALL,
                     ACTION_UNSELECT,
                     ACTION_COLLAPSE_TO_START,
                     ACTION_COLLAPSE_TO_END})
-        @interface Action {}
+        /* package */ @interface Action {}
 
         /**
          * Copy onto the clipboard then delete the selected content. Selection
          * must be editable.
          */
         final String ACTION_CUT = "org.mozilla.geckoview.CUT";
         /**
          * Copy the selected content onto the clipboard.
@@ -2129,17 +2129,17 @@ public class GeckoSession extends LayerS
          */
         void onShowActionRequest(GeckoSession session, Selection selection,
                                  @Action String[] actions, GeckoResponse<String> response);
 
         @IntDef({HIDE_REASON_NO_SELECTION,
                  HIDE_REASON_INVISIBLE_SELECTION,
                  HIDE_REASON_ACTIVE_SELECTION,
                  HIDE_REASON_ACTIVE_SCROLL})
-        @interface HideReason {}
+        /* package */ @interface HideReason {}
 
         /**
          * Actions are no longer available due to the user clearing the selection.
          */
         final int HIDE_REASON_NO_SELECTION = 0;
         /**
          * Actions are no longer available due to the user moving the selection becoming
          * out of view. Previous actions are still available after a callback with this
@@ -2189,24 +2189,25 @@ public class GeckoSession extends LayerS
         /**
         * The view's ability to go forward has changed.
         * @param session The GeckoSession that initiated the callback.
         * @param canGoForward The new value for the ability.
         */
         void onCanGoForward(GeckoSession session, boolean canGoForward);
 
         @IntDef({TARGET_WINDOW_NONE, TARGET_WINDOW_CURRENT, TARGET_WINDOW_NEW})
-        public @interface TargetWindow {}
+        /* package */ @interface TargetWindow {}
         public static final int TARGET_WINDOW_NONE = 0;
         public static final int TARGET_WINDOW_CURRENT = 1;
         public static final int TARGET_WINDOW_NEW = 2;
 
         @IntDef(flag = true,
                 value = {LOAD_REQUEST_IS_USER_TRIGGERED})
-        public @interface LoadRequestFlags {}
+        /* package */ @interface LoadRequestFlags {}
+
         // Match with nsIDocShell.idl.
         /**
          * The load request was triggered by user input.
          */
         public static final int LOAD_REQUEST_IS_USER_TRIGGERED = 0x1000;
 
         /**
          * A request to open an URI. This is called before each page load to
@@ -2386,17 +2387,17 @@ public class GeckoSession extends LayerS
             void confirm(String username, String password);
         }
 
         class AuthOptions {
             @IntDef(flag = true,
                     value = {AUTH_FLAG_HOST, AUTH_FLAG_PROXY,
                              AUTH_FLAG_ONLY_PASSWORD, AUTH_FLAG_PREVIOUS_FAILED,
                              AUTH_FLAG_CROSS_ORIGIN_SUB_RESOURCE})
-            public @interface AuthFlag {}
+            /* package */ @interface AuthFlag {}
 
             /**
              * The auth prompt is for a network host.
              */
             public static final int AUTH_FLAG_HOST = 1;
             /**
              * The auth prompt is for a proxy.
              */
@@ -2410,17 +2411,18 @@ public class GeckoSession extends LayerS
              */
             public static final int AUTH_FLAG_PREVIOUS_FAILED = 16;
             /**
              * The auth prompt is for a cross-origin sub-resource.
              */
             public static final int AUTH_FLAG_CROSS_ORIGIN_SUB_RESOURCE = 32;
 
             @IntDef({AUTH_LEVEL_NONE, AUTH_LEVEL_PW_ENCRYPTED, AUTH_LEVEL_SECURE})
-            public @interface AuthLevel {}
+            /* package */ @interface AuthLevel {}
+
             /**
              * The auth request is unencrypted or the encryption status is unknown.
              */
             public static final int AUTH_LEVEL_NONE = 0;
             /**
              * The auth request only encrypts password but not data.
              */
             public static final int AUTH_LEVEL_PW_ENCRYPTED = 1;
@@ -2472,17 +2474,18 @@ public class GeckoSession extends LayerS
          * @param options AuthOptions containing options for the prompt
          * @param callback Callback interface.
          */
         void onAuthPrompt(GeckoSession session, String title, String msg,
                            AuthOptions options, AuthCallback callback);
 
         class Choice {
             @IntDef({CHOICE_TYPE_MENU, CHOICE_TYPE_SINGLE, CHOICE_TYPE_MULTIPLE})
-            public @interface ChoiceType {}
+            /* package */ @interface ChoiceType {}
+
             /**
              * Display choices in a menu that dismisses as soon as an item is chosen.
              */
             public static final int CHOICE_TYPE_MENU = 1;
 
             /**
              * Display choices in a list that allows a single selection.
              */
@@ -2615,17 +2618,18 @@ public class GeckoSession extends LayerS
          * @param callback Callback interface; the result passed to confirm() must be in
          *                 HTML color format.
          */
         void onColorPrompt(GeckoSession session, String title, String value,
                             TextCallback callback);
 
         @IntDef({DATETIME_TYPE_DATE, DATETIME_TYPE_MONTH, DATETIME_TYPE_WEEK,
                  DATETIME_TYPE_TIME, DATETIME_TYPE_DATETIME_LOCAL})
-        public @interface DatetimeType {}
+        /* package */ @interface DatetimeType {}
+
         /**
          * Prompt for year, month, and day.
          */
         static final int DATETIME_TYPE_DATE = 1;
 
         /**
          * Prompt for year and month.
          */
@@ -2681,17 +2685,17 @@ public class GeckoSession extends LayerS
              *
              * @param context An application Context for parsing URIs.
              * @param uris Array of URI objects for the selected files.
              */
             void confirm(Context context, Uri[] uris);
         }
 
         @IntDef({FILE_TYPE_SINGLE, FILE_TYPE_MULTIPLE})
-        public @interface FileType {}
+        /* package */ @interface FileType {}
         static final int FILE_TYPE_SINGLE = 1;
         static final int FILE_TYPE_MULTIPLE = 2;
 
         /**
          * Display a file prompt.
          *
          * @param session GeckoSession that triggered the prompt
          * @param title Title for the prompt dialog.
@@ -2725,17 +2729,18 @@ public class GeckoSession extends LayerS
      * protection events.
      **/
     public interface TrackingProtectionDelegate {
         @Retention(RetentionPolicy.SOURCE)
         @IntDef(flag = true,
                 value = { CATEGORY_NONE, CATEGORY_AD, CATEGORY_ANALYTIC,
                           CATEGORY_SOCIAL, CATEGORY_CONTENT, CATEGORY_ALL,
                           CATEGORY_TEST })
-        public @interface Category {}
+        /* package */ @interface Category {}
+
         static final int CATEGORY_NONE = 0;
         /**
          * Block advertisement trackers.
          */
         static final int CATEGORY_AD = 1 << 0;
         /**
          * Block analytics trackers.
          */
@@ -2777,17 +2782,18 @@ public class GeckoSession extends LayerS
      * two requests are generated: one request for the Android app permission through
      * requestAppPermissions, which is typically handled by a system permission dialog;
      * and another request for the content permission (e.g. through
      * requestContentPermission), which is typically handled by an app-specific
      * permission dialog.
      **/
     public interface PermissionDelegate {
         @IntDef({PERMISSION_GEOLOCATION, PERMISSION_DESKTOP_NOTIFICATION})
-        public @interface Permission {}
+        /* package */ @interface Permission {}
+
         /**
          * Permission for using the geolocation API.
          * See: https://developer.mozilla.org/en-US/docs/Web/API/Geolocation
          */
         public static final int PERMISSION_GEOLOCATION = 0;
 
         /**
          * Permission for using the notifications API.
@@ -2840,17 +2846,17 @@ public class GeckoSession extends LayerS
         void onContentPermissionRequest(GeckoSession session, String uri,
                                         @Permission int type,
                                         String access, Callback callback);
 
         class MediaSource {
             @IntDef({SOURCE_CAMERA, SOURCE_SCREEN, SOURCE_APPLICATION,
                      SOURCE_WINDOW, SOURCE_BROWSER, SOURCE_MICROPHONE,
                      SOURCE_AUDIOCAPTURE, SOURCE_OTHER})
-            public @interface Source {}
+            /* package */ @interface Source {}
 
             /**
              * The media source is a camera.
              */
             public static final int SOURCE_CAMERA = 0;
 
             /**
              * The media source is the screen.
@@ -2883,17 +2889,18 @@ public class GeckoSession extends LayerS
             public static final int SOURCE_AUDIOCAPTURE = 6;
 
             /**
              * The media source does not fall into any of the other categories.
              */
             public static final int SOURCE_OTHER = 7;
 
             @IntDef({TYPE_VIDEO, TYPE_AUDIO})
-            public @interface Type {}
+            /* package */ @interface Type {}
+
             /**
              * The media type is video.
              */
             public static final int TYPE_VIDEO = 0;
 
             /**
              * The media type is audio.
              */
@@ -3026,17 +3033,18 @@ public class GeckoSession extends LayerS
     /**
      * Interface that SessionTextInput uses for performing operations such as opening and closing
      * the software keyboard. If the delegate is not set, these operations are forwarded to the
      * system {@link android.view.inputmethod.InputMethodManager} automatically.
      */
     public interface TextInputDelegate {
         @Retention(RetentionPolicy.SOURCE)
         @IntDef({RESTART_REASON_FOCUS, RESTART_REASON_BLUR, RESTART_REASON_CONTENT_CHANGE})
-        @interface RestartReason {}
+        /* package */ @interface RestartReason {}
+
         /** Restarting input due to an input field gaining focus. */
         int RESTART_REASON_FOCUS = 0;
         /** Restarting input due to an input field losing focus. */
         int RESTART_REASON_BLUR = 1;
         /**
          * Restarting input due to the content of the input field changing. For example, the
          * input field type may have changed, or the current composition may have been committed
          * outside of the input method.