Since I have experienced problems and different behaviour reading EXIF information from different manufacturer I'd suggest that you get the orientation from the saved image URI, then you could save it to the EXIF interface.
public static void getImageOrientationFromUri(@NonNull ContentResolver contentResolver, @NonNull Uri uri) {
if (uri.getPath() == null)
throw new NullPointerException("URI Path should not be null");
float rotationInDegrees = 0;
Cursor cursor = contentResolver.query(uri, new String[]{MediaStore.Images.ImageColumns.ORIENTATION},
null,
null,
null);
if (cursor != null && cursor.moveToFirst()) {
int col = cursor.getColumnIndex(MediaStore.Images.ImageColumns.ORIENTATION);
if (col != -1)
rotationInDegrees = cursor.getInt(col);
cursor.close();
}
// here you can save to the EXIF interface getting the apropriate value from rotationInDegrees
//If you want to display the image create the bitmap using:
//Bitmap sourceBitmap = MediaStore.Images.Media.getBitmap(contentResolver, uri);
//Matrix matrix = new Matrix();
//matrix.preRotate(rotationInDegrees);
//you can change the signature of the method to return a `Bitmap` and return
//Bitmap.createBitmap(sourceBitmap, 0, 0, sourceBitmap.getWidth(), sourceBitmap.getHeight(), matrix, false);
}