Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/0.9.34'
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarty committed May 13, 2020
2 parents c1a911a + f9f1a3a commit 353034e
Show file tree
Hide file tree
Showing 55 changed files with 809 additions and 885 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

* [ ] Pull request is based on the develop branch
* [ ] Pull request updates [CHANGES.rst](https://github.com/matrix-org/matrix-android-sdk/blob/develop/CHANGES.rst)
* [ ] Pull request includes a [sign off](https://github.com/matrix-org/synapse/blob/master/CONTRIBUTING.rst#sign-off)
* [ ] Pull request includes a [sign off](https://github.com/matrix-org/synapse/blob/master/CONTRIBUTING.md#sign-off)
24 changes: 24 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
Changes to Matrix Android SDK in 0.9.34 (2020-05-13)
=======================================================

Features:
- MSC2437: Store tagged events in Room Account Data

Improvements:
- Enhance the room account data API naming.
- MXSession: Do not refresh TURN servers when VoIP is not supported

Bugfix:
- Fix issue with identity server (missing access token) (vector-im/riot-android#3404)
- Fix crash in MXCryptoImpl (vector-im/riot-android#3396)

API Change:
- RoomAccountdata.hasTags() has been deprecated. Use .hasRoomTags() instead.
- RoomAccountdata.getKeys() has been deprecated. Use .getRoomTagsKeys() instead.
- RoomAccountdata.handleTagEvent() has been removed. Use .handleEvent() instead.
- IMXStore.setRoomsWithoutURLPreview() has been removed.
- IMXStore.getRoomsWithoutURLPreviews() has been removed. Use RoomAccountdata.isURLPreviewAllowedByUser() instead.

Others:
- Provided support for implementation of reading "im.vector.riot.jitsi" from /.well-known/matrix/client

Changes to Matrix Android SDK in 0.9.33 (2020-02-10)
=======================================================

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Contributing code to Matrix
===========================

Please see https://github.com/matrix-org/synapse/blob/master/CONTRIBUTING.rst
Please see https://github.com/matrix-org/synapse/blob/master/CONTRIBUTING.md
for details on how to contribute code to Matrix.org projects!
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class HomeServerConnectionConfig {

// the home server URI
private Uri mHomeServerUri;
// the jitsi server URI. Can be null
@Nullable
private Uri mJitsiServerUri;
// the identity server URI. Can be null
@Nullable
private Uri mIdentityServerUri;
Expand Down Expand Up @@ -93,6 +96,13 @@ public Uri getHomeserverUri() {
return mHomeServerUri;
}

/**
* @return the jitsi server uri
*/
public Uri getJitsiServerUri() {
return mJitsiServerUri;
}

/**
* @return the identity server uri, or null if not defined
*/
Expand Down Expand Up @@ -163,6 +173,20 @@ public void setCredentials(Credentials credentials) {
mIdentityServerUri = Uri.parse(identityServerUrl);
}
}

if (credentials.wellKnown.jitsiServer != null) {
String jitsiServerUrl = credentials.wellKnown.jitsiServer.preferredDomain;

if (!TextUtils.isEmpty(jitsiServerUrl)) {
// add trailing "/"
if (!jitsiServerUrl.endsWith("/")) {
jitsiServerUrl =jitsiServerUrl + "/";
}

Log.d("setCredentials", "Overriding jitsi server url to " + jitsiServerUrl);
mJitsiServerUri = Uri.parse(jitsiServerUrl);
}
}
}
}

Expand Down Expand Up @@ -223,6 +247,7 @@ public Proxy getProxyConfig() {
public String toString() {
return "HomeserverConnectionConfig{" +
"mHomeServerUri=" + mHomeServerUri +
", mJitsiServerUri=" + mJitsiServerUri +
", mIdentityServerUri=" + mIdentityServerUri +
", mAntiVirusServerUri=" + mAntiVirusServerUri +
", mAllowedFingerprints size=" + mAllowedFingerprints.size() +
Expand All @@ -246,6 +271,10 @@ public JSONObject toJson() throws JSONException {
JSONObject json = new JSONObject();

json.put("home_server_url", mHomeServerUri.toString());
Uri jitsiServerUri = getJitsiServerUri();
if (jitsiServerUri != null) {
json.put("jitsi_server_url", jitsiServerUri.toString());
}
Uri identityServerUri = getIdentityServerUri();
if (identityServerUri != null) {
json.put("identity_server_url", identityServerUri.toString());
Expand Down Expand Up @@ -316,6 +345,7 @@ public static HomeServerConnectionConfig fromJson(JSONObject jsonObject) throws

Builder builder = new Builder()
.withHomeServerUri(Uri.parse(jsonObject.getString("home_server_url")))
.withJitsiServerUri(jsonObject.has("jitsi_server_url") ? Uri.parse(jsonObject.getString("jitsi_server_url")) : null)
.withIdentityServerUri(jsonObject.has("identity_server_url") ? Uri.parse(jsonObject.getString("identity_server_url")) : null)
.withCredentials(creds)
.withPin(jsonObject.optBoolean("pin", false));
Expand Down Expand Up @@ -413,6 +443,37 @@ public Builder withHomeServerUri(final Uri homeServerUri) {
return this;
}

/**
* @param jitsiServerUri The URI to use to manage identity. Can be null
* @return this builder
*/
public Builder withJitsiServerUri(@Nullable final Uri jitsiServerUri) {
if (jitsiServerUri != null
&& !jitsiServerUri.toString().isEmpty()
&& !"http".equals(jitsiServerUri.getScheme())
&& !"https".equals(jitsiServerUri.getScheme())) {
throw new RuntimeException("Invalid jitsi server URI: " + jitsiServerUri);
}

// add trailing /
if ((null != jitsiServerUri) && !jitsiServerUri.toString().endsWith("/")) {
try {
String url = jitsiServerUri.toString();
mHomeServerConnectionConfig.mJitsiServerUri = Uri.parse(url + "/");
} catch (Exception e) {
throw new RuntimeException("Invalid jitsi server URI: " + jitsiServerUri);
}
} else {
if (jitsiServerUri != null && jitsiServerUri.toString().isEmpty()) {
mHomeServerConnectionConfig.mJitsiServerUri = null;
} else {
mHomeServerConnectionConfig.mJitsiServerUri = jitsiServerUri;
}
}

return this;
}

/**
* @param identityServerUri The URI to use to manage identity. Can be null
* @return this builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ import com.google.gson.annotations.SerializedName
* }
* ]
* }
* "im.vector.riot.jitsi": {
* "preferredDomain": "https://jitsi.riot.im/"
* }
* }
* </pre>
*/
Expand Down Expand Up @@ -81,4 +84,8 @@ class WellKnown {
}
return managers
}

@JvmField
@SerializedName("im.vector.riot.jitsi")
var jitsiServer: WellKnownPreferredConfig? = null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.androidsdk.rest.model

import com.google.gson.annotations.SerializedName

/**
* https://matrix.org/docs/spec/client_server/r0.4.0.html#server-discovery
* <pre>
* {
* "preferredDomain": "https://jitsi.riot.im/"
* }
* </pre>
*/
class WellKnownPreferredConfig {

@JvmField
@SerializedName("preferredDomain")
var preferredDomain: String? = null
}

Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.text.TextUtils;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
Expand Down Expand Up @@ -297,6 +298,10 @@ public MXCryptoImpl(@NonNull CryptoSession matrixSession,
myDevices.put(mMyDevice.deviceId, mMyDevice);

mCryptoStore.storeUserDevices(mSession.getMyUserId(), myDevices);

// Create the VerificationManager before setting the CryptoEventsListener, to avoid crash (vector-im/riot-android#3396)
mShortCodeVerificationManager = new VerificationManager(mSession);

mSession.getDataHandler().setCryptoEventsListener(mEventListener);

mEncryptingHandlerThread = new HandlerThread("MXCrypto_encrypting_" + mSession.getMyUserId(), Thread.MIN_PRIORITY);
Expand All @@ -318,7 +323,6 @@ public MXCryptoImpl(@NonNull CryptoSession matrixSession,
mReceivedRoomKeyRequests.addAll(mCryptoStore.getPendingIncomingRoomKeyRequests());

mKeysBackup = new KeysBackup(this, homeServerConnectionConfig);
mShortCodeVerificationManager = new VerificationManager(mSession);
}

/**
Expand Down Expand Up @@ -1610,7 +1614,10 @@ public Map<String, Map<String, String>> signObject(String strToSign) {
* @param event the event
*/
private void onToDeviceEvent(final CryptoEvent event) {
mShortCodeVerificationManager.onToDeviceEvent(event);
// It should not happen anymore
if (mShortCodeVerificationManager != null) {
mShortCodeVerificationManager.onToDeviceEvent(event);
}

if (TextUtils.equals(event.getType(), CryptoEvent.EVENT_TYPE_ROOM_KEY)
|| TextUtils.equals(event.getType(), CryptoEvent.EVENT_TYPE_FORWARDED_ROOM_KEY)) {
Expand Down
4 changes: 2 additions & 2 deletions matrix-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 933
versionName "0.9.33"
versionCode 934
versionName "0.9.34"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

// Enable multi dex for test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2027,6 +2027,10 @@ public void onRoomTagEvent(final String roomId) {
mMxEventDispatcher.dispatchOnRoomTagEvent(roomId, ignoreEvent(roomId));
}

public void onTaggedEventsEvent(final String roomId) {
mMxEventDispatcher.dispatchOnTaggedEventsEvent(roomId, ignoreEvent(roomId));
}

public void onReadMarkerEvent(final String roomId) {
mMxEventDispatcher.dispatchOnReadMarkerEvent(roomId, ignoreEvent(roomId));
}
Expand Down
8 changes: 4 additions & 4 deletions matrix-sdk/src/main/java/org/matrix/androidsdk/MXSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ public void startEventStream(String initialToken) {
* Gracefully stop the event stream.
*/
public void stopEventStream() {
if (null != mCallsManager) {
if (isVoipCallSupported()) {
mCallsManager.stopTurnServerRefresh();
}

Expand All @@ -1198,7 +1198,7 @@ public void stopEventStream() {
public void pauseEventStream() {
checkIfAlive();

if (null != mCallsManager) {
if (isVoipCallSupported()) {
mCallsManager.pauseTurnServerRefresh();
}

Expand Down Expand Up @@ -1237,7 +1237,7 @@ public void resumeEventStream() {
mNetworkConnectivityReceiver.checkNetworkConnection(mContext);
}

if (null != mCallsManager) {
if (isVoipCallSupported()) {
mCallsManager.unpauseTurnServerRefresh();
}

Expand Down Expand Up @@ -1752,7 +1752,7 @@ public List<Room> roomsWithTag(final String tag) {
} else {
final Collection<Room> rooms = mDataHandler.getStore().getRooms();
for (Room room : rooms) {
if (!room.getAccountData().hasTags()) {
if (!room.getAccountData().hasRoomTags()) {
taggedRooms.add(room);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,27 @@ public void run() {
});
}

public void dispatchOnTaggedEventsEvent(final String roomId, boolean ignoreEvent) {
if (ignoreEvent) {
return;
}

final List<IMXEventListener> eventListeners = getListenersSnapshot();

mUiHandler.post(new Runnable() {
@Override
public void run() {
for (IMXEventListener listener : eventListeners) {
try {
listener.onTaggedEventsEvent(roomId);
} catch (Exception e) {
Log.e(LOG_TAG, "onTaggedEventsEvent " + e.getMessage(), e);
}
}
}
});
}

public void dispatchOnReadMarkerEvent(final String roomId, boolean ignoreEvent) {
if (ignoreEvent) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ public void onLiveEvent(Event event, RoomState roomState) {
}
});

refreshTurnServer();
if (isSupported()) {
refreshTurnServer();
}
}

/**
Expand Down
12 changes: 12 additions & 0 deletions matrix-sdk/src/main/java/org/matrix/androidsdk/core/JsonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.matrix.androidsdk.rest.model.RoomTags;
import org.matrix.androidsdk.rest.model.RoomTombstoneContent;
import org.matrix.androidsdk.rest.model.StateEvent;
import org.matrix.androidsdk.rest.model.TaggedEventsContent;
import org.matrix.androidsdk.rest.model.User;
import org.matrix.androidsdk.rest.model.bingrules.Condition;
import org.matrix.androidsdk.rest.model.login.RegistrationFlowResponse;
Expand Down Expand Up @@ -457,6 +458,17 @@ public static RoomPinnedEventsContent toRoomPinnedEventsContent(final JsonElemen
return toClass(jsonElement, RoomPinnedEventsContent.class);
}

/**
* Convert a JSON object to a TaggedEventsContent.
* The result is never null.
*
* @param jsonObject the json to convert
* @return a TaggedEventsContent
*/
public static TaggedEventsContent toTaggedEventsContent(JsonElement jsonObject) {
return toClass(jsonObject, TaggedEventsContent.class);
}

/**
* Convert a JSON object into a class instance.
* The returned value cannot be null.
Expand Down
Loading

0 comments on commit 353034e

Please sign in to comment.