@Override public void initWithMatrixSession(MXSession matrixSession, String roomId) { mSession = matrixSession; mCrypto = matrixSession.getCrypto(); mRoomId = roomId; mDeviceId = matrixSession.getCredentials().deviceId; // Default rotation periods // TODO: Make it configurable via parameters mSessionRotationPeriodMsgs = 100; mSessionRotationPeriodMs = 7 * 24 * 3600 * 1000; }
Event event = new Event(Event.EVENT_TYPE_CALL_HANGUP, hangupContent, mSession.getCredentials().userId, mCallSignalingRoom.getRoomId());
/** * Send the answer event * * @param sessionDescription the session description */ private void sendAnswer(final SessionDescription sessionDescription) { // check if the call has not been killed if (isCallEnded()) { Log.d(LOG_TAG, "sendAnswer isCallEnded"); return; } Log.d(LOG_TAG, "sendAnswer"); // build the invitation event JsonObject answerContent = new JsonObject(); answerContent.addProperty("version", 0); answerContent.addProperty("call_id", mCallId); answerContent.addProperty("lifetime", CALL_TIMEOUT_MS); JsonObject offerContent = new JsonObject(); offerContent.addProperty("sdp", sessionDescription.description); offerContent.addProperty("type", sessionDescription.type.canonicalForm()); answerContent.add("answer", offerContent); Event event = new Event(Event.EVENT_TYPE_CALL_ANSWER, answerContent, mSession.getCredentials().userId, mCallSignalingRoom.getRoomId()); mPendingEvents.add(event); sendNextEvent(); mIsAnswered = true; }
inviteContent.add("offer", offerContent); Event event = new Event(Event.EVENT_TYPE_CALL_INVITE, inviteContent, mSession.getCredentials().userId, mCallSignalingRoom.getRoomId());
payloadJson.put("sender_device", mSession.getCredentials().deviceId);
/** * Constructor * * @param session the session * @param networkConnectivityReceiver the network events listener */ public BingRulesManager(MXSession session, NetworkConnectivityReceiver networkConnectivityReceiver) { mSession = session; mApiClient = session.getBingRulesApiClient(); mMyUserId = session.getCredentials().userId; mDataHandler = session.getDataHandler(); mNetworkListener = new IMXNetworkEventListener() { @Override public void onNetworkConnectionUpdate(boolean isConnected) { // mLoadRulesCallback is set when a loadRules failed // so when a network is available, trigger again loadRules if (isConnected && (null != mLoadRulesCallback)) { loadRules(mLoadRulesCallback); } } }; mNetworkConnectivityReceiver = networkConnectivityReceiver; networkConnectivityReceiver.addEventListener(mNetworkListener); }
Event event = new Event(eventType, content, mSession.getCredentials().userId, mCallSignalingRoom.getRoomId());
mRoomDecryptors = new HashMap<>(); String deviceId = mSession.getCredentials().deviceId; mSession.getCredentials().deviceId = deviceId = mCryptoStore.getDeviceId(); mSession.getCredentials().deviceId = deviceId = UUID.randomUUID().toString(); Log.d(LOG_TAG, "Warning: No device id in MXCredentials. An id was created. Think of storing it"); mCryptoStore.storeDeviceId(deviceId); keys.put("ed25519:" + mSession.getCredentials().deviceId, mOlmDevice.getDeviceEd25519Key()); keys.put("curve25519:" + mSession.getCredentials().deviceId, mOlmDevice.getDeviceCurve25519Key());
&& !TextUtils.equals(event.getSender(), session.getCredentials().userId);
@Test public void test01_testCryptoNoDeviceId() throws Exception { Log.e(LOG_TAG, "test01_testCryptoNoDeviceId"); Context context = InstrumentationRegistry.getContext(); final Map<String, Object> results = new HashMap<>(); MXSession bobSession = mTestHelper.createAccount(TestConstants.USER_BOB, mCryptoTestHelper.getDefaultSessionParams()); Assert.assertNull(bobSession.getCrypto()); bobSession.getCredentials().deviceId = null; CountDownLatch lock1 = new CountDownLatch(1); bobSession.enableCrypto(true, new TestApiCallback<Void>(lock1) { @Override public void onSuccess(Void info) { results.put("enableCrypto", "enableCrypto"); super.onSuccess(info); } }); mTestHelper.await(lock1); Assert.assertTrue(results.containsKey("enableCrypto")); Assert.assertNotNull(bobSession.getCrypto()); Assert.assertNotNull(bobSession.getCredentials().deviceId); bobSession.clear(context); }
final Context context = InstrumentationRegistry.getContext(); Credentials credentials = from.getCredentials(); HomeServerConnectionConfig hs = createHomeServerConfig(credentials); MXFileStore store = new MXFileStore(hs, false, context);
final MXSession bobSession = cryptoTestData.getSecondSession(); Credentials bobCredentials = bobSession.getCredentials(); bobSession.clear(context);
final Room roomFromAlicePOV = aliceSession.getDataHandler().getRoom(aliceRoomId); String bobDeviceId1 = bobSession.getCredentials().deviceId; String bobId = bobSession.getCredentials().userId; bobSession.logout(context, new TestApiCallback<Void>(lock2) { @Override String bobDeviceId2 = bobSession2.getCredentials().deviceId; Assert.assertNotEquals(bobDeviceId2, bobDeviceId1);
.setDeviceVerification(MXDeviceInfo.DEVICE_VERIFICATION_BLOCKED, bobSession.getCredentials().deviceId, bobSession.getMyUserId(), new TestApiCallback<Void>(lock1b) { @Override .setDeviceVerification(MXDeviceInfo.DEVICE_VERIFICATION_UNVERIFIED, bobSession.getCredentials().deviceId, bobSession.getMyUserId(), new TestApiCallback<Void>(lock2b) { @Override
final Map<String, Object> results = new HashMap<>(); aliceSession.getCredentials().deviceId = "AliceDevice";
Credentials bobCredentials = bobSession.getCredentials(); bobSession.clear(context);
Credentials aliceCredentials = aliceSession.getCredentials();
bobSession.getCredentials().deviceId = "BobDevice";
Assert.assertTrue(results.containsKey("sendEvent")); Credentials aliceCredentials = aliceSession.getCredentials(); Credentials aliceCredentials2 = new Credentials();
Assert.assertTrue(results.containsKey("sendEvent")); Credentials aliceCredentials = aliceSession.getCredentials(); Credentials aliceCredentials2 = new Credentials();