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.28'
Browse files Browse the repository at this point in the history
  • Loading branch information
BillCarsonFr committed Oct 3, 2019
2 parents 3b808f6 + 0fabb2f commit 35d5ad5
Show file tree
Hide file tree
Showing 221 changed files with 4,284 additions and 1,600 deletions.
54 changes: 53 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
Changes to Matrix Android SDK in 0.9.28 (2019-10-03)
=======================================================

Improvements:
- Display correctly the revoked third-party invites.
- Support optional default STUN server when no ICE provided by HS
- Use wellknown to discover the IS of a HS (vector-im/riot-android#3283)
- Make identity server configurable
- Privacy: MSC2290 (#3300)

API Change:
- `MXSession.openIdToken()` callback has a more typed parameter
- DefaultRetrofit2CallbackWrapper has been removed because it does not manage MatrixError. Use RestAdapterCallback instead.
- IMXEventListener.onAccountDataUpdated() method now has a parameter: the account data which has been updated.
- Third party identifiers (mail, phone) related calls (add/bind) are now delegated to the IdentityServerManager instead of
directly from MyUser. Now use mxSession.getIdentityManager().xxx
- Room#invite now requires the session (to delegate to correct identity server)

Translations:
- Emoji verification name discrepancy between riot-web and riotX (vector-im/riotX-android#355)

Others:
- Remove ParentRestClient from crypto module and use a common parent Rest Client (dinsic-pim/tchap-android#539)
- MXSession: Add doesServerRequireIdentityServerParam() and doesServerAcceptIdentityAccessToken() methods.
- Remove the bind true flag from 3PID calls on registration (vector-im/riot-android#3252)

Changes to Matrix Android SDK in 0.9.27 (2019-08-28)
=======================================================

/!\ Security:
- The homeserver access token was incorrectly included in requests sent to the Identity Server, a separate service.
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).

Features:
- Allow Matrix SDK client to configure the filter used for pagination (vector-im/riot-android#3237)

Improvements:
- Add a TermsManager (vector-im/riot-android#3225)

Bugfix:
- Stop sending the access token of the homeserver to the identity server
- VoIP: Stop falling back to Google for STUN (vector-im/riot-android#3223).
- EventIDs: Add regex to match eventIDs for v4 and v5 rooms
- Failed to send a message in a new joined room (invited by email)

Others:
- Remove useless log (vector-im/riot-android#3236)

Build:
- Migrate to androidx (following https://developer.android.com/jetpack/androidx/migrate)
- WebRTC: upgrade webrtc library, using the one build along with Jitsi

Changes to Matrix Android SDK in 0.9.26 (2019-07-24)
=======================================================

Expand Down Expand Up @@ -1558,4 +1610,4 @@ Build:
-

Test:
-
-
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ allprojects {
includeGroupByRegex "org\\.matrix\\.gitlab\\.matrix-org"
}
}
// Jitsi repo
maven {
url "https://github.com/vector-im/jitsi_libre_maven/raw/master/releases"
}
google()
jcenter()
mavenCentral()
maven {
url "https://github.com/jitsi/jitsi-maven-repository/raw/master/releases"
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
# SONAR_LOGIN=sonar_login

org.gradle.configureondemand=false
android.useAndroidX=true
android.enableJetifier=true
14 changes: 8 additions & 6 deletions matrix-sdk-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

compileOptions {
Expand Down Expand Up @@ -41,14 +41,16 @@ dependencies {
implementation "com.google.code.gson:gson:$gson_version"
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'

implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'

implementation "com.android.support:appcompat-v7:$support_lib_version"
implementation "com.android.support:preference-v7:$support_lib_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.preference:preference:1.0.0'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.matrix.androidsdk.core.interceptors;

import android.support.annotation.NonNull;
import androidx.annotation.NonNull;

import org.json.JSONArray;
import org.json.JSONException;
Expand Down
8 changes: 7 additions & 1 deletion matrix-sdk-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
<manifest package="org.matrix.androidsdk.core" />
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.matrix.androidsdk.core">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
package org.matrix.androidsdk;

import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.text.TextUtils;

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

// the home server URI
private Uri mHomeServerUri;
// the identity server URI
// the identity server URI. Can be null
@Nullable
private Uri mIdentityServerUri;
// the anti-virus server URI
private Uri mAntiVirusServerUri;
Expand Down Expand Up @@ -85,14 +86,11 @@ public Uri getHomeserverUri() {
}

/**
* @return the identity server uri
* @return the identity server uri, or null if not defined
*/
@Nullable
public Uri getIdentityServerUri() {
if (null != mIdentityServerUri) {
return mIdentityServerUri;
}
// Else consider the HS uri by default.
return mHomeServerUri;
return mIdentityServerUri;
}

/**
Expand Down Expand Up @@ -223,7 +221,11 @@ public JSONObject toJson() throws JSONException {
JSONObject json = new JSONObject();

json.put("home_server_url", mHomeServerUri.toString());
json.put("identity_server_url", getIdentityServerUri().toString());
Uri identityServerUri = getIdentityServerUri();
if (identityServerUri != null) {
json.put("identity_server_url", identityServerUri.toString());
}

if (mAntiVirusServerUri != null) {
json.put("antivirus_server_url", mAntiVirusServerUri.toString());
}
Expand Down Expand Up @@ -378,7 +380,10 @@ public Builder withHomeServerUri(final Uri homeServerUri) {
* @return this builder
*/
public Builder withIdentityServerUri(@Nullable final Uri identityServerUri) {
if ((null != identityServerUri) && (!"http".equals(identityServerUri.getScheme()) && !"https".equals(identityServerUri.getScheme()))) {
if (identityServerUri != null
&& !identityServerUri.toString().isEmpty()
&& !"http".equals(identityServerUri.getScheme())
&& !"https".equals(identityServerUri.getScheme())) {
throw new RuntimeException("Invalid identity server URI: " + identityServerUri);
}

Expand All @@ -391,7 +396,11 @@ public Builder withIdentityServerUri(@Nullable final Uri identityServerUri) {
throw new RuntimeException("Invalid identity server URI: " + identityServerUri);
}
} else {
mHomeServerConnectionConfig.mIdentityServerUri = identityServerUri;
if (identityServerUri != null && identityServerUri.toString().isEmpty()) {
mHomeServerConnectionConfig.mIdentityServerUri = null;
} else {
mHomeServerConnectionConfig.mIdentityServerUri = identityServerUri;
}
}

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.google.gson.Gson;

import org.matrix.androidsdk.core.JsonUtils;
import org.matrix.androidsdk.core.Log;
import org.matrix.androidsdk.core.PolymorphicRequestBodyConverter;
import org.matrix.androidsdk.core.UnsentEventsManager;
import org.matrix.androidsdk.core.json.GsonProvider;
import org.matrix.androidsdk.core.listeners.IMXNetworkEventListener;
import org.matrix.androidsdk.crypto.rest.ParentRestClient;
import org.matrix.androidsdk.network.NetworkConnectivityReceiver;
import org.matrix.androidsdk.rest.model.login.Credentials;

Expand Down Expand Up @@ -61,8 +61,15 @@ public class RestClient<T> {
/**
* Prefix used in path of identity server API requests.
*/
public static final String URI_IDENTITY_PATH = "_matrix/identity/api/v1";
public static final String URI_API_PREFIX_IDENTITY = URI_IDENTITY_PATH + "/";
public static final String URI_IDENTITY_PATH = "_matrix/identity/api/v1/";
public static final String URI_IDENTITY_PATH_V2 = "_matrix/identity/v2/";

public static final String URI_API_PREFIX_IDENTITY = "_matrix/identity/api/v1";

/**
* Prefix used for integration manager
*/
public static final String URI_INTEGRATION_MANAGER_PATH = "_matrix/integrations/v1/";

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

protected static final int CONNECTION_TIMEOUT_MS = 30000;

private Credentials mCredentials;
private String mAccessToken;

protected T mApi;

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

// http client
private OkHttpClient mOkHttpClient = new OkHttpClient();
private OkHttpClient mOkHttpClient;

public RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uriPrefix) {
this(hsConfig, type, uriPrefix, JsonUtils.getKotlinGson(), EndPointServer.HOME_SERVER);
this(hsConfig, type, uriPrefix, GsonProvider.provideGson(), EndPointServer.HOME_SERVER);
}

public RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uriPrefix, boolean withNullSerialization) {
this(hsConfig, type, uriPrefix, withNullSerialization, EndPointServer.HOME_SERVER);
public RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uriPrefix, Gson gson) {
this(hsConfig, type, uriPrefix, gson, EndPointServer.HOME_SERVER);
}

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

/**
Expand All @@ -119,17 +126,18 @@ public RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uri
* @param hsConfig the home server configuration.
* @param type the REST type
* @param uriPrefix the URL request prefix
* @param withNullSerialization true to serialise class member with null value
* @param gson the gson parser
* @param endPointServer tell which server is used to define the base url
*/
public RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uriPrefix, boolean withNullSerialization, EndPointServer endPointServer) {
this(hsConfig, type, uriPrefix, JsonUtils.getGson(withNullSerialization), endPointServer);
}

// Private constructor with Gson instance as a parameter
private RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uriPrefix, Gson gson, EndPointServer endPointServer) {
public RestClient(HomeServerConnectionConfig hsConfig, Class<T> type, String uriPrefix, Gson gson, EndPointServer endPointServer) {
mHsConfig = hsConfig;
mCredentials = hsConfig.getCredentials();

if (endPointServer == EndPointServer.HOME_SERVER) {
Credentials credentials = hsConfig.getCredentials();
if (credentials != null) {
mAccessToken = credentials.accessToken;
}
}

Interceptor authenticationInterceptor = new Interceptor() {

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

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

request = newRequestBuilder.build();
Expand Down Expand Up @@ -210,9 +218,11 @@ private String sanitizeDynamicPath(String dynamicPath) {
* Ex: Riot/0.8.12 (Linux; U; Android 6.0.1; SM-A510F Build/MMB29; Flavour FDroid; MatrixAndroidSDK 0.9.6)
*
* @param appContext the application context
* @param versionName the application version name. Can be BuildConfig.VERSION_NAME by instance
* @param flavorDescription the flavor description
*/
public static void initUserAgent(@Nullable Context appContext,
@NonNull String versionName,
@NonNull String flavorDescription) {
String appName = "";
String appVersion = "";
Expand Down Expand Up @@ -249,16 +259,14 @@ public static void initUserAgent(@Nullable Context appContext,
// if there is no user agent or cannot parse it
if ((null == sUserAgent) || (sUserAgent.lastIndexOf(")") == -1) || !sUserAgent.contains("(")) {
sUserAgent = appName + "/" + appVersion + " ( Flavour " + flavorDescription
+ "; MatrixAndroidSDK " + BuildConfig.VERSION_NAME + ")";
+ "; MatrixAndroidSDK " + versionName + ")";
} else {
// update
sUserAgent = appName + "/" + appVersion + " " +
sUserAgent.substring(sUserAgent.indexOf("("), sUserAgent.lastIndexOf(")") - 1) +
"; Flavour " + flavorDescription +
"; MatrixAndroidSDK " + BuildConfig.VERSION_NAME + ")";
"; MatrixAndroidSDK " + versionName + ")";
}

ParentRestClient.initUserAgent(sUserAgent);
}

/**
Expand Down Expand Up @@ -346,21 +354,12 @@ public void onNetworkConnectionUpdate(boolean isConnected) {
}

/**
* Get the user's credentials. Typically for saving them somewhere persistent.
*
* @return the user credentials
*/
public Credentials getCredentials() {
return mCredentials;
}

/**
* Provide the user's credentials. To be called after login or registration.
* Update the Access Token of the Rest Client. To be called after login or registration.
*
* @param credentials the user credentials
* @param newAccessToken the new Access Token
*/
public void setCredentials(Credentials credentials) {
mCredentials = credentials;
public void setAccessToken(String newAccessToken) {
mAccessToken = newAccessToken;
}

}
Loading

0 comments on commit 35d5ad5

Please sign in to comment.