Bug 1955343 - Part 1: Resolve warnings in WebNotification.java r=geckoview-reviewers,owlish
authorKagami Sascha Rosylight <saschanaz@outlook.com>
Sat, 12 Apr 2025 11:27:25 +0000 (3 months ago)
changeset 782984 5771786e2fb3b2f5b092ad3ad28f7a84c09bda1e
parent 782983 7d28c00760782dd3bac0e3e1508bc9dadc3c9e9c
child 782985 fe59e1658be03e94f8e8210225dbb0303eb2472f
push id42708
push userabutkovits@mozilla.com
push dateSat, 12 Apr 2025 21:12:21 +0000 (3 months ago)
treeherdermozilla-central@78ae23e3694a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgeckoview-reviewers, owlish
bugs1955343
milestone139.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1955343 - Part 1: Resolve warnings in WebNotification.java r=geckoview-reviewers,owlish Differential Revision: https://phabricator.services.mozilla.com/D242582
mobile/android/geckoview/api.txt
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebNotification.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md
--- a/mobile/android/geckoview/api.txt
+++ b/mobile/android/geckoview/api.txt
@@ -2817,17 +2817,17 @@ package org.mozilla.geckoview {
 
   public class WebNotification implements Parcelable {
     method @UiThread public void click();
     method @UiThread public void dismiss();
     field public static final Parcelable.Creator<WebNotification> CREATOR;
     field @Nullable public final String imageUrl;
     field @Nullable public final String lang;
     field public final boolean privateBrowsing;
-    field @NonNull public final boolean requireInteraction;
+    field public final boolean requireInteraction;
     field public final boolean silent;
     field @Nullable public final String source;
     field @NonNull public final String tag;
     field @Nullable public final String text;
     field @Nullable public final String textDirection;
     field @Nullable public final String title;
     field @NonNull public final int[] vibrate;
   }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebNotification.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebNotification.java
@@ -5,16 +5,17 @@
 package org.mozilla.geckoview;
 
 import android.os.Parcel;
 import android.os.ParcelFormatException;
 import android.os.Parcelable;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.annotation.UiThread;
+import java.util.Objects;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.annotation.WrapForJNI;
 import org.mozilla.gecko.util.ThreadUtils;
 
 /**
  * This class represents a single <a
  * href="https://developer.mozilla.org/en-US/docs/Web/API/Notification">Web Notification</a>. These
  * can be received by connecting a {@link WebNotificationDelegate} to {@link GeckoRuntime} via
@@ -75,17 +76,17 @@ public class WebNotification implements 
   /**
    * RequireInteraction indicates whether a notification should remain active until the user clicks
    * or dismisses it, rather than closing automatically.
    *
    * @see <a
    *     href="https://developer.mozilla.org/en-US/docs/Web/API/Notification/requireInteraction">Web
    *     Notification - requireInteraction</a>
    */
-  public final @NonNull boolean requireInteraction;
+  public final boolean requireInteraction;
 
   /**
    * This is the URL of the page or Service Worker that generated the notification. Null if this
    * notification was not generated by a Web Page (e.g. from an Extension).
    *
    * <p>TODO: make NonNull once we have Bug 1589693
    */
   public final @Nullable String source;
@@ -116,30 +117,30 @@ public class WebNotification implements 
   /* package */ WebNotification(
       @Nullable final String title,
       @NonNull final String tag,
       @Nullable final String cookie,
       @Nullable final String text,
       @Nullable final String imageUrl,
       @Nullable final String textDirection,
       @Nullable final String lang,
-      @NonNull final boolean requireInteraction,
+      final boolean requireInteraction,
       @NonNull final String source,
       final boolean silent,
       final boolean privateBrowsing,
       @NonNull final int[] vibrate) {
     this.tag = tag;
     this.mCookie = cookie;
     this.title = title;
     this.text = text;
     this.imageUrl = imageUrl;
     this.textDirection = textDirection;
     this.lang = lang;
     this.requireInteraction = requireInteraction;
-    this.source = "".equals(source) ? null : source;
+    this.source = source.isEmpty() ? null : source;
     this.silent = silent;
     this.vibrate = vibrate;
     this.privateBrowsing = privateBrowsing;
   }
 
   /**
    * This should be called when the user taps or clicks a notification. Note that this does not
    * automatically dismiss the notification as far as Web Content is concerned. For that, see {@link
@@ -174,43 +175,43 @@ public class WebNotification implements 
 
   @Override
   public void writeToParcel(final Parcel dest, final int flags) {
     dest.writeInt(VERSION);
     dest.writeString(title);
     dest.writeString(tag);
     dest.writeString(mCookie);
     dest.writeString(text);
-    if (imageUrl.length() < IMAGE_URL_LENGTH_MAX) {
+    if (imageUrl != null && imageUrl.length() < IMAGE_URL_LENGTH_MAX) {
       dest.writeString(imageUrl);
     } else {
       dest.writeString("");
     }
     dest.writeString(textDirection);
     dest.writeString(lang);
     dest.writeInt(requireInteraction ? 1 : 0);
     dest.writeString(source);
     dest.writeInt(silent ? 1 : 0);
     dest.writeInt(privateBrowsing ? 1 : 0);
     dest.writeIntArray(vibrate);
   }
 
   private WebNotification(final Parcel in) {
     title = in.readString();
-    tag = in.readString();
+    tag = Objects.requireNonNull(in.readString());
     mCookie = in.readString();
     text = in.readString();
     imageUrl = in.readString();
     textDirection = in.readString();
     lang = in.readString();
     requireInteraction = in.readInt() == 1;
     source = in.readString();
     silent = in.readInt() == 1;
     privateBrowsing = in.readInt() == 1;
-    vibrate = in.createIntArray();
+    vibrate = Objects.requireNonNull(in.createIntArray());
   }
 
   public static final Creator<WebNotification> CREATOR =
       new Creator<>() {
         @Override
         public WebNotification createFromParcel(final Parcel in) {
           final int version = in.readInt();
           if (version != VERSION) {
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md
@@ -1700,9 +1700,9 @@ to allow adding gecko profiler markers.
 [65.19]: {{javadoc_uri}}/GeckoSession.NavigationDelegate.LoadRequest.html#isRedirect
 [65.20]: {{javadoc_uri}}/GeckoSession.html#LOAD_FLAGS_BYPASS_CLASSIFIER
 [65.21]: {{javadoc_uri}}/GeckoSession.ContentDelegate.ContextElement.html
 [65.22]: {{javadoc_uri}}/GeckoSession.ContentDelegate.html#onContextMenu(org.mozilla.geckoview.GeckoSession,int,int,org.mozilla.geckoview.GeckoSession.ContentDelegate.ContextElement)
 [65.23]: {{javadoc_uri}}/GeckoSession.FinderResult.html
 [65.24]: {{javadoc_uri}}/CrashReporter.html#sendCrashReport(android.content.Context,android.os.Bundle,java.lang.String)
 [65.25]: {{javadoc_uri}}/GeckoResult.html
 
-[api-version]: f538591c2dfeec76c798c4c1b77639ac544f8aff
+[api-version]: b51ff966a5b8afe9a5b130e2fc13f0aada807c90