Program: 38127
Project: 38127
Buggy source:
private void filterPreferences(int cameraId){
  ListPreference whiteBalance=mPreferenceGroup.findPreference(KEY_WHITE_BALANCE);
  ListPreference flashMode=mPreferenceGroup.findPreference(KEY_FLASH_MODE);
  ListPreference colorEffect=mPreferenceGroup.findPreference(KEY_COLOR_EFFECT);
  ListPreference sceneMode=mPreferenceGroup.findPreference(KEY_SCENE_MODE);
  ListPreference cameraIdPref=mPreferenceGroup.findPreference(KEY_CAMERA_ID);
  ListPreference pictureSize=mPreferenceGroup.findPreference(KEY_PICTURE_SIZE);
  ListPreference exposure=mPreferenceGroup.findPreference(KEY_EXPOSURE);
  ListPreference iso=mPreferenceGroup.findPreference(KEY_ISO);
  ListPreference clearsight=mPreferenceGroup.findPreference(KEY_CLEARSIGHT);
  ListPreference monoPreview=mPreferenceGroup.findPreference(KEY_MONO_PREVIEW);
  ListPreference monoOnly=mPreferenceGroup.findPreference(KEY_MONO_ONLY);
  ListPreference mpo=mPreferenceGroup.findPreference(KEY_MPO);
  ListPreference redeyeReduction=mPreferenceGroup.findPreference(KEY_REDEYE_REDUCTION);
  ListPreference videoQuality=mPreferenceGroup.findPreference(KEY_VIDEO_QUALITY);
  ListPreference videoEncoder=mPreferenceGroup.findPreference(KEY_VIDEO_ENCODER);
  ListPreference audioEncoder=mPreferenceGroup.findPreference(KEY_AUDIO_ENCODER);
  ListPreference noiseReduction=mPreferenceGroup.findPreference(KEY_NOISE_REDUCTION);
  ListPreference faceDetection=mPreferenceGroup.findPreference(KEY_FACE_DETECTION);
  ListPreference makeup=mPreferenceGroup.findPreference(KEY_MAKEUP);
  ListPreference trackingfocus=mPreferenceGroup.findPreference(KEY_TRACKINGFOCUS);
  ListPreference hfr=mPreferenceGroup.findPreference(KEY_VIDEO_HIGH_FRAME_RATE);
  if (whiteBalance != null) {
    if (filterUnsupportedOptions(whiteBalance,getSupportedWhiteBalanceModes(cameraId))) {
      mFilteredKeys.add(whiteBalance.getKey());
    }
  }
  if (flashMode != null) {
    if (!isFlashAvailable(mCameraId)) {
      removePreference(mPreferenceGroup,KEY_FLASH_MODE);
      mFilteredKeys.add(flashMode.getKey());
    }
  }
  if (colorEffect != null) {
    if (filterUnsupportedOptions(colorEffect,getSupportedColorEffects(cameraId))) {
      mFilteredKeys.add(colorEffect.getKey());
    }
  }
  if (sceneMode != null) {
    if (filterUnsupportedOptions(sceneMode,getSupportedSceneModes(cameraId))) {
      mFilteredKeys.add(sceneMode.getKey());
    }
  }
  if (cameraIdPref != null)   buildCameraId();
  if (pictureSize != null) {
    if (filterUnsupportedOptions(pictureSize,getSupportedPictureSize(cameraId))) {
      mFilteredKeys.add(pictureSize.getKey());
    }
 else {
      if (CameraSettings.filterSimilarPictureSize(mPreferenceGroup,pictureSize)) {
        mFilteredKeys.add(pictureSize.getKey());
      }
    }
  }
  if (exposure != null)   buildExposureCompensation(cameraId);
  if (iso != null) {
    if (filterUnsupportedOptions(iso,getSupportedIso(cameraId))) {
      mFilteredKeys.add(iso.getKey());
    }
  }
  if (videoQuality != null) {
    CameraSettings.filterUnsupportedOptions(mPreferenceGroup,videoQuality,getSupportedVideoSize(cameraId));
    mVideoQualityEntryValues=videoQuality.getEntryValues();
    mVideoQualityEntries=videoQuality.getEntries();
  }
  if (iso != null) {
    if (filterUnsupportedOptions(videoQuality,getSupportedVideoSize(cameraId))) {
      mFilteredKeys.add(redeyeReduction.getKey());
    }
  }
  if (!mIsMonoCameraPresent) {
    if (clearsight != null)     removePreference(mPreferenceGroup,KEY_CLEARSIGHT);
    if (monoPreview != null)     removePreference(mPreferenceGroup,KEY_MONO_PREVIEW);
    if (monoOnly != null)     removePreference(mPreferenceGroup,KEY_MONO_ONLY);
    if (mpo != null)     removePreference(mPreferenceGroup,KEY_MPO);
  }
  if (redeyeReduction != null) {
    if (filterUnsupportedOptions(redeyeReduction,getSupportedRedeyeReduction(cameraId))) {
      mFilteredKeys.add(redeyeReduction.getKey());
    }
  }
  if (videoEncoder != null) {
    if (filterUnsupportedOptions(videoEncoder,getSupportedVideoEncoders(videoEncoder.getEntryValues()))) {
      mFilteredKeys.add(videoEncoder.getKey());
    }
  }
  if (audioEncoder != null) {
    if (filterUnsupportedOptions(audioEncoder,getSupportedAudioEncoders(audioEncoder.getEntryValues()))) {
      mFilteredKeys.add(audioEncoder.getKey());
    }
  }
  if (noiseReduction != null) {
    if (filterUnsupportedOptions(noiseReduction,getSupportedNoiseReductionModes(cameraId))) {
      mFilteredKeys.add(noiseReduction.getKey());
    }
  }
  if (faceDetection != null) {
    if (!isFaceDetectionSupported(cameraId)) {
      removePreference(mPreferenceGroup,KEY_FACE_DETECTION);
    }
  }
  if (trackingfocus != null) {
    if (!TrackingFocusFrameListener.isSupportedStatic())     removePreference(mPreferenceGroup,KEY_TRACKINGFOCUS);
  }
  if (hfr != null) {
    buildHFR();
  }
  if (!mIsFrontCameraPresent || !isFacingFront(mCameraId)) {
    removePreference(mPreferenceGroup,KEY_SELFIE_FLASH);
    removePreference(mPreferenceGroup,KEY_SELFIEMIRROR);
  }
}

Fixed version (ground truth):
private void filterPreferences(int cameraId){
  ListPreference whiteBalance=mPreferenceGroup.findPreference(KEY_WHITE_BALANCE);
  ListPreference flashMode=mPreferenceGroup.findPreference(KEY_FLASH_MODE);
  ListPreference colorEffect=mPreferenceGroup.findPreference(KEY_COLOR_EFFECT);
  ListPreference sceneMode=mPreferenceGroup.findPreference(KEY_SCENE_MODE);
  ListPreference cameraIdPref=mPreferenceGroup.findPreference(KEY_CAMERA_ID);
  ListPreference pictureSize=mPreferenceGroup.findPreference(KEY_PICTURE_SIZE);
  ListPreference exposure=mPreferenceGroup.findPreference(KEY_EXPOSURE);
  ListPreference iso=mPreferenceGroup.findPreference(KEY_ISO);
  ListPreference clearsight=mPreferenceGroup.findPreference(KEY_CLEARSIGHT);
  ListPreference monoPreview=mPreferenceGroup.findPreference(KEY_MONO_PREVIEW);
  ListPreference monoOnly=mPreferenceGroup.findPreference(KEY_MONO_ONLY);
  ListPreference mpo=mPreferenceGroup.findPreference(KEY_MPO);
  ListPreference redeyeReduction=mPreferenceGroup.findPreference(KEY_REDEYE_REDUCTION);
  ListPreference videoQuality=mPreferenceGroup.findPreference(KEY_VIDEO_QUALITY);
  ListPreference videoEncoder=mPreferenceGroup.findPreference(KEY_VIDEO_ENCODER);
  ListPreference audioEncoder=mPreferenceGroup.findPreference(KEY_AUDIO_ENCODER);
  ListPreference noiseReduction=mPreferenceGroup.findPreference(KEY_NOISE_REDUCTION);
  ListPreference faceDetection=mPreferenceGroup.findPreference(KEY_FACE_DETECTION);
  ListPreference makeup=mPreferenceGroup.findPreference(KEY_MAKEUP);
  ListPreference trackingfocus=mPreferenceGroup.findPreference(KEY_TRACKINGFOCUS);
  ListPreference hfr=mPreferenceGroup.findPreference(KEY_VIDEO_HIGH_FRAME_RATE);
  if (whiteBalance != null) {
    if (filterUnsupportedOptions(whiteBalance,getSupportedWhiteBalanceModes(cameraId))) {
      mFilteredKeys.add(whiteBalance.getKey());
    }
  }
  if (flashMode != null) {
    if (!isFlashAvailable(mCameraId)) {
      removePreference(mPreferenceGroup,KEY_FLASH_MODE);
      mFilteredKeys.add(flashMode.getKey());
    }
  }
  if (colorEffect != null) {
    if (filterUnsupportedOptions(colorEffect,getSupportedColorEffects(cameraId))) {
      mFilteredKeys.add(colorEffect.getKey());
    }
  }
  if (sceneMode != null) {
    if (filterUnsupportedOptions(sceneMode,getSupportedSceneModes(cameraId))) {
      mFilteredKeys.add(sceneMode.getKey());
    }
  }
  if (cameraIdPref != null)   buildCameraId();
  if (pictureSize != null) {
    if (filterUnsupportedOptions(pictureSize,getSupportedPictureSize(cameraId))) {
      mFilteredKeys.add(pictureSize.getKey());
    }
 else {
      if (CameraSettings.filterSimilarPictureSize(mPreferenceGroup,pictureSize)) {
        mFilteredKeys.add(pictureSize.getKey());
      }
    }
  }
  if (exposure != null)   buildExposureCompensation(cameraId);
  if (iso != null) {
    if (filterUnsupportedOptions(iso,getSupportedIso(cameraId))) {
      mFilteredKeys.add(iso.getKey());
    }
  }
  if (videoQuality != null) {
    CameraSettings.filterUnsupportedOptions(mPreferenceGroup,videoQuality,getSupportedVideoSize(cameraId));
    mVideoQualityEntryValues=videoQuality.getEntryValues();
    mVideoQualityEntries=videoQuality.getEntries();
  }
  if (!mIsMonoCameraPresent) {
    if (clearsight != null)     removePreference(mPreferenceGroup,KEY_CLEARSIGHT);
    if (monoPreview != null)     removePreference(mPreferenceGroup,KEY_MONO_PREVIEW);
    if (monoOnly != null)     removePreference(mPreferenceGroup,KEY_MONO_ONLY);
    if (mpo != null)     removePreference(mPreferenceGroup,KEY_MPO);
  }
  if (redeyeReduction != null) {
    if (filterUnsupportedOptions(redeyeReduction,getSupportedRedeyeReduction(cameraId))) {
      mFilteredKeys.add(redeyeReduction.getKey());
    }
  }
  if (videoEncoder != null) {
    if (filterUnsupportedOptions(videoEncoder,getSupportedVideoEncoders(videoEncoder.getEntryValues()))) {
      mFilteredKeys.add(videoEncoder.getKey());
    }
  }
  if (audioEncoder != null) {
    if (filterUnsupportedOptions(audioEncoder,getSupportedAudioEncoders(audioEncoder.getEntryValues()))) {
      mFilteredKeys.add(audioEncoder.getKey());
    }
  }
  if (noiseReduction != null) {
    if (filterUnsupportedOptions(noiseReduction,getSupportedNoiseReductionModes(cameraId))) {
      mFilteredKeys.add(noiseReduction.getKey());
    }
  }
  if (faceDetection != null) {
    if (!isFaceDetectionSupported(cameraId)) {
      removePreference(mPreferenceGroup,KEY_FACE_DETECTION);
    }
  }
  if (trackingfocus != null) {
    if (!TrackingFocusFrameListener.isSupportedStatic())     removePreference(mPreferenceGroup,KEY_TRACKINGFOCUS);
  }
  if (hfr != null) {
    buildHFR();
  }
  if (!mIsFrontCameraPresent || !isFacingFront(mCameraId)) {
    removePreference(mPreferenceGroup,KEY_SELFIE_FLASH);
    removePreference(mPreferenceGroup,KEY_SELFIEMIRROR);
  }
}