Class FactoryUtility
- java.lang.Object
-
- com.mitac.api.libs.ApiBindBase
-
- com.mitac.api.libs.FactoryUtility
-
public class FactoryUtility extends ApiBindBase
This class provides factory side needed APIs which usually needs to be signed with platform key
-
-
Constructor Summary
Constructors Constructor Description FactoryUtility(android.content.Context context)
This constructor will not bind the service automatically.FactoryUtility(android.content.Context context, ServiceStatusCallback callback)
This constructor will bind the service automatically.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bindService()
bind serviceboolean
clearSignature(java.lang.String fileName)
Clear signature file from Reserved partition.boolean
doFactoryReset()
do FactoryResetjava.lang.String
getDeviceUUID()
Reads devic UUID informationjava.lang.String
getSerialNumber()
get serial numberboolean
isServiceReady()
Check if service is ready.java.lang.String
readMID()
Reads MID information from reserved partition.java.lang.String
readReservedTextFile(java.lang.String fileName)
Reads text file from reserved partition.boolean
removeReservedFile(java.lang.String fileName)
remove a file in /Reserved folderboolean
removeSerialNumber()
clear serial numberboolean
reservedFileExists(java.lang.String fileName)
Checks whether file exists or not.boolean
setSerialNumber(java.lang.String sn)
set serial numbervoid
unbindService()
unbind serviceboolean
writeMID(java.lang.String content)
Writes MID information to reserved partition.boolean
writeReservedTextFile(java.lang.String fileName, java.lang.String content, boolean appended, boolean newline)
Writes text file to reserved partition.boolean
writeSignature(java.lang.String fileName, byte[] signature)
Writes signature to Reserved partition.
-
-
-
Constructor Detail
-
FactoryUtility
public FactoryUtility(android.content.Context context)
This constructor will not bind the service automatically. Please callbindService()
at least once before using APIs.- Parameters:
context
- better to useContext.getApplicationContext()
to prevent memory leaks- Throws:
java.lang.IllegalArgumentException
- if context is null.
-
FactoryUtility
public FactoryUtility(android.content.Context context, ServiceStatusCallback callback)
This constructor will bind the service automatically.- Parameters:
context
- better to useContext.getApplicationContext()
to prevent memory leakscallback
- used to get the notification when service is ready.- Throws:
java.lang.IllegalArgumentException
- if context or callback is null.- See Also:
ServiceStatusCallback
-
-
Method Detail
-
bindService
public void bindService()
Description copied from class:ApiBindBase
bind service- Specified by:
bindService
in classApiBindBase
-
unbindService
public void unbindService()
Description copied from class:ApiBindBase
unbind service- Specified by:
unbindService
in classApiBindBase
-
writeSignature
public boolean writeSignature(java.lang.String fileName, byte[] signature)
Writes signature to Reserved partition.Application needs to request "com.mitac.permission.WRITE_RESERVED" permission in the manifest which platform key signed needed.
Callers without the permission will trigger a
SecurityException
- Parameters:
fileName
- signature file namesignature
- signature buffers- Returns:
- false if remote write fail
- Throws:
java.lang.SecurityException
- if fail to get the requested permission
-
clearSignature
public boolean clearSignature(java.lang.String fileName)
Clear signature file from Reserved partition.Application needs to request "com.mitac.permission.WRITE_RESERVED" permission in the manifest which platform key signed needed.
Callers without the permission will trigger a
SecurityException
- Parameters:
fileName
- the signature file that need to be removed.- Returns:
- false if fail to remove the file.
-
readReservedTextFile
public java.lang.String readReservedTextFile(java.lang.String fileName)
Reads text file from reserved partition.Application needs to request "com.mitac.permission.WRITE_RESERVED" permission in the manifest which platform key signed needed.
Callers without the permission will trigger a
SecurityException
- Parameters:
fileName
- the text file name that needs to be read from.- Returns:
- the content of the file; null if remote fail or nothing can be read.
-
writeReservedTextFile
public boolean writeReservedTextFile(java.lang.String fileName, java.lang.String content, boolean appended, boolean newline)
Writes text file to reserved partition.Application needs to request "com.mitac.permission.WRITE_RESERVED" permission in the manifest which platform key signed needed.
Callers without the permission will trigger a
SecurityException
- Parameters:
fileName
- the text file name that going to be written.content
- the content that needs to be written to.appended
- append content to the file if file exists.newline
- add new line for the content.- Returns:
- false if fail to write the file from remote.
-
reservedFileExists
public boolean reservedFileExists(java.lang.String fileName)
Checks whether file exists or not.Application needs to request "com.mitac.permission.WRITE_RESERVED" permission in the manifest which platform key signed needed.
Callers without the permission will trigger a
SecurityException
- Parameters:
fileName
- the file that need to be checked- Returns:
- true if file exists; false otherwise.
-
setSerialNumber
public boolean setSerialNumber(java.lang.String sn)
set serial number- Parameters:
sn
- serial number,- Returns:
true
if ready; false otherwise.
-
getSerialNumber
public java.lang.String getSerialNumber()
get serial number- Returns:
- serial number data.
-
removeSerialNumber
public boolean removeSerialNumber()
clear serial number- Returns:
true
if ready; false otherwise.
-
readMID
public java.lang.String readMID()
Reads MID information from reserved partition.Application needs to request "com.mitac.permission.WRITE_RESERVED" permission in the manifest which platform key signed needed.
Callers without the permission will trigger a
SecurityException
- Returns:
- the operation state of writing; null if remote fail or nothing can be read.
-
writeMID
public boolean writeMID(java.lang.String content)
Writes MID information to reserved partition.Application needs to request "com.mitac.permission.WRITE_RESERVED" permission in the manifest which platform key signed needed.
Callers without the permission will trigger a
SecurityException
- Parameters:
content
- the MID information that needs to be written to, which looks like 722W10000001, can not be blank or null, and length can not larger than 12.- Returns:
- false if fail to write MID from remote.
-
removeReservedFile
public boolean removeReservedFile(java.lang.String fileName)
remove a file in /Reserved folder- Parameters:
fileName
- the text file name that going to be removed. It should not include path- Returns:
true
if ready; false otherwise.
-
isServiceReady
public boolean isServiceReady()
Check if service is ready.- Returns:
true
if ready; false otherwise.
-
doFactoryReset
public boolean doFactoryReset()
do FactoryReset- Returns:
- false if there is an exception
-
getDeviceUUID
public java.lang.String getDeviceUUID()
Reads devic UUID information- Returns:
- null if remote fail or nothing can be read.
-
-