Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove SoLoaderShim, use SoLoader #1989

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions animated-gif/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies {
provided "com.google.code.findbugs:jsr305:${JSR_305_VERSION}"
compile "com.parse.bolts:bolts-tasks:${BOLTS_ANDROID_VERSION}"
provided "javax.annotation:javax.annotation-api:${ANNOTATION_API_VERSION}"
implementation "com.facebook.soloader:soloader:${SOLOADER_VERSION}"
compile project(':fbcore')
compile project(':animated-base')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

import com.facebook.common.internal.DoNotStrip;
import com.facebook.common.internal.Preconditions;
import com.facebook.common.soloader.SoLoaderShim;
import com.facebook.imagepipeline.animated.base.AnimatedDrawableFrameInfo;
import com.facebook.imagepipeline.animated.base.AnimatedDrawableFrameInfo.BlendOperation;
import com.facebook.imagepipeline.animated.base.AnimatedImage;
import com.facebook.imagepipeline.animated.factory.AnimatedImageDecoder;
import com.facebook.soloader.SoLoader;
import java.nio.ByteBuffer;
import javax.annotation.concurrent.ThreadSafe;

Expand All @@ -41,7 +41,7 @@ public class GifImage implements AnimatedImage, AnimatedImageDecoder {
private static synchronized void ensure() {
if (!sInitialized) {
sInitialized = true;
SoLoaderShim.loadLibrary("gifimage");
SoLoader.loadLibrary("gifimage");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,25 @@

package com.facebook.imagepipeline.animated.factory;

import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.isNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;

import android.graphics.Bitmap;
import android.graphics.Rect;
import com.facebook.animated.gif.GifImage;
import com.facebook.common.memory.PooledByteBuffer;
import com.facebook.common.references.CloseableReference;
import com.facebook.common.references.ResourceReleaser;
import com.facebook.common.soloader.SoLoaderShim;
import com.facebook.imageformat.ImageFormat;
import com.facebook.imagepipeline.animated.base.AnimatedDrawableBackend;
import com.facebook.imagepipeline.animated.base.AnimatedImageResult;
Expand All @@ -31,6 +40,7 @@
import com.facebook.imagepipeline.image.EncodedImage;
import com.facebook.imagepipeline.testing.MockBitmapFactory;
import com.facebook.imagepipeline.testing.TrivialPooledByteBuffer;
import com.facebook.soloader.SoLoader;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -58,7 +68,7 @@ public class AnimatedImageFactoryGifImplTest {
public PowerMockRule rule = new PowerMockRule();

static {
SoLoaderShim.setInTestMode();
SoLoader.setInTestMode();
}

private static ResourceReleaser<PooledByteBuffer> FAKE_RESOURCE_RELEASER =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,25 @@

package com.facebook.imagepipeline.animated.factory;

import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.isNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;

import android.graphics.Bitmap;
import android.graphics.Rect;
import com.facebook.animated.webp.WebPImage;
import com.facebook.common.memory.PooledByteBuffer;
import com.facebook.common.references.CloseableReference;
import com.facebook.common.references.ResourceReleaser;
import com.facebook.common.soloader.SoLoaderShim;
import com.facebook.imageformat.ImageFormat;
import com.facebook.imagepipeline.animated.base.AnimatedDrawableBackend;
import com.facebook.imagepipeline.animated.base.AnimatedImageResult;
Expand Down Expand Up @@ -57,10 +66,6 @@ public class AnimatedImageFactoryWebPImplTest {
@Rule
public PowerMockRule rule = new PowerMockRule();

static {
SoLoaderShim.setInTestMode();
}

private static ResourceReleaser<PooledByteBuffer> FAKE_RESOURCE_RELEASER =
new ResourceReleaser<PooledByteBuffer>() {

Expand Down
3 changes: 3 additions & 0 deletions drawee-backends/drawee-pipeline/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ version = VERSION_NAME
dependencies {
compileOnly "com.android.support:support-core-utils:${SUPPORT_LIB_VERSION}"
compileOnly "com.google.code.findbugs:jsr305:${JSR_305_VERSION}"

implementation "com.facebook.soloader:soloader:${SOLOADER_VERSION}"

api project(':fbcore')
api project(':drawee')
api project(':imagepipeline')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import com.facebook.imagepipeline.core.ImagePipeline;
import com.facebook.imagepipeline.core.ImagePipelineConfig;
import com.facebook.imagepipeline.core.ImagePipelineFactory;
import com.facebook.soloader.SoLoader;
import java.io.IOException;
import javax.annotation.Nullable;

/**
Expand Down Expand Up @@ -57,6 +59,11 @@ public static void initialize(
} else {
sIsInitialized = true;
}
try {
SoLoader.init(context, 0);
} catch (IOException e) {
throw new RuntimeException("Could not initialize SoLoader", e);
}
// we should always use the application context to avoid memory leaks
context = context.getApplicationContext();
if (imagePipelineConfig == null) {
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ MOCKITO_CORE_VERSION=1.10.19
NINEOLDANDROID_VERSION=2.4.0
POWERMOCK_VERSION=1.6.6
ROBOLECTRIC_VERSION=3.0
SOLOADER_VERSION=0.3.0
SUPPORT_LIB_VERSION=27.0.2
VOLLEY_VERSION=1.0.0

Expand Down
1 change: 1 addition & 0 deletions imagepipeline-base/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies {
compileOnly "com.google.code.findbugs:jsr305:${JSR_305_VERSION}"
compileOnly "javax.annotation:javax.annotation-api:${ANNOTATION_API_VERSION}"

implementation "com.facebook.soloader:soloader:${SOLOADER_VERSION}"
implementation "com.parse.bolts:bolts-tasks:${BOLTS_ANDROID_VERSION}"
implementation project(':fbcore')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;

import com.facebook.common.soloader.SoLoaderShim;
import com.facebook.soloader.SoLoader;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
Expand All @@ -29,7 +29,7 @@
public class ImageFormatCheckerTest {

static {
SoLoaderShim.setInTestMode();
SoLoader.setInTestMode();
}

@Test
Expand Down
1 change: 1 addition & 0 deletions imagepipeline/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies {
compileOnly "javax.annotation:javax.annotation-api:${ANNOTATION_API_VERSION}"

api project(':imagepipeline-base')
implementation "com.facebook.soloader:soloader:${SOLOADER_VERSION}"

implementation "com.parse.bolts:bolts-tasks:${BOLTS_ANDROID_VERSION}"
implementation project(':fbcore')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

package com.facebook.imagepipeline.nativecode;

import com.facebook.common.soloader.SoLoaderShim;
import com.facebook.soloader.SoLoader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -39,6 +39,6 @@ public class ImagePipelineNativeLoader {
}

public static void load() {
SoLoaderShim.loadLibrary("imagepipeline");
SoLoader.loadLibrary("imagepipeline");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,29 @@

package com.facebook.imagepipeline.memory;

import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import com.facebook.common.soloader.SoLoaderShim;
import com.facebook.imagepipeline.testing.MockBitmapFactory;
import com.facebook.imageutils.BitmapUtil;
import org.junit.*;
import org.junit.runner.*;
import org.mockito.*;
import com.facebook.soloader.SoLoader;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.invocation.*;
import org.mockito.stubbing.*;
import org.powermock.core.classloader.annotations.*;
import org.robolectric.*;
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.robolectric.RobolectricTestRunner;

/**
Basic tests for BitmapPool */
Expand All @@ -34,7 +41,7 @@
public class BitmapPoolTest {

static {
SoLoaderShim.setInTestMode();
SoLoader.setInTestMode();
}

@Mock(answer = Answers.CALLS_REAL_METHODS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
package com.facebook.imagepipeline.memory;

import com.facebook.common.soloader.SoLoaderShim;
import com.facebook.soloader.SoLoader;
import org.junit.BeforeClass;

/**
Expand All @@ -20,12 +20,6 @@ public class TestUsingNativeMemoryChunk {

@BeforeClass
public static void allowNativeStaticInitializers() {
SoLoaderShim.setHandler(
new SoLoaderShim.Handler() {
@Override
public void loadLibrary(String libraryName) {
// ignore it
}
});
SoLoader.setInTestMode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,21 @@

package com.facebook.imagepipeline.platform;

import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.isNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mockStatic;
import static org.powermock.api.mockito.PowerMockito.verifyStatic;

Expand All @@ -24,13 +37,13 @@
import com.facebook.common.internal.Throwables;
import com.facebook.common.memory.PooledByteBuffer;
import com.facebook.common.references.CloseableReference;
import com.facebook.common.soloader.SoLoaderShim;
import com.facebook.imageformat.DefaultImageFormats;
import com.facebook.imagepipeline.image.EncodedImage;
import com.facebook.imagepipeline.memory.BitmapPool;
import com.facebook.imagepipeline.testing.MockBitmapFactory;
import com.facebook.imagepipeline.testing.TrivialPooledByteBuffer;
import com.facebook.imageutils.JfifUtil;
import com.facebook.soloader.SoLoader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand Down Expand Up @@ -66,7 +79,7 @@ public class ArtDecoderTest {
public PowerMockRule rule = new PowerMockRule();

static {
SoLoaderShim.setInTestMode();
SoLoader.setInTestMode();
}

private static final int RANDOM_SEED = 10101;
Expand Down
Loading