I find these variable names very confusing.  The point of this function is to select a preview size from the list of available preview sizes.  But here you appear to be setting the previewWidth and previewHeight before even examining the list of sizes.  And previewAspectRatio is not actually the aspect ratio of the previews provided by the camera hardware. It is instead the aspect ratio of the visible portion of the preview.

Please rename all of these variables.