-
public abstract class FileSystemManagerAccess file system APIs.
-
-
Field Summary
Fields Modifier and Type Field Description public final static intMODE_READ_ONLYpublic final static intMODE_WRITE_ONLYpublic final static intMODE_READ_WRITEpublic final static intMODE_CREATEpublic final static intMODE_TRUNCATEpublic final static intMODE_APPEND
-
Method Summary
Modifier and Type Method Description static synchronized BindergetService()Get the service that exports the file system of the current process over Binder IPC. static FileSystemManagergetLocal()Get the FileSystemManager to access the file system of the current local process. static FileSystemManagergetRemote(@NonNull() IBinder binder)Create a FileSystemManager to access the file system of a remote process. abstract ExtendedFilegetFile(@NonNull() String pathname)abstract ExtendedFilegetFile(@Nullable() String parent, @NonNull() String child)final ExtendedFilegetFile(@Nullable() File parent, @NonNull() String child)final ExtendedFilegetFile(@NonNull() URI uri)final FileChannelopenChannel(@NonNull() String pathname, int mode)Opens a file channel to access the file. abstract FileChannelopenChannel(@NonNull() File file, int mode)Opens a file channel to access the file. -
-
Method Detail
-
getService
@NonNull() static synchronized Binder getService()
Get the service that exports the file system of the current process over Binder IPC.
Sending the Binder obtained from this method to a client process enablesthe current process to perform file system operations on behalf of the client.This allows a client process to access files normally denied by its permissions.This method is usually called in a root process, and the Binder service returned willbe send over to a non-root client process.
You can pass this Binder object in multiple ways, such as returning it in the
{@code onBind()}method of root services, passing it around in a Bundle,or returning it in an AIDL interface method. The receiving end will get an IBinder,which the developer should then pass to getRemote for usage.
-
getLocal
@NonNull() static FileSystemManager getLocal()
Get the FileSystemManager to access the file system of the current local process.
-
getRemote
@NonNull() static FileSystemManager getRemote(@NonNull() IBinder binder)
Create a FileSystemManager to access the file system of a remote process.
Several APIs are not supported through a remote process:
Calling these APIs will throw UnsupportedOperationException.- Parameters:
binder- a remote proxy of the Binder obtained from getService
-
getFile
@NonNull() abstract ExtendedFile getFile(@NonNull() String pathname)
-
getFile
@NonNull() abstract ExtendedFile getFile(@Nullable() String parent, @NonNull() String child)
-
getFile
@NonNull() final ExtendedFile getFile(@NonNull() URI uri)
-
openChannel
@NonNull() final FileChannel openChannel(@NonNull() String pathname, int mode)
Opens a file channel to access the file.
- Parameters:
pathname- the file to be opened.mode- the desired access mode.
-
openChannel
@NonNull() abstract FileChannel openChannel(@NonNull() File file, int mode)
Opens a file channel to access the file.
- Parameters:
file- the file to be opened.mode- the desired access mode.
-
-
-
-