Merge "Rename ChildCallback and IkeCallback" am: 819c419ff9 am: fb79a8ce89
am: e088b7c4ee

Change-Id: Ie76f3a35883c4aa905273f34061056683f56ab81
diff --git a/src/java/com/android/ike/ikev2/IChildSessionCallback.java b/src/java/com/android/ike/ikev2/ChildSessionCallback.java
similarity index 92%
rename from src/java/com/android/ike/ikev2/IChildSessionCallback.java
rename to src/java/com/android/ike/ikev2/ChildSessionCallback.java
index 81f751d..071ad43 100644
--- a/src/java/com/android/ike/ikev2/IChildSessionCallback.java
+++ b/src/java/com/android/ike/ikev2/ChildSessionCallback.java
@@ -22,7 +22,7 @@
 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 @@
     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 7e674ef..0d591fe 100644
--- a/src/java/com/android/ike/ikev2/ChildSessionStateMachine.java
+++ b/src/java/com/android/ike/ikev2/ChildSessionStateMachine.java
@@ -145,7 +145,7 @@
     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 @@
             IpSecManager ipSecManager,
             ChildSessionOptions sessionOptions,
             Executor userCbExecutor,
-            IChildSessionCallback userCallback,
+            ChildSessionCallback userCallback,
             IChildSessionSmCallback childSmCallback) {
         super(TAG, looper);
 
@@ -293,7 +293,7 @@
          * <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 @@
 
             mUserCbExecutor.execute(
                     () -> {
-                        mUserCallback.onError(new IkeInternalException(e));
+                        mUserCallback.onClosedExceptionally(new IkeInternalException(e));
                     });
             logWtf("Unexpected exception in " + getCurrentState().getName(), e);
             quitNow();
@@ -636,7 +636,7 @@
 
         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 53c7d81..dc68e9f 100644
--- a/src/java/com/android/ike/ikev2/ChildSessionStateMachineFactory.java
+++ b/src/java/com/android/ike/ikev2/ChildSessionStateMachineFactory.java
@@ -37,7 +37,7 @@
             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 @@
                 Context context,
                 ChildSessionOptions sessionOptions,
                 Executor userCbExecutor,
-                IChildSessionCallback userCallbacks,
+                ChildSessionCallback userCallbacks,
                 IChildSessionSmCallback childSmCallback);
     }
 
@@ -75,7 +75,7 @@
                 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 a144731..5039f2a 100644
--- a/src/java/com/android/ike/ikev2/IkeLocalRequestScheduler.java
+++ b/src/java/com/android/ike/ikev2/IkeLocalRequestScheduler.java
@@ -93,11 +93,11 @@
      * 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 446ce28..38ab15b 100644
--- a/src/java/com/android/ike/ikev2/IkeManager.java
+++ b/src/java/com/android/ike/ikev2/IkeManager.java
@@ -54,9 +54,9 @@
      * @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 @@
             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 2147471..19d9cb9 100644
--- a/src/java/com/android/ike/ikev2/IkeSession.java
+++ b/src/java/com/android/ike/ikev2/IkeSession.java
@@ -38,8 +38,8 @@
             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 @@
             IkeSessionOptions ikeSessionOptions,
             ChildSessionOptions firstChildSessionOptions,
             Executor userCbExecutor,
-            IIkeSessionCallback ikeSessionCallback,
-            IChildSessionCallback firstChildSessionCallback) {
+            IkeSessionCallback ikeSessionCallback,
+            ChildSessionCallback firstChildSessionCallback) {
         mIkeSessionStateMachine =
                 new IkeSessionStateMachine(
                         looper,
@@ -99,17 +99,17 @@
     /**
      * 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 @@
      *     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
similarity index 93%
rename from src/java/com/android/ike/ikev2/IIkeSessionCallback.java
rename to src/java/com/android/ike/ikev2/IkeSessionCallback.java
index ee19679..6608120 100644
--- a/src/java/com/android/ike/ikev2/IIkeSessionCallback.java
+++ b/src/java/com/android/ike/ikev2/IkeSessionCallback.java
@@ -21,7 +21,7 @@
 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 @@
     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 @@
      *
      * @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 c089325..7172dac 100644
--- a/src/java/com/android/ike/ikev2/IkeSessionStateMachine.java
+++ b/src/java/com/android/ike/ikev2/IkeSessionStateMachine.java
@@ -281,13 +281,13 @@
     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 @@
     // 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 @@
             IkeSessionOptions ikeOptions,
             ChildSessionOptions firstChildOptions,
             Executor userCbExecutor,
-            IIkeSessionCallback ikeSessionCallback,
-            IChildSessionCallback firstChildSessionCallback,
+            IkeSessionCallback ikeSessionCallback,
+            ChildSessionCallback firstChildSessionCallback,
             IkeEapAuthenticatorFactory eapAuthenticatorFactory) {
         super(TAG, looper);
 
@@ -443,8 +443,8 @@
             IkeSessionOptions ikeOptions,
             ChildSessionOptions firstChildOptions,
             Executor userCbExecutor,
-            IIkeSessionCallback ikeSessionCallback,
-            IChildSessionCallback firstChildSessionCallback) {
+            IkeSessionCallback ikeSessionCallback,
+            ChildSessionCallback firstChildSessionCallback) {
         this(
                 looper,
                 context,
@@ -457,7 +457,7 @@
                 new IkeEapAuthenticatorFactory());
     }
 
-    private boolean hasChildSessionCallback(IChildSessionCallback callback) {
+    private boolean hasChildSessionCallback(ChildSessionCallback callback) {
         synchronized (mChildCbToSessions) {
             return mChildCbToSessions.containsKey(callback);
         }
@@ -478,7 +478,7 @@
     @VisibleForTesting
     void registerChildSessionCallback(
             ChildSessionOptions childOptions,
-            IChildSessionCallback callbacks,
+            ChildSessionCallback callbacks,
             boolean isFirstChild) {
         synchronized (mChildCbToSessions) {
             if (!isFirstChild && getCurrentState() == null) {
@@ -503,7 +503,7 @@
     }
 
     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 @@
                         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 @@
                                         + " of sync.");
                 mUserCbExecutor.execute(
                         () -> {
-                            mIkeSessionCallback.onError(new IkeInternalException(error));
+                            mIkeSessionCallback.onClosedExceptionally(
+                                    new IkeInternalException(error));
                         });
                 loge("Fatal error", error);
 
@@ -757,13 +758,13 @@
     /** 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 @@
         }
 
         @Override
-        public void onChildSessionClosed(IChildSessionCallback userCallbacks) {
+        public void onChildSessionClosed(ChildSessionCallback userCallbacks) {
             synchronized (mChildCbToSessions) {
                 mChildCbToSessions.remove(userCallbacks);
             }
@@ -860,7 +861,7 @@
 
             mUserCbExecutor.execute(
                     () -> {
-                        mIkeSessionCallback.onError(new IkeInternalException(e));
+                        mIkeSessionCallback.onClosedExceptionally(new IkeInternalException(e));
                     });
             logWtf("Unexpected exception in " + getCurrentState().getName(), e);
             quitNow();
@@ -924,7 +925,7 @@
         closeAllSaRecords(false /*expectSaClosed*/);
         mUserCbExecutor.execute(
                 () -> {
-                    mIkeSessionCallback.onError(ikeException);
+                    mIkeSessionCallback.onClosedExceptionally(ikeException);
                 });
         loge("IKE Session fatal error in " + getCurrentState().getName(), ikeException);
 
@@ -1970,7 +1971,7 @@
             }
         }
 
-        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 9aca851..1b6276a 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 @@
     private ChildSaProposal mMockNegotiatedProposal;
 
     private Executor mSpyUserCbExecutor;
-    private IChildSessionCallback mMockChildSessionCallback;
+    private ChildSessionCallback mMockChildSessionCallback;
     private IChildSessionSmCallback mMockChildSessionSmCallback;
 
     private ArgumentCaptor<ChildSaRecordConfig> mChildSaRecordConfigCaptor =
@@ -246,7 +246,7 @@
                             command.run();
                         });
 
-        mMockChildSessionCallback = mock(IChildSessionCallback.class);
+        mMockChildSessionCallback = mock(ChildSessionCallback.class);
         mChildSessionOptions = buildChildSessionOptions();
 
         // Setup thread and looper
@@ -587,7 +587,7 @@
         verify(mMockChildSessionSmCallback).onProcedureFinished(mChildSessionStateMachine);
         verify(mMockChildSessionSmCallback).onChildSessionClosed(mMockChildSessionCallback);
 
-        verify(mMockChildSessionCallback).onError(any(exceptionClass));
+        verify(mMockChildSessionCallback).onClosedExceptionally(any(exceptionClass));
     }
 
     @Test
@@ -764,7 +764,7 @@
         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 93bcf2c..819c328 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 @@
     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 @@
                             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 @@
                         eq(mContext),
                         eq(mChildSessionOptions),
                         eq(mSpyUserCbExecutor),
-                        any(IChildSessionCallback.class),
+                        any(ChildSessionCallback.class),
                         any(IChildSessionSmCallback.class)))
                 .thenReturn(child);
     }
@@ -1303,7 +1303,7 @@
      * @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 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 @@
                 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 @@
     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 @@
 
         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 @@
 
         // 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 @@
 
         // 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 @@
         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 @@
         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 @@
         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 @@
 
         // 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 @@
 
         // 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 @@
 
         // 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 @@
 
         // 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 @@
         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 @@
         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 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 @@
 
         // Expect failure - callbacks not registered
         try {
-            mIkeSessionStateMachine.closeChildSession(mock(IChildSessionCallback.class));
+            mIkeSessionStateMachine.closeChildSession(mock(ChildSessionCallback.class));
         } catch (IllegalArgumentException expected) {
         }
     }
@@ -3737,7 +3741,7 @@
     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 @@
 
         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 @@
 
         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 @@
 
         // 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 @@
         mLooper.dispatchAll();
 
         assertNull(mIkeSessionStateMachine.getCurrentState());
-        verify(mMockIkeSessionCallback).onError(any(IkeInternalException.class));
+        verify(mMockIkeSessionCallback).onClosedExceptionally(any(IkeInternalException.class));
     }
 
     @Test
@@ -3970,7 +3975,7 @@
 
         // 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 @@
 
         // 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 43881d1..28a1311 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 @@
     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 @@
         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 {