/** * Update the network connectivity receiver. * * @param networkConnectivityReceiver the network connectivity receiver */ public void setNetworkConnectivityReceiver(NetworkConnectivityReceiver networkConnectivityReceiver) { mNetworkConnectivityReceiver = networkConnectivityReceiver; if (null != getCrypto()) { getCrypto().setNetworkConnectivityReceiver(mNetworkConnectivityReceiver); } }
/** * Start the crypto */ private void startCrypto(final boolean isInitialSync) { if ((null != getCrypto()) && !getCrypto().isStarted() && !getCrypto().isStarting()) { getCrypto().setNetworkConnectivityReceiver(mNetworkConnectivityReceiver); getCrypto().start(isInitialSync, new ApiCallback<Void>() { @Override public void onSuccess(Void info) { onCryptoSyncComplete(); } private void onError(String errorMessage) { Log.e(LOG_TAG, "## onInitialSyncComplete() : getCrypto().start fails " + errorMessage); } @Override public void onNetworkError(Exception e) { onError(e.getMessage()); } @Override public void onMatrixError(MatrixError e) { onError(e.getMessage()); } @Override public void onUnexpectedError(Exception e) { onError(e.getMessage()); } }); } }
/** * Decrypt an encrypted event * * @param event the event to decrypt * @param timelineId the timeline identifier * @return true if the event has been decrypted */ public boolean decryptEvent(Event event, String timelineId) { if ((null != event) && TextUtils.equals(event.getType(), Event.EVENT_TYPE_MESSAGE_ENCRYPTED)) { if (null != getCrypto()) { MXEventDecryptionResult result = null; try { result = getCrypto().decryptEvent(event, timelineId); } catch (MXDecryptionException exception) { event.setCryptoError(exception.getCryptoError()); } if (null != result) { event.setClearData(result); return true; } } else { event.setCryptoError(new MXCryptoError(MXCryptoError.ENCRYPTING_NOT_ENABLED_ERROR_CODE, MXCryptoError.ENCRYPTING_NOT_ENABLED_REASON, null)); } } return false; }
if (null != mDataHandler.getCrypto() && !TextUtils.isEmpty(algorithm)) { Map<String, Object> params = new HashMap<>(); params.put("algorithm", algorithm); if (null == mDataHandler.getCrypto()) { callback.onMatrixError(new MXCryptoError(MXCryptoError.ENCRYPTING_NOT_ENABLED_ERROR_CODE, MXCryptoError.ENCRYPTING_NOT_ENABLED_REASON, MXCryptoError.ENCRYPTING_NOT_ENABLED_REASON));
if (null != dataHandler.getCrypto()) { dataHandler.decryptEvent(indexedEvent, mEventTimeline.getTimelineId());
} else if (mDataHandler.getCrypto() != mCrypto) { Log.e(LOG_TAG, "## checkCrypto() : the data handler crypto was not initialized"); mDataHandler.setCrypto(mCrypto);