Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bd03c963 authored by Brian Stack's avatar Brian Stack
Browse files

Remove unnecessary UWB functions

The removed functions provided no added benefit to the current UWB
API. For instance, the supported channels for an individual protocol
may be different than what UwbManager#getSupportedChannelsNumbers
would return. Instead, the supported channels are provided through the
UwbManager#getSpecificationInfo API which allows a client to easily
see which channels (and other parameters) a particular protocol
supports.

Bug: 180533171
Test: atest UwbManagerTests CtsUwbTestCases
Change-Id: I81675429d73486f0b002e76acabaa4883990ab11
parent 7aa01124
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -14275,21 +14275,10 @@ package android.uwb {
  public final class UwbManager {
    method @RequiresPermission(android.Manifest.permission.UWB_PRIVILEGED) public long elapsedRealtimeResolutionNanos();
    method @RequiresPermission(android.Manifest.permission.UWB_PRIVILEGED) public int getAngleOfArrivalSupport();
    method @RequiresPermission(android.Manifest.permission.UWB_PRIVILEGED) public int getMaxRemoteDevicesPerInitiatorSession();
    method @RequiresPermission(android.Manifest.permission.UWB_PRIVILEGED) public int getMaxRemoteDevicesPerResponderSession();
    method @RequiresPermission(android.Manifest.permission.UWB_PRIVILEGED) public int getMaxSimultaneousSessions();
    method @NonNull @RequiresPermission(android.Manifest.permission.UWB_PRIVILEGED) public android.os.PersistableBundle getSpecificationInfo();
    method @NonNull @RequiresPermission(android.Manifest.permission.UWB_PRIVILEGED) public java.util.List<java.lang.Integer> getSupportedChannelNumbers();
    method @NonNull @RequiresPermission(android.Manifest.permission.UWB_PRIVILEGED) public java.util.Set<java.lang.Integer> getSupportedPreambleCodeIndices();
    method @RequiresPermission(android.Manifest.permission.UWB_PRIVILEGED) public boolean isRangingSupported();
    method @NonNull @RequiresPermission(android.Manifest.permission.UWB_PRIVILEGED) public AutoCloseable openRangingSession(@NonNull android.os.PersistableBundle, @NonNull java.util.concurrent.Executor, @NonNull android.uwb.RangingSession.Callback);
    method @RequiresPermission(android.Manifest.permission.UWB_PRIVILEGED) public void registerAdapterStateCallback(@NonNull java.util.concurrent.Executor, @NonNull android.uwb.UwbManager.AdapterStateCallback);
    method @RequiresPermission(android.Manifest.permission.UWB_PRIVILEGED) public void unregisterAdapterStateCallback(@NonNull android.uwb.UwbManager.AdapterStateCallback);
    field public static final int ANGLE_OF_ARRIVAL_SUPPORT_TYPE_2D = 2; // 0x2
    field public static final int ANGLE_OF_ARRIVAL_SUPPORT_TYPE_3D_HEMISPHERICAL = 3; // 0x3
    field public static final int ANGLE_OF_ARRIVAL_SUPPORT_TYPE_3D_SPHERICAL = 4; // 0x4
    field public static final int ANGLE_OF_ARRIVAL_SUPPORT_TYPE_NONE = 1; // 0x1
  }
  public static interface UwbManager.AdapterStateCallback {
+0 −44
Original line number Diff line number Diff line
/*
 * Copyright 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.uwb;

/**
 * @hide
 */
@Backing(type="int")
enum AngleOfArrivalSupport {
  /**
   * The device does not support angle of arrival
   */
  NONE,

  /**
   * The device supports planar angle of arrival
   */
  TWO_DIMENSIONAL,

  /**
   * The device does supports three dimensional angle of arrival with hemispherical azimuth angles
   */
  THREE_DIMENSIONAL_HEMISPHERICAL,

  /**
   * The device does supports three dimensional angle of arrival with full azimuth angles
   */
  THREE_DIMENSIONAL_SPHERICAL,
}
+0 −59
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.uwb;

import android.os.PersistableBundle;
import android.uwb.AngleOfArrivalSupport;
import android.uwb.IUwbAdapterStateCallbacks;
import android.uwb.IUwbRangingCallbacks;
import android.uwb.SessionHandle;
@@ -46,43 +45,6 @@ interface IUwbAdapter {
   */
  void unregisterAdapterStateCallbacks(in IUwbAdapterStateCallbacks callbacks);

  /**
   * Returns true if ranging is supported, false otherwise
   */
  boolean isRangingSupported();

  /**
   * Get the angle of arrival supported by this device
   *
   * @return the angle of arrival type supported
   */
  AngleOfArrivalSupport getAngleOfArrivalSupport();

  /**
   * Generates a list of the supported 802.15.4z channels
   *
   * The list must be prioritized in the order of preferred channel usage.
   *
   * The list must only contain channels that are permitted to be used in the
   * device's current location.
   *
   * @return an array of support channels on the device for the current location.
   */
  int[] getSupportedChannels();

  /**
   * Generates a list of the supported 802.15.4z preamble codes
   *
   * The list must be prioritized in the order of preferred preamble usage.
   *
   * The list must only contain preambles that are permitted to be used in the
   * device's current location.
   *
   * @return an array of supported preambles on the device for the current
   *         location.
   */
  int[] getSupportedPreambleCodes();

  /**
   * Get the accuracy of the ranging timestamps
   *
@@ -90,27 +52,6 @@ interface IUwbAdapter {
   */
  long getTimestampResolutionNanos();

  /**
   * Get the supported number of simultaneous ranging sessions
   *
   * @return the supported number of simultaneous ranging sessions
   */
  int getMaxSimultaneousSessions();

  /**
   * Get the maximum number of remote devices per session when local device is initiator
   *
   * @return the maximum number of remote devices supported in a single session
   */
  int getMaxRemoteDevicesPerInitiatorSession();

  /**
   * Get the maximum number of remote devices per session when local device is responder
   *
   * @return the maximum number of remote devices supported in a single session
   */
  int getMaxRemoteDevicesPerResponderSession();

  /**
   * Provides the capabilities and features of the device
   *
+0 −175
Original line number Diff line number Diff line
@@ -32,10 +32,6 @@ import android.os.ServiceManager;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Executor;

/**
@@ -194,133 +190,6 @@ public final class UwbManager {
        }
    }

    /**
     * Check if ranging is supported, regardless of ranging method
     *
     * @return true if ranging is supported
     */
    @RequiresPermission(Manifest.permission.UWB_PRIVILEGED)
    public boolean isRangingSupported() {
        try {
            return mUwbAdapter.isRangingSupported();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * @hide
     */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(value = {
            ANGLE_OF_ARRIVAL_SUPPORT_TYPE_NONE,
            ANGLE_OF_ARRIVAL_SUPPORT_TYPE_2D,
            ANGLE_OF_ARRIVAL_SUPPORT_TYPE_3D_HEMISPHERICAL,
            ANGLE_OF_ARRIVAL_SUPPORT_TYPE_3D_SPHERICAL})
    public @interface AngleOfArrivalSupportType {}

    /**
     * Indicate absence of support for angle of arrival measurement
     */
    public static final int ANGLE_OF_ARRIVAL_SUPPORT_TYPE_NONE = 1;

    /**
     * Indicate support for planar angle of arrival measurement, due to antenna
     * limitation. Typically requires at least two antennas.
     */
    public static final int ANGLE_OF_ARRIVAL_SUPPORT_TYPE_2D = 2;

    /**
     * Indicate support for three dimensional angle of arrival measurement.
     * Typically requires at least three antennas. However, due to antenna
     * arrangement, a platform may only support hemi-spherical azimuth angles
     * ranging from -pi/2 to pi/2
     */
    public static final int ANGLE_OF_ARRIVAL_SUPPORT_TYPE_3D_HEMISPHERICAL = 3;

    /**
     * Indicate support for three dimensional angle of arrival measurement.
     * Typically requires at least three antennas. This mode supports full
     * azimuth angles ranging from -pi to pi.
     */
    public static final int ANGLE_OF_ARRIVAL_SUPPORT_TYPE_3D_SPHERICAL = 4;

    /**
     * Gets the {@link AngleOfArrivalSupportType} supported on this platform
     * <p>Possible return values are
     * {@link #ANGLE_OF_ARRIVAL_SUPPORT_TYPE_NONE},
     * {@link #ANGLE_OF_ARRIVAL_SUPPORT_TYPE_2D},
     * {@link #ANGLE_OF_ARRIVAL_SUPPORT_TYPE_3D_HEMISPHERICAL},
     * {@link #ANGLE_OF_ARRIVAL_SUPPORT_TYPE_3D_SPHERICAL}.
     *
     * @return angle of arrival type supported
     */
    @AngleOfArrivalSupportType
    @RequiresPermission(Manifest.permission.UWB_PRIVILEGED)
    public int getAngleOfArrivalSupport() {
        try {
            switch (mUwbAdapter.getAngleOfArrivalSupport()) {
                case AngleOfArrivalSupport.TWO_DIMENSIONAL:
                    return ANGLE_OF_ARRIVAL_SUPPORT_TYPE_2D;

                case AngleOfArrivalSupport.THREE_DIMENSIONAL_HEMISPHERICAL:
                    return ANGLE_OF_ARRIVAL_SUPPORT_TYPE_3D_HEMISPHERICAL;

                case AngleOfArrivalSupport.THREE_DIMENSIONAL_SPHERICAL:
                    return ANGLE_OF_ARRIVAL_SUPPORT_TYPE_3D_SPHERICAL;

                case AngleOfArrivalSupport.NONE:
                default:
                    return ANGLE_OF_ARRIVAL_SUPPORT_TYPE_NONE;
            }
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Get a {@link List} of supported channel numbers based on the device's current location
     * <p>The returned values are ordered by the system's desired ordered of use, with the first
     * entry being the most preferred.
     *
     * <p>Channel numbers are defined based on the IEEE 802.15.4z standard for UWB.
     *
     * @return {@link List} of supported channel numbers ordered by preference
     */
    @NonNull
    @RequiresPermission(Manifest.permission.UWB_PRIVILEGED)
    public List<Integer> getSupportedChannelNumbers() {
        List<Integer> channels = new ArrayList<>();
        try {
            for (int channel : mUwbAdapter.getSupportedChannels()) {
                channels.add(channel);
            }
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        return channels;
    }

    /**
     * Get a {@link List} of supported preamble code indices
     * <p> Preamble code indices are defined based on the IEEE 802.15.4z standard for UWB.
     *
     * @return {@link List} of supported preamble code indices
     */
    @NonNull
    @RequiresPermission(Manifest.permission.UWB_PRIVILEGED)
    public Set<Integer> getSupportedPreambleCodeIndices() {
        Set<Integer> preambles = new HashSet<>();
        try {
            for (int preamble : mUwbAdapter.getSupportedPreambleCodes()) {
                preambles.add(preamble);
            }
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        return preambles;
    }

    /**
     * Get the timestamp resolution for events in nanoseconds
     * <p>This value defines the maximum error of all timestamps for events reported to
@@ -338,50 +207,6 @@ public final class UwbManager {
        }
    }

    /**
     * Get the number of simultaneous sessions allowed in the system
     *
     * @return the maximum allowed number of simultaneously open {@link RangingSession} instances.
     */
    @RequiresPermission(Manifest.permission.UWB_PRIVILEGED)
    public int getMaxSimultaneousSessions() {
        try {
            return mUwbAdapter.getMaxSimultaneousSessions();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Get the maximum number of remote devices in a {@link RangingSession} when the local device
     * is the initiator.
     *
     * @return the maximum number of remote devices per {@link RangingSession}
     */
    @RequiresPermission(Manifest.permission.UWB_PRIVILEGED)
    public int getMaxRemoteDevicesPerInitiatorSession() {
        try {
            return mUwbAdapter.getMaxRemoteDevicesPerInitiatorSession();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Get the maximum number of remote devices in a {@link RangingSession} when the local device
     * is a responder.
     *
     * @return the maximum number of remote devices per {@link RangingSession}
     */
    @RequiresPermission(Manifest.permission.UWB_PRIVILEGED)
    public int getMaxRemoteDevicesPerResponderSession() {
        try {
            return mUwbAdapter.getMaxRemoteDevicesPerResponderSession();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Open a {@link RangingSession} with the given parameters
     * <p>The {@link RangingSession.Callback#onOpened(RangingSession)} function is called with a