Xposed
Added in API level 60
public abstract class

BaseService

extends Object
java.lang.Object
   ↳ de.robv.android.xposed.services.BaseService

Class Overview

General definition of a file access service provided by the Xposed framework.

References to a concrete subclass should generally be retrieved from SELinuxHelper.

Summary

Constants
int F_OK Flag for checkFileAccess(String, int): File/directory exists.
int R_OK Flag for checkFileAccess(String, int): Read access.
int W_OK Flag for checkFileAccess(String, int): Write access.
int X_OK Flag for checkFileAccess(String, int): Executable access.
Public Methods
abstract boolean checkFileAccess(String filename, int mode)
Check whether a file is accessible.
boolean checkFileExists(String filename)
Check whether a file exists.
FileResult getFileInputStream(String filename, long previousSize, long previousTime)
Get a stream to the file content, but only if it has changed since the last time.
InputStream getFileInputStream(String filename)
Get a stream to the file content.
long getFileModificationTime(String filename)
Determine the size time of a file.
long getFileSize(String filename)
Determine the size time of a file.
boolean hasDirectFileAccess()
Checks whether the services accesses files directly (instead of using IPC).
abstract byte[] readFile(String filename)
Read a file into memory.
abstract FileResult readFile(String filename, long previousSize, long previousTime)
Read a file into memory, but only if it has changed since the last time.
abstract FileResult readFile(String filename, int offset, int length, long previousSize, long previousTime)
Read a file into memory, optionally only if it has changed since the last time.
abstract FileResult statFile(String filename)
Determine the size and modification time of a file.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int F_OK

Added in API level 60

Flag for checkFileAccess(String, int): File/directory exists.

Constant Value: 0 (0x00000000)

public static final int R_OK

Added in API level 60

Flag for checkFileAccess(String, int): Read access.

Constant Value: 4 (0x00000004)

public static final int W_OK

Added in API level 60

Flag for checkFileAccess(String, int): Write access.

Constant Value: 2 (0x00000002)

public static final int X_OK

Added in API level 60

Flag for checkFileAccess(String, int): Executable access.

Constant Value: 1 (0x00000001)

Public Methods

public abstract boolean checkFileAccess (String filename, int mode)

Added in API level 60

Check whether a file is accessible. SELinux might enforce stricter checks.

Parameters
filename The absolute path of the file to check.
mode The mode for POSIX's access() function.
Returns
  • The result of the access() function.

public boolean checkFileExists (String filename)

Added in API level 60

Check whether a file exists.

Parameters
filename The absolute path of the file to check.
Returns
  • The result of the access() function.

public FileResult getFileInputStream (String filename, long previousSize, long previousTime)

Added in API level 60

Get a stream to the file content, but only if it has changed since the last time. Depending on the service, it may or may not be read completely into memory.

Parameters
filename The absolute path of the file to read.
previousSize Optional: File size of last read.
previousTime Optional: File modification time of last read.
Returns
  • A FileResult object holding the result.

    The FileResult.stream field might be null if the file is unmodified (previousSize and previousTime are still valid).

Throws
IOException In case an error occurred while reading the file.

public InputStream getFileInputStream (String filename)

Added in API level 60

Get a stream to the file content. Depending on the service, it may or may not be read completely into memory.

Parameters
filename The absolute path of the file to read.
Returns
Throws
IOException In case an error occurred while reading the file.

public long getFileModificationTime (String filename)

Added in API level 60

Determine the size time of a file.

Parameters
filename The absolute path of the file to check.
Returns
  • The file modification time.
Throws
IOException In case an error occurred while retrieving the information.

public long getFileSize (String filename)

Added in API level 60

Determine the size time of a file.

Parameters
filename The absolute path of the file to check.
Returns
  • The file size.
Throws
IOException In case an error occurred while retrieving the information.

public boolean hasDirectFileAccess ()

Added in API level 60

Checks whether the services accesses files directly (instead of using IPC).

Returns
  • true in case direct access is possible.

public abstract byte[] readFile (String filename)

Added in API level 60

Read a file into memory.

Parameters
filename The absolute path of the file to read.
Returns
  • A byte array with the file content.
Throws
IOException In case an error occurred while reading the file.

public abstract FileResult readFile (String filename, long previousSize, long previousTime)

Added in API level 60

Read a file into memory, but only if it has changed since the last time.

Parameters
filename The absolute path of the file to read.
previousSize File size of last read.
previousTime File modification time of last read.
Returns
  • A FileResult object holding the result.

    The FileResult.content field might be null if the file is unmodified (previousSize and previousTime are still valid).

Throws
IOException In case an error occurred while reading the file.

public abstract FileResult readFile (String filename, int offset, int length, long previousSize, long previousTime)

Added in API level 60

Read a file into memory, optionally only if it has changed since the last time.

Parameters
filename The absolute path of the file to read.
offset Number of bytes to skip at the beginning of the file.
length Number of bytes to read (0 means read to end of file).
previousSize Optional: File size of last read.
previousTime Optional: File modification time of last read.
Returns
  • A FileResult object holding the result.

    The FileResult.content field might be null if the file is unmodified (previousSize and previousTime are still valid).

Throws
IOException In case an error occurred while reading the file.

public abstract FileResult statFile (String filename)

Added in API level 60

Determine the size and modification time of a file.

Parameters
filename The absolute path of the file to check.
Returns
Throws
IOException In case an error occurred while retrieving the information.