masonamerica.platform.PersistentStorage |
Support for storage of key-value pairs which persists across device wipes / factory resets. This is used for various security related features. A reasonable implementation of this needs to store items on a partition which is unaffected by factory reset. The actual format of the storage is left up to the implementation. The implementation in this file is suitable for devices which have a /persist partition (recent QCOM devices fit this criteria).
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets an array of bytes from persistent storage.
| |||||||||||
Whether device supports persistent properties
| |||||||||||
Read an integer from persistent storage
| |||||||||||
Read a string from persistent storage
| |||||||||||
Remove all the data written by this application (and anything in its shared
uid).
| |||||||||||
Writes a byte array to persistent storage.
| |||||||||||
Write an integer to persistent storage, which persists through factory reset
| |||||||||||
Write a string to persistent storage, which persists thru factory reset
|
Gets an array of bytes from persistent storage.
Use readPersistentString(String)
and readPersistentInt(String)
for typed
helpers.
Returns | |
---|---|
byte[] |
previously stored byte array, null if not found |
Whether device supports persistent properties
Returns | |
---|---|
boolean |
boolean Supported devices must return always true |
Read an integer from persistent storage
Parameters | |
---|---|
key |
String :
String identifier for this item. Must not exceed 64 characters. |
Returns | |
---|---|
int |
the stored integer, zero if not found |
Read a string from persistent storage
Parameters | |
---|---|
key |
String :
String identifier for this item. Must not exceed 64 characters. |
Returns | |
---|---|
String |
the stored UTF-8 encoded string, null if not found |
Remove all the data written by this application (and anything in its shared uid).
Returns | |
---|---|
boolean |
true if the operation succeeded |
Writes a byte array to persistent storage.
Use writePersistentString(String, String)
and
writePersistentInt(String, int)
for typed helpers.
The storage of the data is implementation specific. In this implementation,
we hash the key with SHA-256 and use the hex string as the stored key.
Implementations should delete the key if a null buffer is passed.
Returns | |
---|---|
boolean |
true if the operation succeeded |
Write an integer to persistent storage, which persists through factory reset
Parameters | |
---|---|
key |
String :
String identifier for this item. Must not exceed 64 characters. |
value |
int :
The integer to store |
Returns | |
---|---|
boolean |
true on success |
Write a string to persistent storage, which persists thru factory reset
Parameters | |
---|---|
key |
String :
String identifier for this item. Must not exceed 64 characters. |
value |
String :
The UTF-8 encoded string to store of at least 1 character.
null deletes the key/value pair. |
Returns | |
---|---|
boolean |
true on success |