Thanks for the comments explaining this.  I'm not convinced at all that this is a robust algorithm.

Consider the hamachi, with its 3:2 screen size.  On that device, aspects.container will be 1.5, aspects.preview will be 1.3, and that means we'll end up aspectFill false, and the preview will be letterboxed and will have black bars.