From 690c7e58556335220791af156660a65af1fdebd6 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Mon, 19 Mar 2018 11:19:39 +0100 Subject: [android] - verify optional before accessing it --- platform/android/src/file_source.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/platform/android/src/file_source.cpp b/platform/android/src/file_source.cpp index 612619a30b..d8d715dbd3 100644 --- a/platform/android/src/file_source.cpp +++ b/platform/android/src/file_source.cpp @@ -70,14 +70,16 @@ void FileSource::resume(jni::JNIEnv&) { activationCounter.value()++; if (activationCounter == 1) { - fileSource->resume(); + fileSource->resume(); } } void FileSource::pause(jni::JNIEnv&) { - activationCounter.value()--; - if (activationCounter == 0) { - fileSource->pause(); + if (activationCounter) { + activationCounter.value()--; + if (activationCounter == 0) { + fileSource->pause(); + } } } -- cgit v1.2.1 From 58e4d395bfd2a7c9871dcef81c32141f5308f4e4 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Mon, 26 Mar 2018 09:40:38 -0400 Subject: [android] - don't load default style if style json string was set (#11519) --- .../java/com/mapbox/mapboxsdk/maps/MapboxMap.java | 8 +-- .../mapboxsdk/testapp/style/StyleLoaderTest.java | 77 ++++++++++++++++++++++ 2 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/StyleLoaderTest.java diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index ba116e1278..85ac99a188 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -111,7 +111,7 @@ public final class MapboxMap { void onStart() { nativeMapView.update(); trackingSettings.onStart(); - if (TextUtils.isEmpty(nativeMapView.getStyleUrl())) { + if (TextUtils.isEmpty(nativeMapView.getStyleUrl()) && TextUtils.isEmpty(nativeMapView.getStyleJson())) { // if user hasn't loaded a Style yet nativeMapView.setStyleUrl(Style.MAPBOX_STREETS); } @@ -1882,7 +1882,6 @@ public final class MapboxMap { * * @param listener The callback that's invoked when the map is scrolled. * To unset the callback, use null. - * * @deprecated Use {@link #addOnScrollListener(OnScrollListener)} instead. */ @Deprecated @@ -1895,7 +1894,6 @@ public final class MapboxMap { * * @param listener The callback that's invoked when the map is scrolled. * To unset the callback, use null. - * */ public void addOnScrollListener(@Nullable OnScrollListener listener) { onRegisterTouchListener.onAddScrollListener(listener); @@ -1906,7 +1904,6 @@ public final class MapboxMap { * * @param listener The callback that's invoked when the map is scrolled. * To unset the callback, use null. - * */ public void removeOnScrollListener(@Nullable OnScrollListener listener) { onRegisterTouchListener.onRemoveScrollListener(listener); @@ -1917,7 +1914,6 @@ public final class MapboxMap { * * @param listener The callback that's invoked when the map is flinged. * To unset the callback, use null. - * * @deprecated Use {@link #addOnFlingListener(OnFlingListener)} instead. */ @Deprecated @@ -1950,7 +1946,6 @@ public final class MapboxMap { * * @param listener The callback that's invoked when the user clicks on the map view. * To unset the callback, use null. - * * @deprecated Use {@link #addOnMapClickListener(OnMapClickListener)} instead. */ @Deprecated @@ -1983,7 +1978,6 @@ public final class MapboxMap { * * @param listener The callback that's invoked when the user long clicks on the map view. * To unset the callback, use null. - * * @deprecated Use {@link #addOnMapLongClickListener(OnMapLongClickListener)} instead. */ @Deprecated diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/StyleLoaderTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/StyleLoaderTest.java new file mode 100644 index 0000000000..1a5201193c --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/StyleLoaderTest.java @@ -0,0 +1,77 @@ +package com.mapbox.mapboxsdk.testapp.style; + + +import android.support.test.espresso.UiController; + +import com.mapbox.mapboxsdk.maps.MapView; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction; +import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; +import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; +import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils; + +import org.junit.Test; + +import java.io.IOException; + +import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; +import static org.junit.Assert.assertEquals; + +/** + * Tests around style loading + */ +public class StyleLoaderTest extends BaseActivityTest { + + + @Override + protected Class getActivityClass() { + return EspressoTestActivity.class; + } + + @Test + public void testSetGetStyleJsonString() throws Exception { + validateTestSetup(); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + try { + String expected = ResourceUtils.readRawResource(rule.getActivity(), R.raw.local_style); + mapboxMap.setStyleJson(expected); + String actual = mapboxMap.getStyleJson(); + assertEquals("Style json should match", expected, actual); + } catch (IOException exception) { + exception.printStackTrace(); + } + } + }); + } + + @Test + public void testDefaultStyleLoadWithActivityLifecycleChange() throws Exception { + validateTestSetup(); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + try { + String expected = ResourceUtils.readRawResource(rule.getActivity(), R.raw.local_style); + mapboxMap.setStyleJson(expected); + + // fake activity stop/start + MapView mapView = (MapView) rule.getActivity().findViewById(R.id.mapView); + mapView.onPause(); + mapView.onStop(); + + mapView.onStart(); + mapView.onResume(); + + String actual = mapboxMap.getStyleJson(); + assertEquals("Style URL should be empty", "", mapboxMap.getStyleUrl()); + assertEquals("Style json should match", expected, actual); + } catch (IOException exception) { + exception.printStackTrace(); + } + } + }); + } +} \ No newline at end of file -- cgit v1.2.1 From 69dfd1ed3eaf279a6fadcf6482145532a93db846 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Thu, 1 Mar 2018 11:04:32 +0100 Subject: [android] - delete local ref pixel buffer when converting Image.java to core --- platform/android/src/map/image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/android/src/map/image.cpp b/platform/android/src/map/image.cpp index 52e0e0d255..c3b22b0054 100644 --- a/platform/android/src/map/image.cpp +++ b/platform/android/src/map/image.cpp @@ -29,7 +29,7 @@ mbgl::style::Image Image::getImage(jni::JNIEnv& env, jni::Object image) { } jni::GetArrayRegion(env, *pixels, 0, size, reinterpret_cast(premultipliedImage.data.get())); - + jni::DeleteLocalRef(env, pixels); return mbgl::style::Image {name, std::move(premultipliedImage), pixelRatio}; } -- cgit v1.2.1 From 804738fe145c43628648c8dd352d649b57bc7037 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Fri, 2 Mar 2018 10:21:43 +0100 Subject: [android] - use float for pixelratio when creating a snapshotter --- .../main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java index 1c59bb468e..161b4c7380 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java @@ -82,7 +82,7 @@ public class MapSnapshotter { * MapSnapshotter options */ public static class Options { - private int pixelRatio = 1; + private float pixelRatio = 1; private int width; private int height; private String styleUrl = Style.MAPBOX_STREETS; @@ -122,7 +122,7 @@ public class MapSnapshotter { * @param pixelRatio the pixel ratio to use (default: 1) * @return the mutated {@link Options} */ - public Options withPixelRatio(int pixelRatio) { + public Options withPixelRatio(float pixelRatio) { this.pixelRatio = pixelRatio; return this; } @@ -164,7 +164,7 @@ public class MapSnapshotter { /** * @return the pixel ratio */ - public int getPixelRatio() { + public float getPixelRatio() { return pixelRatio; } -- cgit v1.2.1 From 3a1db905fc2258a67385a742393893d982ca896c Mon Sep 17 00:00:00 2001 From: Tobrun Date: Fri, 2 Mar 2018 10:05:04 +0100 Subject: [android] - validate if width and height aren't 0 when creating options class --- .../src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java index 161b4c7380..0895096f6e 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java @@ -95,6 +95,9 @@ public class MapSnapshotter { * @param height the height of the image */ public Options(int width, int height) { + if (width == 0 || height == 0) { + throw new IllegalArgumentException("Unable to create a snapshot with width or height set to 0"); + } this.width = width; this.height = height; } -- cgit v1.2.1 From f2eb250518b3ca6d8956936362cc9568c277d609 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Thu, 8 Mar 2018 07:30:31 +0100 Subject: [android] - check for null body on http request, cleanup code --- .../com/mapbox/mapboxsdk/http/HTTPRequest.java | 168 +++++++++++---------- platform/android/src/http_file_source.cpp | 2 +- 2 files changed, 91 insertions(+), 79 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java index 129e75965e..3491ec5c85 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java @@ -3,11 +3,14 @@ package com.mapbox.mapboxsdk.http; import android.content.Context; import android.content.pm.PackageInfo; import android.os.Build; +import android.support.annotation.NonNull; import android.text.TextUtils; +import android.util.Log; import com.mapbox.mapboxsdk.BuildConfig; import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.constants.MapboxConstants; +import com.mapbox.services.android.telemetry.utils.TelemetryUtils; import java.io.IOException; import java.io.InterruptedIOException; @@ -26,55 +29,42 @@ import okhttp3.HttpUrl; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import timber.log.Timber; -import static com.mapbox.services.android.telemetry.utils.TelemetryUtils.toHumanReadableAscii; +import okhttp3.ResponseBody; +import timber.log.Timber; import static android.util.Log.DEBUG; +import static android.util.Log.ERROR; import static android.util.Log.INFO; +import static android.util.Log.VERBOSE; import static android.util.Log.WARN; class HTTPRequest implements Callback { - private static OkHttpClient mClient = new OkHttpClient.Builder().dispatcher(getDispatcher()).build(); - private static boolean logEnabled = true; - private static boolean logRequestUrl = false; - - private String USER_AGENT_STRING = null; - private static final int CONNECTION_ERROR = 0; private static final int TEMPORARY_ERROR = 1; private static final int PERMANENT_ERROR = 2; - // Reentrancy is not needed, but "Lock" is an - // abstract class. - private ReentrantLock mLock = new ReentrantLock(); - - private long mNativePtr = 0; - - private Call mCall; - private Request mRequest; - - private static Dispatcher getDispatcher() { - Dispatcher dispatcher = new Dispatcher(); - // Matches core limit set on - // https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/src/http_file_source.cpp#L192 - dispatcher.setMaxRequestsPerHost(20); - return dispatcher; - } - - private native void nativeOnFailure(int type, String message); + private static OkHttpClient client = new OkHttpClient.Builder().dispatcher(getDispatcher()).build(); + private static boolean logEnabled = true; + private static boolean logRequestUrl = false; - private native void nativeOnResponse(int code, String etag, String modified, String cacheControl, String expires, - String retryAfter, String xRateLimitReset, byte[] body); + // Reentrancy is not needed, but "Lock" is an abstract class. + private ReentrantLock lock = new ReentrantLock(); + private String userAgentString; + private long nativePtr = 0; + private Call call; private HTTPRequest(long nativePtr, String resourceUrl, String etag, String modified) { - mNativePtr = nativePtr; + this.nativePtr = nativePtr; try { HttpUrl httpUrl = HttpUrl.parse(resourceUrl); - final String host = httpUrl.host().toLowerCase(MapboxConstants.MAPBOX_LOCALE); + if (httpUrl == null) { + log(Log.ERROR, String.format("[HTTP] Unable to parse resourceUrl %s", resourceUrl)); + } + final String host = httpUrl.host().toLowerCase(MapboxConstants.MAPBOX_LOCALE); // Don't try a request to remote server if we aren't connected if (!Mapbox.isConnected() && !host.equals("127.0.0.1") && !host.equals("localhost")) { throw new NoRouteToHostException("No Internet connection available."); @@ -99,18 +89,18 @@ class HTTPRequest implements Callback { } else if (modified.length() > 0) { builder = builder.addHeader("If-Modified-Since", modified); } - mRequest = builder.build(); - mCall = mClient.newCall(mRequest); - mCall.enqueue(this); + Request request = builder.build(); + call = client.newCall(request); + call.enqueue(this); } catch (Exception exception) { - handleFailure(mCall, exception); + handleFailure(call, exception); } } public void cancel() { - // mCall can be null if the constructor gets aborted (e.g, under a NoRouteToHostException). - if (mCall != null) { - mCall.cancel(); + // call can be null if the constructor gets aborted (e.g, under a NoRouteToHostException). + if (call != null) { + call.cancel(); } // TODO: We need a lock here because we can try @@ -118,37 +108,40 @@ class HTTPRequest implements Callback { // answered on the OkHTTP thread. We could get rid of // this lock by using Runnable when we move Android // implementation of mbgl::RunLoop to Looper. - mLock.lock(); - mNativePtr = 0; - mLock.unlock(); + lock.lock(); + nativePtr = 0; + lock.unlock(); } @Override - public void onResponse(Call call, Response response) throws IOException { + public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException { + if (response.isSuccessful()) { + log(VERBOSE, String.format("[HTTP] Request was successful (code = %s).", response.code())); + } else { + // We don't want to call this unsuccessful because a 304 isn't really an error + String message = !TextUtils.isEmpty(response.message()) ? response.message() : "No additional information"; + log(DEBUG, String.format("[HTTP] Request with response code = %s: %s", response.code(), message)); + } - if (logEnabled) { - if (response.isSuccessful()) { - Timber.v("[HTTP] Request was successful (code = %s).", response.code()); - } else { - // We don't want to call this unsuccessful because a 304 isn't really an error - String message = !TextUtils.isEmpty(response.message()) ? response.message() : "No additional information"; - Timber.d("[HTTP] Request with response code = %s: %s", response.code(), message); - } + ResponseBody responseBody = response.body(); + if (responseBody == null) { + log(ERROR, "[HTTP] Received empty response body"); + return; } byte[] body; try { - body = response.body().bytes(); + body = responseBody.bytes(); } catch (IOException ioException) { onFailure(call, ioException); // throw ioException; return; } finally { - response.body().close(); + response.close(); } - mLock.lock(); - if (mNativePtr != 0) { + lock.lock(); + if (nativePtr != 0) { nativeOnResponse(response.code(), response.header("ETag"), response.header("Last-Modified"), @@ -158,14 +151,34 @@ class HTTPRequest implements Callback { response.header("x-rate-limit-reset"), body); } - mLock.unlock(); + lock.unlock(); } @Override - public void onFailure(Call call, IOException e) { + public void onFailure(@NonNull Call call, @NonNull IOException e) { handleFailure(call, e); } + static void enableLog(boolean enabled) { + logEnabled = enabled; + } + + static void enablePrintRequestUrlOnFailure(boolean enabled) { + logRequestUrl = enabled; + } + + static void setOKHttpClient(OkHttpClient client) { + HTTPRequest.client = client; + } + + private static Dispatcher getDispatcher() { + Dispatcher dispatcher = new Dispatcher(); + // Matches core limit set on + // https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/src/http_file_source.cpp#L192 + dispatcher.setMaxRequestsPerHost(20); + return dispatcher; + } + private void handleFailure(Call call, Exception e) { String errorMessage = e.getMessage() != null ? e.getMessage() : "Error processing the request"; int type = getFailureType(e); @@ -175,11 +188,11 @@ class HTTPRequest implements Callback { logFailure(type, errorMessage, requestUrl); } - mLock.lock(); - if (mNativePtr != 0) { + lock.lock(); + if (nativePtr != 0) { nativeOnFailure(type, errorMessage); } - mLock.unlock(); + lock.unlock(); } private int getFailureType(Exception e) { @@ -192,19 +205,26 @@ class HTTPRequest implements Callback { return PERMANENT_ERROR; } + private void log(int type, String errorMessage) { + if (logEnabled) { + Timber.log(type, errorMessage); + } + } + private void logFailure(int type, String errorMessage, String requestUrl) { - Timber.log( - type == TEMPORARY_ERROR ? DEBUG : type == CONNECTION_ERROR ? INFO : WARN, - "Request failed due to a %s error: %s %s", - type == TEMPORARY_ERROR ? "temporary" : type == CONNECTION_ERROR ? "connection" : "permanent", - errorMessage, - logRequestUrl ? requestUrl : "" + log(type == TEMPORARY_ERROR ? DEBUG : type == CONNECTION_ERROR ? INFO : WARN, + String.format( + "Request failed due to a %s error: %s %s", + type == TEMPORARY_ERROR ? "temporary" : type == CONNECTION_ERROR ? "connection" : "permanent", + errorMessage, + logRequestUrl ? requestUrl : "" + ) ); } private String getUserAgent() { - if (USER_AGENT_STRING == null) { - return USER_AGENT_STRING = toHumanReadableAscii( + if (userAgentString == null) { + userAgentString = TelemetryUtils.toHumanReadableAscii( String.format("%s %s (%s) Android/%s (%s)", getApplicationIdentifier(), BuildConfig.MAPBOX_VERSION_STRING, @@ -212,9 +232,8 @@ class HTTPRequest implements Callback { Build.VERSION.SDK_INT, Build.CPU_ABI) ); - } else { - return USER_AGENT_STRING; } + return userAgentString; } private String getApplicationIdentifier() { @@ -227,15 +246,8 @@ class HTTPRequest implements Callback { } } - static void enableLog(boolean enabled) { - logEnabled = enabled; - } - - static void enablePrintRequestUrlOnFailure(boolean enabled) { - logRequestUrl = enabled; - } + private native void nativeOnFailure(int type, String message); - static void setOKHttpClient(OkHttpClient client) { - mClient = client; - } + private native void nativeOnResponse(int code, String etag, String modified, String cacheControl, String expires, + String retryAfter, String xRateLimitReset, byte[] body); } diff --git a/platform/android/src/http_file_source.cpp b/platform/android/src/http_file_source.cpp index 8eb9416e9d..cda84209ea 100644 --- a/platform/android/src/http_file_source.cpp +++ b/platform/android/src/http_file_source.cpp @@ -61,7 +61,7 @@ void RegisterNativeHTTPRequest(jni::JNIEnv& env) { #define METHOD(MethodPtr, name) jni::MakeNativePeerMethod(name) - jni::RegisterNativePeer(env, HTTPRequest::javaClass, "mNativePtr", + jni::RegisterNativePeer(env, HTTPRequest::javaClass, "nativePtr", METHOD(&HTTPRequest::onFailure, "nativeOnFailure"), METHOD(&HTTPRequest::onResponse, "nativeOnResponse")); } -- cgit v1.2.1 From b411eedf501e6c1b7bae712c201723a5b4e812ba Mon Sep 17 00:00:00 2001 From: Tobrun Date: Mon, 26 Mar 2018 12:15:05 -0400 Subject: [android] - update changelog v5.5.1 --- platform/android/CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md index d0d29eabf6..dc7ff98828 100644 --- a/platform/android/CHANGELOG.md +++ b/platform/android/CHANGELOG.md @@ -2,6 +2,15 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to do so please see the [`Contributing Guide`](https://github.com/mapbox/mapbox-gl-native/blob/master/CONTRIBUTING.md) first to get started. +## 5.5.1 - March 26, 2018 + - Verify optional access of FileSource deactivation [#11480](https://github.com/mapbox/mapbox-gl-native/pull/11480) + - Prevent default style loading when style json was set [#11519](https://github.com/mapbox/mapbox-gl-native/pull/11519) + - Delete local reference when convering Image.java [#11350](https://github.com/mapbox/mapbox-gl-native/pull/11350) + - Use float for pixel ratio when creating a snapshotter [#11367](https://github.com/mapbox/mapbox-gl-native/pull/11367) + - Validate if width and height aren't 0 when creating a snapshot [#11364](https://github.com/mapbox/mapbox-gl-native/pull/11364) + - Null check body of http request [#11413](https://github.com/mapbox/mapbox-gl-native/pull/11413) + - Clamp TileJSON bounds [#11425](https://github.com/mapbox/mapbox-gl-native/pull/11425) + ## 5.5.0 - March 1, 2018 - TileJSON Bounds allows values inclusive of world extents [#11178](https://github.com/mapbox/mapbox-gl-native/pull/11178) - LatLngBounds returned by VisibleRegion when map is rotated [#11226](https://github.com/mapbox/mapbox-gl-native/pull/11226) -- cgit v1.2.1 From dc874f2d5f246b14145332b05656494116565253 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Mon, 26 Mar 2018 12:19:42 -0400 Subject: [android] - bump snapshot version --- platform/android/MapboxGLAndroidSDK/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/android/MapboxGLAndroidSDK/gradle.properties b/platform/android/MapboxGLAndroidSDK/gradle.properties index f5dc431d40..de93849169 100644 --- a/platform/android/MapboxGLAndroidSDK/gradle.properties +++ b/platform/android/MapboxGLAndroidSDK/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.mapbox.mapboxsdk -VERSION_NAME=5.5.1-SNAPSHOT +VERSION_NAME=5.5.2-SNAPSHOT POM_DESCRIPTION=Mapbox GL Android SDK POM_URL=https://github.com/mapbox/mapbox-gl-native -- cgit v1.2.1 From 4ba63d541b61502abcfdb5f21319d6fa21f92feb Mon Sep 17 00:00:00 2001 From: Anand Thakker Date: Thu, 5 Apr 2018 10:57:52 -0400 Subject: Remove unused lambda capture (#11601) Fixes #11588 --- platform/node/src/node_thread_pool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/node/src/node_thread_pool.cpp b/platform/node/src/node_thread_pool.cpp index fd6df575fc..1f37565e8a 100644 --- a/platform/node/src/node_thread_pool.cpp +++ b/platform/node/src/node_thread_pool.cpp @@ -6,7 +6,7 @@ namespace node_mbgl { NodeThreadPool::NodeThreadPool() - : queue(new util::AsyncQueue>(uv_default_loop(), [this](std::weak_ptr mailbox) { + : queue(new util::AsyncQueue>(uv_default_loop(), [](std::weak_ptr mailbox) { Worker* worker = new Worker(mailbox); Nan::AsyncQueueWorker(worker); })) { -- cgit v1.2.1 From f55a324917e979e85b97ba56b6de765ca1cf4267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Paczos?= Date: Tue, 10 Apr 2018 15:32:32 +0200 Subject: [android] - fixed scale animation focal point (#11643) --- .../src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java index 1788cb4428..07106689be 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java @@ -662,7 +662,8 @@ final class MapGestureDetector { @Override public void onAnimationUpdate(ValueAnimator animation) { - transform.setZoom((Float) animation.getAnimatedValue(), scalePointBegin, 0, true); + PointF scalePoint = focalPoint != null ? focalPoint : scalePointBegin; + transform.setZoom((Float) animation.getAnimatedValue(), scalePoint, 0, true); } }); animator.addListener(new AnimatorListenerAdapter() { -- cgit v1.2.1 From 88d21e17dc218638fad232c050e67797a3c5cb9d Mon Sep 17 00:00:00 2001 From: Tobrun Date: Tue, 10 Apr 2018 11:10:14 +0200 Subject: [android] - add paused state to map renderer, don't render snapshot when paused (#11358) --- .../com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java | 8 ++++++-- .../activity/imagegenerator/SnapshotActivity.java | 8 ++++++++ platform/android/src/map_renderer.cpp | 16 ++++++++++++++-- platform/android/src/map_renderer.hpp | 5 +++++ platform/android/src/native_map_view.hpp | 1 - 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java index fcee5bd179..f1c70325a0 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java @@ -37,11 +37,11 @@ public abstract class MapRenderer implements MapRendererScheduler { } public void onPause() { - // Implement if needed + nativeOnPause(); } public void onResume() { - // Implement if needed + nativeOnResume(); } public void onStop() { @@ -124,6 +124,10 @@ public abstract class MapRenderer implements MapRendererScheduler { private native void nativeRender(); + private native void nativeOnResume(); + + private native void nativeOnPause(); + private long frames; private long timeElapsed; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java index 655012f799..0910045885 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java @@ -17,6 +17,8 @@ import com.mapbox.mapboxsdk.testapp.R; import java.util.Locale; +import timber.log.Timber; + /** * Test activity showcasing the Snapshot API to create and display a bitmap of the current shown Map. */ @@ -79,6 +81,12 @@ public class SnapshotActivity extends AppCompatActivity implements OnMapReadyCal @Override protected void onPause() { super.onPause(); + mapboxMap.snapshot(new MapboxMap.SnapshotReadyCallback() { + @Override + public void onSnapshotReady(Bitmap snapshot) { + Timber.e("Regression test for https://github.com/mapbox/mapbox-gl-native/pull/11358"); + } + }); mapView.onPause(); } diff --git a/platform/android/src/map_renderer.cpp b/platform/android/src/map_renderer.cpp index 2440ac93ef..f7e16b7091 100644 --- a/platform/android/src/map_renderer.cpp +++ b/platform/android/src/map_renderer.cpp @@ -136,7 +136,7 @@ void MapRenderer::render(JNIEnv&) { renderer->render(*params); // Deliver the snapshot if requested - if (snapshotCallback) { + if (snapshotCallback && !paused) { snapshotCallback->operator()(backend->readFramebuffer()); snapshotCallback.reset(); } @@ -174,6 +174,14 @@ void MapRenderer::onSurfaceChanged(JNIEnv&, jint width, jint height) { requestRender(); } +void MapRenderer::onResume(JNIEnv&) { + paused = false; +} + +void MapRenderer::onPause(JNIEnv&) { + paused = true; +} + // Static methods // jni::Class MapRenderer::javaClass; @@ -192,7 +200,11 @@ void MapRenderer::registerNative(jni::JNIEnv& env) { METHOD(&MapRenderer::onSurfaceCreated, "nativeOnSurfaceCreated"), METHOD(&MapRenderer::onSurfaceChanged, - "nativeOnSurfaceChanged")); + "nativeOnSurfaceChanged"), + METHOD(&MapRenderer::onResume, + "nativeOnResume"), + METHOD(&MapRenderer::onPause, + "nativeOnPause")); } MapRenderer& MapRenderer::getNativePeer(JNIEnv& env, jni::Object jObject) { diff --git a/platform/android/src/map_renderer.hpp b/platform/android/src/map_renderer.hpp index c36357af7a..5fb5ef1a61 100644 --- a/platform/android/src/map_renderer.hpp +++ b/platform/android/src/map_renderer.hpp @@ -98,6 +98,10 @@ private: void onSurfaceChanged(JNIEnv&, jint width, jint height); + void onResume(JNIEnv&); + + void onPause(JNIEnv&); + private: GenericUniqueWeakObject javaPeer; @@ -120,6 +124,7 @@ private: std::mutex updateMutex; bool framebufferSizeChanged = false; + std::atomic paused {false}; std::unique_ptr snapshotCallback; }; diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp index d7e3b17b99..1b6371d726 100755 --- a/platform/android/src/native_map_view.hpp +++ b/platform/android/src/native_map_view.hpp @@ -257,7 +257,6 @@ private: MapRenderer& mapRenderer; std::string styleUrl; - std::string apiKey; float pixelRatio; -- cgit v1.2.1 From 46d3756cbd537fdde57f6ec64497b97c6050cb4d Mon Sep 17 00:00:00 2001 From: Ivo van Dongen Date: Tue, 3 Apr 2018 15:59:35 +0300 Subject: [core] re-bind uniform locations after re-linking program - On some gl implementations the uniform locations are shifted after linking the program a second time, resulting in errors when using any uniform. On some implementations they are actually doubled. Re-binding the uniforms after selectively binding the vertex attributes prevents this. --- src/mbgl/gl/program.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mbgl/gl/program.hpp b/src/mbgl/gl/program.hpp index 3b54ec194a..af02ad3d54 100644 --- a/src/mbgl/gl/program.hpp +++ b/src/mbgl/gl/program.hpp @@ -36,8 +36,13 @@ public: context.createShader(ShaderType::Fragment, fragmentSource))), uniformsState((context.linkProgram(program), Uniforms::bindLocations(program))), attributeLocations(Attributes::bindLocations(program)) { + // Re-link program after manually binding only active attributes in Attributes::bindLocations context.linkProgram(program); + + // We have to re-initialize the uniforms state from the bindings as the uniform locations + // get shifted on some implementations + uniformsState = Uniforms::bindLocations(program); } template -- cgit v1.2.1 From 4f809d6626cf661ecc3993f7ffa49b338d8c63ad Mon Sep 17 00:00:00 2001 From: Ivo van Dongen Date: Thu, 5 Apr 2018 16:14:22 +0300 Subject: [android] release local refs early --- platform/android/src/image.cpp | 7 ++++++- platform/android/src/text/local_glyph_rasterizer.cpp | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/android/src/image.cpp b/platform/android/src/image.cpp index 2a33944b18..0456381578 100644 --- a/platform/android/src/image.cpp +++ b/platform/android/src/image.cpp @@ -16,7 +16,12 @@ PremultipliedImage decodeImage(const std::string& string) { reinterpret_cast(string.data())); auto bitmap = android::BitmapFactory::DecodeByteArray(*env, array, 0, string.size()); - return android::Bitmap::GetImage(*env, bitmap); + jni::DeleteLocalRef(*env, array); + + auto image = android::Bitmap::GetImage(*env, bitmap); + jni::DeleteLocalRef(*env, bitmap); + + return image; } } // namespace mbgl diff --git a/platform/android/src/text/local_glyph_rasterizer.cpp b/platform/android/src/text/local_glyph_rasterizer.cpp index ce1b0fc8fd..d232058d15 100644 --- a/platform/android/src/text/local_glyph_rasterizer.cpp +++ b/platform/android/src/text/local_glyph_rasterizer.cpp @@ -46,6 +46,7 @@ PremultipliedImage LocalGlyphRasterizer::drawGlyphBitmap(const std::string& font jniFontFamily, static_cast(bold), static_cast(glyphID)); + jni::DeleteLocalRef(*env, jniFontFamily); PremultipliedImage result = Bitmap::GetImage(*env, javaBitmap); jni::DeleteLocalRef(*env, javaBitmap); -- cgit v1.2.1 From 451e6bc8a0ca3e2d2f1629d5351cc3724648b97e Mon Sep 17 00:00:00 2001 From: Tobrun Date: Thu, 5 Apr 2018 22:37:45 +0200 Subject: [android] - add delete local refs calls for make jni strings --- platform/android/src/offline/offline_manager.cpp | 8 ++++++-- platform/android/src/offline/offline_region.cpp | 12 +++++++++--- platform/android/src/snapshotter/map_snapshotter.cpp | 4 +++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/platform/android/src/offline/offline_manager.cpp b/platform/android/src/offline/offline_manager.cpp index 02871e7fdf..4960ae2845 100644 --- a/platform/android/src/offline/offline_manager.cpp +++ b/platform/android/src/offline/offline_manager.cpp @@ -102,7 +102,9 @@ void OfflineManager::ListOfflineRegionsCallback::onError(jni::JNIEnv& env, std::exception_ptr error) { static auto method = javaClass.GetMethod(env, "onError"); std::string message = mbgl::util::toString(error); - callback.Call(env, method, jni::Make(env, message)); + auto jmessage = jni::Make(env, message); + callback.Call(env, method, jmessage); + jni::DeleteLocalRef(env, jmessage); } void OfflineManager::ListOfflineRegionsCallback::onList(jni::JNIEnv& env, @@ -138,7 +140,9 @@ void OfflineManager::CreateOfflineRegionCallback::onError(jni::JNIEnv& env, std::exception_ptr error) { static auto method = javaClass.GetMethod(env, "onError"); std::string message = mbgl::util::toString(error); - callback.Call(env, method, jni::Make(env, message)); + auto jmessage = jni::Make(env, message); + callback.Call(env, method, jmessage); + jni::DeleteLocalRef(env, jmessage); } void OfflineManager::CreateOfflineRegionCallback::onCreate(jni::JNIEnv& env, diff --git a/platform/android/src/offline/offline_region.cpp b/platform/android/src/offline/offline_region.cpp index 856434d266..27de76fb00 100644 --- a/platform/android/src/offline/offline_region.cpp +++ b/platform/android/src/offline/offline_region.cpp @@ -239,7 +239,9 @@ void OfflineRegion::OfflineRegionStatusCallback::onError(jni::JNIEnv& env, std::exception_ptr error) { static auto method = javaClass.GetMethod(env, "onError"); std::string message = mbgl::util::toString(error); - callback.Call(env, method, jni::Make(env, message)); + auto jmessage = jni::Make(env, message); + callback.Call(env, method, jmessage); + jni::DeleteLocalRef(env, jmessage); } void OfflineRegion::OfflineRegionStatusCallback::onStatus(jni::JNIEnv& env, @@ -267,7 +269,9 @@ void OfflineRegion::OfflineRegionDeleteCallback::onError(jni::JNIEnv& env, std::exception_ptr error) { static auto method = javaClass.GetMethod(env, "onError"); std::string message = mbgl::util::toString(error); - callback.Call(env, method, jni::Make(env, message)); + auto jmessage = jni::Make(env, message); + callback.Call(env, method, jmessage); + jni::DeleteLocalRef(env, jmessage); } void OfflineRegion::OfflineRegionDeleteCallback::onDelete(jni::JNIEnv& env, jni::Object callback) { @@ -289,7 +293,9 @@ void OfflineRegion::OfflineRegionUpdateMetadataCallback::onError(jni::JNIEnv& en std::exception_ptr error) { static auto method = javaClass.GetMethod(env, "onError"); std::string message = mbgl::util::toString(error); - callback.Call(env, method, jni::Make(env, message)); + auto jmessage = jni::Make(env, message); + callback.Call(env, method, jmessage); + jni::DeleteLocalRef(env, jmessage); } void OfflineRegion::OfflineRegionUpdateMetadataCallback::onUpdate(jni::JNIEnv& env, diff --git a/platform/android/src/snapshotter/map_snapshotter.cpp b/platform/android/src/snapshotter/map_snapshotter.cpp index 71f8b4f4c0..a006953d36 100644 --- a/platform/android/src/snapshotter/map_snapshotter.cpp +++ b/platform/android/src/snapshotter/map_snapshotter.cpp @@ -71,7 +71,9 @@ void MapSnapshotter::start(JNIEnv& env) { if (err) { // error handler callback static auto onSnapshotFailed = javaClass.GetMethod(*_env, "onSnapshotFailed"); - javaPeer->Call(*_env, onSnapshotFailed, jni::Make(*_env, util::toString(err))); + auto message = jni::Make(*_env, util::toString(err)); + javaPeer->Call(*_env, onSnapshotFailed, message); + jni::DeleteLocalRef(*_env, message); } else { // Create the wrapper auto mapSnapshot = android::MapSnapshot::New(*_env, std::move(image), pixelRatio, attributions, showLogo, pointForFn); -- cgit v1.2.1 From 2993a0d59bca56ec08a4e51ae0cc13b9edf205ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Paczos?= Date: Wed, 4 Apr 2018 11:55:46 +0200 Subject: [android] invalidate camera position before delivering onMapReady (#11585) --- .../src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index 85ac99a188..a6da4c57fb 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -168,6 +168,7 @@ public final class MapboxMap { * Called before the OnMapReadyCallback is invoked. */ void onPreMapReady() { + invalidateCameraPosition(); annotationManager.reloadMarkers(); annotationManager.adjustTopOffsetPixels(this); } @@ -912,7 +913,7 @@ public final class MapboxMap { /** * Invalidates the current camera position by reconstructing it from mbgl */ - void invalidateCameraPosition() { + private void invalidateCameraPosition() { CameraPosition cameraPosition = transform.invalidateCameraPosition(); if (cameraPosition != null) { transform.updateCameraPosition(cameraPosition); -- cgit v1.2.1 From 50a8a44bc6442bbb32025bb898796f9ac5df5987 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Tue, 10 Apr 2018 16:43:11 +0200 Subject: [android] - update changelog for v5.5.2 --- platform/android/CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md index dc7ff98828..f62ecca2e4 100644 --- a/platform/android/CHANGELOG.md +++ b/platform/android/CHANGELOG.md @@ -2,6 +2,14 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to do so please see the [`Contributing Guide`](https://github.com/mapbox/mapbox-gl-native/blob/master/CONTRIBUTING.md) first to get started. +## 5.5.2 - April 10, 2018 + - Correct animation scale point [#11643](https://github.com/mapbox/mapbox-gl-native/pull/11643) + - Re-bind uniform locations after re-linking program [#11583](https://github.com/mapbox/mapbox-gl-native/pull/11583) + - Invalidate camera position before delivering onMapReady [#11585](https://github.com/mapbox/mapbox-gl-native/pull/11585) + - Null java peer callback [#11358](https://github.com/mapbox/mapbox-gl-native/pull/11358) + - Add missing delete local reference [#11608](https://github.com/mapbox/mapbox-gl-native/pull/11608) + - Release local refs [#11599](https://github.com/mapbox/mapbox-gl-native/pull/11599) + ## 5.5.1 - March 26, 2018 - Verify optional access of FileSource deactivation [#11480](https://github.com/mapbox/mapbox-gl-native/pull/11480) - Prevent default style loading when style json was set [#11519](https://github.com/mapbox/mapbox-gl-native/pull/11519) -- cgit v1.2.1 From 8e200ae38736e402929c90a105db9ff6f7677c2a Mon Sep 17 00:00:00 2001 From: Tobrun Date: Tue, 10 Apr 2018 16:55:16 +0200 Subject: [android] - bump snapshot version to v5.6.0 --- platform/android/MapboxGLAndroidSDK/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/android/MapboxGLAndroidSDK/gradle.properties b/platform/android/MapboxGLAndroidSDK/gradle.properties index de93849169..5b8260a53c 100644 --- a/platform/android/MapboxGLAndroidSDK/gradle.properties +++ b/platform/android/MapboxGLAndroidSDK/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.mapbox.mapboxsdk -VERSION_NAME=5.5.2-SNAPSHOT +VERSION_NAME=5.6.0-SNAPSHOT POM_DESCRIPTION=Mapbox GL Android SDK POM_URL=https://github.com/mapbox/mapbox-gl-native -- cgit v1.2.1 From 0bd9eac1744124e135df03753baa7395917ccf23 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 2 May 2018 12:34:50 -0700 Subject: [ios, macos] Avoid implicit capture of MBGLOfflineRegionObserver this pointer MBGLOfflineRegionObserver is owned by the offline database thread, and might be destroyed by the time the dispatch_async completes. Instead of implicitly capturing this, capture a copy of the MBGLOfflinePack weak pointer. --- platform/darwin/src/MGLOfflinePack.mm | 9 ++++++--- platform/ios/CHANGELOG.md | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/platform/darwin/src/MGLOfflinePack.mm b/platform/darwin/src/MGLOfflinePack.mm index 60a7b55531..4653021a58 100644 --- a/platform/darwin/src/MGLOfflinePack.mm +++ b/platform/darwin/src/MGLOfflinePack.mm @@ -227,19 +227,22 @@ NSError *MGLErrorFromResponseError(mbgl::Response::Error error) { @end void MBGLOfflineRegionObserver::statusChanged(mbgl::OfflineRegionStatus status) { + __weak MGLOfflinePack *weakPack = pack; dispatch_async(dispatch_get_main_queue(), ^{ - [pack offlineRegionStatusDidChange:status]; + [weakPack offlineRegionStatusDidChange:status]; }); } void MBGLOfflineRegionObserver::responseError(mbgl::Response::Error error) { + __weak MGLOfflinePack *weakPack = pack; dispatch_async(dispatch_get_main_queue(), ^{ - [pack didReceiveError:MGLErrorFromResponseError(error)]; + [weakPack didReceiveError:MGLErrorFromResponseError(error)]; }); } void MBGLOfflineRegionObserver::mapboxTileCountLimitExceeded(uint64_t limit) { + __weak MGLOfflinePack *weakPack = pack; dispatch_async(dispatch_get_main_queue(), ^{ - [pack didReceiveMaximumAllowedMapboxTiles:limit]; + [weakPack didReceiveMaximumAllowedMapboxTiles:limit]; }); } diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index e7277a2e10..438186c2b9 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,6 +2,10 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. +## 3.7.7 + +* Fixed a crash when removing an `MGLOfflinePack`. ([#6092](https://github.com/mapbox/mapbox-gl-native/issues/6092)) + ## 3.7.6 - March 12, 2018 * Fixed an issue where full-resolution tiles could fail to replace lower-resolution placeholders. ([#11227](https://github.com/mapbox/mapbox-gl-native/pull/11227)) -- cgit v1.2.1 From aadaa1c95b3f52483d1513efdff0b6d06c6c5420 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Thu, 3 May 2018 17:36:02 -0400 Subject: [ios] Prepare ios-v3.7.7 release (#11828) Bring ios-v4.0.0 changelog backward --- platform/ios/CHANGELOG.md | 72 +++++++++++++++++++++- .../ios/Mapbox-iOS-SDK-nightly-dynamic.podspec | 2 +- platform/ios/Mapbox-iOS-SDK-symbols.podspec | 2 +- platform/ios/Mapbox-iOS-SDK.podspec | 2 +- 4 files changed, 73 insertions(+), 5 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 438186c2b9..392df1d1ea 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,9 +2,77 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. -## 3.7.7 +## 3.7.7 - May 3, 2018 -* Fixed a crash when removing an `MGLOfflinePack`. ([#6092](https://github.com/mapbox/mapbox-gl-native/issues/6092)) +* Fixed a crash when removing an `MGLOfflinePack`. ([#11821](https://github.com/mapbox/mapbox-gl-native/issues/11821)) + +## 4.0.0 - April 19, 2018 + +The 4.0._x_ series of releases will be the last to support iOS 8. The minimum iOS deployment version will increase to iOS 9.0 in a future release. + +### Packaging + +* Removed support for 32-bit simulators. ([#10962](https://github.com/mapbox/mapbox-gl-native/pull/10962)) +* Added Danish, Hebrew, and European Portuguese localizations. ([#10967](https://github.com/mapbox/mapbox-gl-native/pull/10967), [#11136](https://github.com/mapbox/mapbox-gl-native/pull/11134), [#11695](https://github.com/mapbox/mapbox-gl-native/pull/11695)) +* Removed methods, properties, and constants that had been deprecated as of v3.7.6. ([#11205](https://github.com/mapbox/mapbox-gl-native/pull/11205), [#11681](https://github.com/mapbox/mapbox-gl-native/pull/11681)) +* Refined certain Swift interfaces by converting them from class methods to class properties. ([#11674](https://github.com/mapbox/mapbox-gl-native/pull/11674)) +* Revamped the “Adding Points to a Map” guide. ([#11496](https://github.com/mapbox/mapbox-gl-native/pull/11496)) + +### Style layers + +* The layout and paint properties on subclasses of `MGLStyleLayer` are now of type `NSExpression` instead of `MGLStyleValue`. A new “Predicates and Expressions” guide provides an overview of the supported operators, which include arithmetic and conditional operators. ([#10726](https://github.com/mapbox/mapbox-gl-native/pull/10726)) +* A style can now display a heatmap layer that visualizes a point data distribution. You can customize the appearance at runtime using the `MGLHeatmapStyleLayer` class. ([#11046](https://github.com/mapbox/mapbox-gl-native/pull/11046)) +* A style can now display a smooth hillshading layer and customize its appearance at runtime using the `MGLHillshadeStyleLayer` class. Hillshading is based on a rasterized digital elevation model supplied by the `MGLRasterDEMSource` class. ([#10642](https://github.com/mapbox/mapbox-gl-native/pull/10642)) +* You can now set the `MGLVectorStyleLayer.predicate` property to a predicate that contains arithmetic and calls to built-in `NSExpression` functions. You may need to cast a feature attribute key to `NSString` or `NSNumber` before comparing it to a string or number. ([#11587](https://github.com/mapbox/mapbox-gl-native/pull/11587)) +* Replaced the `MGLStyle.localizesLabels` property with an `-[MGLStyle localizeLabelsIntoLocale:]` method that allows you to specify the language to localize into. Also added an `-[NSExpression(MGLAdditions) mgl_expressionLocalizedIntoLocale:]` method for localizing an individual value used with `MGLSymbolStyleLayer.text`. ([#11651](https://github.com/mapbox/mapbox-gl-native/pull/11651)) +* The `MGLSymbolStyleLayer.textFontNames` property can now depend on a feature’s attributes. ([#10850](https://github.com/mapbox/mapbox-gl-native/pull/10850)) +* Changes to the `MGLStyleLayer.minimumZoomLevel` and `MGLStyleLayer.maximumZoomLevel` properties take effect immediately. ([#11399](https://github.com/mapbox/mapbox-gl-native/pull/11399)) + +### Content sources + +* Renamed `MGLRasterSource` to `MGLRasterTileSource` and `MGLVectorSource` to `MGLVectorTileSource`. ([#11568](https://github.com/mapbox/mapbox-gl-native/pull/11568)) +* Added an `MGLComputedShapeSource` class that allows applications to supply vector data to a style layer on a per-tile basis. ([#9983](https://github.com/mapbox/mapbox-gl-native/pull/9983)) +* Properties such as `MGLSymbolStyleLayer.iconAllowsOverlap` and `MGLSymbolStyleLayer.iconIgnoresPlacement` now account for symbols in other sources. ([#10436](https://github.com/mapbox/mapbox-gl-native/pull/10436)) + +### Map rendering + +* Improved the reliability of collision detection between symbols near the edges of tiles, as well as between symbols when the map is tilted. It is no longer necessary to enable `MGLSymbolStyleLayer.symbolAvoidsEdges` to prevent symbols in adjacent tiles from overlapping with each other. ([#10436](https://github.com/mapbox/mapbox-gl-native/pull/10436)) +* Symbols can fade in and out as the map pans, rotates, or tilts. ([#10436](https://github.com/mapbox/mapbox-gl-native/pull/10436)) +* Fixed an issue preventing a dynamically-added `MGLRasterStyleLayer` from drawing until the map pans. ([#10270](https://github.com/mapbox/mapbox-gl-native/pull/10270)) +* Fixed an issue preventing `MGLImageSource`s from drawing on the map when the map is zoomed in and tilted. ([#10677](https://github.com/mapbox/mapbox-gl-native/pull/10677)) +* Improved the sharpness of raster tiles on Retina displays. ([#10984](https://github.com/mapbox/mapbox-gl-native/pull/10984)) +* Fixed a crash parsing a malformed style. ([#11001](https://github.com/mapbox/mapbox-gl-native/pull/11001)) +* Reduced memory usage by clearing in-memory tile cache before entering background. ([#11197](https://github.com/mapbox/mapbox-gl-native/pull/11197)) +* Fixed an issue where symbols with empty labels would always be hidden. ([#11206](https://github.com/mapbox/mapbox-gl-native/pull/11206)) +* Fixed an issue where a tilted map could flicker while displaying rotating symbols. ([#11488](https://github.com/mapbox/mapbox-gl-native/pull/11488)) +* Increased the maximum width of labels by a factor of two. ([#11508](https://github.com/mapbox/mapbox-gl-native/pull/11508)) + +### Annotations + +* Changed the default value of `MGLAnnotationView.scalesWithViewingDistance` to `NO`, to improve performance. If your use case involves many annotation views, consider keeping this property disabled. ([#11636](https://github.com/mapbox/mapbox-gl-native/pull/11636)) +* Fixed an issue preventing `MGLAnnotationImage.image` from being updated. ([#10372](https://github.com/mapbox/mapbox-gl-native/pull/10372)) +* Improved performance of `MGLAnnotationView`-backed annotations that have `scalesWithViewingDistance` enabled. ([#10951](https://github.com/mapbox/mapbox-gl-native/pull/10951)) +* Fixed an issue where tapping a group of annotations may not have selected the nearest annotation. ([#11438](https://github.com/mapbox/mapbox-gl-native/pull/11438)) +* The `MGLMapView.selectedAnnotations` property (backed by `-[MGLMapView setSelectedAnnotations:]`) now selects annotations that are off-screen. ([#9790](https://github.com/mapbox/mapbox-gl-native/issues/9790)) +* The `animated` parameter to `-[MGLMapView selectAnnotation:animated:]` now controls whether the annotation and its callout are brought on-screen. If `animated` is `NO` then the annotation is selected if offscreen, but the map is not panned. Currently only point annotations are supported. Setting the `MGLMapView.selectedAnnotations` property now animates. ([#3249](https://github.com/mapbox/mapbox-gl-native/issues/3249)) +* Fixed a crash when rapidly adding and removing annotations. ([#11551](https://github.com/mapbox/mapbox-gl-native/issues/11551), [#11575](https://github.com/mapbox/mapbox-gl-native/issues/11575)) +* Marked protocol method `-[MGLCalloutView presentCalloutFromRect:inView:constrainedToView:animated:]` as unavailable. Use `-[MGLCalloutView presentCalloutFromRect:inView:constrainedToRect:animated:]` instead. ([#11738](https://github.com/mapbox/mapbox-gl-native/pull/11738)) + +### Map snapshots + +* Fixed a memory leak that occurred when creating a map snapshot. ([#10585](https://github.com/mapbox/mapbox-gl-native/pull/10585)) + +### Other changes + +* The `-[MGLMapView convertRect:toCoordinateBoundsFromView:]` method and the `MGLMapView.visibleCoordinateBounds` property’s getter now indicate that the coordinate bounds straddles the antimeridian by extending one side beyond ±180 degrees longitude. ([#11265](https://github.com/mapbox/mapbox-gl-native/pull/11265)) +* Feature querying results now account for the `MGLSymbolStyleLayer.circleStrokeWidth` property. ([#10897](https://github.com/mapbox/mapbox-gl-native/pull/10897)) +* Fixed an issue preventing labels from being transliterated when VoiceOver was enabled on iOS 10._x_ and below. ([#10881](https://github.com/mapbox/mapbox-gl-native/pull/10881)) +* Labels are now transliterated from more languages when VoiceOver is enabled. ([#10881](https://github.com/mapbox/mapbox-gl-native/pull/10881)) +* Long-pressing the attribution button causes the SDK’s version number to be displayed in the action sheet that appears. ([#10650](https://github.com/mapbox/mapbox-gl-native/pull/10650)) +* Reduced offline download sizes for styles with symbol layers that render only icons, and no text. ([#11055](https://github.com/mapbox/mapbox-gl-native/pull/11055)) +* Added haptic feedback that occurs when the user rotates the map to due north, configurable via `MGLMapView.hapticFeedbackEnabled`. ([#10847](https://github.com/mapbox/mapbox-gl-native/pull/10847)) +* Added `MGLMapView.showsScale` as the recommended way to show the scale bar. This property can be set directly in Interface Builder. ([#11335](https://github.com/mapbox/mapbox-gl-native/pull/11335)) +* Fixed an issue where the scale bar would not appear until the map had moved. ([#11335](https://github.com/mapbox/mapbox-gl-native/pull/11335)) ## 3.7.6 - March 12, 2018 diff --git a/platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec b/platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec index 268b7b9da6..9d714ccb6a 100644 --- a/platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec +++ b/platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '3.7.6' + version = '3.7.7' m.name = 'Mapbox-iOS-SDK-nightly-dynamic' m.version = "#{version}-nightly" diff --git a/platform/ios/Mapbox-iOS-SDK-symbols.podspec b/platform/ios/Mapbox-iOS-SDK-symbols.podspec index a1b2441d29..ebf758cbf6 100644 --- a/platform/ios/Mapbox-iOS-SDK-symbols.podspec +++ b/platform/ios/Mapbox-iOS-SDK-symbols.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '3.7.6' + version = '3.7.7' m.name = 'Mapbox-iOS-SDK-symbols' m.version = "#{version}-symbols" diff --git a/platform/ios/Mapbox-iOS-SDK.podspec b/platform/ios/Mapbox-iOS-SDK.podspec index 7e696a23cf..d8ac87363b 100644 --- a/platform/ios/Mapbox-iOS-SDK.podspec +++ b/platform/ios/Mapbox-iOS-SDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '3.7.6' + version = '3.7.7' m.name = 'Mapbox-iOS-SDK' m.version = version -- cgit v1.2.1 From 7693a00581315c750b5a00cf9d87b15cb1970bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Paczos?= Date: Mon, 30 Apr 2018 18:32:37 +0200 Subject: [android] - checking is renderer is not destroyed before delivering the snapshot --- .../mapboxsdk/maps/renderer/MapRenderer.java | 8 ++------ platform/android/src/map_renderer.cpp | 23 +++++++--------------- platform/android/src/map_renderer.hpp | 6 +----- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java index f1c70325a0..fcee5bd179 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java @@ -37,11 +37,11 @@ public abstract class MapRenderer implements MapRendererScheduler { } public void onPause() { - nativeOnPause(); + // Implement if needed } public void onResume() { - nativeOnResume(); + // Implement if needed } public void onStop() { @@ -124,10 +124,6 @@ public abstract class MapRenderer implements MapRendererScheduler { private native void nativeRender(); - private native void nativeOnResume(); - - private native void nativeOnPause(); - private long frames; private long timeElapsed; diff --git a/platform/android/src/map_renderer.cpp b/platform/android/src/map_renderer.cpp index f7e16b7091..ba6fdc63b0 100644 --- a/platform/android/src/map_renderer.cpp +++ b/platform/android/src/map_renderer.cpp @@ -29,6 +29,7 @@ MapRenderer::MapRenderer(jni::JNIEnv& _env, jni::Object obj, MapRenderer::~MapRenderer() = default; void MapRenderer::reset() { + destroyed = true; // Make sure to destroy the renderer on the GL Thread auto self = ActorRef(*this, mailbox); self.ask(&MapRenderer::resetRenderer).wait(); @@ -88,8 +89,10 @@ void MapRenderer::requestSnapshot(SnapshotCallback callback) { self.invoke( &MapRenderer::scheduleSnapshot, std::make_unique([&, callback=std::move(callback), runloop=util::RunLoop::Get()](PremultipliedImage image) { - runloop->invoke([callback=std::move(callback), image=std::move(image)]() mutable { - callback(std::move(image)); + runloop->invoke([callback=std::move(callback), image=std::move(image), renderer=std::move(this)]() mutable { + if (renderer && !renderer->destroyed) { + callback(std::move(image)); + } }); snapshotCallback.reset(); }) @@ -136,7 +139,7 @@ void MapRenderer::render(JNIEnv&) { renderer->render(*params); // Deliver the snapshot if requested - if (snapshotCallback && !paused) { + if (snapshotCallback) { snapshotCallback->operator()(backend->readFramebuffer()); snapshotCallback.reset(); } @@ -174,14 +177,6 @@ void MapRenderer::onSurfaceChanged(JNIEnv&, jint width, jint height) { requestRender(); } -void MapRenderer::onResume(JNIEnv&) { - paused = false; -} - -void MapRenderer::onPause(JNIEnv&) { - paused = true; -} - // Static methods // jni::Class MapRenderer::javaClass; @@ -200,11 +195,7 @@ void MapRenderer::registerNative(jni::JNIEnv& env) { METHOD(&MapRenderer::onSurfaceCreated, "nativeOnSurfaceCreated"), METHOD(&MapRenderer::onSurfaceChanged, - "nativeOnSurfaceChanged"), - METHOD(&MapRenderer::onResume, - "nativeOnResume"), - METHOD(&MapRenderer::onPause, - "nativeOnPause")); + "nativeOnSurfaceChanged")); } MapRenderer& MapRenderer::getNativePeer(JNIEnv& env, jni::Object jObject) { diff --git a/platform/android/src/map_renderer.hpp b/platform/android/src/map_renderer.hpp index 5fb5ef1a61..97d2db4a91 100644 --- a/platform/android/src/map_renderer.hpp +++ b/platform/android/src/map_renderer.hpp @@ -98,10 +98,6 @@ private: void onSurfaceChanged(JNIEnv&, jint width, jint height); - void onResume(JNIEnv&); - - void onPause(JNIEnv&); - private: GenericUniqueWeakObject javaPeer; @@ -124,7 +120,7 @@ private: std::mutex updateMutex; bool framebufferSizeChanged = false; - std::atomic paused {false}; + std::atomic destroyed {false}; std::unique_ptr snapshotCallback; }; -- cgit v1.2.1 From 2d11d89547b79150c93c9c265fda71c769d457af Mon Sep 17 00:00:00 2001 From: tobrun Date: Fri, 4 May 2018 15:40:41 +0200 Subject: [android] - update changelog for v5.5.3 --- platform/android/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md index f62ecca2e4..bee3c886a6 100644 --- a/platform/android/CHANGELOG.md +++ b/platform/android/CHANGELOG.md @@ -2,6 +2,9 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to do so please see the [`Contributing Guide`](https://github.com/mapbox/mapbox-gl-native/blob/master/CONTRIBUTING.md) first to get started. +## 5.5.3 - May 4, 2018 + - Check if renderer is not destroyed before delivering snapshot [#11800](https://github.com/mapbox/mapbox-gl-native/pull/11800) + ## 5.5.2 - April 10, 2018 - Correct animation scale point [#11643](https://github.com/mapbox/mapbox-gl-native/pull/11643) - Re-bind uniform locations after re-linking program [#11583](https://github.com/mapbox/mapbox-gl-native/pull/11583) -- cgit v1.2.1 From 0141f65e7be21b067957a8e8cb3474ab46e12b48 Mon Sep 17 00:00:00 2001 From: Randall Lee Date: Mon, 7 May 2018 17:57:42 -0400 Subject: [iOS] - Update telemetry certificate pinning (#11845) * Update telemetry certificate pinning * Load both CN certificates * [ios] Use China events endpoint with China API endpoint * Update CHANGELOG.md --- platform/darwin/src/MGLNetworkConfiguration.h | 6 ++++++ platform/darwin/src/MGLNetworkConfiguration.m | 3 +++ platform/ios/CHANGELOG.md | 4 ++++ platform/ios/ios.xcodeproj/project.pbxproj | 12 ++++++++++++ .../ios/resources/api_mapbox_cn-digicert_2018.der | Bin 0 -> 1704 bytes .../ios/resources/api_mapbox_cn-geotrust_2018.der | Bin 0 -> 1578 bytes platform/ios/src/MGLAPIClient.m | 18 +++++++++++++++++- 7 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 platform/ios/resources/api_mapbox_cn-digicert_2018.der create mode 100644 platform/ios/resources/api_mapbox_cn-geotrust_2018.der diff --git a/platform/darwin/src/MGLNetworkConfiguration.h b/platform/darwin/src/MGLNetworkConfiguration.h index 644291ee13..f1fe7bab2c 100644 --- a/platform/darwin/src/MGLNetworkConfiguration.h +++ b/platform/darwin/src/MGLNetworkConfiguration.h @@ -2,6 +2,12 @@ NS_ASSUME_NONNULL_BEGIN +/// The default base URL for Mapbox APIs other than the telemetry API. +extern NSString * const MGLDefaultMapboxAPIBaseURL; + +/// The PRC base URL for Mapbox APIs other than the telemetry API. +extern NSString * const MGLChinaMapboxAPIBaseURL; + /** The MGLNetworkConfiguration object provides a global way to set a base API URL for retrieval of map data, styles, and other resources. diff --git a/platform/darwin/src/MGLNetworkConfiguration.m b/platform/darwin/src/MGLNetworkConfiguration.m index 82d333dc99..d0ee01c5a2 100644 --- a/platform/darwin/src/MGLNetworkConfiguration.m +++ b/platform/darwin/src/MGLNetworkConfiguration.m @@ -1,5 +1,8 @@ #import "MGLNetworkConfiguration.h" +NSString * const MGLDefaultMapboxAPIBaseURL = @"https://api.mapbox.com"; +NSString * const MGLChinaMapboxAPIBaseURL = @"https://api.mapbox.cn"; + @implementation MGLNetworkConfiguration + (void)load { diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 392df1d1ea..1b0806b689 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,6 +2,10 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. +## 3.7.8 - May 7, 2018 + +* Improved compatibility with Mapbox China APIs. ([#11845](https://github.com/mapbox/mapbox-gl-native/pull/11845)) + ## 3.7.7 - May 3, 2018 * Fixed a crash when removing an `MGLOfflinePack`. ([#11821](https://github.com/mapbox/mapbox-gl-native/issues/11821)) diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index bbd4067534..2bc216ff1c 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -247,6 +247,10 @@ 968F36B51E4D128D003A5522 /* MGLDistanceFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = 3557F7AE1E1D27D300CCA5E6 /* MGLDistanceFormatter.h */; settings = {ATTRIBUTES = (Public, ); }; }; 96E027231E57C76E004B8E66 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 96E027251E57C76E004B8E66 /* Localizable.strings */; }; 96F3F73C1F57124B003E2D2C /* MGLUserLocationHeadingIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = 96F3F73B1F5711F1003E2D2C /* MGLUserLocationHeadingIndicator.h */; }; + AC0C15F3209D0E6900B65675 /* api_mapbox_cn-geotrust_2018.der in Resources */ = {isa = PBXBuildFile; fileRef = AC0C15F1209D0E3600B65675 /* api_mapbox_cn-geotrust_2018.der */; }; + AC0C15F4209D0E7000B65675 /* api_mapbox_cn-geotrust_2018.der in Resources */ = {isa = PBXBuildFile; fileRef = AC0C15F1209D0E3600B65675 /* api_mapbox_cn-geotrust_2018.der */; }; + AC0C15F5209D0E7200B65675 /* api_mapbox_cn-digicert_2018.der in Resources */ = {isa = PBXBuildFile; fileRef = AC0C15F2209D0E6000B65675 /* api_mapbox_cn-digicert_2018.der */; }; + AC0C15F6209D0E7300B65675 /* api_mapbox_cn-digicert_2018.der in Resources */ = {isa = PBXBuildFile; fileRef = AC0C15F2209D0E6000B65675 /* api_mapbox_cn-digicert_2018.der */; }; AC518DFF201BB55A00EBC820 /* MGLTelemetryConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = AC518DFD201BB55A00EBC820 /* MGLTelemetryConfig.h */; }; AC518E00201BB55A00EBC820 /* MGLTelemetryConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = AC518DFD201BB55A00EBC820 /* MGLTelemetryConfig.h */; }; AC518E03201BB56000EBC820 /* MGLTelemetryConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = AC518DFE201BB55A00EBC820 /* MGLTelemetryConfig.m */; }; @@ -756,6 +760,8 @@ 96E0272D1E57C7E6004B8E66 /* vi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = vi; path = vi.lproj/Localizable.strings; sourceTree = ""; }; 96E0272E1E57C7E7004B8E66 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = ""; }; 96F3F73B1F5711F1003E2D2C /* MGLUserLocationHeadingIndicator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLUserLocationHeadingIndicator.h; sourceTree = ""; }; + AC0C15F1209D0E3600B65675 /* api_mapbox_cn-geotrust_2018.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = "api_mapbox_cn-geotrust_2018.der"; sourceTree = ""; }; + AC0C15F2209D0E6000B65675 /* api_mapbox_cn-digicert_2018.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = "api_mapbox_cn-digicert_2018.der"; sourceTree = ""; }; AC518DFD201BB55A00EBC820 /* MGLTelemetryConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLTelemetryConfig.h; sourceTree = ""; }; AC518DFE201BB55A00EBC820 /* MGLTelemetryConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLTelemetryConfig.m; sourceTree = ""; }; CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCameraChangeReason.h; sourceTree = ""; }; @@ -1479,6 +1485,8 @@ DAC49C5F1CD02BC9009E1AA3 /* Localizable.stringsdict */, DA8933EF1CCD387900E68420 /* strip-frameworks.sh */, 40599F001DEE1B2400182B5D /* api_mapbox_staging.der */, + AC0C15F2209D0E6000B65675 /* api_mapbox_cn-digicert_2018.der */, + AC0C15F1209D0E3600B65675 /* api_mapbox_cn-geotrust_2018.der */, 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert_2016.der */, 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust_2016.der */, 40EA6BBD1EF4598900FCCDA2 /* api_mapbox_com-digicert_2017.der */, @@ -2225,12 +2233,14 @@ files = ( DA8933BC1CCD2CA100E68420 /* Foundation.strings in Resources */, DA8933A31CCC95B000E68420 /* Localizable.strings in Resources */, + AC0C15F5209D0E7200B65675 /* api_mapbox_cn-digicert_2018.der in Resources */, 960D0C361ECF5AAF008E151F /* Images.xcassets in Resources */, DA8933F01CCD387900E68420 /* strip-frameworks.sh in Resources */, DAC49C5C1CD02BC9009E1AA3 /* Localizable.stringsdict in Resources */, DA8933BF1CCD2CAD00E68420 /* Foundation.stringsdict in Resources */, 40EA6BC11EF4599600FCCDA2 /* api_mapbox_com-digicert_2017.der in Resources */, 408982E91DEE208200754016 /* api_mapbox_staging.der in Resources */, + AC0C15F3209D0E6900B65675 /* api_mapbox_cn-geotrust_2018.der in Resources */, 408982EA1DEE208B00754016 /* api_mapbox_com-digicert_2016.der in Resources */, 40EA6BC31EF4599D00FCCDA2 /* api_mapbox_com-geotrust_2017.der in Resources */, 408982EB1DEE209100754016 /* api_mapbox_com-geotrust_2016.der in Resources */, @@ -2241,6 +2251,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + AC0C15F4209D0E7000B65675 /* api_mapbox_cn-geotrust_2018.der in Resources */, DA8933E01CCD31DF00E68420 /* Localizable.strings in Resources */, DA8933DB1CCD31D400E68420 /* Foundation.strings in Resources */, 960D0C371ECF5AAF008E151F /* Images.xcassets in Resources */, @@ -2250,6 +2261,7 @@ 40599F0C1DEE1B7600182B5D /* api_mapbox_staging.der in Resources */, 40599F0D1DEE1B7A00182B5D /* api_mapbox_com-digicert_2016.der in Resources */, 40599F0E1DEE1B7E00182B5D /* api_mapbox_com-geotrust_2016.der in Resources */, + AC0C15F6209D0E7300B65675 /* api_mapbox_cn-digicert_2018.der in Resources */, 40EA6BC21EF4599700FCCDA2 /* api_mapbox_com-digicert_2017.der in Resources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/platform/ios/resources/api_mapbox_cn-digicert_2018.der b/platform/ios/resources/api_mapbox_cn-digicert_2018.der new file mode 100644 index 0000000000..e458713337 Binary files /dev/null and b/platform/ios/resources/api_mapbox_cn-digicert_2018.der differ diff --git a/platform/ios/resources/api_mapbox_cn-geotrust_2018.der b/platform/ios/resources/api_mapbox_cn-geotrust_2018.der new file mode 100644 index 0000000000..e3d4b222ae Binary files /dev/null and b/platform/ios/resources/api_mapbox_cn-geotrust_2018.der differ diff --git a/platform/ios/src/MGLAPIClient.m b/platform/ios/src/MGLAPIClient.m index 8a987d76d8..68e78835c3 100644 --- a/platform/ios/src/MGLAPIClient.m +++ b/platform/ios/src/MGLAPIClient.m @@ -2,9 +2,11 @@ #import "NSBundle+MGLAdditions.h" #import "NSData+MGLAdditions.h" #import "MGLAccountManager.h" +#import "MGLNetworkConfiguration.h" static NSString * const MGLAPIClientUserAgentBase = @"MapboxEventsiOS"; static NSString * const MGLAPIClientBaseURL = @"https://events.mapbox.com"; +static NSString * const MGLAPIClientChinaBaseURL = @"https://events.mapbox.cn"; static NSString * const MGLAPIClientEventsPath = @"events/v2"; static NSString * const MGLAPIClientHeaderFieldUserAgentKey = @"User-Agent"; @@ -21,6 +23,8 @@ static NSString * const MGLAPIClientHTTPMethodPost = @"POST"; @property (nonatomic, copy) NSData *geoTrustCert_2016; @property (nonatomic, copy) NSData *digicertCert_2017; @property (nonatomic, copy) NSData *geoTrustCert_2017; +@property (nonatomic, copy) NSData *digicertCert_cn_2018; +@property (nonatomic, copy) NSData *geoTrustCert_cn_2018; @property (nonatomic, copy) NSData *testServerCert; @property (nonatomic, copy) NSString *userAgent; @property (nonatomic) BOOL usesTestServer; @@ -102,6 +106,8 @@ static NSString * const MGLAPIClientHTTPMethodPost = @"POST"; if (testServerURL && [testServerURL.scheme isEqualToString:@"https"]) { self.baseURL = testServerURL; self.usesTestServer = YES; + } else if ([[[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLMapboxAPIBaseURL"] isEqualToString:MGLChinaMapboxAPIBaseURL]) { + self.baseURL = [NSURL URLWithString:MGLAPIClientChinaBaseURL]; } else { self.baseURL = [NSURL URLWithString:MGLAPIClientBaseURL]; } @@ -117,6 +123,10 @@ static NSString * const MGLAPIClientHTTPMethodPost = @"POST"; self.geoTrustCert_2017 = certificate; [self loadCertificate:&certificate withResource:@"api_mapbox_com-digicert_2017"]; self.digicertCert_2017 = certificate; + [self loadCertificate:&certificate withResource:@"api_mapbox_cn-geotrust_2018"]; + self.geoTrustCert_cn_2018 = certificate; + [self loadCertificate:&certificate withResource:@"api_mapbox_cn-digicert_2018"]; + self.digicertCert_cn_2018 = certificate; [self loadCertificate:&certificate withResource:@"api_mapbox_staging"]; self.testServerCert = certificate; } @@ -174,17 +184,23 @@ static NSString * const MGLAPIClientHTTPMethodPost = @"POST"; // Look for a pinned certificate in the server's certificate chain CFIndex numKeys = SecTrustGetCertificateCount(serverTrust); - // Check certs in the following order: digicert 2016, digicert 2017, geotrust 2016, geotrust 2017 + // Check certs in the following order: digicert 2016, digicert 2017, digicert CN 2018, geotrust 2016, geotrust 2017, geotrust CN 2018 found = [self evaluateCertificateWithCertificateData:self.digicertCert_2016 keyCount:numKeys serverTrust:serverTrust challenge:challenge completionHandler:completionHandler]; if (!found) { found = [self evaluateCertificateWithCertificateData:self.digicertCert_2017 keyCount:numKeys serverTrust:serverTrust challenge:challenge completionHandler:completionHandler]; } + if (!found) { + found = [self evaluateCertificateWithCertificateData:self.digicertCert_cn_2018 keyCount:numKeys serverTrust:serverTrust challenge:challenge completionHandler:completionHandler]; + } if (!found) { found = [self evaluateCertificateWithCertificateData:self.geoTrustCert_2016 keyCount:numKeys serverTrust:serverTrust challenge:challenge completionHandler:completionHandler]; } if (!found) { found = [self evaluateCertificateWithCertificateData:self.geoTrustCert_2017 keyCount:numKeys serverTrust:serverTrust challenge:challenge completionHandler:completionHandler]; } + if (!found) { + found = [self evaluateCertificateWithCertificateData:self.geoTrustCert_cn_2018 keyCount:numKeys serverTrust:serverTrust challenge:challenge completionHandler:completionHandler]; + } // If challenge can't be completed with any of the above certs, then try the test server if the app is configured to use the test server if (!found && _usesTestServer) { -- cgit v1.2.1 From 30e8798d768847d821128b3ce8ce348811f53a22 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Mon, 7 May 2018 17:07:13 -0400 Subject: [ios] Prepare ios-v3.7.8 release --- platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec | 2 +- platform/ios/Mapbox-iOS-SDK-symbols.podspec | 2 +- platform/ios/Mapbox-iOS-SDK.podspec | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec b/platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec index 9d714ccb6a..265331791a 100644 --- a/platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec +++ b/platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '3.7.7' + version = '3.7.8' m.name = 'Mapbox-iOS-SDK-nightly-dynamic' m.version = "#{version}-nightly" diff --git a/platform/ios/Mapbox-iOS-SDK-symbols.podspec b/platform/ios/Mapbox-iOS-SDK-symbols.podspec index ebf758cbf6..3e3311f912 100644 --- a/platform/ios/Mapbox-iOS-SDK-symbols.podspec +++ b/platform/ios/Mapbox-iOS-SDK-symbols.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '3.7.7' + version = '3.7.8' m.name = 'Mapbox-iOS-SDK-symbols' m.version = "#{version}-symbols" diff --git a/platform/ios/Mapbox-iOS-SDK.podspec b/platform/ios/Mapbox-iOS-SDK.podspec index d8ac87363b..6eaac7b73b 100644 --- a/platform/ios/Mapbox-iOS-SDK.podspec +++ b/platform/ios/Mapbox-iOS-SDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '3.7.7' + version = '3.7.8' m.name = 'Mapbox-iOS-SDK' m.version = version -- cgit v1.2.1