I'm writing an Android app that reads photos from the device's storage and filters them by orientation.
When taking a photo with Android's default Camera app (Android 4.4 KitKat), the photo's orientation is not saved (the orientation is always 0 in the photo's details). Some other Camera apps do save the orientation.
Is this a bug/feature of the default Camera app?
Is there a way, when the orientation was not set in the Exif header by the Camera app, to know if the device was upside-down or not when a photo was taken?
I've just tried, and I see what you mean. Even in full resolution, my Nexus 4 (with KitKat) seems to use actual image rotation rather than EXIF orientation data.
I would say this is a feature, not a bug. The EXIF rotation data is typically used to say "I shot this photo as portrait, but the image data is landscape, because I'm a puny, low-memory mobile device, and that's how my sensor captures it, and this saves me having to use loads of memory and CPU rotating the image data."
(Although you can view the rotated image on the device, bear in mind that the image on the screen will be much lower resolution—the fairly average camera on the Nexus 4, for example, has about ten times the number of pixels as the Nexus 4's screen, so you only have to hold a tiny rotated copy of the image in memory to put it on the display. Making a rotated copy of the full-size image is significantly more expensive, and that's why a lot of phones use EXIF rotation data alongside the originally captured image in whatever native orientation the camera produces.)
To put it another way, the EXIF orientation value is used for corrections—you only need it if the image data is stored a different way from the orientation the camera was being held in for taking the picture. You can't rely on it for telling you how the camera was being held. And some devices will be clever enough to just store the image data in the right orientation in the first place (possibly through some kind of hardware feature that makes the rotation relatively cheap.)
The same photo app may even take different approaches for different resolutions, using EXIF data for high resolutions that would be costly to rotate, but rotating the image data itself (and clearing the EXIF orientation flag) for scaled images ("Hey, if I'm going to be scaling the data anyway, I might as well put it in the right orientation, too...")