Prevent skipBytes from infinitely looping

Code copied from ag/13237582

Skipping bytes on a stream may return 0 forever (e.g. network
stream is disconnected), so need to break out of while loop if that
happens.

Bug: 175808980
Test: N/A (difficult to reproduce this case)
Change-Id: Ie462e471046a71f96c6e240f21c3bc04e528c7ef
(cherry picked from commit 3fc3824a8e4e467968eb263845e6b187e4829bb6)
diff --git a/exifinterface/exifinterface/src/main/java/androidx/exifinterface/media/ExifInterface.java b/exifinterface/exifinterface/src/main/java/androidx/exifinterface/media/ExifInterface.java
index 04a3912..47702d9 100644
--- a/exifinterface/exifinterface/src/main/java/androidx/exifinterface/media/ExifInterface.java
+++ b/exifinterface/exifinterface/src/main/java/androidx/exifinterface/media/ExifInterface.java
@@ -7873,13 +7873,18 @@
 
         @Override
         public int skipBytes(int byteCount) throws IOException {
-            int totalSkip = Math.min(byteCount, mLength - mPosition);
-            int skipped = 0;
-            while (skipped < totalSkip) {
-                skipped += mDataInputStream.skipBytes(totalSkip - skipped);
+            int totalBytesToSkip = Math.min(byteCount, mLength - mPosition);
+            int totalSkipped = 0;
+            while (totalSkipped < totalBytesToSkip) {
+                int skipped = mDataInputStream.skipBytes(totalBytesToSkip - totalSkipped);
+                if (skipped > 0) {
+                    totalSkipped += skipped;
+                } else {
+                    break;
+                }
             }
-            mPosition += skipped;
-            return skipped;
+            mPosition += totalSkipped;
+            return totalSkipped;
         }
 
         @Override