Java Code Examples for android.util.Range#getUpper()
The following examples show how to use
android.util.Range#getUpper() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OneCameraCharacteristicsImpl.java From Camera2 with Apache License 2.0 | 5 votes |
@Override public boolean isExposureCompensationSupported() { // Turn off exposure compensation for Nexus 6 on L (API level 21) // because the bug in framework b/19219128. if (ApiHelper.IS_NEXUS_6 && ApiHelper.isLollipop()) { return false; } Range<Integer> compensationRange = mCameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_RANGE); return compensationRange.getLower() != 0 || compensationRange.getUpper() != 0; }
Example 2
Source File: OneCameraCharacteristicsImpl.java From Camera2 with Apache License 2.0 | 5 votes |
@Override public int getMaxExposureCompensation() { if (!isExposureCompensationSupported()) { return -1; } Range<Integer> compensationRange = mCameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_RANGE); return compensationRange.getUpper(); }
Example 3
Source File: LegacyMetadataMapper.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
private static int[] convertAeFpsRangeToLegacy(Range<Integer> fpsRange) { int[] legacyFps = new int[2]; legacyFps[Camera.Parameters.PREVIEW_FPS_MIN_INDEX] = fpsRange.getLower(); legacyFps[Camera.Parameters.PREVIEW_FPS_MAX_INDEX] = fpsRange.getUpper(); return legacyFps; }
Example 4
Source File: LegacyRequestMapper.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
private static int[] convertAeFpsRangeToLegacy(Range<Integer> fpsRange) { int[] legacyFps = new int[2]; legacyFps[Parameters.PREVIEW_FPS_MIN_INDEX] = fpsRange.getLower() * 1000; legacyFps[Parameters.PREVIEW_FPS_MAX_INDEX] = fpsRange.getUpper() * 1000; return legacyFps; }
Example 5
Source File: CameraConstrainedHighSpeedCaptureSessionImpl.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override public List<CaptureRequest> createHighSpeedRequestList(CaptureRequest request) throws CameraAccessException { if (request == null) { throw new IllegalArgumentException("Input capture request must not be null"); } Collection<Surface> outputSurfaces = request.getTargets(); Range<Integer> fpsRange = request.get(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE); StreamConfigurationMap config = mCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); SurfaceUtils.checkConstrainedHighSpeedSurfaces(outputSurfaces, fpsRange, config); // Request list size: to limit the preview to 30fps, need use maxFps/30; to maximize // the preview frame rate, should use maxBatch size for that high speed stream // configuration. We choose the former for now. int requestListSize = fpsRange.getUpper() / 30; List<CaptureRequest> requestList = new ArrayList<CaptureRequest>(); // Prepare the Request builders: need carry over the request controls. // First, create a request builder that will only include preview or recording target. CameraMetadataNative requestMetadata = new CameraMetadataNative(request.getNativeCopy()); // Note that after this step, the requestMetadata is mutated (swapped) and can not be used // for next request builder creation. CaptureRequest.Builder singleTargetRequestBuilder = new CaptureRequest.Builder( requestMetadata, /*reprocess*/false, CameraCaptureSession.SESSION_ID_NONE, request.getLogicalCameraId(), /*physicalCameraIdSet*/ null); // Carry over userTag, as native metadata doesn't have this field. singleTargetRequestBuilder.setTag(request.getTag()); // Overwrite the capture intent to make sure a good value is set. Iterator<Surface> iterator = outputSurfaces.iterator(); Surface firstSurface = iterator.next(); Surface secondSurface = null; if (outputSurfaces.size() == 1 && SurfaceUtils.isSurfaceForHwVideoEncoder(firstSurface)) { singleTargetRequestBuilder.set(CaptureRequest.CONTROL_CAPTURE_INTENT, CaptureRequest.CONTROL_CAPTURE_INTENT_PREVIEW); } else { // Video only, or preview + video singleTargetRequestBuilder.set(CaptureRequest.CONTROL_CAPTURE_INTENT, CaptureRequest.CONTROL_CAPTURE_INTENT_VIDEO_RECORD); } singleTargetRequestBuilder.setPartOfCHSRequestList(/*partOfCHSList*/true); // Second, Create a request builder that will include both preview and recording targets. CaptureRequest.Builder doubleTargetRequestBuilder = null; if (outputSurfaces.size() == 2) { // Have to create a new copy, the original one was mutated after a new // CaptureRequest.Builder creation. requestMetadata = new CameraMetadataNative(request.getNativeCopy()); doubleTargetRequestBuilder = new CaptureRequest.Builder( requestMetadata, /*reprocess*/false, CameraCaptureSession.SESSION_ID_NONE, request.getLogicalCameraId(), /*physicalCameraIdSet*/null); doubleTargetRequestBuilder.setTag(request.getTag()); doubleTargetRequestBuilder.set(CaptureRequest.CONTROL_CAPTURE_INTENT, CaptureRequest.CONTROL_CAPTURE_INTENT_VIDEO_RECORD); doubleTargetRequestBuilder.addTarget(firstSurface); secondSurface = iterator.next(); doubleTargetRequestBuilder.addTarget(secondSurface); doubleTargetRequestBuilder.setPartOfCHSRequestList(/*partOfCHSList*/true); // Make sure singleTargetRequestBuilder contains only recording surface for // preview + recording case. Surface recordingSurface = firstSurface; if (!SurfaceUtils.isSurfaceForHwVideoEncoder(recordingSurface)) { recordingSurface = secondSurface; } singleTargetRequestBuilder.addTarget(recordingSurface); } else { // Single output case: either recording or preview. singleTargetRequestBuilder.addTarget(firstSurface); } // Generate the final request list. for (int i = 0; i < requestListSize; i++) { if (i == 0 && doubleTargetRequestBuilder != null) { // First request should be recording + preview request requestList.add(doubleTargetRequestBuilder.build()); } else { requestList.add(singleTargetRequestBuilder.build()); } } return Collections.unmodifiableList(requestList); }
Example 6
Source File: AndroidCamera2Settings.java From Camera2 with Apache License 2.0 | 4 votes |
private boolean matchesTemplateDefault(Key<?> setting) { if (setting == CONTROL_AE_REGIONS) { return mMeteringAreas.size() == 0; } else if (setting == CONTROL_AF_REGIONS) { return mFocusAreas.size() == 0; } else if (setting == CONTROL_AE_TARGET_FPS_RANGE) { Range<Integer> defaultFpsRange = mTemplateSettings.get(CONTROL_AE_TARGET_FPS_RANGE); return (mPreviewFpsRangeMin == 0 && mPreviewFpsRangeMax == 0) || (defaultFpsRange != null && mPreviewFpsRangeMin == defaultFpsRange.getLower() && mPreviewFpsRangeMax == defaultFpsRange.getUpper()); } else if (setting == JPEG_QUALITY) { return Objects.equals(mJpegCompressQuality, mTemplateSettings.get(JPEG_QUALITY)); } else if (setting == CONTROL_AE_EXPOSURE_COMPENSATION) { return Objects.equals(mExposureCompensationIndex, mTemplateSettings.get(CONTROL_AE_EXPOSURE_COMPENSATION)); } else if (setting == CONTROL_VIDEO_STABILIZATION_MODE) { Integer videoStabilization = mTemplateSettings.get(CONTROL_VIDEO_STABILIZATION_MODE); return (videoStabilization != null && (mVideoStabilizationEnabled && videoStabilization == CONTROL_VIDEO_STABILIZATION_MODE_ON) || (!mVideoStabilizationEnabled && videoStabilization == CONTROL_VIDEO_STABILIZATION_MODE_OFF)); } else if (setting == CONTROL_AE_LOCK) { return Objects.equals(mAutoExposureLocked, mTemplateSettings.get(CONTROL_AE_LOCK)); } else if (setting == CONTROL_AWB_LOCK) { return Objects.equals(mAutoWhiteBalanceLocked, mTemplateSettings.get(CONTROL_AWB_LOCK)); } else if (setting == JPEG_THUMBNAIL_SIZE) { if (mExifThumbnailSize == null) { // It doesn't matter if this is true or false since setting this // to null in the request settings will use the default anyway. return false; } android.util.Size defaultThumbnailSize = mTemplateSettings.get(JPEG_THUMBNAIL_SIZE); return (mExifThumbnailSize.width() == 0 && mExifThumbnailSize.height() == 0) || (defaultThumbnailSize != null && mExifThumbnailSize.width() == defaultThumbnailSize.getWidth() && mExifThumbnailSize.height() == defaultThumbnailSize.getHeight()); } Log.w(TAG, "Settings implementation checked default of unhandled option key"); // Since this class isn't equipped to handle it, claim it matches the default to prevent // updateRequestSettingOrForceToDefault from going with the user-provided preference return true; }
Example 7
Source File: AndroidCamera2Capabilities.java From Camera2 with Apache License 2.0 | 4 votes |
AndroidCamera2Capabilities(CameraCharacteristics p) { super(new Stringifier()); StreamConfigurationMap s = p.get(SCALER_STREAM_CONFIGURATION_MAP); for (Range<Integer> fpsRange : p.get(CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES)) { mSupportedPreviewFpsRange.add(new int[] { fpsRange.getLower(), fpsRange.getUpper() }); } // TODO: We only support TextureView preview rendering mSupportedPreviewSizes.addAll(Size.buildListFromAndroidSizes(Arrays.asList( s.getOutputSizes(SurfaceTexture.class)))); for (int format : s.getOutputFormats()) { mSupportedPreviewFormats.add(format); } // TODO: We only support MediaRecorder video capture mSupportedVideoSizes.addAll(Size.buildListFromAndroidSizes(Arrays.asList( s.getOutputSizes(MediaRecorder.class)))); // TODO: We only support JPEG image capture mSupportedPhotoSizes.addAll(Size.buildListFromAndroidSizes(Arrays.asList( s.getOutputSizes(ImageFormat.JPEG)))); mSupportedPhotoFormats.addAll(mSupportedPreviewFormats); buildSceneModes(p); buildFlashModes(p); buildFocusModes(p); buildWhiteBalances(p); // TODO: Populate mSupportedFeatures // TODO: Populate mPreferredPreviewSizeForVideo Range<Integer> ecRange = p.get(CONTROL_AE_COMPENSATION_RANGE); mMinExposureCompensation = ecRange.getLower(); mMaxExposureCompensation = ecRange.getUpper(); Rational ecStep = p.get(CONTROL_AE_COMPENSATION_STEP); mExposureCompensationStep = (float) ecStep.getNumerator() / ecStep.getDenominator(); mMaxNumOfFacesSupported = p.get(STATISTICS_INFO_MAX_FACE_COUNT); mMaxNumOfMeteringArea = p.get(CONTROL_MAX_REGIONS_AE); mMaxZoomRatio = p.get(SCALER_AVAILABLE_MAX_DIGITAL_ZOOM); // TODO: Populate mHorizontalViewAngle // TODO: Populate mVerticalViewAngle // TODO: Populate mZoomRatioList // TODO: Populate mMaxZoomIndex if (supports(FocusMode.AUTO)) { mMaxNumOfFocusAreas = p.get(CONTROL_MAX_REGIONS_AF); if (mMaxNumOfFocusAreas > 0) { mSupportedFeatures.add(Feature.FOCUS_AREA); } } if (mMaxNumOfMeteringArea > 0) { mSupportedFeatures.add(Feature.METERING_AREA); } if (mMaxZoomRatio > CameraCapabilities.ZOOM_RATIO_UNZOOMED) { mSupportedFeatures.add(Feature.ZOOM); } // TODO: Detect other features }
Example 8
Source File: UiObject2Element.java From appium-uiautomator2-server with Apache License 2.0 | 4 votes |
@Nullable @Override public String getAttribute(String attr) throws UiObjectNotFoundException { final Attribute dstAttribute = Attribute.fromString(attr); if (dstAttribute == null) { throw generateNoAttributeException(attr); } final Object result; switch (dstAttribute) { case TEXT: result = getText(); break; case CONTENT_DESC: result = element.getContentDescription(); break; case CLASS: result = element.getClassName(); break; case RESOURCE_ID: result = element.getResourceName(); break; case CONTENT_SIZE: result = ElementHelpers.getContentSize(this); break; case ENABLED: result = element.isEnabled(); break; case CHECKABLE: result = element.isCheckable(); break; case CHECKED: result = element.isChecked(); break; case CLICKABLE: result = element.isClickable(); break; case FOCUSABLE: result = element.isFocusable(); break; case FOCUSED: result = element.isFocused(); break; case LONG_CLICKABLE: result = element.isLongClickable(); break; case SCROLLABLE: result = element.isScrollable(); break; case SELECTED: result = element.isSelected(); break; case DISPLAYED: result = AccessibilityNodeInfoHelpers.isVisible(AccessibilityNodeInfoGetter.fromUiObject(element)); break; case PASSWORD: result = AccessibilityNodeInfoHelpers.isPassword(AccessibilityNodeInfoGetter.fromUiObject(element)); break; case BOUNDS: result = element.getVisibleBounds().toShortString(); break; case PACKAGE: result = AccessibilityNodeInfoHelpers.getPackageName(AccessibilityNodeInfoGetter.fromUiObject(element)); break; case SELECTION_END: case SELECTION_START: Range<Integer> selectionRange = AccessibilityNodeInfoHelpers.getSelectionRange(AccessibilityNodeInfoGetter.fromUiObject(element)); result = selectionRange == null ? null : (dstAttribute == Attribute.SELECTION_END ? selectionRange.getUpper() : selectionRange.getLower()); break; default: throw generateNoAttributeException(attr); } if (result == null) { return null; } return (result instanceof String) ? (String) result : String.valueOf(result); }
Example 9
Source File: UiObjectElement.java From appium-uiautomator2-server with Apache License 2.0 | 4 votes |
@Nullable @Override public String getAttribute(String attr) throws UiObjectNotFoundException { final Attribute dstAttribute = Attribute.fromString(attr); if (dstAttribute == null) { throw generateNoAttributeException(attr); } final Object result; switch (dstAttribute) { case TEXT: result = getText(); break; case CONTENT_DESC: result = element.getContentDescription(); break; case CLASS: result = element.getClassName(); break; case RESOURCE_ID: result = getResourceId(); break; case CONTENT_SIZE: result = ElementHelpers.getContentSize(this); break; case ENABLED: result = element.isEnabled(); break; case CHECKABLE: result = element.isCheckable(); break; case CHECKED: result = element.isChecked(); break; case CLICKABLE: result = element.isClickable(); break; case FOCUSABLE: result = element.isFocusable(); break; case FOCUSED: result = element.isFocused(); break; case LONG_CLICKABLE: result = element.isLongClickable(); break; case SCROLLABLE: result = element.isScrollable(); break; case SELECTED: result = element.isSelected(); break; case DISPLAYED: result = element.exists() && AccessibilityNodeInfoHelpers.isVisible(AccessibilityNodeInfoGetter.fromUiObject(element)); break; case PASSWORD: result = AccessibilityNodeInfoHelpers.isPassword(AccessibilityNodeInfoGetter.fromUiObject(element)); break; case BOUNDS: result = element.getVisibleBounds().toShortString(); break; case PACKAGE: { result = AccessibilityNodeInfoHelpers.getPackageName(AccessibilityNodeInfoGetter.fromUiObject(element)); break; } case SELECTION_END: case SELECTION_START: Range<Integer> selectionRange = AccessibilityNodeInfoHelpers.getSelectionRange(AccessibilityNodeInfoGetter.fromUiObject(element)); result = selectionRange == null ? null : (dstAttribute == Attribute.SELECTION_END ? selectionRange.getUpper() : selectionRange.getLower()); break; default: throw generateNoAttributeException(attr); } if (result == null) { return null; } return (result instanceof String) ? (String) result : String.valueOf(result); }