com.intel.util
Class FlashStorage
java.lang.Objectcom.intel.util.FlashStorage
public class FlashStorage
- extends java.lang.Object
This class exposes flash storage access APIs for the applets.
In general, using flash for applets data storage is not recommended since the flash space available for applets is very limited. In addition, by default applets are not granted flash storage access permissions, unless implicitly specified in the permissions section of the applet installation package. The applet data is stored in flash as an encrypted BLOB with integrity protection, and each applet can only access its own flash data. Currently, only one flash data file per applet is supported. Due to flash wear-out considerations, an applet is allowed to use up to 100 write/erase flash data operations per machine boot. In addition, the applet allowed operations counter will be reset again 24 hours after the applet was installed and every 24 hours since the last write/erase operation.
Instead of using flash storage, applets should use offline data storage (for example, hard disk) for saving their non-volatile data.
Method Summary | |
---|---|
static void |
eraseFlashData(int fileName)
Removes the specified applet file from the flash. |
static int |
getFlashDataSize(int fileName)
Returns the size of the specified applet file on the flash. |
static int |
readFlashData(int fileName,
byte[] dest,
int destOff)
Reads the data from the specified applet file in flash and copies it into the given destination array. |
static void |
writeFlashData(int fileName,
byte[] src,
int srcOff,
int srcLen)
Writes the provided data into the specified applet file in the flash. |
Methods inherited from class java.lang.Object |
---|
equals, hashCode, toString |
Method Detail |
---|
getFlashDataSize
public static int getFlashDataSize(int fileName) throws UtilException
- Returns the size of the specified applet file on the flash.
- Parameters:
fileName
- the index of the file. Note that currently only index 0 is supported.- Returns:
- The size of the applet file in flash. For invalid/non existent files, the returned size will be 0.
- Throws:
IllegalParameterException
- if the file's index is invalid.UtilException
- declared for forwards compatibility.
readFlashData
public static int readFlashData(int fileName, byte[] dest, int destOff) throws UtilException
- Reads the data from the specified applet file in flash and copies it into the
given destination array.
- Parameters:
fileName
- the index of the file to read. Note that currently only index 0 is supported.dest
- the destination array to hold the file datadestOff
- the offset in dest array- Returns:
- The number of bytes copied into dest array.
- Throws:
FileNotFoundException
- if the file doesn't exist.IllegalParameterException
- if the file's index is invalid.UtilException
- declared for forwards compatibility.
writeFlashData
public static void writeFlashData(int fileName, byte[] src, int srcOff, int srcLen) throws UtilException
- Writes the provided data into the specified applet file in the flash.
- Parameters:
fileName
- the index of the file to write. Note that currently only index 0 is supported.src
- an array holding the data to be copied into the filesrcOff
- the offset in src arraysrcLen
- the length of the data to write- Throws:
AccessDeniedException
- if the size of the new data along with any other flash data already allocated for this applet exceeds the applet flash quota.FlashWearoutException
- if the flash wearout mechanism blocked the write/erase, or if the applet exhausted the number of operations allowed for the current period.IllegalParameterException
- if the file's index is invalid, or the source data length is 0.UtilException
- in case of internal error.
eraseFlashData
public static void eraseFlashData(int fileName) throws UtilException
- Removes the specified applet file from the flash.
- Parameters:
fileName
- the index of the file to remove. Note that currently only index 0 is supported.- Throws:
FlashWearoutException
- if the flash wearout mechanism blocked the write/erase, or if the applet exhausted the number of operations allowed for the current period.IllegalParameterException
- if the file's index is invalid.FileNotFoundException
- if the file doesn't exist.UtilException
- in case of internal error.