Merge "UWB: Add Reason to onRangingStop()"
This commit is contained in:
@@ -12568,7 +12568,7 @@ package android.uwb {
|
|||||||
method public void onStartFailed(int, @NonNull android.os.PersistableBundle);
|
method public void onStartFailed(int, @NonNull android.os.PersistableBundle);
|
||||||
method public void onStarted(@NonNull android.os.PersistableBundle);
|
method public void onStarted(@NonNull android.os.PersistableBundle);
|
||||||
method public void onStopFailed(int, @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_BAD_PARAMETERS = 3; // 0x3
|
||||||
field public static final int REASON_GENERIC_ERROR = 4; // 0x4
|
field public static final int REASON_GENERIC_ERROR = 4; // 0x4
|
||||||
field public static final int REASON_LOCAL_REQUEST = 1; // 0x1
|
field public static final int REASON_LOCAL_REQUEST = 1; // 0x1
|
||||||
|
|||||||
@@ -92,9 +92,13 @@ interface IUwbRangingCallbacks {
|
|||||||
* Called when the ranging session has been stopped
|
* Called when the ranging session has been stopped
|
||||||
*
|
*
|
||||||
* @param sessionHandle the session the callback is being invoked for
|
* @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
|
* Called when a ranging session fails to stop
|
||||||
|
|||||||
@@ -165,7 +165,8 @@ public class RangingManager extends android.uwb.IUwbRangingCallbacks.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRangingStopped(SessionHandle sessionHandle) {
|
public void onRangingStopped(SessionHandle sessionHandle, @RangingChangeReason int reason,
|
||||||
|
PersistableBundle params) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (!hasSession(sessionHandle)) {
|
if (!hasSession(sessionHandle)) {
|
||||||
Log.w(TAG, "onRangingStopped - received unexpected SessionHandle: "
|
Log.w(TAG, "onRangingStopped - received unexpected SessionHandle: "
|
||||||
@@ -174,7 +175,7 @@ public class RangingManager extends android.uwb.IUwbRangingCallbacks.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RangingSession session = mRangingSessionTable.get(sessionHandle);
|
RangingSession session = mRangingSessionTable.get(sessionHandle);
|
||||||
session.onRangingStopped();
|
session.onRangingStopped(convertToReason(reason), params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -191,8 +191,11 @@ public final class RangingSession implements AutoCloseable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked when a request to stop the session succeeds
|
* 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
|
* Invoked when a request to stop the session fails
|
||||||
@@ -434,14 +437,15 @@ public final class RangingSession implements AutoCloseable {
|
|||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void onRangingStopped() {
|
public void onRangingStopped(@Callback.Reason int reason,
|
||||||
|
@NonNull PersistableBundle params) {
|
||||||
if (mState == State.CLOSED) {
|
if (mState == State.CLOSED) {
|
||||||
Log.w(TAG, "onRangingStopped invoked for a closed session");
|
Log.w(TAG, "onRangingStopped invoked for a closed session");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mState = State.IDLE;
|
mState = State.IDLE;
|
||||||
executeCallback(() -> mCallback.onStopped());
|
executeCallback(() -> mCallback.onStopped(reason, params));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -123,8 +123,8 @@ public class RangingManagerTest {
|
|||||||
rangingManager.onRangingReconfigureFailed(handle, REASON, PARAMS);
|
rangingManager.onRangingReconfigureFailed(handle, REASON, PARAMS);
|
||||||
verify(callback, times(1)).onReconfigureFailed(eq(REASON), eq(PARAMS));
|
verify(callback, times(1)).onReconfigureFailed(eq(REASON), eq(PARAMS));
|
||||||
|
|
||||||
rangingManager.onRangingStopped(handle);
|
rangingManager.onRangingStopped(handle, REASON, PARAMS);
|
||||||
verify(callback, times(1)).onStopped();
|
verify(callback, times(1)).onStopped(eq(REASON), eq(PARAMS));
|
||||||
|
|
||||||
rangingManager.onRangingStopFailed(handle, REASON, PARAMS);
|
rangingManager.onRangingStopFailed(handle, REASON, PARAMS);
|
||||||
verify(callback, times(1)).onStopFailed(eq(REASON), eq(PARAMS));
|
verify(callback, times(1)).onStopFailed(eq(REASON), eq(PARAMS));
|
||||||
|
|||||||
Reference in New Issue
Block a user