diff options
author | Yan Yan <evitayan@google.com> | 2019-10-24 17:56:32 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-10-24 17:56:32 +0000 |
commit | 819c419ff9a87355a0cfa2776cd9afe324158667 (patch) | |
tree | f63198de2b1f55c01b527799f0a31b667a5c3fe3 | |
parent | 2a5659184e937c3032a4a5cac3916702388e8105 (diff) | |
parent | e45db1b36ad14a794ba321d28cc2faf7101b56cf (diff) | |
download | ike-819c419ff9a87355a0cfa2776cd9afe324158667.tar.gz |
Merge "Rename ChildCallback and IkeCallback"
-rw-r--r-- | src/java/com/android/ike/ikev2/ChildSessionCallback.java (renamed from src/java/com/android/ike/ikev2/IChildSessionCallback.java) | 6 | ||||
-rw-r--r-- | src/java/com/android/ike/ikev2/ChildSessionStateMachine.java | 10 | ||||
-rw-r--r-- | src/java/com/android/ike/ikev2/ChildSessionStateMachineFactory.java | 6 | ||||
-rw-r--r-- | src/java/com/android/ike/ikev2/IkeLocalRequestScheduler.java | 4 | ||||
-rw-r--r-- | src/java/com/android/ike/ikev2/IkeManager.java | 8 | ||||
-rw-r--r-- | src/java/com/android/ike/ikev2/IkeSession.java | 18 | ||||
-rw-r--r-- | src/java/com/android/ike/ikev2/IkeSessionCallback.java (renamed from src/java/com/android/ike/ikev2/IIkeSessionCallback.java) | 8 | ||||
-rw-r--r-- | src/java/com/android/ike/ikev2/IkeSessionStateMachine.java | 37 | ||||
-rw-r--r-- | tests/iketests/src/java/com/android/ike/ikev2/ChildSessionStateMachineTest.java | 8 | ||||
-rw-r--r-- | tests/iketests/src/java/com/android/ike/ikev2/IkeSessionStateMachineTest.java | 69 | ||||
-rw-r--r-- | tests/iketests/src/java/com/android/ike/ikev2/IkeSessionTest.java | 8 |
11 files changed, 94 insertions, 88 deletions
diff --git a/src/java/com/android/ike/ikev2/IChildSessionCallback.java b/src/java/com/android/ike/ikev2/ChildSessionCallback.java index 81f751dc..071ad432 100644 --- a/src/java/com/android/ike/ikev2/IChildSessionCallback.java +++ b/src/java/com/android/ike/ikev2/ChildSessionCallback.java @@ -22,7 +22,7 @@ import android.net.IpSecTransform; import com.android.ike.ikev2.exceptions.IkeException; /** Callback interface for receiving state changes of a Child Session. */ -public interface IChildSessionCallback { +public interface ChildSessionCallback { /** * Called when Child Session setup succeeds. * @@ -40,11 +40,11 @@ public interface IChildSessionCallback { void onClosed(); /** - * Called if Child Session setup fails or Child Session is deleted because of a fatal error. + * Called if Child Session setup fails or Child Session is closed because of a fatal error. * * @param exception the detailed error. */ - void onError(IkeException exception); + void onClosedExceptionally(IkeException exception); /** * Called when a new {@link IpSecTransform} is created for this Child Session. diff --git a/src/java/com/android/ike/ikev2/ChildSessionStateMachine.java b/src/java/com/android/ike/ikev2/ChildSessionStateMachine.java index 7e674ef2..0d591fee 100644 --- a/src/java/com/android/ike/ikev2/ChildSessionStateMachine.java +++ b/src/java/com/android/ike/ikev2/ChildSessionStateMachine.java @@ -145,7 +145,7 @@ public class ChildSessionStateMachine extends AbstractSessionStateMachine { private final ChildSessionOptions mChildSessionOptions; private final Executor mUserCbExecutor; - private final IChildSessionCallback mUserCallback; + private final ChildSessionCallback mUserCallback; /** Callback to notify IKE Session the state changes. */ private final IChildSessionSmCallback mChildSmCallback; @@ -219,7 +219,7 @@ public class ChildSessionStateMachine extends AbstractSessionStateMachine { IpSecManager ipSecManager, ChildSessionOptions sessionOptions, Executor userCbExecutor, - IChildSessionCallback userCallback, + ChildSessionCallback userCallback, IChildSessionSmCallback childSmCallback) { super(TAG, looper); @@ -293,7 +293,7 @@ public class ChildSessionStateMachine extends AbstractSessionStateMachine { * <p>This method MUST be called after the user callbacks have been fired, and MUST always * be called before the state machine can shut down. */ - void onChildSessionClosed(IChildSessionCallback userCallbacks); + void onChildSessionClosed(ChildSessionCallback userCallbacks); /** * Notify that a Child procedure has been finished and the IKE Session should close itself @@ -577,7 +577,7 @@ public class ChildSessionStateMachine extends AbstractSessionStateMachine { mUserCbExecutor.execute( () -> { - mUserCallback.onError(new IkeInternalException(e)); + mUserCallback.onClosedExceptionally(new IkeInternalException(e)); }); logWtf("Unexpected exception in " + getCurrentState().getName(), e); quitNow(); @@ -636,7 +636,7 @@ public class ChildSessionStateMachine extends AbstractSessionStateMachine { mUserCbExecutor.execute( () -> { - mUserCallback.onError(ikeException); + mUserCallback.onClosedExceptionally(ikeException); }); loge("Child Session fatal error", ikeException); diff --git a/src/java/com/android/ike/ikev2/ChildSessionStateMachineFactory.java b/src/java/com/android/ike/ikev2/ChildSessionStateMachineFactory.java index 53c7d81f..dc68e9f1 100644 --- a/src/java/com/android/ike/ikev2/ChildSessionStateMachineFactory.java +++ b/src/java/com/android/ike/ikev2/ChildSessionStateMachineFactory.java @@ -37,7 +37,7 @@ final class ChildSessionStateMachineFactory { Context context, ChildSessionOptions sessionOptions, Executor userCbExecutor, - IChildSessionCallback userCallbacks, + ChildSessionCallback userCallbacks, IChildSessionSmCallback childSmCallback) { return sChildSessionHelper.makeChildSessionStateMachine( looper, context, sessionOptions, userCbExecutor, userCallbacks, childSmCallback); @@ -60,7 +60,7 @@ final class ChildSessionStateMachineFactory { Context context, ChildSessionOptions sessionOptions, Executor userCbExecutor, - IChildSessionCallback userCallbacks, + ChildSessionCallback userCallbacks, IChildSessionSmCallback childSmCallback); } @@ -75,7 +75,7 @@ final class ChildSessionStateMachineFactory { Context context, ChildSessionOptions sessionOptions, Executor userCbExecutor, - IChildSessionCallback userCallbacks, + ChildSessionCallback userCallbacks, IChildSessionSmCallback childSmCallback) { ChildSessionStateMachine childSession = new ChildSessionStateMachine( diff --git a/src/java/com/android/ike/ikev2/IkeLocalRequestScheduler.java b/src/java/com/android/ike/ikev2/IkeLocalRequestScheduler.java index a1447313..5039f2a4 100644 --- a/src/java/com/android/ike/ikev2/IkeLocalRequestScheduler.java +++ b/src/java/com/android/ike/ikev2/IkeLocalRequestScheduler.java @@ -93,11 +93,11 @@ public final class IkeLocalRequestScheduler { * initiated locally. */ public static class ChildLocalRequest extends LocalRequest { - public final IChildSessionCallback childSessionCallback; + public final ChildSessionCallback childSessionCallback; public final ChildSessionOptions childSessionOptions; ChildLocalRequest( - int type, IChildSessionCallback childCallback, ChildSessionOptions childOptions) { + int type, ChildSessionCallback childCallback, ChildSessionOptions childOptions) { super(type); childSessionOptions = childOptions; childSessionCallback = childCallback; diff --git a/src/java/com/android/ike/ikev2/IkeManager.java b/src/java/com/android/ike/ikev2/IkeManager.java index 446ce281..38ab15ba 100644 --- a/src/java/com/android/ike/ikev2/IkeManager.java +++ b/src/java/com/android/ike/ikev2/IkeManager.java @@ -54,9 +54,9 @@ public final class IkeManager { * @param userCbExecutor the {@link Executor} upon which all callbacks will be posted. For * security and consistency, the callbacks posted to this executor MUST be executed * serially, in the order they were posted. - * @param ikeSessionCallback the {@link IIkeSessionCallback} interface to notify users the state + * @param ikeSessionCallback the {@link IkeSessionCallback} interface to notify users the state * changes of the IKE Session. - * @param firstChildSessionCallback the {@link IChildSessionCallback} interface to notify users + * @param firstChildSessionCallback the {@link ChildSessionCallback} interface to notify users * the state changes of the Child Session. * @return an instance of {@link IkeSession} */ @@ -64,8 +64,8 @@ public final class IkeManager { IkeSessionOptions ikeSessionOptions, ChildSessionOptions firstChildSessionOptions, Executor userCbExecutor, - IIkeSessionCallback ikeSessionCallback, - IChildSessionCallback firstChildSessionCallback) { + IkeSessionCallback ikeSessionCallback, + ChildSessionCallback firstChildSessionCallback) { return new IkeSession( mContext, ikeSessionOptions, diff --git a/src/java/com/android/ike/ikev2/IkeSession.java b/src/java/com/android/ike/ikev2/IkeSession.java index 2147471a..19d9cb96 100644 --- a/src/java/com/android/ike/ikev2/IkeSession.java +++ b/src/java/com/android/ike/ikev2/IkeSession.java @@ -38,8 +38,8 @@ public final class IkeSession implements AutoCloseable { IkeSessionOptions ikeSessionOptions, ChildSessionOptions firstChildSessionOptions, Executor userCbExecutor, - IIkeSessionCallback ikeSessionCallback, - IChildSessionCallback firstChildSessionCallback) { + IkeSessionCallback ikeSessionCallback, + ChildSessionCallback firstChildSessionCallback) { this( IkeThreadHolder.IKE_WORKER_THREAD.getLooper(), context, @@ -60,8 +60,8 @@ public final class IkeSession implements AutoCloseable { IkeSessionOptions ikeSessionOptions, ChildSessionOptions firstChildSessionOptions, Executor userCbExecutor, - IIkeSessionCallback ikeSessionCallback, - IChildSessionCallback firstChildSessionCallback) { + IkeSessionCallback ikeSessionCallback, + ChildSessionCallback firstChildSessionCallback) { mIkeSessionStateMachine = new IkeSessionStateMachine( looper, @@ -99,17 +99,17 @@ public final class IkeSession implements AutoCloseable { /** * Initiate Create Child exchange on the IKE worker thread. * - * <p>Users MUST provide a unique {@link IChildSessionCallback} instance for each new Child + * <p>Users MUST provide a unique {@link ChildSessionCallback} instance for each new Child * Session. * * @param childSessionOptions the {@link ChildSessionOptions} that contains the Child Session * configurations to negotiate. - * @param childSessionCallback the {@link IChildSessionCallback} interface to notify users the + * @param childSessionCallback the {@link ChildSessionCallback} interface to notify users the * state changes of the Child Session. - * @throws IllegalArgumentException if the IChildSessionCallback is already in use. + * @throws IllegalArgumentException if the ChildSessionCallback is already in use. */ public void openChildSession( - ChildSessionOptions childSessionOptions, IChildSessionCallback childSessionCallback) { + ChildSessionOptions childSessionOptions, ChildSessionCallback childSessionCallback) { mIkeSessionStateMachine.openChildSession(childSessionOptions, childSessionCallback); } @@ -120,7 +120,7 @@ public final class IkeSession implements AutoCloseable { * interface to notify users the deletion result. * @throws IllegalArgumentException if no Child Session found bound with this callback. */ - public void closeChildSession(IChildSessionCallback childSessionCallback) { + public void closeChildSession(ChildSessionCallback childSessionCallback) { mIkeSessionStateMachine.closeChildSession(childSessionCallback); } diff --git a/src/java/com/android/ike/ikev2/IIkeSessionCallback.java b/src/java/com/android/ike/ikev2/IkeSessionCallback.java index ee196797..66081206 100644 --- a/src/java/com/android/ike/ikev2/IIkeSessionCallback.java +++ b/src/java/com/android/ike/ikev2/IkeSessionCallback.java @@ -21,7 +21,7 @@ import android.annotation.NonNull; import com.android.ike.ikev2.exceptions.IkeException; /** Callback interface for receiving state changes of an IKE Session. */ -public interface IIkeSessionCallback { +public interface IkeSessionCallback { /** * Called when negotiation and authentication for this new IKE Session succeeds. * @@ -39,11 +39,11 @@ public interface IIkeSessionCallback { void onClosed(); /** - * Called if IKE Session negotiation fails or IKE Session is deleted because of a fatal error. + * Called if IKE Session negotiation fails or IKE Session is closed because of a fatal error. * * @param exception the detailed error. */ - void onError(IkeException exception); + void onClosedExceptionally(IkeException exception); /** * Called if a recoverable error is encountered in an established IKE Session. @@ -54,5 +54,5 @@ public interface IIkeSessionCallback { * * @param exception the detailed error. */ - void onInfo(IkeException exception); + void onError(IkeException exception); } diff --git a/src/java/com/android/ike/ikev2/IkeSessionStateMachine.java b/src/java/com/android/ike/ikev2/IkeSessionStateMachine.java index c0893254..7172dace 100644 --- a/src/java/com/android/ike/ikev2/IkeSessionStateMachine.java +++ b/src/java/com/android/ike/ikev2/IkeSessionStateMachine.java @@ -281,13 +281,13 @@ public class IkeSessionStateMachine extends AbstractSessionStateMachine { private final IpSecManager mIpSecManager; private final IkeLocalRequestScheduler mScheduler; private final Executor mUserCbExecutor; - private final IIkeSessionCallback mIkeSessionCallback; + private final IkeSessionCallback mIkeSessionCallback; private final IkeEapAuthenticatorFactory mEapAuthenticatorFactory; private final TempFailureHandler mTempFailHandler; @VisibleForTesting @GuardedBy("mChildCbToSessions") - final HashMap<IChildSessionCallback, ChildSessionStateMachine> mChildCbToSessions = + final HashMap<ChildSessionCallback, ChildSessionStateMachine> mChildCbToSessions = new HashMap<>(); /** @@ -334,7 +334,7 @@ public class IkeSessionStateMachine extends AbstractSessionStateMachine { // FIXME: b/131265898 Move into CreateIkeLocalIkeAuth, and pass through to // CreateIkeLocalIkeAuthPostEap once passing entry data is supported private ChildSessionOptions mFirstChildSessionOptions; - private IChildSessionCallback mFirstChildCallbacks; + private ChildSessionCallback mFirstChildCallbacks; /** Package */ @VisibleForTesting IkeSaRecord mCurrentIkeSaRecord; @@ -384,8 +384,8 @@ public class IkeSessionStateMachine extends AbstractSessionStateMachine { IkeSessionOptions ikeOptions, ChildSessionOptions firstChildOptions, Executor userCbExecutor, - IIkeSessionCallback ikeSessionCallback, - IChildSessionCallback firstChildSessionCallback, + IkeSessionCallback ikeSessionCallback, + ChildSessionCallback firstChildSessionCallback, IkeEapAuthenticatorFactory eapAuthenticatorFactory) { super(TAG, looper); @@ -443,8 +443,8 @@ public class IkeSessionStateMachine extends AbstractSessionStateMachine { IkeSessionOptions ikeOptions, ChildSessionOptions firstChildOptions, Executor userCbExecutor, - IIkeSessionCallback ikeSessionCallback, - IChildSessionCallback firstChildSessionCallback) { + IkeSessionCallback ikeSessionCallback, + ChildSessionCallback firstChildSessionCallback) { this( looper, context, @@ -457,7 +457,7 @@ public class IkeSessionStateMachine extends AbstractSessionStateMachine { new IkeEapAuthenticatorFactory()); } - private boolean hasChildSessionCallback(IChildSessionCallback callback) { + private boolean hasChildSessionCallback(ChildSessionCallback callback) { synchronized (mChildCbToSessions) { return mChildCbToSessions.containsKey(callback); } @@ -478,7 +478,7 @@ public class IkeSessionStateMachine extends AbstractSessionStateMachine { @VisibleForTesting void registerChildSessionCallback( ChildSessionOptions childOptions, - IChildSessionCallback callbacks, + ChildSessionCallback callbacks, boolean isFirstChild) { synchronized (mChildCbToSessions) { if (!isFirstChild && getCurrentState() == null) { @@ -503,7 +503,7 @@ public class IkeSessionStateMachine extends AbstractSessionStateMachine { } void openChildSession( - ChildSessionOptions childSessionOptions, IChildSessionCallback childSessionCallback) { + ChildSessionOptions childSessionOptions, ChildSessionCallback childSessionCallback) { if (childSessionCallback == null) { throw new IllegalArgumentException("Child Session Callback must be provided"); } @@ -520,7 +520,7 @@ public class IkeSessionStateMachine extends AbstractSessionStateMachine { CMD_LOCAL_REQUEST_CREATE_CHILD, childSessionCallback, childSessionOptions)); } - void closeChildSession(IChildSessionCallback childSessionCallback) { + void closeChildSession(ChildSessionCallback childSessionCallback) { if (childSessionCallback == null) { throw new IllegalArgumentException("Child Session Callback must be provided"); } @@ -576,7 +576,8 @@ public class IkeSessionStateMachine extends AbstractSessionStateMachine { + " of sync."); mUserCbExecutor.execute( () -> { - mIkeSessionCallback.onError(new IkeInternalException(error)); + mIkeSessionCallback.onClosedExceptionally( + new IkeInternalException(error)); }); loge("Fatal error", error); @@ -757,13 +758,13 @@ public class IkeSessionStateMachine extends AbstractSessionStateMachine { /** Class to group parameters for negotiating the first Child SA. */ private static class FirstChildNegotiationData { public final ChildSessionOptions childSessionOptions; - public final IChildSessionCallback childSessionCallback; + public final ChildSessionCallback childSessionCallback; public final List<IkePayload> reqPayloads; public final List<IkePayload> respPayloads; FirstChildNegotiationData( ChildSessionOptions childSessionOptions, - IChildSessionCallback childSessionCallback, + ChildSessionCallback childSessionCallback, List<IkePayload> reqPayloads, List<IkePayload> respPayloads) { this.childSessionOptions = childSessionOptions; @@ -838,7 +839,7 @@ public class IkeSessionStateMachine extends AbstractSessionStateMachine { } @Override - public void onChildSessionClosed(IChildSessionCallback userCallbacks) { + public void onChildSessionClosed(ChildSessionCallback userCallbacks) { synchronized (mChildCbToSessions) { mChildCbToSessions.remove(userCallbacks); } @@ -860,7 +861,7 @@ public class IkeSessionStateMachine extends AbstractSessionStateMachine { mUserCbExecutor.execute( () -> { - mIkeSessionCallback.onError(new IkeInternalException(e)); + mIkeSessionCallback.onClosedExceptionally(new IkeInternalException(e)); }); logWtf("Unexpected exception in " + getCurrentState().getName(), e); quitNow(); @@ -924,7 +925,7 @@ public class IkeSessionStateMachine extends AbstractSessionStateMachine { closeAllSaRecords(false /*expectSaClosed*/); mUserCbExecutor.execute( () -> { - mIkeSessionCallback.onError(ikeException); + mIkeSessionCallback.onClosedExceptionally(ikeException); }); loge("IKE Session fatal error in " + getCurrentState().getName(), ikeException); @@ -1970,7 +1971,7 @@ public class IkeSessionStateMachine extends AbstractSessionStateMachine { } } - private ChildSessionStateMachine getChildSession(IChildSessionCallback callbacks) { + private ChildSessionStateMachine getChildSession(ChildSessionCallback callbacks) { synchronized (mChildCbToSessions) { return mChildCbToSessions.get(callbacks); } diff --git a/tests/iketests/src/java/com/android/ike/ikev2/ChildSessionStateMachineTest.java b/tests/iketests/src/java/com/android/ike/ikev2/ChildSessionStateMachineTest.java index 9aca851e..1b6276a6 100644 --- a/tests/iketests/src/java/com/android/ike/ikev2/ChildSessionStateMachineTest.java +++ b/tests/iketests/src/java/com/android/ike/ikev2/ChildSessionStateMachineTest.java @@ -194,7 +194,7 @@ public final class ChildSessionStateMachineTest { private ChildSaProposal mMockNegotiatedProposal; private Executor mSpyUserCbExecutor; - private IChildSessionCallback mMockChildSessionCallback; + private ChildSessionCallback mMockChildSessionCallback; private IChildSessionSmCallback mMockChildSessionSmCallback; private ArgumentCaptor<ChildSaRecordConfig> mChildSaRecordConfigCaptor = @@ -246,7 +246,7 @@ public final class ChildSessionStateMachineTest { command.run(); }); - mMockChildSessionCallback = mock(IChildSessionCallback.class); + mMockChildSessionCallback = mock(ChildSessionCallback.class); mChildSessionOptions = buildChildSessionOptions(); // Setup thread and looper @@ -587,7 +587,7 @@ public final class ChildSessionStateMachineTest { verify(mMockChildSessionSmCallback).onProcedureFinished(mChildSessionStateMachine); verify(mMockChildSessionSmCallback).onChildSessionClosed(mMockChildSessionCallback); - verify(mMockChildSessionCallback).onError(any(exceptionClass)); + verify(mMockChildSessionCallback).onClosedExceptionally(any(exceptionClass)); } @Test @@ -764,7 +764,7 @@ public final class ChildSessionStateMachineTest { mLooper.dispatchAll(); assertNull(mChildSessionStateMachine.getCurrentState()); - verify(mMockChildSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockChildSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); verifyNotifyUserDeleteChildSa(mSpyCurrentChildSaRecord); } diff --git a/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionStateMachineTest.java b/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionStateMachineTest.java index 93bcf2cd..819c3280 100644 --- a/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionStateMachineTest.java +++ b/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionStateMachineTest.java @@ -257,8 +257,8 @@ public final class IkeSessionStateMachineTest { private ChildSessionOptions mChildSessionOptions; private Executor mSpyUserCbExecutor; - private IIkeSessionCallback mMockIkeSessionCallback; - private IChildSessionCallback mMockChildSessionCallback; + private IkeSessionCallback mMockIkeSessionCallback; + private ChildSessionCallback mMockChildSessionCallback; private EncryptionTransform mIkeEncryptionTransform; private IntegrityTransform mIkeIntegrityTransform; @@ -635,8 +635,8 @@ public final class IkeSessionStateMachineTest { command.run(); }); - mMockIkeSessionCallback = mock(IIkeSessionCallback.class); - mMockChildSessionCallback = mock(IChildSessionCallback.class); + mMockIkeSessionCallback = mock(IkeSessionCallback.class); + mMockChildSessionCallback = mock(ChildSessionCallback.class); mLooper = new TestLooper(); @@ -1288,7 +1288,7 @@ public final class IkeSessionStateMachineTest { eq(mContext), eq(mChildSessionOptions), eq(mSpyUserCbExecutor), - any(IChildSessionCallback.class), + any(ChildSessionCallback.class), any(IChildSessionSmCallback.class))) .thenReturn(child); } @@ -1303,7 +1303,7 @@ public final class IkeSessionStateMachineTest { * @param sm The ChildSessionStateMachine instance to be used. */ private void registerChildStateMachine( - IChildSessionCallback callback, ChildSessionStateMachine sm) { + ChildSessionCallback callback, ChildSessionStateMachine sm) { setupChildStateMachineFactory(sm); mIkeSessionStateMachine.registerChildSessionCallback( mChildSessionOptions, callback, false /*isFirstChild*/); @@ -1313,7 +1313,7 @@ public final class IkeSessionStateMachineTest { public void testCreateAdditionalChild() throws Exception { setupIdleStateMachine(); - IChildSessionCallback childCallback = mock(IChildSessionCallback.class); + ChildSessionCallback childCallback = mock(ChildSessionCallback.class); ChildSessionStateMachine childStateMachine = mock(ChildSessionStateMachine.class); registerChildStateMachine(childCallback, childStateMachine); @@ -1422,7 +1422,7 @@ public final class IkeSessionStateMachineTest { IkeSessionStateMachine.CMD_EXECUTE_LOCAL_REQ, new ChildLocalRequest( IkeSessionStateMachine.CMD_LOCAL_REQUEST_DELETE_CHILD, - mock(IChildSessionCallback.class), + mock(ChildSessionCallback.class), null /*childOptions*/)); mLooper.dispatchAll(); @@ -1472,11 +1472,11 @@ public final class IkeSessionStateMachineTest { private IChildSessionSmCallback createChildAndGetChildSessionSmCallback( ChildSessionStateMachine child, int remoteSpi) throws Exception { return createChildAndGetChildSessionSmCallback( - child, remoteSpi, mock(IChildSessionCallback.class)); + child, remoteSpi, mock(ChildSessionCallback.class)); } private IChildSessionSmCallback createChildAndGetChildSessionSmCallback( - ChildSessionStateMachine child, int remoteSpi, IChildSessionCallback childCallback) + ChildSessionStateMachine child, int remoteSpi, ChildSessionCallback childCallback) throws Exception { registerChildStateMachine(childCallback, child); @@ -1845,8 +1845,8 @@ public final class IkeSessionStateMachineTest { ChildSessionStateMachine childOne = mock(ChildSessionStateMachine.class); ChildSessionStateMachine childTwo = mock(ChildSessionStateMachine.class); - registerChildStateMachine(mock(IChildSessionCallback.class), childOne); - registerChildStateMachine(mock(IChildSessionCallback.class), childTwo); + registerChildStateMachine(mock(ChildSessionCallback.class), childOne); + registerChildStateMachine(mock(ChildSessionCallback.class), childTwo); mIkeSessionStateMachine.mCurrentIkeSaRecord = null; @@ -2073,7 +2073,8 @@ public final class IkeSessionStateMachineTest { // Verify IKE Session was closed properly assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(AuthenticationFailedException.class)); + verify(mMockIkeSessionCallback) + .onClosedExceptionally(any(AuthenticationFailedException.class)); } @Test @@ -2096,7 +2097,7 @@ public final class IkeSessionStateMachineTest { // Verify IKE Session is closed properly assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); } @Test @@ -2218,7 +2219,8 @@ public final class IkeSessionStateMachineTest { mLooper.dispatchAll(); // Verify state machine quit properly - verify(mMockIkeSessionCallback).onError(any(AuthenticationFailedException.class)); + verify(mMockIkeSessionCallback) + .onClosedExceptionally(any(AuthenticationFailedException.class)); assertNull(mIkeSessionStateMachine.getCurrentState()); } @@ -2262,7 +2264,8 @@ public final class IkeSessionStateMachineTest { mLooper.dispatchAll(); // Fires user error callbacks - verify(mMockIkeSessionCallback).onError(argThat(err -> err.getCause() == error)); + verify(mMockIkeSessionCallback) + .onClosedExceptionally(argThat(err -> err.getCause() == error)); // Verify state machine quit properly verify(mSpyCurrentIkeSaRecord).close(); @@ -2283,7 +2286,8 @@ public final class IkeSessionStateMachineTest { mLooper.dispatchAll(); // Fires user error callbacks - verify(mMockIkeSessionCallback).onError(any(AuthenticationFailedException.class)); + verify(mMockIkeSessionCallback) + .onClosedExceptionally(any(AuthenticationFailedException.class)); // Verify state machine quit properly verify(mSpyCurrentIkeSaRecord).close(); @@ -2448,7 +2452,7 @@ public final class IkeSessionStateMachineTest { // Verify IKE Session is closed properly assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); // Collected response fragments are cleared assertNull(mSpyCurrentIkeSaRecord.getCollectedFragments(true /*isResp*/)); @@ -2563,7 +2567,7 @@ public final class IkeSessionStateMachineTest { // Verify IKE Session is closed properly assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); } @Test @@ -2617,7 +2621,7 @@ public final class IkeSessionStateMachineTest { // Verify IKE Session is closed properly assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); } @Test @@ -2648,7 +2652,7 @@ public final class IkeSessionStateMachineTest { // Verify IKE Session is closed properly assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(IkeInternalException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(IkeInternalException.class)); } @Test @@ -3459,7 +3463,7 @@ public final class IkeSessionStateMachineTest { verifyEncryptAndEncodeNeverCalled(mSpyCurrentIkeSaRecord); // Verify state machine quit properly - verify(mMockIkeSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); assertNull(mIkeSessionStateMachine.getCurrentState()); } @@ -3483,7 +3487,7 @@ public final class IkeSessionStateMachineTest { mLooper.dispatchAll(); // Verify state machine quit properly - verify(mMockIkeSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); assertNull(mIkeSessionStateMachine.getCurrentState()); } @@ -3680,7 +3684,7 @@ public final class IkeSessionStateMachineTest { public void testOpenChildSession() throws Exception { setupIdleStateMachine(); - IChildSessionCallback cb = mock(IChildSessionCallback.class); + ChildSessionCallback cb = mock(ChildSessionCallback.class); mIkeSessionStateMachine.openChildSession(mChildSessionOptions, cb); // Test that inserting the same cb returns an error, even before the state @@ -3716,7 +3720,7 @@ public final class IkeSessionStateMachineTest { // Expect failure - callbacks not registered try { - mIkeSessionStateMachine.closeChildSession(mock(IChildSessionCallback.class)); + mIkeSessionStateMachine.closeChildSession(mock(ChildSessionCallback.class)); } catch (IllegalArgumentException expected) { } } @@ -3737,7 +3741,7 @@ public final class IkeSessionStateMachineTest { public void testCloseImmediatelyAfterOpenChildSession() throws Exception { setupIdleStateMachine(); - IChildSessionCallback cb = mock(IChildSessionCallback.class); + ChildSessionCallback cb = mock(ChildSessionCallback.class); mIkeSessionStateMachine.openChildSession(mChildSessionOptions, cb); // Verify that closing the session immediately still picks up the child callback @@ -3783,7 +3787,7 @@ public final class IkeSessionStateMachineTest { assertNull(ikeSession.getCurrentState()); verify(mSpyUserCbExecutor).execute(any(Runnable.class)); - verify(mMockIkeSessionCallback).onError(any(IkeInternalException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(IkeInternalException.class)); verify(spyIkeLog).wtf(anyString(), anyString(), any(RuntimeException.class)); } @@ -3799,7 +3803,7 @@ public final class IkeSessionStateMachineTest { assertNull(mIkeSessionStateMachine.getCurrentState()); verify(mSpyUserCbExecutor).execute(any(Runnable.class)); - verify(mMockIkeSessionCallback).onError(any(IkeInternalException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(IkeInternalException.class)); verify(spyIkeLog).wtf(anyString(), anyString(), any(RuntimeException.class)); } @@ -3827,7 +3831,8 @@ public final class IkeSessionStateMachineTest { // Fires user error callbacks verify(mMockIkeSessionCallback) - .onError(argThat(err -> err instanceof NoValidProposalChosenException)); + .onClosedExceptionally( + argThat(err -> err instanceof NoValidProposalChosenException)); // Verify state machine quit properly assertNull(mIkeSessionStateMachine.getCurrentState()); } @@ -3909,7 +3914,7 @@ public final class IkeSessionStateMachineTest { mLooper.dispatchAll(); assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(IkeInternalException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(IkeInternalException.class)); } @Test @@ -3970,7 +3975,7 @@ public final class IkeSessionStateMachineTest { // Verify IKE Session is closed properly assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); } @Test @@ -3999,7 +4004,7 @@ public final class IkeSessionStateMachineTest { // Verify IKE Session has quit assertNull(mIkeSessionStateMachine.getCurrentState()); - verify(mMockIkeSessionCallback).onError(any(InvalidSyntaxException.class)); + verify(mMockIkeSessionCallback).onClosedExceptionally(any(InvalidSyntaxException.class)); } @Test diff --git a/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionTest.java b/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionTest.java index 43881d1d..28a13110 100644 --- a/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionTest.java +++ b/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionTest.java @@ -54,8 +54,8 @@ public final class IkeSessionTest { private IkeSessionOptions mIkeSessionOptions; private ChildSessionOptions mMockChildSessionOptions; private Executor mUserCbExecutor; - private IIkeSessionCallback mMockIkeSessionCb; - private IChildSessionCallback mMockChildSessionCb; + private IkeSessionCallback mMockIkeSessionCb; + private ChildSessionCallback mMockChildSessionCb; @Before public void setUp() throws Exception { @@ -68,8 +68,8 @@ public final class IkeSessionTest { mIkeSessionOptions = buildIkeSessionOptions(); mMockChildSessionOptions = mock(ChildSessionOptions.class); mUserCbExecutor = (r) -> r.run(); // Inline executor for testing purposes. - mMockIkeSessionCb = mock(IIkeSessionCallback.class); - mMockChildSessionCb = mock(IChildSessionCallback.class); + mMockIkeSessionCb = mock(IkeSessionCallback.class); + mMockChildSessionCb = mock(ChildSessionCallback.class); } private IkeSessionOptions buildIkeSessionOptions() throws Exception { |