From 248970aad7a72eea2d65d824fa50ea4f0c6b1677 Mon Sep 17 00:00:00 2001 From: Arc Wang Date: Fri, 18 Jun 2021 10:07:50 +0800 Subject: [PATCH] Fix negative size when size is greater than 2,147,483,647 Java integer max is 2,147,483,647, it's about 2GB. Use getLong to get size from provider instead of getInt. Bug: 190721008 Test: manual visual Copy video files more than 2,147,483,647 bytes and observe Videos size information. Change-Id: Ic804db43554fdd580627faebecfe30d9ad2a9120 --- .../settings/deviceinfo/storage/StorageAsyncLoader.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java b/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java index 0a67ef29a27..611ee24baaa 100644 --- a/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java +++ b/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java @@ -122,7 +122,7 @@ public class StorageAsyncLoader UserHandle.of(userId)); } catch (NameNotFoundException e) { Log.e(TAG, "Not able to get Context for user ID " + userId); - return 0; + return 0L; } try (Cursor cursor = perUserContext.getContentResolver().query( @@ -131,9 +131,9 @@ public class StorageAsyncLoader queryArgs, null /* cancellationSignal */)) { if (cursor == null) { - return 0; + return 0L; } - return cursor.moveToFirst() ? cursor.getInt(0) : 0; + return cursor.moveToFirst() ? cursor.getLong(0) : 0L; } }