Skip to content

Commit df9577d

Browse files
committed
Remove SoLoaderShim, use SoLoader
1 parent b83a71b commit df9577d

File tree

20 files changed

+134
-142
lines changed

20 files changed

+134
-142
lines changed

animated-gif/build.gradle

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,24 @@ project.group = GROUP
55
version = VERSION_NAME
66

77
dependencies {
8-
provided "com.google.code.findbugs:jsr305:${JSR_305_VERSION}"
9-
compile "com.parse.bolts:bolts-tasks:${BOLTS_ANDROID_VERSION}"
10-
provided "javax.annotation:javax.annotation-api:${ANNOTATION_API_VERSION}"
11-
compile project(':fbcore')
12-
compile project(':animated-base')
13-
14-
testCompile project(':imagepipeline-base-test')
15-
testCompile project(':imagepipeline-test')
16-
testCompile "junit:junit:${JUNIT_VERSION}"
17-
testCompile "org.mockito:mockito-core:${MOCKITO_CORE_VERSION}"
18-
testCompile("org.powermock:powermock-api-mockito:${POWERMOCK_VERSION}") {
8+
compileOnly "com.google.code.findbugs:jsr305:${JSR_305_VERSION}"
9+
compileOnly "javax.annotation:javax.annotation-api:${ANNOTATION_API_VERSION}"
10+
11+
implementation "com.facebook.soloader:soloader:${SOLOADER_VERSION}"
12+
implementation "com.parse.bolts:bolts-tasks:${BOLTS_ANDROID_VERSION}"
13+
implementation project(':fbcore')
14+
implementation project(':animated-base')
15+
16+
testImplementation project(':imagepipeline-base-test')
17+
testImplementation project(':imagepipeline-test')
18+
testImplementation "junit:junit:${JUNIT_VERSION}"
19+
testImplementation "org.mockito:mockito-core:${MOCKITO_CORE_VERSION}"
20+
testImplementation("org.powermock:powermock-api-mockito:${POWERMOCK_VERSION}") {
1921
exclude group: 'org.mockito', module: 'mockito-all'
2022
}
21-
testCompile "org.powermock:powermock-module-junit4-rule:${POWERMOCK_VERSION}"
22-
testCompile "org.powermock:powermock-classloading-xstream:${POWERMOCK_VERSION}"
23-
testCompile("org.robolectric:robolectric:${ROBOLECTRIC_VERSION}") {
23+
testImplementation "org.powermock:powermock-module-junit4-rule:${POWERMOCK_VERSION}"
24+
testImplementation "org.powermock:powermock-classloading-xstream:${POWERMOCK_VERSION}"
25+
testImplementation("org.robolectric:robolectric:${ROBOLECTRIC_VERSION}") {
2426
exclude group: 'commons-logging', module: 'commons-logging'
2527
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
2628
}

animated-gif/src/main/java/com/facebook/animated/gif/GifImage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
import com.facebook.common.internal.DoNotStrip;
1313
import com.facebook.common.internal.Preconditions;
14-
import com.facebook.common.soloader.SoLoaderShim;
1514
import com.facebook.imagepipeline.animated.base.AnimatedDrawableFrameInfo;
1615
import com.facebook.imagepipeline.animated.base.AnimatedDrawableFrameInfo.BlendOperation;
1716
import com.facebook.imagepipeline.animated.base.AnimatedImage;
1817
import com.facebook.imagepipeline.animated.factory.AnimatedImageDecoder;
18+
import com.facebook.soloader.SoLoader;
1919
import java.nio.ByteBuffer;
2020
import javax.annotation.concurrent.ThreadSafe;
2121

@@ -41,7 +41,7 @@ public class GifImage implements AnimatedImage, AnimatedImageDecoder {
4141
private static synchronized void ensure() {
4242
if (!sInitialized) {
4343
sInitialized = true;
44-
SoLoaderShim.loadLibrary("gifimage");
44+
SoLoader.loadLibrary("gifimage");
4545
}
4646
}
4747

animated-gif/src/test/java/com/facebook/imagepipeline/animated/factory/AnimatedImageFactoryGifImplTest.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,25 @@
1010

1111
package com.facebook.imagepipeline.animated.factory;
1212

13-
import static org.junit.Assert.*;
14-
import static org.mockito.Mockito.*;
13+
import static org.junit.Assert.assertFalse;
14+
import static org.junit.Assert.assertNotNull;
15+
import static org.junit.Assert.assertNull;
16+
import static org.junit.Assert.assertSame;
17+
import static org.mockito.Mockito.any;
18+
import static org.mockito.Mockito.isNull;
19+
import static org.mockito.Mockito.mock;
20+
import static org.mockito.Mockito.times;
21+
import static org.mockito.Mockito.verify;
22+
import static org.mockito.Mockito.verifyNoMoreInteractions;
23+
import static org.mockito.Mockito.verifyZeroInteractions;
24+
import static org.mockito.Mockito.when;
1525

1626
import android.graphics.Bitmap;
1727
import android.graphics.Rect;
1828
import com.facebook.animated.gif.GifImage;
1929
import com.facebook.common.memory.PooledByteBuffer;
2030
import com.facebook.common.references.CloseableReference;
2131
import com.facebook.common.references.ResourceReleaser;
22-
import com.facebook.common.soloader.SoLoaderShim;
2332
import com.facebook.imageformat.ImageFormat;
2433
import com.facebook.imagepipeline.animated.base.AnimatedDrawableBackend;
2534
import com.facebook.imagepipeline.animated.base.AnimatedImageResult;
@@ -31,6 +40,7 @@
3140
import com.facebook.imagepipeline.image.EncodedImage;
3241
import com.facebook.imagepipeline.testing.MockBitmapFactory;
3342
import com.facebook.imagepipeline.testing.TrivialPooledByteBuffer;
43+
import com.facebook.soloader.SoLoader;
3444
import org.junit.Before;
3545
import org.junit.Rule;
3646
import org.junit.Test;
@@ -58,7 +68,7 @@ public class AnimatedImageFactoryGifImplTest {
5868
public PowerMockRule rule = new PowerMockRule();
5969

6070
static {
61-
SoLoaderShim.setInTestMode();
71+
SoLoader.setInTestMode();
6272
}
6373

6474
private static ResourceReleaser<PooledByteBuffer> FAKE_RESOURCE_RELEASER =

animated-webp/src/test/java/com/facebook/imagepipeline/animated/factory/AnimatedImageFactoryWebPImplTest.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,25 @@
1010

1111
package com.facebook.imagepipeline.animated.factory;
1212

13-
import static org.junit.Assert.*;
14-
import static org.mockito.Mockito.*;
13+
import static org.junit.Assert.assertFalse;
14+
import static org.junit.Assert.assertNotNull;
15+
import static org.junit.Assert.assertNull;
16+
import static org.junit.Assert.assertSame;
17+
import static org.mockito.Mockito.any;
18+
import static org.mockito.Mockito.isNull;
19+
import static org.mockito.Mockito.mock;
20+
import static org.mockito.Mockito.times;
21+
import static org.mockito.Mockito.verify;
22+
import static org.mockito.Mockito.verifyNoMoreInteractions;
23+
import static org.mockito.Mockito.verifyZeroInteractions;
24+
import static org.mockito.Mockito.when;
1525

1626
import android.graphics.Bitmap;
1727
import android.graphics.Rect;
1828
import com.facebook.animated.webp.WebPImage;
1929
import com.facebook.common.memory.PooledByteBuffer;
2030
import com.facebook.common.references.CloseableReference;
2131
import com.facebook.common.references.ResourceReleaser;
22-
import com.facebook.common.soloader.SoLoaderShim;
2332
import com.facebook.imageformat.ImageFormat;
2433
import com.facebook.imagepipeline.animated.base.AnimatedDrawableBackend;
2534
import com.facebook.imagepipeline.animated.base.AnimatedImageResult;
@@ -57,10 +66,6 @@ public class AnimatedImageFactoryWebPImplTest {
5766
@Rule
5867
public PowerMockRule rule = new PowerMockRule();
5968

60-
static {
61-
SoLoaderShim.setInTestMode();
62-
}
63-
6469
private static ResourceReleaser<PooledByteBuffer> FAKE_RESOURCE_RELEASER =
6570
new ResourceReleaser<PooledByteBuffer>() {
6671

drawee-backends/drawee-pipeline/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ version = VERSION_NAME
66
dependencies {
77
compileOnly "com.android.support:support-core-utils:${SUPPORT_LIB_VERSION}"
88
compileOnly "com.google.code.findbugs:jsr305:${JSR_305_VERSION}"
9+
10+
implementation "com.facebook.soloader:soloader:${SOLOADER_VERSION}"
11+
912
api project(':fbcore')
1013
api project(':drawee')
1114
api project(':imagepipeline')

drawee-backends/drawee-pipeline/src/main/java/com/facebook/drawee/backends/pipeline/Fresco.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import com.facebook.imagepipeline.core.ImagePipeline;
1616
import com.facebook.imagepipeline.core.ImagePipelineConfig;
1717
import com.facebook.imagepipeline.core.ImagePipelineFactory;
18+
import com.facebook.soloader.SoLoader;
19+
import java.io.IOException;
1820
import javax.annotation.Nullable;
1921

2022
/**
@@ -57,6 +59,11 @@ public static void initialize(
5759
} else {
5860
sIsInitialized = true;
5961
}
62+
try {
63+
SoLoader.init(context, 0);
64+
} catch (IOException e) {
65+
throw new RuntimeException("Could not initialize SoLoader", e);
66+
}
6067
// we should always use the application context to avoid memory leaks
6168
context = context.getApplicationContext();
6269
if (imagePipelineConfig == null) {

fbcore/src/main/java/com/facebook/common/soloader/SoLoaderShim.java

Lines changed: 0 additions & 67 deletions
This file was deleted.

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ MOCKITO_CORE_VERSION=1.10.19
4040
NINEOLDANDROID_VERSION=2.4.0
4141
POWERMOCK_VERSION=1.6.6
4242
ROBOLECTRIC_VERSION=3.0
43+
SOLOADER_VERSION=0.1.0
4344
SUPPORT_LIB_VERSION=27.0.2
4445
VOLLEY_VERSION=1.0.0
4546

imagepipeline-base/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ dependencies {
1111
compileOnly "com.google.code.findbugs:jsr305:${JSR_305_VERSION}"
1212
compileOnly "javax.annotation:javax.annotation-api:${ANNOTATION_API_VERSION}"
1313

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

imagepipeline-base/src/test/java/com/facebook/imageformat/ImageFormatCheckerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import static org.junit.Assert.assertNotNull;
1313
import static org.junit.Assert.assertSame;
1414

15-
import com.facebook.common.soloader.SoLoaderShim;
15+
import com.facebook.soloader.SoLoader;
1616
import java.io.IOException;
1717
import java.io.InputStream;
1818
import java.util.ArrayList;
@@ -29,7 +29,7 @@
2929
public class ImageFormatCheckerTest {
3030

3131
static {
32-
SoLoaderShim.setInTestMode();
32+
SoLoader.setInTestMode();
3333
}
3434

3535
@Test

0 commit comments

Comments
 (0)