Mobile devices are oriented as either portrait (tall) or landscape (wide).

Yellowstone

The yellowstone is a landscape-left default device (normal for Android tablets). The configuration XML file on the device specifies the camera intrinsics in landscape format (i.e. width 1280 height 720) and an orientation matrix (which is the identity).

Phab2Pro

The Phab2Pro is a portrait-default device (normal for Android phones). The config file specifies the intrinsics in landscape format (i.e. width 1920 height 1080) with no orientation matrix. There's also a load of extrinsics params in the config file which are rotated matrices - these don't exist in the yellowstone calibration.xml file.

If you take a picture in portrait mode using the camera app on Phab2Pro, you get a portrait picture (as you'd expect) and you get a landscape picture in landscape orientation (as you'd expect).

Application Code

The Unity code (and I presume the Java code/C code, as this isn't unity specific) is basically saying "get the intrinsics, then look at the current screen orientation, and if the screen is portrait but the intrinsics are landscape, then flip the width and height". A correct way to do this would be to specify the intrinsics based on the default device orientation and then rotate them based on the device rotation.