Class ShadowCompanionDeviceManager

java.lang.Object
org.robolectric.shadows.ShadowCompanionDeviceManager

@Implements(value=android.companion.CompanionDeviceManager.class, minSdk=26) public class ShadowCompanionDeviceManager extends Object
Shadow for CompanionDeviceManager.
  • Constructor Details

    • ShadowCompanionDeviceManager

      public ShadowCompanionDeviceManager()
  • Method Details

    • getAssociations

      @Implementation protected List<String> getAssociations()
    • addAssociation

      public void addAssociation(String deviceMacAddress)
    • addAssociation

      public void addAssociation(AssociationInfo info)
    • disassociate

      @Implementation protected void disassociate(String deviceMacAddress)
    • disassociate

      @Implementation(minSdk=33) protected void disassociate(int associationId)
    • hasNotificationAccess

      @Implementation protected boolean hasNotificationAccess(ComponentName component)
    • setNotificationAccess

      public void setNotificationAccess(ComponentName component, boolean hasAccess)
    • requestNotificationAccess

      @Implementation protected void requestNotificationAccess(ComponentName component)
    • 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

      @Implementation(minSdk=34) protected void detachSystemDataTransport(int associationId)
    • 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

      @Implementation(minSdk=33) protected void startObservingDevicePresence(String deviceAddress)
    • startObservingDevicePresence

      @Implementation(minSdk=36) protected void startObservingDevicePresence(ObservingDevicePresenceRequest request)
    • getLastObservingDevicePresenceRequestAssociationId

      public int getLastObservingDevicePresenceRequestAssociationId()
      Returns the associationId from the request passed to CompanionDeviceManager#startObservingDevicePresence(ObservingDevicePresenceRequest).
    • enableSystemDataSyncForTypes

      @Implementation(minSdk=34) protected void enableSystemDataSyncForTypes(int associationId, int flags)
    • getLastAssociationRequest

      public AssociationRequest getLastAssociationRequest()
      This method will return the last AssociationRequest passed to CompanionDeviceManager#associate(AssociationRequest, CompanionDeviceManager.Callback, Handler) or CompanionDeviceManager#associate(AssociationRequest, Executor, CompanionDeviceManager.Callback, Handler).

      Note that the value returned is only changed when calling associate and will be set if that method throws an exception. Moreover, this value will unchanged if disassociate is called.

    • getAttachedInputStream

      public InputStream getAttachedInputStream(int associationId)
      This method will return the last input stream passed to CompanionDeviceManager#attachSystemDataTransport(int, InputStream, OutputStream). for the given association, or null if no such association exists.
    • getAttachedOutputStream

      public OutputStream getAttachedOutputStream(int associationId)
      This method will return the last output stream passed to CompanionDeviceManager#attachSystemDataTransport(int, InputStream, OutputStream). for the given association, or null if no such association exists.
    • getLastAssociationCallback

      public CompanionDeviceManager.Callback getLastAssociationCallback()
      This method will return the last CompanionDeviceManager.Callback passed to CompanionDeviceManager#associate(AssociationRequest, CompanionDeviceManager.Callback, Handler) or CompanionDeviceManager#associate(AssociationRequest, Executor, CompanionDeviceManager.Callback, Handler).

      Note that the value returned is only changed when calling associate and will be set if that method throws an exception. Moreover, this value will unchanged if disassociate is called.

    • getLastRequestedNotificationAccess

      public ComponentName getLastRequestedNotificationAccess()
      If an association is set, this method will return the last ComponentName passed to CompanionDeviceManager#requestNotificationAccess(ComponentName).
    • getLastSystemApiAssociationMacAddress

      public MacAddress getLastSystemApiAssociationMacAddress()
      Returns the last MacAddress passed to systemApi associate.

      Note that the value returned is only changed when calling associate and will be set if that method throws an exception. Moreover, this value will unchanged if disassociate is called.

    • getLastObservingDevicePresenceDeviceAddress

      public String getLastObservingDevicePresenceDeviceAddress()
      Returns the last device address passed to CompanionDeviceManager.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 to CompanionDeviceManager#enableSystemDataSyncForTypes(int, int) for the given association, or 0 if no such association exists.
    • getMyAssociations

      @Implementation(minSdk=33) protected List<AssociationInfo> getMyAssociations()
    • getAllAssociations

      @Implementation(minSdk=33) protected List<AssociationInfo> getAllAssociations()
    • getAssociationInfos

      protected List<AssociationInfo> 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

      @Implementation(minSdk=36) protected boolean removeBond(int associationId)
      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

      public final void setSelfAssociationInfo(AssociationInfo selfAssociationInfo)
      Sets the current association info for the current device.

      Any listener registered with addOnMessageReceivedListener(Executor, int, BiConsumer) after this call is eligible for invocation via sendMessage(int, byte[], int[]) calls referencing the same association ID in selfAssociationInfo.

    • getMessageReceivedListeners

      public com.google.common.collect.ImmutableSet<BiConsumer<Integer,byte[]>> getMessageReceivedListeners(int messageType)
      This method will return the registered listeners passed to CompanionDeviceManager#addOnMessageReceivedListener(Executor, int, BiConsumer) for the given messageType.
    • 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

      @Implementation(minSdk=37) protected List<AssociationInfo> getTrustedAssociations()
    • isSystemDataTransportAttached

      @Implementation(minSdk=37) protected boolean isSystemDataTransportAttached(int associationId)
    • 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

      @Implementation(minSdk=37) protected void clearOnActionResultListener(String serviceName)
    • notifyActionResult

      @Implementation(minSdk=37) protected void notifyActionResult(int associationId, Object result)