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 newAssociation)
    • 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)
    • 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)
    • 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.

    • 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.

    • getMyAssociations

      @Implementation(minSdk=33) protected List<AssociationInfo> getMyAssociations()
    • 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.