Class ShadowUwbManager

java.lang.Object
org.robolectric.shadows.ShadowUwbManager

@Implements(value=android.uwb.UwbManager.class, minSdk=31, isInAndroidSdk=false) public class ShadowUwbManager extends Object
Adds Robolectric support for UWB ranging.
  • Constructor Details

    • ShadowUwbManager

      public ShadowUwbManager()
  • Method Details

    • registerAdapterStateCallback

      @Implementation protected void registerAdapterStateCallback(Executor executor, android.uwb.UwbManager.AdapterStateCallback callback)
    • simulateAdapterStateChange

      public void simulateAdapterStateChange(int state, int reason)
      Simulates adapter state change by invoking a callback registered by registerAdapterStateCallback(Executor executor, AdapterStateCallback callback).
      Parameters:
      state - A state that should be passed to the callback.
      reason - A reason that should be passed to the callback.
      Throws:
      IllegalArgumentException - if the callback is missing.
    • getSpecificationInfo

      @Implementation protected PersistableBundle getSpecificationInfo()
      Simply returns the bundle provided by ShadowUwbManager#setSpecificationInfo(), allowing the tester to dictate available features.
    • openRangingSession

      @Implementation protected CancellationSignal openRangingSession(PersistableBundle params, Executor executor, android.uwb.RangingSession.Callback callback)
      Instantiates a ShadowRangingSession with the adapter provided by ShadowUwbManager#setUwbAdapter(), allowing the tester dictate the results of ranging attempts.
      Throws:
      IllegalArgumentException - if UWB is disabled.
    • setUwbAdapter

      public void setUwbAdapter(ShadowRangingSession.Adapter adapter)
      Sets the UWB adapter to use for new ShadowRangingSessions.
    • setSpecificationInfo

      public void setSpecificationInfo(PersistableBundle specificationInfo)
      Sets the bundle to be returned by UwbManager.getSpecificationInfo().
    • openRangingSession

      @Implementation(minSdk=33) protected CancellationSignal openRangingSession(PersistableBundle params, Executor executor, android.uwb.RangingSession.Callback callback, String chipId)
      Instantiates a ShadowRangingSession with the multi-chip API call. chipId is unused in the shadow implementation, so this is equivalent to openRangingSession(PersistableBundle, Executor, RangingSession.Callback)
    • isUwbEnabled

      @Implementation(minSdk=33) protected boolean isUwbEnabled()
      Returns whether UWB is enabled or disabled.
    • setUwbEnabled

      @Implementation protected void setUwbEnabled(boolean enabled)
      Disables or enables UWB by the user.
      Parameters:
      enabled - value representing intent to disable or enable UWB.
    • getChipInfos

      @Implementation(minSdk=33) protected List<PersistableBundle> getChipInfos()
      Simply returns the List of bundles provided by setChipInfos(List) , allowing the tester to set multi-chip configuration.
    • setChipInfos

      public void setChipInfos(List<PersistableBundle> chipInfos)
      Sets the list of bundles to be returned by UwbManager.getChipInfos().