MemoryFile is documented as a wrapper around Android's Ashmem: https://developer.android.com/reference/android/os/MemoryFile.html
Ashmem, of course, is used to perform IPC. However in the current api of MemoryFile I don't see anything facilitating IPC.
Say in process A I want to share a Bitmap to other processes. And I want to achieve this with MemoryFile. In process A:
file = new MemoryFile("BitmapFile", 20 * 1024 * 1024);
final Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ipc);
final ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
final byte[] byteArray = stream.toByteArray();
file.writeBytes(byteArray, 0, 0, byteArray.length);
After this an Ashmem object should have been created and bitmap data is written into it. Now I want to share it with Process B. What I am expecting is that there is a method in MemoryFile returning a file descriptor. The I can pass this file descriptor to Process B via Binder. Then Process B can create a MemoryFile with this file descriptor and read data. However there is no api in MemoryFile facilitating this. How can I do IPC with MemoryFile then?