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

Commit 1058fb63 authored by Richard Coles's avatar Richard Coles
Browse files

Override equals/hashCode/toString for WebViewProviderInfo.

WebViewProviderInfo is an immutable value class; override equals(),
hashCode(), and toString() to make it easier to test.

Bug: 319292658
Test: atest WebViewUpdateManagerTest
Flag: NONE overriding object methods is not tracked in API textfiles
Change-Id: I323fed3d72cc50b2b2aa781158508e8d94ae0ace
parent d659822b
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.util.Base64;

import java.util.Arrays;
import java.util.Objects;

/**
 * @hide
 */
@@ -80,6 +83,35 @@ public final class WebViewProviderInfo implements Parcelable {
        out.writeTypedArray(signatures, 0);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o instanceof WebViewProviderInfo that) {
            return this.packageName.equals(that.packageName)
                    && this.description.equals(that.description)
                    && this.availableByDefault == that.availableByDefault
                    && this.isFallback == that.isFallback
                    && Arrays.equals(this.signatures, that.signatures);
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return Objects.hash(packageName, description, availableByDefault,
                isFallback, Arrays.hashCode(signatures));
    }

    @Override
    public String toString() {
        return "WebViewProviderInfo; packageName=" + packageName
                + " description=\"" + description
                + "\" availableByDefault=" + availableByDefault
                + " isFallback=" + isFallback
                + " signatures=" + Arrays.toString(signatures);
    }

    // fields read from framework resource
    public final String packageName;
    public final String description;