UWB: Add Reason to onRangingStop()

Bug: 184689372
Test: atest android.uwb
Signed-off-by: Harpreet Eli Sangha <eliptus@google.com>
Change-Id: Iff880ac6d8343df784fb8cb830ec830749351820
This commit is contained in:
Harpreet Eli Sangha
2021-04-07 11:26:40 +09:00
parent 1f0cc46671
commit dd0543f051
5 changed files with 18 additions and 9 deletions

View File

@@ -14218,7 +14218,7 @@ package android.uwb {
method public void onStartFailed(int, @NonNull android.os.PersistableBundle);
method public void onStarted(@NonNull android.os.PersistableBundle);
method public void onStopFailed(int, @NonNull android.os.PersistableBundle);
method public void onStopped();
method public void onStopped(int, @NonNull android.os.PersistableBundle);
field public static final int REASON_BAD_PARAMETERS = 3; // 0x3
field public static final int REASON_GENERIC_ERROR = 4; // 0x4
field public static final int REASON_LOCAL_REQUEST = 1; // 0x1

View File

@@ -92,9 +92,13 @@ interface IUwbRangingCallbacks {
* Called when the ranging session has been stopped
*
* @param sessionHandle the session the callback is being invoked for
* @param reason the reason the session was stopped
* @param parameters protocol specific parameters
*/
void onRangingStopped(in SessionHandle sessionHandle);
void onRangingStopped(in SessionHandle sessionHandle,
RangingChangeReason reason,
in PersistableBundle parameters);
/**
* Called when a ranging session fails to stop

View File

@@ -171,7 +171,8 @@ public class RangingManager extends android.uwb.IUwbRangingCallbacks.Stub {
}
@Override
public void onRangingStopped(SessionHandle sessionHandle) {
public void onRangingStopped(SessionHandle sessionHandle, @RangingChangeReason int reason,
PersistableBundle params) {
synchronized (this) {
if (!hasSession(sessionHandle)) {
Log.w(TAG, "onRangingStopped - received unexpected SessionHandle: "
@@ -180,7 +181,7 @@ public class RangingManager extends android.uwb.IUwbRangingCallbacks.Stub {
}
RangingSession session = mRangingSessionTable.get(sessionHandle);
session.onRangingStopped();
session.onRangingStopped(convertToReason(reason), params);
}
}

View File

@@ -191,8 +191,11 @@ public final class RangingSession implements AutoCloseable {
/**
* Invoked when a request to stop the session succeeds
*
* @param reason reason for the session stop
* @param parameters protocol specific parameters related to the stop reason
*/
void onStopped();
void onStopped(@Reason int reason, @NonNull PersistableBundle parameters);
/**
* Invoked when a request to stop the session fails
@@ -434,14 +437,15 @@ public final class RangingSession implements AutoCloseable {
/**
* @hide
*/
public void onRangingStopped() {
public void onRangingStopped(@Callback.Reason int reason,
@NonNull PersistableBundle params) {
if (mState == State.CLOSED) {
Log.w(TAG, "onRangingStopped invoked for a closed session");
return;
}
mState = State.IDLE;
executeCallback(() -> mCallback.onStopped());
executeCallback(() -> mCallback.onStopped(reason, params));
}
/**

View File

@@ -128,8 +128,8 @@ public class RangingManagerTest {
rangingManager.onRangingReconfigureFailed(handle, REASON, PARAMS);
verify(callback, times(1)).onReconfigureFailed(eq(REASON), eq(PARAMS));
rangingManager.onRangingStopped(handle);
verify(callback, times(1)).onStopped();
rangingManager.onRangingStopped(handle, REASON, PARAMS);
verify(callback, times(1)).onStopped(eq(REASON), eq(PARAMS));
rangingManager.onRangingStopFailed(handle, REASON, PARAMS);
verify(callback, times(1)).onStopFailed(eq(REASON), eq(PARAMS));