Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[android] Revert native loading behavior #10180

Merged
merged 1 commit into from
Oct 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,41 +1,20 @@
package com.mapbox.mapboxsdk;

import android.content.Context;

import java.io.File;

import timber.log.Timber;

/**
* Centralises the knowledge about "mapbox-gl" library loading.
*/
public class LibraryLoader {

private static final String LIBRARY_NAME = "libmapbox-gl.so";

/**
* Loads "libmapbox-gl.so" native shared library.
*/
public static void load() {
try {
System.loadLibrary("mapbox-gl");
} catch (UnsatisfiedLinkError error) {
Context context = Mapbox.getApplicationContext();
if (context != null) {
Timber.d("Loading %s from internal storage.", LIBRARY_NAME);
System.load(getLibraryLocation(context).getAbsolutePath());
}
Timber.e(error, "Failed to load native shared library.");
}
}

/**
* Returns a file in the app internal storage that may contain a locally cached copy
* of the Mapbox native library.
*
* @param context The application context
* @return a file object
*/
public static File getLibraryLocation(Context context) {
return new File(context.getFilesDir(), LIBRARY_NAME);
}
}