Search in sources :

Example 6 with Rational

use of android.util.Rational in project android_frameworks_base by ResurrectionRemix.

the class StaticMetadata method getAeCompensationStepChecked.

/**
     * Get value of key android.control.aeCompensationStep and do the sanity check.
     *
     * @return default value if the value is null.
     */
public Rational getAeCompensationStepChecked() {
    Key<Rational> key = CameraCharacteristics.CONTROL_AE_COMPENSATION_STEP;
    Rational compensationStep = getValueFromKeyNonNull(key);
    if (compensationStep == null) {
        // Return default step.
        return CONTROL_AE_COMPENSATION_STEP_DEFAULT;
    }
    // Legacy devices don't have a minimum step requirement
    if (isHardwareLevelLimitedOrBetter()) {
        float compensationStepF = (float) compensationStep.getNumerator() / compensationStep.getDenominator();
        checkTrueForKey(key, " value must be no more than 1/2", compensationStepF <= 0.5f);
    }
    return compensationStep;
}
Also used : Rational(android.util.Rational)

Example 7 with Rational

use of android.util.Rational in project android_frameworks_base by ResurrectionRemix.

the class CameraMetadataTest method testReadWritePrimitive.

@SmallTest
public void testReadWritePrimitive() {
    // int32 (single)
    checkKeyGetAndSet("android.control.aeExposureCompensation", Integer.TYPE, 0xC0FFEE);
    // byte (single)
    checkKeyGetAndSet("android.flash.maxEnergy", Byte.TYPE, (byte) 6);
    // int64 (single)
    checkKeyGetAndSet("android.flash.firingTime", Long.TYPE, 0xABCD12345678FFFFL);
    // float (single)
    checkKeyGetAndSet("android.lens.aperture", Float.TYPE, Float.MAX_VALUE);
    // double (single) -- technically double x 3, but we fake it
    checkKeyGetAndSet("android.jpeg.gpsCoordinates", Double.TYPE, Double.MAX_VALUE);
    // rational (single)
    checkKeyGetAndSet("android.sensor.baseGainFactor", Rational.class, new Rational(1, 2));
    /**
         * Weirder cases, that don't map 1:1 with the native types
         */
    // bool (single) -- with TYPE_BYTE
    checkKeyGetAndSet("android.control.aeLock", Boolean.TYPE, true);
    // integer (single) -- with TYPE_BYTE
    checkKeyGetAndSet("android.control.aePrecaptureTrigger", Integer.TYPE, 6);
}
Also used : Rational(android.util.Rational) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 8 with Rational

use of android.util.Rational in project android_frameworks_base by ResurrectionRemix.

the class CameraMetadataTest method testReadWritePrimitiveArray.

@SmallTest
public void testReadWritePrimitiveArray() {
    // int32 (n)
    checkKeyGetAndSet("android.sensor.info.sensitivityRange", int[].class, new int[] { 0xC0FFEE, 0xDEADF00D });
    // byte (n)
    checkKeyGetAndSet("android.statistics.faceScores", byte[].class, new byte[] { 1, 2, 3, 4 });
    // int64 (n)
    checkKeyGetAndSet("android.scaler.availableProcessedMinDurations", long[].class, new long[] { 0xABCD12345678FFFFL, 0x1234ABCD5678FFFFL, 0xFFFF12345678ABCDL });
    // float (n)
    checkKeyGetAndSet("android.lens.info.availableApertures", float[].class, new float[] { Float.MAX_VALUE, Float.MIN_NORMAL, Float.MIN_VALUE });
    // double (n) -- in particular double x 3
    checkKeyGetAndSet("android.jpeg.gpsCoordinates", double[].class, new double[] { Double.MAX_VALUE, Double.MIN_NORMAL, Double.MIN_VALUE });
    // rational (n) -- in particular rational x 9
    checkKeyGetAndSet("android.sensor.calibrationTransform1", Rational[].class, new Rational[] { new Rational(1, 2), new Rational(3, 4), new Rational(5, 6), new Rational(7, 8), new Rational(9, 10), new Rational(10, 11), new Rational(12, 13), new Rational(14, 15), new Rational(15, 16) });
    /**
         * Weirder cases, that don't map 1:1 with the native types
         */
    // bool (n) -- with TYPE_BYTE
    checkKeyGetAndSet("android.control.aeLock", boolean[].class, new boolean[] { true, false, true });
    // integer (n) -- with TYPE_BYTE
    checkKeyGetAndSet("android.control.aeAvailableModes", int[].class, new int[] { 1, 2, 3, 4 });
}
Also used : Rational(android.util.Rational) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 9 with Rational

use of android.util.Rational in project android_frameworks_base by ResurrectionRemix.

the class RangeTest method testInRange.

@SmallTest
public void testInRange() {
    Range<Integer> hundredOneTwo = Range.create(100, 200);
    assertInRange(hundredOneTwo, 100);
    assertInRange(hundredOneTwo, 200);
    assertInRange(hundredOneTwo, 150);
    assertOutOfRange(hundredOneTwo, 99);
    assertOutOfRange(hundredOneTwo, 201);
    assertOutOfRange(hundredOneTwo, 100000);
    Range<Float> infinities = Range.create(Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY);
    assertInRange(infinities, Float.NEGATIVE_INFINITY);
    assertInRange(infinities, Float.POSITIVE_INFINITY);
    assertInRange(infinities, 0.0f);
    assertOutOfRange(infinities, Float.NaN);
    Range<Rational> negativeOneTenthPositiveOneTenth = new Range<Rational>(new Rational(-1, 10), new Rational(1, 10));
    assertInRange(negativeOneTenthPositiveOneTenth, new Rational(-1, 10));
    assertInRange(negativeOneTenthPositiveOneTenth, new Rational(1, 10));
    assertInRange(negativeOneTenthPositiveOneTenth, Rational.ZERO);
    assertOutOfRange(negativeOneTenthPositiveOneTenth, new Rational(-100, 1));
    assertOutOfRange(negativeOneTenthPositiveOneTenth, new Rational(100, 1));
}
Also used : Rational(android.util.Rational) Range(android.util.Range) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 10 with Rational

use of android.util.Rational in project android_frameworks_base by ResurrectionRemix.

the class ColorSpaceTransform method copyElements.

/**
     * Copy the {@link Rational} elements in row-major order from this matrix into the destination.
     *
     * @param destination
     *          an array big enough to hold at least {@code 9} elements after the
     *          {@code offset}
     * @param offset
     *          a non-negative offset into the array
     * @throws NullPointerException
     *          If {@code destination} was {@code null}
     * @throws ArrayIndexOutOfBoundsException
     *          If there's not enough room to write the elements at the specified destination and
     *          offset.
     */
public void copyElements(Rational[] destination, int offset) {
    checkArgumentNonnegative(offset, "offset must not be negative");
    checkNotNull(destination, "destination must not be null");
    if (destination.length - offset < COUNT) {
        throw new ArrayIndexOutOfBoundsException("destination too small to fit elements");
    }
    for (int i = 0, j = 0; i < COUNT; ++i, j += RATIONAL_SIZE) {
        int numerator = mElements[j + OFFSET_NUMERATOR];
        int denominator = mElements[j + OFFSET_DENOMINATOR];
        destination[i + offset] = new Rational(numerator, denominator);
    }
}
Also used : Rational(android.util.Rational)

Aggregations

Rational (android.util.Rational)96 SmallTest (android.test.suitebuilder.annotation.SmallTest)50 Range (android.util.Range)15 Size (android.util.Size)6 Point (android.graphics.Point)5 Pair (android.util.Pair)5 InvalidObjectException (java.io.InvalidObjectException)5 PictureInPictureParams (android.app.PictureInPictureParams)4 TargetApi (android.annotation.TargetApi)3 MediaWrapper (org.videolan.medialibrary.media.MediaWrapper)2 SuppressLint (android.annotation.SuppressLint)1 PendingIntent (android.app.PendingIntent)1 RemoteAction (android.app.RemoteAction)1 Intent (android.content.Intent)1 Rect (android.graphics.Rect)1 RequiresApi (androidx.annotation.RequiresApi)1 RequiresPermission (androidx.annotation.RequiresPermission)1 CameraSelector (androidx.camera.core.CameraSelector)1 StringBuilder (java.lang.StringBuilder)1 DecimalFormat (java.text.DecimalFormat)1