From eb72c55665cc6c2164e0fc6eafdd275befbc5ccb Mon Sep 17 00:00:00 2001 From: Oliver Woodman Date: Mon, 23 May 2022 15:39:51 +0000 Subject: [PATCH] Fix lat/long rounding error Use of Math.round fixes incorrect rounding of negative lat/long values. Bug: 232327925 Test: atest CtsMediaTestCases Change-Id: I9e1fd3ec9d64461f0ec223ca091bb8aeb737c952 --- media/java/android/media/MediaMuxer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/media/java/android/media/MediaMuxer.java b/media/java/android/media/MediaMuxer.java index b8e7930e1dcac..c63a5d8d36a2a 100644 --- a/media/java/android/media/MediaMuxer.java +++ b/media/java/android/media/MediaMuxer.java @@ -430,8 +430,8 @@ final public class MediaMuxer { * @throws IllegalStateException If this method is called after {@link #start}. */ public void setLocation(float latitude, float longitude) { - int latitudex10000 = (int) (latitude * 10000 + 0.5); - int longitudex10000 = (int) (longitude * 10000 + 0.5); + int latitudex10000 = Math.round(latitude * 10000); + int longitudex10000 = Math.round(longitude * 10000); if (latitudex10000 > 900000 || latitudex10000 < -900000) { String msg = "Latitude: " + latitude + " out of range.";