Merge "Fix SharedMemory.MemoryRegistration.size calculation when PAGE_SIZE is 0." into main
diff --git a/core/java/android/os/SharedMemory.java b/core/java/android/os/SharedMemory.java
index a15b3bb..46ae9d8 100644
--- a/core/java/android/os/SharedMemory.java
+++ b/core/java/android/os/SharedMemory.java
@@ -381,9 +381,11 @@
         private MemoryRegistration(int size) {
             // Round up to the nearest page size
             final int PAGE_SIZE = OsConstants._SC_PAGE_SIZE;
-            final int remainder = size % PAGE_SIZE;
-            if (remainder != 0) {
-                size += PAGE_SIZE - remainder;
+            if (PAGE_SIZE > 0) {
+                final int remainder = size % PAGE_SIZE;
+                if (remainder != 0) {
+                    size += PAGE_SIZE - remainder;
+                }
             }
             mSize = size;
             mReferenceCount = 1;