Class ShadowCompanionDeviceManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddAssociation(String deviceMacAddress) protected voidaddOnMessageReceivedListener(Executor executor, int messageType, BiConsumer<Integer, byte[]> listener) protected voidassociate(AssociationRequest request, CompanionDeviceManager.Callback callback, Handler handler) protected voidassociate(AssociationRequest request, Executor executor, CompanionDeviceManager.Callback callback) protected voidassociate(String packageName, MacAddress macAddress, byte[] certificate) protected voidattachSystemDataTransport(int associationId, InputStream inputStream, OutputStream outputStream) protected voidclearOnActionResultListener(String serviceName) protected voiddetachSystemDataTransport(int associationId) protected voiddisassociate(int associationId) protected voiddisassociate(String deviceMacAddress) protected voidenableSystemDataSyncForTypes(int associationId, int flags) protected List<AssociationInfo> protected List<AssociationInfo> getAttachedInputStream(int associationId) This method will return the last input stream passed toCompanionDeviceManager#attachSystemDataTransport(int, InputStream, OutputStream).getAttachedOutputStream(int associationId) This method will return the last output stream passed toCompanionDeviceManager#attachSystemDataTransport(int, InputStream, OutputStream).This method will return the lastCompanionDeviceManager.Callbackpassed toCompanionDeviceManager#associate(AssociationRequest, CompanionDeviceManager.Callback, Handler)orCompanionDeviceManager#associate(AssociationRequest, Executor, CompanionDeviceManager.Callback, Handler).This method will return the lastAssociationRequestpassed toCompanionDeviceManager#associate(AssociationRequest, CompanionDeviceManager.Callback, Handler)orCompanionDeviceManager#associate(AssociationRequest, Executor, CompanionDeviceManager.Callback, Handler).Returns the last device address passed toCompanionDeviceManager.startObservingDevicePresence(String).intReturns the associationId from the request passed toCompanionDeviceManager#startObservingDevicePresence(ObservingDevicePresenceRequest).intGet the last associationId removeBond was called with, regardless of success.If an association is set, this method will return the lastComponentNamepassed toCompanionDeviceManager#requestNotificationAccess(ComponentName).Returns the lastMacAddresspassed to systemApiassociate.com.google.common.collect.ImmutableSet<BiConsumer<Integer, byte[]>> getMessageReceivedListeners(int messageType) This method will return the registered listeners passed toCompanionDeviceManager#addOnMessageReceivedListener(Executor, int, BiConsumer)for the givenmessageType.protected List<AssociationInfo> intgetSystemDataSyncFlags(int associationId) Returns the system data sync flags passed toCompanionDeviceManager#enableSystemDataSyncForTypes(int, int)for the given association, or 0 if no such association exists.protected List<AssociationInfo> protected booleanhasNotificationAccess(ComponentName component) booleanisObservingDevicePresence(int associationId) Returns true if the given associationId is being observed for device presence.protected booleanisSystemDataTransportAttached(int associationId) voidmarkAssociationBondNotRemovable(int associationId) Specify that a given association should return False (i.e.voidmarkAssociationBondRemovable(int associationId) Specify that a given association should return True (i.e.protected voidnotifyActionResult(int associationId, Object result) protected booleanremoveBond(int associationId) Handle any attempt to removeBond through CDM.protected voidremoveOnMessageReceivedListener(int messageType, BiConsumer<Integer, byte[]> listener) protected voidrequestAction(Object request, String serviceName, int[] associationIds) protected voidrequestNotificationAccess(ComponentName component) protected voidsendMessage(int messageType, byte[] data, int[] associationIds) voidsetNotificationAccess(ComponentName component, boolean hasAccess) protected voidsetOnActionResultListener(int[] associationIds, String serviceName, Executor executor, BiConsumer<Integer, Object> listener) final voidsetSelfAssociationInfo(AssociationInfo selfAssociationInfo) Sets the current association info for the current device.protected voidprotected voidstartObservingDevicePresence(String deviceAddress)
-
Constructor Details
-
ShadowCompanionDeviceManager
public ShadowCompanionDeviceManager()
-
-
Method Details
-
getAssociations
-
addAssociation
-
addAssociation
-
disassociate
-
disassociate
-
hasNotificationAccess
-
setNotificationAccess
-
requestNotificationAccess
-
associate
@Implementation protected void associate(AssociationRequest request, CompanionDeviceManager.Callback callback, Handler handler) -
attachSystemDataTransport
@Implementation(minSdk=34) protected void attachSystemDataTransport(int associationId, InputStream inputStream, OutputStream outputStream) -
detachSystemDataTransport
-
associate
@Implementation(minSdk=33) protected void associate(AssociationRequest request, Executor executor, CompanionDeviceManager.Callback callback) -
associate
@Implementation(minSdk=33) protected void associate(String packageName, MacAddress macAddress, byte[] certificate) -
startObservingDevicePresence
-
startObservingDevicePresence
@Implementation(minSdk=36) protected void startObservingDevicePresence(ObservingDevicePresenceRequest request) -
getLastObservingDevicePresenceRequestAssociationId
public int getLastObservingDevicePresenceRequestAssociationId()Returns the associationId from the request passed toCompanionDeviceManager#startObservingDevicePresence(ObservingDevicePresenceRequest). -
enableSystemDataSyncForTypes
@Implementation(minSdk=34) protected void enableSystemDataSyncForTypes(int associationId, int flags) -
getLastAssociationRequest
This method will return the lastAssociationRequestpassed toCompanionDeviceManager#associate(AssociationRequest, CompanionDeviceManager.Callback, Handler)orCompanionDeviceManager#associate(AssociationRequest, Executor, CompanionDeviceManager.Callback, Handler).Note that the value returned is only changed when calling
associateand will be set if that method throws an exception. Moreover, this value will unchanged if disassociate is called. -
getAttachedInputStream
This method will return the last input stream passed toCompanionDeviceManager#attachSystemDataTransport(int, InputStream, OutputStream). for the given association, or null if no such association exists. -
getAttachedOutputStream
This method will return the last output stream passed toCompanionDeviceManager#attachSystemDataTransport(int, InputStream, OutputStream). for the given association, or null if no such association exists. -
getLastAssociationCallback
This method will return the lastCompanionDeviceManager.Callbackpassed toCompanionDeviceManager#associate(AssociationRequest, CompanionDeviceManager.Callback, Handler)orCompanionDeviceManager#associate(AssociationRequest, Executor, CompanionDeviceManager.Callback, Handler).Note that the value returned is only changed when calling
associateand will be set if that method throws an exception. Moreover, this value will unchanged if disassociate is called. -
getLastRequestedNotificationAccess
If an association is set, this method will return the lastComponentNamepassed toCompanionDeviceManager#requestNotificationAccess(ComponentName). -
getLastSystemApiAssociationMacAddress
Returns the lastMacAddresspassed to systemApiassociate.Note that the value returned is only changed when calling
associateand will be set if that method throws an exception. Moreover, this value will unchanged if disassociate is called. -
getLastObservingDevicePresenceDeviceAddress
Returns the last device address passed toCompanionDeviceManager.startObservingDevicePresence(String).Note that the value returned is only changed when calling
CompanionDeviceManager.startObservingDevicePresence(String)and will still be set in the event that this method throws an exception. Moreover, this value will unchanged if disassociate is called. -
getSystemDataSyncFlags
public int getSystemDataSyncFlags(int associationId) Returns the system data sync flags passed toCompanionDeviceManager#enableSystemDataSyncForTypes(int, int)for the given association, or 0 if no such association exists. -
getMyAssociations
-
getAllAssociations
-
getAssociationInfos
-
isObservingDevicePresence
public boolean isObservingDevicePresence(int associationId) Returns true if the given associationId is being observed for device presence.- Parameters:
associationId- the associationId to check- Returns:
- true if the given associationId is being observed for device presence, false otherwise
-
markAssociationBondRemovable
public void markAssociationBondRemovable(int associationId) Specify that a given association should return True (i.e. removeBond successful) when removeBond is called for it. -
markAssociationBondNotRemovable
public void markAssociationBondNotRemovable(int associationId) Specify that a given association should return False (i.e. removeBond failed) when removeBond is called for it. -
getLastRemoveBondAssociationId
public int getLastRemoveBondAssociationId()Get the last associationId removeBond was called with, regardless of success. -
removeBond
Handle any attempt to removeBond through CDM. Does not actually remove the underlying BT bond, but records the method call and association ID it was called with, and returns true if the user specified that this ID was removable, or false if not or there is no association for the device.- Parameters:
associationId- - id of association to attempt removal for.- Returns:
- true if value was set previously by user, false otherwise.
-
setSelfAssociationInfo
Sets the current association info for the current device.Any listener registered with
addOnMessageReceivedListener(Executor, int, BiConsumer)after this call is eligible for invocation viasendMessage(int, byte[], int[])calls referencing the same association ID inselfAssociationInfo. -
getMessageReceivedListeners
public com.google.common.collect.ImmutableSet<BiConsumer<Integer,byte[]>> getMessageReceivedListeners(int messageType) This method will return the registered listeners passed toCompanionDeviceManager#addOnMessageReceivedListener(Executor, int, BiConsumer)for the givenmessageType. -
addOnMessageReceivedListener
@Implementation(minSdk=35) protected void addOnMessageReceivedListener(Executor executor, int messageType, BiConsumer<Integer, byte[]> listener) -
removeOnMessageReceivedListener
@Implementation(minSdk=35) protected void removeOnMessageReceivedListener(int messageType, BiConsumer<Integer, byte[]> listener) -
sendMessage
@Implementation(minSdk=35) protected void sendMessage(int messageType, byte[] data, int[] associationIds) -
getTrustedAssociations
-
isSystemDataTransportAttached
-
requestAction
@Implementation(minSdk=37) protected void requestAction(Object request, String serviceName, int[] associationIds) -
setOnActionResultListener
@Implementation(minSdk=37) protected void setOnActionResultListener(int[] associationIds, String serviceName, Executor executor, BiConsumer<Integer, Object> listener) -
clearOnActionResultListener
-
notifyActionResult
-