TiltToWake
public
class
TiltToWake
extends Object
| java.lang.Object | |
| ↳ | com.google.wear.modes.TiltToWake |
Tilt To Wake refers to the device's ability to wake up upon tilting.
This class provides an object to interact with the configured and active values of tilt to wake.
An instance of this class can be obtained by ModeManager.getTiltToWake() API.
Summary
Public methods | |
|---|---|
void
|
addIsActiveListener(Executor executor, Consumer<Boolean> listener)
Adds a listener to listen for the changes in the active value of tilt to wake. |
long
|
getOverriddenReasons()
This method allows checking for the reason behind the state of tilt to wake being overridden. |
boolean
|
isActive()
Gets whether tilt to wake is active or not. |
boolean
|
isConfigured()
Gets the configured value of tilt to wake. |
boolean
|
isOverridden()
Determine if the state of tilt to wake is overridden or not. |
void
|
removeIsActiveListener(Consumer<Boolean> listener)
This removes the previously added listener. |
void
|
setConfigured(boolean value)
Sets the configured value of tilt to wake which can be fetched via |
Inherited methods | |
|---|---|
Public methods
addIsActiveListener
public void addIsActiveListener (Executor executor,
Consumer<Boolean> listener)Adds a listener to listen for the changes in the active value of tilt to wake. The listener will be triggered asynchronously with an initial value on registration and then again when the value changes.
Due to potential race conditions between calls, use of this method should not be mixed
with isActive() method and the value the listener is triggered with should be
treated as the latest active value.
Note: This should be balanced with removeIsActiveListener(Consumer) to prevent
memory leaks.
Requires com.google.wear.services.Permissions.READ_GESTURES_CONFIG
| Parameters | |
|---|---|
executor |
Executor: The listener will be triggered on this Executor |
listener |
Consumer: The listener to add |
getOverriddenReasons
public long getOverriddenReasons ()
This method allows checking for the reason behind the state of tilt to wake being overridden.
See isOverridden() for details.
This method returns a flag (defined in ModeManager) comprising reason(s)
indicating the factors playing a role in overriding the state of tilt to wake. Each flag has
a permission associated with it, and this method only returns the flags the caller already
has the permission for. Please check the respective flag for its permission requirement.
Note: The returned value might also contain ModeManager.FLAG_OVERRIDDEN_BY_UNKNOWN_REASON indicating an unknown cause behind the state
of tilt to wake being overridden.
Requires com.google.wear.services.Permissions.READ_GESTURES_CONFIG
| Returns | |
|---|---|
long |
the combination of flags defined in ModeManager specifying the cause behind
the state of tilt to wake being overridden. Returned value of OL implies that the
state of tilt to wake is not overridden.
Value is either 0 or a combination of the following:
|
isActive
public boolean isActive ()
Gets whether tilt to wake is active or not.
This is the active value of tilt to wake in effect as reflected on the device. It is
determined by the current operating context of the system. Due to potential race conditions
due to change between calls, use of this method should not be mixed with addIsActiveListener(Executor,Consumer).
Requires com.google.wear.services.Permissions.READ_GESTURES_CONFIG
| Returns | |
|---|---|
boolean |
true if tilt to wake is active, else false |
isConfigured
public boolean isConfigured ()
Gets the configured value of tilt to wake.
This reflects the default configured value of tilt to wake and is set via setConfigured(boolean).
Note: If the state of tilt to wake is overridden (isOverridden()), this may
differ from the active value. See isOverridden() for details.
Requires com.google.wear.services.Permissions.READ_GESTURES_CONFIG
| Returns | |
|---|---|
boolean |
the configured value of tilt to wake |
isOverridden
public boolean isOverridden ()
Determine if the state of tilt to wake is overridden or not.
Tilt to wake has a configured value which is the default value for its state. The active value as reflected on the device, on the other hand, is determined by the current operating context of the system and depends on either of the following:
- Either the configured value of tilt to wake
- Or the configured values of all other modes
The state of tilt to wake can be defined as overridden if its configured value does not
play a role in determining its active value. This does not necessarily mean that the
configured value will be different from the active value but rather means that if the
configured value is updated, the active value will not be updated till the override is
lifted.
Requires com.google.wear.services.Permissions.READ_GESTURES_CONFIG
| Returns | |
|---|---|
boolean |
true if the state of tilt to wake is overridden, i.e. updating configured value does not update the active value |
removeIsActiveListener
public void removeIsActiveListener (Consumer<Boolean> listener)
This removes the previously added listener.
| Parameters | |
|---|---|
listener |
Consumer: The listener to remove |
setConfigured
public void setConfigured (boolean value)
Sets the configured value of tilt to wake which can be fetched via isConfigured().
In case an override is not in place, this will also update its active value as reflected on
the device which can be fetched via isActive(). However, in case the state of tilt
to wake is overridden, its active value as on the device will be updated to reflect this
configured value once the override is uplifted.
Requires com.google.wear.services.Permissions.WRITE_GESTURES_CONFIG
| Parameters | |
|---|---|
value |
boolean: True to enable tilt to wake |