--- /home/cmeng/source/smack/Smack-4.4.git/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java	2021-08-23 04:45:44.000000000 
+++ /home/cmeng/workspace/android/atalk-android/aTalk/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java	2024-03-13 14:51:16.000000000 
@@ -232,19 +232,19 @@
      *
      * @throws InterruptedException if the calling thread was interrupted.
      * @throws CorruptedOmemoKeyException if the OMEMO key is corrupted.
      * @throws XMPPException.XMPPErrorException if there was an XMPP error returned.
      * @throws SmackException.NotConnectedException if the XMPP connection is not connected.
      * @throws SmackException.NoResponseException if there was no response from the remote entity.
-     * @throws PubSubException.NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node.
+     * @throws NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node.
      * @throws IOException if an I/O error occurred.
      */
     void init(OmemoManager.LoggedInOmemoManager managerGuard)
             throws InterruptedException, CorruptedOmemoKeyException, XMPPException.XMPPErrorException,
             SmackException.NotConnectedException, SmackException.NoResponseException,
-            PubSubException.NotALeafNodeException, IOException {
+            NotALeafNodeException, IOException {
 
         OmemoManager manager = managerGuard.get();
         OmemoDevice userDevice = manager.getOwnDevice();
 
         // Create new keys if necessary and publish to the server.
         getOmemoStoreBackend().replenishKeys(userDevice);
@@ -550,19 +550,19 @@
      * @return OmemoBundle of the device or null, if it doesn't exist.
      *
      * @throws SmackException.NotConnectedException if the XMPP connection is not connected.
      * @throws InterruptedException if the calling thread was interrupted.
      * @throws SmackException.NoResponseException if there was no response from the remote entity.
      * @throws XMPPException.XMPPErrorException if there was an XMPP error returned.
-     * @throws PubSubException.NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node.
+     * @throws NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node.
      * @throws PubSubException.NotAPubSubNodeException if a involved node is not a PubSub node.
      */
     private static OmemoBundleElement fetchBundle(XMPPConnection connection,
                                                   OmemoDevice contactsDevice)
             throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException,
-            XMPPException.XMPPErrorException, PubSubException.NotALeafNodeException,
+            XMPPException.XMPPErrorException, NotALeafNodeException,
             PubSubException.NotAPubSubNodeException {
 
         PubSubManager pm = PubSubManager.getInstanceFor(connection, contactsDevice.getJid());
         LeafNode node = pm.getLeafNode(contactsDevice.getBundleNodeName());
 
         if (node == null) {
@@ -591,31 +591,33 @@
      * @throws NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node.
      */
     static void publishBundle(XMPPConnection connection, OmemoDevice userDevice, OmemoBundleElement bundle)
             throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException,
             SmackException.NoResponseException, NotALeafNodeException {
         PepManager pm = PepManager.getInstanceFor(connection);
+        LOGGER.log(Level.INFO, "Start OmemoService.publishBundle()");
+        connection.setReplyTimeout(OmemoManager.SMACK_REPLY_OMEMO_PUBLISH);
         pm.publish(userDevice.getBundleNodeName(), new PayloadItem<>(bundle));
     }
 
     /**
      * Retrieve the OMEMO device list of a contact.
      *
      * @param connection authenticated XMPP connection.
      * @param contact BareJid of the contact of which we want to retrieve the device list from.
      * @return device list
      *
      * @throws InterruptedException if the calling thread was interrupted.
-     * @throws PubSubException.NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node.
+     * @throws NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node.
      * @throws SmackException.NoResponseException if there was no response from the remote entity.
      * @throws SmackException.NotConnectedException if the XMPP connection is not connected.
      * @throws XMPPException.XMPPErrorException if there was an XMPP error returned.
      * @throws PubSubException.NotAPubSubNodeException if a involved node is not a PubSub node.
      */
     private static OmemoDeviceListElement fetchDeviceList(XMPPConnection connection, BareJid contact)
-            throws InterruptedException, PubSubException.NotALeafNodeException, SmackException.NoResponseException,
+            throws InterruptedException, NotALeafNodeException, SmackException.NoResponseException,
             SmackException.NotConnectedException, XMPPException.XMPPErrorException,
             PubSubException.NotAPubSubNodeException {
 
         PubSubManager pm = PubSubManager.getInstanceFor(connection, contact);
         String nodeName = OmemoConstants.PEP_NODE_DEVICE_LIST;
         LeafNode node = pm.getLeafNode(nodeName);
@@ -639,13 +641,13 @@
      * @param deviceList users deviceList.
      *
      * @throws InterruptedException if the calling thread was interrupted.
      * @throws XMPPException.XMPPErrorException if there was an XMPP error returned.
      * @throws SmackException.NotConnectedException if the XMPP connection is not connected.
      * @throws SmackException.NoResponseException if there was no response from the remote entity.
-     * @throws PubSubException.NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node.
+     * @throws NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node.
      */
     static void publishDeviceList(XMPPConnection connection, OmemoDeviceListElement deviceList)
             throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException,
             SmackException.NoResponseException, NotALeafNodeException {
         PepManager pm = PepManager.getInstanceFor(connection);
         pm.publish(OmemoConstants.PEP_NODE_DEVICE_LIST, new PayloadItem<>(deviceList));
@@ -655,20 +657,20 @@
      * Refresh our own device list and publish it to the server.
      *
      * @param connection XMPPConnection
      * @param userDevice our OMEMO device
      *
      * @throws InterruptedException if the calling thread was interrupted.
-     * @throws PubSubException.NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node.
+     * @throws NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node.
      * @throws XMPPException.XMPPErrorException if there was an XMPP error returned.
      * @throws SmackException.NotConnectedException if the XMPP connection is not connected.
      * @throws SmackException.NoResponseException if there was no response from the remote entity.
      * @throws IOException if an I/O error occurred.
      */
     private void refreshAndRepublishDeviceList(XMPPConnection connection, OmemoDevice userDevice)
-            throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
+            throws InterruptedException, NotALeafNodeException, XMPPException.XMPPErrorException,
             SmackException.NotConnectedException, SmackException.NoResponseException, IOException {
 
         // refreshOmemoDeviceList;
         OmemoDeviceListElement publishedList;
 
         try {
@@ -734,20 +736,20 @@
      * @param connection authenticated XMPP connection
      * @param userDevice our OmemoDevice
      * @param contact contact we want to fetch the deviceList from
      * @return cached device list after refresh.
      *
      * @throws InterruptedException if the calling thread was interrupted.
-     * @throws PubSubException.NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node.
+     * @throws NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node.
      * @throws XMPPException.XMPPErrorException if there was an XMPP error returned.
      * @throws SmackException.NotConnectedException if the XMPP connection is not connected.
      * @throws SmackException.NoResponseException if there was no response from the remote entity.
      * @throws IOException if an I/O error occurred.
      */
     OmemoCachedDeviceList refreshDeviceList(XMPPConnection connection, OmemoDevice userDevice, BareJid contact)
-            throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
+            throws InterruptedException, NotALeafNodeException, XMPPException.XMPPErrorException,
             SmackException.NotConnectedException, SmackException.NoResponseException, IOException {
         // refreshOmemoDeviceList;
         OmemoDeviceListElement publishedList;
         try {
             publishedList = fetchDeviceList(connection, contact);
         } catch (PubSubException.NotAPubSubNodeException e) {
@@ -785,13 +787,13 @@
             return;
         }
 
         OmemoBundleElement bundleElement;
         try {
             bundleElement = fetchBundle(connection, contactsDevice);
-        } catch (XMPPException.XMPPErrorException | PubSubException.NotALeafNodeException |
+        } catch (XMPPException.XMPPErrorException | NotALeafNodeException |
                 PubSubException.NotAPubSubNodeException e) {
             throw new CannotEstablishOmemoSessionException(contactsDevice, e);
         }
 
         // Select random Bundle
         HashMap<Integer, T_Bundle> bundlesList = getOmemoStoreBackend().keyUtil().BUNDLE.bundles(bundleElement, contactsDevice);
@@ -1210,13 +1212,13 @@
                 LOGGER.log(Level.WARNING, "No raw session found for contact " + device + ". ", e);
 
                 if (OmemoConfiguration.getRepairBrokenSessionsWithPreKeyMessages()) {
                     repairBrokenSessionWithPreKeyMessage(managerGuard, device);
                 }
             } catch (CorruptedOmemoKeyException | CryptoFailedException e) {
-                LOGGER.log(Level.WARNING, "Could not decrypt incoming message: ", e);
+                LOGGER.log(Level.WARNING, "Could not decrypt incoming message for " + stanza.getStanzaId() + "; ", e);
             }
 
             // Upload fresh bundle.
             if (getOmemoStoreBackend().loadOmemoPreKeys(userDevice).size() < OmemoConstants.PRE_KEY_COUNT_PER_BUNDLE) {
                 LOGGER.log(Level.FINE, "We used up a preKey. Upload a fresh bundle.");
                 try {
