Skip to content

Commit

Permalink
Handle getSupportedFlashModes() is null
Browse files Browse the repository at this point in the history
  • Loading branch information
amosyuen committed Jan 15, 2018
1 parent ca72a21 commit 5844bd9
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ public FlashMode getFlashMode() {

@Override
public boolean supportsFlashMode(FlashMode flashMode) {
return mParameters != null && !Sets.intersection(
return mParameters != null
&& mParameters.getSupportedFlashModes() != null
&& !Sets.intersection(
ImmutableSet.copyOf(mParameters.getSupportedFlashModes()),
FLASH_MODE_MAP.get(flashMode))
.isEmpty();
Expand All @@ -380,14 +382,16 @@ public synchronized boolean setFlashMode(FlashMode flashMode) {
}

protected synchronized boolean setFlashModeParams(FlashMode flashMode, Camera.Parameters params) {
Set<String> supportedFlashModes = ImmutableSet.copyOf(params.getSupportedFlashModes());
for (String cameraFlashMode : FLASH_MODE_MAP.get(flashMode)) {
if (supportedFlashModes.contains(cameraFlashMode)) {
if (params.getFlashMode().equals(cameraFlashMode)) {
return false;
if (params.getSupportedFlashModes() != null) {
Set<String> supportedFlashModes = ImmutableSet.copyOf(params.getSupportedFlashModes());
for (String cameraFlashMode : FLASH_MODE_MAP.get(flashMode)) {
if (supportedFlashModes.contains(cameraFlashMode)) {
if (params.getFlashMode().equals(cameraFlashMode)) {
return false;
}
params.setFlashMode(cameraFlashMode);
return true;
}
params.setFlashMode(cameraFlashMode);
return true;
}
}
return false;
Expand Down Expand Up @@ -431,7 +435,8 @@ public void onAutoFocus(boolean success, Camera camera) {

@Override
public boolean canAutoFocus() {
return mParameters != null && !Sets.intersection(
return mParameters != null
&& !Sets.intersection(
ImmutableSet.copyOf(mParameters.getSupportedFocusModes()),
FOCUS_MODE_PREFERRED_ORDER)
.isEmpty();
Expand Down

0 comments on commit 5844bd9

Please sign in to comment.