Program: 21813
Project: 21813
Buggy source:
/** 
 * Set the display orientation. This affects the preview frames and the picture displayed after snapshot. This method is useful for portrait mode applications. This does not affect the order of byte array passed in  {@link PreviewCallback#onPreviewFrame}. This method is not allowed to be called during preview. If you want to make the camera image show in the same orientation as the display, you can use the following code.<p> <pre> public static void setCameraDisplayOrientation(Activity activity, int cameraId, android.hardware.Camera camera) { android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); android.hardware.Camera.getCameraInfo(cameraId, info); int rotation = activity.getWindowManager().getDefaultDisplay() .getRotation(); int degrees = 0; switch (rotation) { case Surface.ROTATION_0: degrees = 0; break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } int result = (info.orientation - degrees + 360) % 360; camera.setDisplayOrientation(result); } </pre>
 * @param degrees the angle that the picture will be rotated clockwise.Valid values are 0, 90, 180, and 270. The starting position is 0 (landscape).
 */
public native final void setDisplayOrientation(int degrees);

Fixed version (ground truth):
/** 
 * Set the clockwise rotation of preview display in degrees. This affects the preview frames and the picture displayed after snapshot. This method is useful for portrait mode applications. Note that preview display of front-facing cameras is flipped horizontally, that is, the image is reflected along the central vertical axis of the camera sensor. So the users can see themselves as looking into a mirror. This does not affect the order of byte array passed in   {@link PreviewCallback#onPreviewFrame}, JPEG pictures, or recorded videos. This method is not allowed to be called during preview. If you want to make the camera image show in the same orientation as the display, you can use the following code.<p> <pre> public static void setCameraDisplayOrientation(Activity activity, int cameraId, android.hardware.Camera camera) { android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); android.hardware.Camera.getCameraInfo(cameraId, info); int rotation = activity.getWindowManager().getDefaultDisplay() .getRotation(); int degrees = 0; switch (rotation) { case Surface.ROTATION_0: degrees = 0; break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } int result; if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { result = (info.orientation + degrees) % 360; result = (360 - result) % 360;  // compensate the mirror } else {  // back-facing result = (info.orientation - degrees + 360) % 360; } camera.setDisplayOrientation(result); } </pre>
 * @param degrees the angle that the picture will be rotated clockwise.Valid values are 0, 90, 180, and 270. The starting position is 0 (landscape).
 * @see #setPreviewDisplay(SurfaceHolder)
 */
public native final void setDisplayOrientation(int degrees);