Loading core/java/android/hardware/camera2/CameraMetadata.java +40 −5 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.hardware.camera2; import android.hardware.camera2.impl.CameraMetadataNative; import android.hardware.camera2.utils.TypeReference; import java.lang.reflect.Field; import java.lang.reflect.Modifier; Loading Loading @@ -126,11 +127,13 @@ public abstract class CameraMetadata { return keyList; } // TODO: make final or abstract public static class Key<T> { private boolean mHasTag; private int mTag; private final Class<T> mType; private final TypeReference<T> mTypeReference; private final String mName; /** Loading @@ -144,6 +147,22 @@ public abstract class CameraMetadata { } mName = name; mType = type; mTypeReference = TypeReference.createSpecializedTypeReference(type); } /** * @hide */ @SuppressWarnings("unchecked") public Key(String name, TypeReference<T> typeReference) { if (name == null) { throw new NullPointerException("Key needs a valid name"); } else if (typeReference == null) { throw new NullPointerException("TypeReference needs to be non-null"); } mName = name; mType = (Class<T>)typeReference.getRawType(); mTypeReference = typeReference; } public final String getName() { Loading @@ -152,11 +171,10 @@ public abstract class CameraMetadata { @Override public final int hashCode() { return mName.hashCode(); return mName.hashCode() ^ mTypeReference.hashCode(); } @Override @SuppressWarnings("unchecked") public final boolean equals(Object o) { if (this == o) { return true; Loading @@ -166,9 +184,8 @@ public abstract class CameraMetadata { return false; } Key lhs = (Key) o; return mName.equals(lhs.mName) && mType.equals(lhs.mType); Key<?> lhs = (Key<?>)o; return mName.equals(lhs.mName) && mTypeReference.equals(lhs.mTypeReference); } /** Loading @@ -192,11 +209,29 @@ public abstract class CameraMetadata { } /** * Get the raw class backing the type {@code T} for this key. * * <p>The distinction is only important if {@code T} is a generic, e.g. * {@code Range<Integer>} since the nested type will be erased.</p> * * @hide */ public final Class<T> getType() { // TODO: remove this; other places should use #getTypeReference() instead return mType; } /** * Get the type reference backing the type {@code T} for this key. * * <p>The distinction is only important if {@code T} is a generic, e.g. * {@code Range<Integer>} since the nested type will be retained.</p> * * @hide */ public final TypeReference<T> getTypeReference() { return mTypeReference; } } /*@O~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~ Loading core/java/android/hardware/camera2/ColorSpaceTransform.java +2 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,8 @@ package android.hardware.camera2; import static com.android.internal.util.Preconditions.*; import android.hardware.camera2.impl.HashCodeHelpers; import android.hardware.camera2.utils.HashCodeHelpers; import java.util.Arrays; Loading core/java/android/hardware/camera2/LensShadingMap.java +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ package android.hardware.camera2; import static com.android.internal.util.Preconditions.*; import static android.hardware.camera2.RggbChannelVector.*; import android.hardware.camera2.impl.HashCodeHelpers; import android.hardware.camera2.utils.HashCodeHelpers; import java.util.Arrays; Loading core/java/android/hardware/camera2/MeteringRectangle.java +2 −5 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import static com.android.internal.util.Preconditions.*; import android.graphics.Point; import android.graphics.Rect; import android.hardware.camera2.impl.HashCodeHelpers; import android.hardware.camera2.utils.HashCodeHelpers; /** * An immutable class to represent a rectangle {@code (x,y, width, height)} with an Loading Loading @@ -186,10 +186,7 @@ public final class MeteringRectangle { */ @Override public boolean equals(final Object other) { if (other instanceof MeteringRectangle) { return equals(other); } return false; return other instanceof MeteringRectangle && equals((MeteringRectangle)other); } /** Loading core/java/android/hardware/camera2/Rational.java +8 −9 Original line number Diff line number Diff line Loading @@ -91,14 +91,14 @@ public final class Rational { * <p>A reduced form of a Rational is calculated by dividing both the numerator and the * denominator by their greatest common divisor.</p> * * <pre> * <pre>{@code * (new Rational(1, 2)).equals(new Rational(1, 2)) == true // trivially true * (new Rational(2, 3)).equals(new Rational(1, 2)) == false // trivially false * (new Rational(1, 2)).equals(new Rational(2, 4)) == true // true after reduction * (new Rational(0, 0)).equals(new Rational(0, 0)) == true // NaN.equals(NaN) * (new Rational(1, 0)).equals(new Rational(5, 0)) == true // both are +infinity * (new Rational(1, 0)).equals(new Rational(-1, 0)) == false // +infinity != -infinity * </pre> * }</pre> * * @param obj a reference to another object * Loading Loading @@ -159,16 +159,15 @@ public final class Rational { return (float) mNumerator / (float) mDenominator; } /** * {@inheritDoc} */ @Override public int hashCode() { final long INT_MASK = 0xffffffffL; long asLong = INT_MASK & mNumerator; asLong <<= 32; asLong |= (INT_MASK & mDenominator); // Bias the hash code for the first (2^16) values for both numerator and denominator int numeratorFlipped = mNumerator << 16 | mNumerator >>> 16; return ((Long)asLong).hashCode(); return mDenominator ^ numeratorFlipped; } /** Loading Loading
core/java/android/hardware/camera2/CameraMetadata.java +40 −5 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.hardware.camera2; import android.hardware.camera2.impl.CameraMetadataNative; import android.hardware.camera2.utils.TypeReference; import java.lang.reflect.Field; import java.lang.reflect.Modifier; Loading Loading @@ -126,11 +127,13 @@ public abstract class CameraMetadata { return keyList; } // TODO: make final or abstract public static class Key<T> { private boolean mHasTag; private int mTag; private final Class<T> mType; private final TypeReference<T> mTypeReference; private final String mName; /** Loading @@ -144,6 +147,22 @@ public abstract class CameraMetadata { } mName = name; mType = type; mTypeReference = TypeReference.createSpecializedTypeReference(type); } /** * @hide */ @SuppressWarnings("unchecked") public Key(String name, TypeReference<T> typeReference) { if (name == null) { throw new NullPointerException("Key needs a valid name"); } else if (typeReference == null) { throw new NullPointerException("TypeReference needs to be non-null"); } mName = name; mType = (Class<T>)typeReference.getRawType(); mTypeReference = typeReference; } public final String getName() { Loading @@ -152,11 +171,10 @@ public abstract class CameraMetadata { @Override public final int hashCode() { return mName.hashCode(); return mName.hashCode() ^ mTypeReference.hashCode(); } @Override @SuppressWarnings("unchecked") public final boolean equals(Object o) { if (this == o) { return true; Loading @@ -166,9 +184,8 @@ public abstract class CameraMetadata { return false; } Key lhs = (Key) o; return mName.equals(lhs.mName) && mType.equals(lhs.mType); Key<?> lhs = (Key<?>)o; return mName.equals(lhs.mName) && mTypeReference.equals(lhs.mTypeReference); } /** Loading @@ -192,11 +209,29 @@ public abstract class CameraMetadata { } /** * Get the raw class backing the type {@code T} for this key. * * <p>The distinction is only important if {@code T} is a generic, e.g. * {@code Range<Integer>} since the nested type will be erased.</p> * * @hide */ public final Class<T> getType() { // TODO: remove this; other places should use #getTypeReference() instead return mType; } /** * Get the type reference backing the type {@code T} for this key. * * <p>The distinction is only important if {@code T} is a generic, e.g. * {@code Range<Integer>} since the nested type will be retained.</p> * * @hide */ public final TypeReference<T> getTypeReference() { return mTypeReference; } } /*@O~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~ Loading
core/java/android/hardware/camera2/ColorSpaceTransform.java +2 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,8 @@ package android.hardware.camera2; import static com.android.internal.util.Preconditions.*; import android.hardware.camera2.impl.HashCodeHelpers; import android.hardware.camera2.utils.HashCodeHelpers; import java.util.Arrays; Loading
core/java/android/hardware/camera2/LensShadingMap.java +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ package android.hardware.camera2; import static com.android.internal.util.Preconditions.*; import static android.hardware.camera2.RggbChannelVector.*; import android.hardware.camera2.impl.HashCodeHelpers; import android.hardware.camera2.utils.HashCodeHelpers; import java.util.Arrays; Loading
core/java/android/hardware/camera2/MeteringRectangle.java +2 −5 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import static com.android.internal.util.Preconditions.*; import android.graphics.Point; import android.graphics.Rect; import android.hardware.camera2.impl.HashCodeHelpers; import android.hardware.camera2.utils.HashCodeHelpers; /** * An immutable class to represent a rectangle {@code (x,y, width, height)} with an Loading Loading @@ -186,10 +186,7 @@ public final class MeteringRectangle { */ @Override public boolean equals(final Object other) { if (other instanceof MeteringRectangle) { return equals(other); } return false; return other instanceof MeteringRectangle && equals((MeteringRectangle)other); } /** Loading
core/java/android/hardware/camera2/Rational.java +8 −9 Original line number Diff line number Diff line Loading @@ -91,14 +91,14 @@ public final class Rational { * <p>A reduced form of a Rational is calculated by dividing both the numerator and the * denominator by their greatest common divisor.</p> * * <pre> * <pre>{@code * (new Rational(1, 2)).equals(new Rational(1, 2)) == true // trivially true * (new Rational(2, 3)).equals(new Rational(1, 2)) == false // trivially false * (new Rational(1, 2)).equals(new Rational(2, 4)) == true // true after reduction * (new Rational(0, 0)).equals(new Rational(0, 0)) == true // NaN.equals(NaN) * (new Rational(1, 0)).equals(new Rational(5, 0)) == true // both are +infinity * (new Rational(1, 0)).equals(new Rational(-1, 0)) == false // +infinity != -infinity * </pre> * }</pre> * * @param obj a reference to another object * Loading Loading @@ -159,16 +159,15 @@ public final class Rational { return (float) mNumerator / (float) mDenominator; } /** * {@inheritDoc} */ @Override public int hashCode() { final long INT_MASK = 0xffffffffL; long asLong = INT_MASK & mNumerator; asLong <<= 32; asLong |= (INT_MASK & mDenominator); // Bias the hash code for the first (2^16) values for both numerator and denominator int numeratorFlipped = mNumerator << 16 | mNumerator >>> 16; return ((Long)asLong).hashCode(); return mDenominator ^ numeratorFlipped; } /** Loading