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

Commit 35d5ad5

Browse files
committed
Merge branch 'release/0.9.28'
2 parents 3b808f6 + 0fabb2f commit 35d5ad5

File tree

221 files changed

+4284
-1600
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+4284
-1600
lines changed

CHANGES.rst

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,55 @@
1+
Changes to Matrix Android SDK in 0.9.28 (2019-10-03)
2+
=======================================================
3+
4+
Improvements:
5+
- Display correctly the revoked third-party invites.
6+
- Support optional default STUN server when no ICE provided by HS
7+
- Use wellknown to discover the IS of a HS (vector-im/riot-android#3283)
8+
- Make identity server configurable
9+
- Privacy: MSC2290 (#3300)
10+
11+
API Change:
12+
- `MXSession.openIdToken()` callback has a more typed parameter
13+
- DefaultRetrofit2CallbackWrapper has been removed because it does not manage MatrixError. Use RestAdapterCallback instead.
14+
- IMXEventListener.onAccountDataUpdated() method now has a parameter: the account data which has been updated.
15+
- Third party identifiers (mail, phone) related calls (add/bind) are now delegated to the IdentityServerManager instead of
16+
directly from MyUser. Now use mxSession.getIdentityManager().xxx
17+
- Room#invite now requires the session (to delegate to correct identity server)
18+
19+
Translations:
20+
- Emoji verification name discrepancy between riot-web and riotX (vector-im/riotX-android#355)
21+
22+
Others:
23+
- Remove ParentRestClient from crypto module and use a common parent Rest Client (dinsic-pim/tchap-android#539)
24+
- MXSession: Add doesServerRequireIdentityServerParam() and doesServerAcceptIdentityAccessToken() methods.
25+
- Remove the bind true flag from 3PID calls on registration (vector-im/riot-android#3252)
26+
27+
Changes to Matrix Android SDK in 0.9.27 (2019-08-28)
28+
=======================================================
29+
30+
/!\ Security:
31+
- The homeserver access token was incorrectly included in requests sent to the Identity Server, a separate service.
32+
The client should prompt the user to logout and login again to renew the token, unless the user is happy to trust the Identity Server provider with their access token (e.g. if the homeserver and identity server are operated by the same provider).
33+
34+
Features:
35+
- Allow Matrix SDK client to configure the filter used for pagination (vector-im/riot-android#3237)
36+
37+
Improvements:
38+
- Add a TermsManager (vector-im/riot-android#3225)
39+
40+
Bugfix:
41+
- Stop sending the access token of the homeserver to the identity server
42+
- VoIP: Stop falling back to Google for STUN (vector-im/riot-android#3223).
43+
- EventIDs: Add regex to match eventIDs for v4 and v5 rooms
44+
- Failed to send a message in a new joined room (invited by email)
45+
46+
Others:
47+
- Remove useless log (vector-im/riot-android#3236)
48+
49+
Build:
50+
- Migrate to androidx (following https://developer.android.com/jetpack/androidx/migrate)
51+
- WebRTC: upgrade webrtc library, using the one build along with Jitsi
52+
153
Changes to Matrix Android SDK in 0.9.26 (2019-07-24)
254
=======================================================
355

@@ -1558,4 +1610,4 @@ Build:
15581610
-
15591611

15601612
Test:
1561-
-
1613+
-

build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ allprojects {
3434
includeGroupByRegex "org\\.matrix\\.gitlab\\.matrix-org"
3535
}
3636
}
37+
// Jitsi repo
38+
maven {
39+
url "https://github.com/vector-im/jitsi_libre_maven/raw/master/releases"
40+
}
3741
google()
3842
jcenter()
3943
mavenCentral()
40-
maven {
41-
url "https://github.com/jitsi/jitsi-maven-repository/raw/master/releases"
42-
}
4344
}
4445
}
4546

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@
2121
# SONAR_LOGIN=sonar_login
2222

2323
org.gradle.configureondemand=false
24+
android.useAndroidX=true
25+
android.enableJetifier=true

matrix-sdk-core/build.gradle

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ android {
1111
versionCode 1
1212
versionName "1.0"
1313

14-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1515
}
1616

1717
compileOptions {
@@ -41,14 +41,16 @@ dependencies {
4141
implementation "com.google.code.gson:gson:$gson_version"
4242
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
4343
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
44+
implementation 'com.facebook.stetho:stetho:1.5.0'
45+
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'
4446

45-
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
47+
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
4648
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
4749

48-
implementation "com.android.support:appcompat-v7:$support_lib_version"
49-
implementation "com.android.support:preference-v7:$support_lib_version"
50+
implementation 'androidx.appcompat:appcompat:1.0.2'
51+
implementation 'androidx.preference:preference:1.0.0'
5052

5153
testImplementation 'junit:junit:4.12'
52-
androidTestImplementation 'com.android.support.test:runner:1.0.2'
53-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
54+
androidTestImplementation 'androidx.test:runner:1.2.0'
55+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
5456
}

matrix-sdk-core/src/debug/java/org/matrix/androidsdk/core/interceptors/FormattedJsonHttpLogger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package org.matrix.androidsdk.core.interceptors;
1818

19-
import android.support.annotation.NonNull;
19+
import androidx.annotation.NonNull;
2020

2121
import org.json.JSONArray;
2222
import org.json.JSONException;
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
<manifest package="org.matrix.androidsdk.core" />
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="org.matrix.androidsdk.core">
4+
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
7+
</manifest>

matrix-sdk/src/main/java/org/matrix/androidsdk/HomeServerConnectionConfig.java renamed to matrix-sdk-core/src/main/java/org/matrix/androidsdk/HomeServerConnectionConfig.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
package org.matrix.androidsdk;
1919

2020
import android.net.Uri;
21-
import android.support.annotation.NonNull;
22-
import android.support.annotation.Nullable;
21+
import androidx.annotation.NonNull;
22+
import androidx.annotation.Nullable;
2323
import android.text.TextUtils;
2424

2525
import org.json.JSONArray;
@@ -42,7 +42,8 @@ public class HomeServerConnectionConfig {
4242

4343
// the home server URI
4444
private Uri mHomeServerUri;
45-
// the identity server URI
45+
// the identity server URI. Can be null
46+
@Nullable
4647
private Uri mIdentityServerUri;
4748
// the anti-virus server URI
4849
private Uri mAntiVirusServerUri;
@@ -85,14 +86,11 @@ public Uri getHomeserverUri() {
8586
}
8687

8788
/**
88-
* @return the identity server uri
89+
* @return the identity server uri, or null if not defined
8990
*/
91+
@Nullable
9092
public Uri getIdentityServerUri() {
91-
if (null != mIdentityServerUri) {
92-
return mIdentityServerUri;
93-
}
94-
// Else consider the HS uri by default.
95-
return mHomeServerUri;
93+
return mIdentityServerUri;
9694
}
9795

9896
/**
@@ -223,7 +221,11 @@ public JSONObject toJson() throws JSONException {
223221
JSONObject json = new JSONObject();
224222

225223
json.put("home_server_url", mHomeServerUri.toString());
226-
json.put("identity_server_url", getIdentityServerUri().toString());
224+
Uri identityServerUri = getIdentityServerUri();
225+
if (identityServerUri != null) {
226+
json.put("identity_server_url", identityServerUri.toString());
227+
}
228+
227229
if (mAntiVirusServerUri != null) {
228230
json.put("antivirus_server_url", mAntiVirusServerUri.toString());
229231
}
@@ -378,7 +380,10 @@ public Builder withHomeServerUri(final Uri homeServerUri) {
378380
* @return this builder
379381
*/
380382
public Builder withIdentityServerUri(@Nullable final Uri identityServerUri) {
381-
if ((null != identityServerUri) && (!"http".equals(identityServerUri.getScheme()) && !"https".equals(identityServerUri.getScheme()))) {
383+
if (identityServerUri != null
384+
&& !identityServerUri.toString().isEmpty()
385+
&& !"http".equals(identityServerUri.getScheme())
386+
&& !"https".equals(identityServerUri.getScheme())) {
382387
throw new RuntimeException("Invalid identity server URI: " + identityServerUri);
383388
}
384389

@@ -391,7 +396,11 @@ public Builder withIdentityServerUri(@Nullable final Uri identityServerUri) {
391396
throw new RuntimeException("Invalid identity server URI: " + identityServerUri);
392397
}
393398
} else {
394-
mHomeServerConnectionConfig.mIdentityServerUri = identityServerUri;
399+
if (identityServerUri != null && identityServerUri.toString().isEmpty()) {
400+
mHomeServerConnectionConfig.mIdentityServerUri = null;
401+
} else {
402+
mHomeServerConnectionConfig.mIdentityServerUri = identityServerUri;
403+
}
395404
}
396405

397406
return this;

matrix-sdk/src/main/java/org/matrix/androidsdk/RestClient.java renamed to matrix-sdk-core/src/main/java/org/matrix/androidsdk/RestClient.java

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@
2121
import android.content.pm.ApplicationInfo;
2222
import android.content.pm.PackageInfo;
2323
import android.content.pm.PackageManager;
24-
import android.support.annotation.NonNull;
25-
import android.support.annotation.Nullable;
2624
import android.text.TextUtils;
2725

26+
import androidx.annotation.NonNull;
27+
import androidx.annotation.Nullable;
28+
2829
import com.google.gson.Gson;
2930

30-
import org.matrix.androidsdk.core.JsonUtils;
3131
import org.matrix.androidsdk.core.Log;
3232
import org.matrix.androidsdk.core.PolymorphicRequestBodyConverter;
3333
import org.matrix.androidsdk.core.UnsentEventsManager;
34+
import org.matrix.androidsdk.core.json.GsonProvider;
3435
import org.matrix.androidsdk.core.listeners.IMXNetworkEventListener;
35-
import org.matrix.androidsdk.crypto.rest.ParentRestClient;
3636
import org.matrix.androidsdk.network.NetworkConnectivityReceiver;
3737
import org.matrix.androidsdk.rest.model.login.Credentials;
3838

@@ -61,8 +61,15 @@ public class RestClient<T> {
6161
/**
6262
* Prefix used in path of identity server API requests.
6363
*/
64-
public static final String URI_IDENTITY_PATH = "_matrix/identity/api/v1";
65-
public static final String URI_API_PREFIX_IDENTITY = URI_IDENTITY_PATH + "/";
64+
public static final String URI_IDENTITY_PATH = "_matrix/identity/api/v1/";
65+
public static final String URI_IDENTITY_PATH_V2 = "_matrix/identity/v2/";
66+
67+
public static final String URI_API_PREFIX_IDENTITY = "_matrix/identity/api/v1";
68+
69+
/**
70+
* Prefix used for integration manager
71+
*/
72+
public static final String URI_INTEGRATION_MANAGER_PATH = "_matrix/integrations/v1/";
6673

6774
/**
6875
* List the servers which should be used to define the base url.
@@ -75,7 +82,7 @@ public enum EndPointServer {
7582

7683
protected static final int CONNECTION_TIMEOUT_MS = 30000;
7784

78-
private Credentials mCredentials;
85+
private String mAccessToken;
7986

8087
protected T mApi;
8188

@@ -90,14 +97,14 @@ public enum EndPointServer {
9097
private static String sUserAgent = null;
9198

9299
// http client
93-
private OkHttpClient mOkHttpClient = new OkHttpClient();
100+
private OkHttpClient mOkHttpClient;
94101

95102
public RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uriPrefix) {
96-
this(hsConfig, type, uriPrefix, JsonUtils.getKotlinGson(), EndPointServer.HOME_SERVER);
103+
this(hsConfig, type, uriPrefix, GsonProvider.provideGson(), EndPointServer.HOME_SERVER);
97104
}
98105

99-
public RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uriPrefix, boolean withNullSerialization) {
100-
this(hsConfig, type, uriPrefix, withNullSerialization, EndPointServer.HOME_SERVER);
106+
public RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uriPrefix, Gson gson) {
107+
this(hsConfig, type, uriPrefix, gson, EndPointServer.HOME_SERVER);
101108
}
102109

103110
/**
@@ -106,11 +113,11 @@ public RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uri
106113
* @param hsConfig the home server configuration.
107114
* @param type the REST type
108115
* @param uriPrefix the URL request prefix
109-
* @param withNullSerialization true to serialise class member with null value
116+
* @param gson the gson parser
110117
* @param useIdentityServer true to use the identity server URL as base request
111118
*/
112-
public RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uriPrefix, boolean withNullSerialization, boolean useIdentityServer) {
113-
this(hsConfig, type, uriPrefix, withNullSerialization, useIdentityServer ? EndPointServer.IDENTITY_SERVER : EndPointServer.HOME_SERVER);
119+
public RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uriPrefix, Gson gson, boolean useIdentityServer) {
120+
this(hsConfig, type, uriPrefix, gson, useIdentityServer ? EndPointServer.IDENTITY_SERVER : EndPointServer.HOME_SERVER);
114121
}
115122

116123
/**
@@ -119,17 +126,18 @@ public RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uri
119126
* @param hsConfig the home server configuration.
120127
* @param type the REST type
121128
* @param uriPrefix the URL request prefix
122-
* @param withNullSerialization true to serialise class member with null value
129+
* @param gson the gson parser
123130
* @param endPointServer tell which server is used to define the base url
124131
*/
125-
public RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uriPrefix, boolean withNullSerialization, EndPointServer endPointServer) {
126-
this(hsConfig, type, uriPrefix, JsonUtils.getGson(withNullSerialization), endPointServer);
127-
}
128-
129-
// Private constructor with Gson instance as a parameter
130-
private RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uriPrefix, Gson gson, EndPointServer endPointServer) {
132+
public RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uriPrefix, Gson gson, EndPointServer endPointServer) {
131133
mHsConfig = hsConfig;
132-
mCredentials = hsConfig.getCredentials();
134+
135+
if (endPointServer == EndPointServer.HOME_SERVER) {
136+
Credentials credentials = hsConfig.getCredentials();
137+
if (credentials != null) {
138+
mAccessToken = credentials.accessToken;
139+
}
140+
}
133141

134142
Interceptor authenticationInterceptor = new Interceptor() {
135143

@@ -143,8 +151,8 @@ public Response intercept(Chain chain) throws IOException {
143151
}
144152

145153
// Add the access token to all requests if it is set
146-
if ((mCredentials != null) && (mCredentials.accessToken != null)) {
147-
newRequestBuilder.addHeader("Authorization", "Bearer " + mCredentials.accessToken);
154+
if (mAccessToken != null) {
155+
newRequestBuilder.addHeader("Authorization", "Bearer " + mAccessToken);
148156
}
149157

150158
request = newRequestBuilder.build();
@@ -210,9 +218,11 @@ private String sanitizeDynamicPath(String dynamicPath) {
210218
* Ex: Riot/0.8.12 (Linux; U; Android 6.0.1; SM-A510F Build/MMB29; Flavour FDroid; MatrixAndroidSDK 0.9.6)
211219
*
212220
* @param appContext the application context
221+
* @param versionName the application version name. Can be BuildConfig.VERSION_NAME by instance
213222
* @param flavorDescription the flavor description
214223
*/
215224
public static void initUserAgent(@Nullable Context appContext,
225+
@NonNull String versionName,
216226
@NonNull String flavorDescription) {
217227
String appName = "";
218228
String appVersion = "";
@@ -249,16 +259,14 @@ public static void initUserAgent(@Nullable Context appContext,
249259
// if there is no user agent or cannot parse it
250260
if ((null == sUserAgent) || (sUserAgent.lastIndexOf(")") == -1) || !sUserAgent.contains("(")) {
251261
sUserAgent = appName + "/" + appVersion + " ( Flavour " + flavorDescription
252-
+ "; MatrixAndroidSDK " + BuildConfig.VERSION_NAME + ")";
262+
+ "; MatrixAndroidSDK " + versionName + ")";
253263
} else {
254264
// update
255265
sUserAgent = appName + "/" + appVersion + " " +
256266
sUserAgent.substring(sUserAgent.indexOf("("), sUserAgent.lastIndexOf(")") - 1) +
257267
"; Flavour " + flavorDescription +
258-
"; MatrixAndroidSDK " + BuildConfig.VERSION_NAME + ")";
268+
"; MatrixAndroidSDK " + versionName + ")";
259269
}
260-
261-
ParentRestClient.initUserAgent(sUserAgent);
262270
}
263271

264272
/**
@@ -346,21 +354,12 @@ public void onNetworkConnectionUpdate(boolean isConnected) {
346354
}
347355

348356
/**
349-
* Get the user's credentials. Typically for saving them somewhere persistent.
350-
*
351-
* @return the user credentials
352-
*/
353-
public Credentials getCredentials() {
354-
return mCredentials;
355-
}
356-
357-
/**
358-
* Provide the user's credentials. To be called after login or registration.
357+
* Update the Access Token of the Rest Client. To be called after login or registration.
359358
*
360-
* @param credentials the user credentials
359+
* @param newAccessToken the new Access Token
361360
*/
362-
public void setCredentials(Credentials credentials) {
363-
mCredentials = credentials;
361+
public void setAccessToken(String newAccessToken) {
362+
mAccessToken = newAccessToken;
364363
}
365364

366365
}

0 commit comments

Comments
 (0)