Package com.mitac.api.libs
Class LED
- java.lang.Object
-
- com.mitac.api.libs.ApiBindBase
-
- com.mitac.api.libs.LED
-
public class LED extends ApiBindBase
This class provides LED related APIs.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
LED.LED_ID
check systemProperties("ro.boot.hw_version") ,if not '01',then only support 3 kinds color:@ID_RED ,@ID_GREEN, @ID_BLUEstatic interface
LED.LED_STATUS
LED status definition check systemProperties("ro.boot.hw_version") ,if not '01',then only support 3 kinds:@STATUS_OFF ,@STATUS_ON, @STATUS_BLINK
-
Constructor Summary
Constructors Constructor Description LED(android.content.Context context)
This constructor will not bind the service automatically.LED(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
controlLed(int ledId, int status, int onMs, int offMs)
Control LED on or offboolean
isServiceReady()
Check if service is ready.void
unbindService()
Unbind service
-
-
-
Constructor Detail
-
LED
public LED(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.
-
LED
public LED(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()
Bind service- Specified by:
bindService
in classApiBindBase
-
unbindService
public void unbindService()
Unbind service- Specified by:
unbindService
in classApiBindBase
-
isServiceReady
public boolean isServiceReady()
Check if service is ready.- Returns:
true
if ready; false otherwise.
-
controlLed
public boolean controlLed(int ledId, int status, int onMs, int offMs)
Control LED on or off- Parameters:
ledId
- , a value ofLED.LED_ID
e.gLED.LED_ID.ID_RED
: red led,LED.LED_ID.ID_RED
|LED.LED_ID.ID_GREEN
this is depended on your hardware, some LEDs may not be supported.status
- , a value ofLED.LED_STATUS
which you want to change to beonMs
- , the duration of LED onoffMs
- , the duration of LED off- Returns:
- success or failure
-
-