public final class LocalScanner extends LocalScannerBase
Scanner
. This class handles simple scanning of files, string and buffers.settingsLoader
Constructor and Description |
---|
LocalScanner(android.content.Context context)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
cancelScanner()
Cancels the scanner and the scan in progress.
|
void |
destroy()
Destroys the scanner.
|
void |
loadSettings(java.io.File settingsFile)
Loads the settings from a file.
|
void |
loadSettings(java.lang.String settings)
Loads the settings from a string.
|
java.util.List<Threat> |
scanBuffer(byte[] buffer,
boolean stopAtFirstThreat,
java.lang.String fileName)
Executes a buffer scan.
|
void |
scanBuffer(byte[] buffer,
ThreatHandler threatHandler,
java.lang.String fileName)
Executes a buffer scan with a custom
ThreatHandler . |
java.util.List<Threat> |
scanFile(java.io.File file,
boolean stopAtFirstThreat)
Executes a file scan.
|
void |
scanFile(java.io.File file,
ThreatHandler threatHandler)
Executes a file scan with a custom
ThreatHandler . |
java.util.List<Threat> |
scanString(java.lang.String string,
boolean stopAtFirstThreat)
Executes a string scan.
|
void |
scanString(java.lang.String string,
ThreatHandler threatHandler)
Executes a string scan with a custom
ThreatHandler . |
checkScanBufferExceptions, checkScanBufferExceptions, checkScanFileExceptions, checkScanFileExceptions, checkScanStringExceptions, checkScanStringExceptions, checkWriteStoragePermission, isLicenseLoaded, isSettingsLoaded, loadLicense, loadLicense
public LocalScanner(android.content.Context context) throws NoPermissionException
LocalScanner
, make sure android.permission.WRITE_EXTERNAL_STORAGE is granted.context
- The context.NoPermissionException
- If android.permission.WRITE_EXTERNAL_STORAGE is not granted.public java.util.List<Threat> scanFile(java.io.File file, boolean stopAtFirstThreat) throws InvalidLicenseException, LicenseExpiredException, LicenseException, SettingsException, NoPermissionException, java.io.IOException, UnsupportedMimeTypeException, java.lang.Exception
file
- The file to be scanned.stopAtFirstThreat
- If true, it will stop after the first threat is found. If false, it will scan the whole file.Threat
.InvalidLicenseException
- If the license is invalid.LicenseExpiredException
- If the license is expiredLicenseException
- If the license is not loaded.SettingsException
- If the settings are invalid or not loaded.NoPermissionException
- If android.permission.WRITE_EXTERNAL_STORAGE is not granted.java.io.IOException
- If there was an error reading the file.UnsupportedMimeTypeException
- If this type of file cannot be scanned.java.lang.Exception
- Generic exception.public void scanFile(java.io.File file, ThreatHandler threatHandler) throws InvalidLicenseException, LicenseExpiredException, LicenseException, SettingsException, NoPermissionException, java.io.IOException, UnsupportedMimeTypeException, java.lang.Exception
ThreatHandler
.file
- The file to be scanned.threatHandler
- The custom handler that returns and handles the threat.InvalidLicenseException
- If the license is invalid.LicenseExpiredException
- If the license is expired.LicenseException
- If the license is not loaded.SettingsException
- If the settings are invalid or not loaded.NoPermissionException
- If android.permission.WRITE_EXTERNAL_STORAGE is not granted.java.io.IOException
- If there was an error reading the file.UnsupportedMimeTypeException
- If this type of file cannot be scanned.java.lang.Exception
- Generic exception.public java.util.List<Threat> scanString(java.lang.String string, boolean stopAtFirstThreat) throws InvalidLicenseException, LicenseExpiredException, LicenseException, SettingsException, NoPermissionException, java.lang.Exception
string
- The string to be scanned.stopAtFirstThreat
- If true, it will stop after the first threat is found. If false, it will scan the whole string.Threat
.InvalidLicenseException
- If the license is invalid.LicenseExpiredException
- If the license is expired.LicenseException
- If the license is not loaded.SettingsException
- If the settings are invalid or not loaded.NoPermissionException
- If android.permission.WRITE_EXTERNAL_STORAGE is not granted.java.lang.Exception
- Generic exception.public void scanString(java.lang.String string, ThreatHandler threatHandler) throws InvalidLicenseException, LicenseExpiredException, LicenseException, SettingsException, NoPermissionException, java.lang.Exception
ThreatHandler
.string
- The string to be scanned.threatHandler
- The custom handler that returns and handles the threat.InvalidLicenseException
- If the license is invalid.LicenseExpiredException
- If the license is expired.LicenseException
- If the license is not loaded.SettingsException
- If the settings are invalid or not loaded.NoPermissionException
- If android.permission.WRITE_EXTERNAL_STORAGE is not granted.java.lang.Exception
- Generic exception.public java.util.List<Threat> scanBuffer(byte[] buffer, boolean stopAtFirstThreat, java.lang.String fileName) throws InvalidLicenseException, LicenseExpiredException, LicenseException, SettingsException, NoPermissionException, java.lang.Exception
buffer
- The buffer to be scanned.stopAtFirstThreat
- If true, it will stop after the first threat is found. If false, it will scan the whole buffer.fileName
- If you scan the buffer from a file, specify the file name.Threat
.InvalidLicenseException
- If the license is invalid.LicenseExpiredException
- If the license is expired.LicenseException
- If the license is not loaded.SettingsException
- If the settings are invalid or not loaded.NoPermissionException
- If android.permission.WRITE_EXTERNAL_STORAGE is not granted.java.lang.Exception
- Generic exception.public void scanBuffer(byte[] buffer, ThreatHandler threatHandler, java.lang.String fileName) throws InvalidLicenseException, LicenseExpiredException, LicenseException, SettingsException, NoPermissionException, java.lang.Exception
ThreatHandler
.buffer
- The buffer to be scanned.threatHandler
- The custom handler that returns and handles the threat.fileName
- If you scan the buffer from a file, specify the file name.InvalidLicenseException
- If the license is invalid.LicenseExpiredException
- If the license is expired.LicenseException
- If the license is not loaded.SettingsException
- If the settings are invalid or not loaded.NoPermissionException
- If android.permission.WRITE_EXTERNAL_STORAGE is not granted.java.lang.Exception
- Generic exception.public void loadSettings(java.io.File settingsFile) throws SettingsException, NoPermissionException, java.io.IOException, java.lang.Exception
loadSettings
in class LocalScannerBase
settingsFile
- The file containing the settings.SettingsException
- If there was an error loading the settings.NoPermissionException
- If android.permission.WRITE_EXTERNAL_STORAGE is not granted.java.io.IOException
- If there was an error reading the file.java.lang.Exception
- Generic exception.public void loadSettings(java.lang.String settings) throws SettingsException, NoPermissionException, java.lang.Exception
loadSettings
in class LocalScannerBase
settings
- The string containing the settings.SettingsException
- If there was an error loading the settings.NoPermissionException
- If android.permission.WRITE_EXTERNAL_STORAGE is not granted.java.lang.Exception
- Generic exception.public void cancelScanner()
LocalScanner
cannot be used again.public void destroy()