mirror of
https://github.com/samsonjs/media.git
synced 2026-03-29 10:05:48 +00:00
[MOD] Use Cronet from Play Services, as default instead of using embedded one. It lets to reduce APK size ~8MB.
This commit is contained in:
parent
818925d4a7
commit
e4f6666cb2
2 changed files with 63 additions and 10 deletions
|
|
@ -31,7 +31,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
api 'org.chromium.net:cronet-embedded:76.3809.111'
|
||||
api "com.google.android.gms:play-services-cronet:17.0.0"
|
||||
implementation project(modulePrefix + 'library-core')
|
||||
implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion
|
||||
compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
|
@ -56,7 +58,6 @@ import org.chromium.net.CronetEngine;
|
|||
import org.chromium.net.NetworkException;
|
||||
import org.chromium.net.UrlRequest;
|
||||
import org.chromium.net.UrlResponseInfo;
|
||||
import org.chromium.net.impl.UrlResponseInfoImpl;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
|
@ -147,14 +148,66 @@ public final class CronetDataSourceTest {
|
|||
private UrlResponseInfo createUrlResponseInfoWithUrl(String url, int statusCode) {
|
||||
ArrayList<Map.Entry<String, String>> responseHeaderList = new ArrayList<>();
|
||||
responseHeaderList.addAll(testResponseHeader.entrySet());
|
||||
return new UrlResponseInfoImpl(
|
||||
Collections.singletonList(url),
|
||||
statusCode,
|
||||
null, // httpStatusText
|
||||
responseHeaderList,
|
||||
false, // wasCached
|
||||
null, // negotiatedProtocol
|
||||
null); // proxyServer
|
||||
return new UrlResponseInfo() {
|
||||
@Override
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUrlChain() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHttpStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHttpStatusText() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map.Entry<String, String>> getAllHeadersAsList() {
|
||||
return responseHeaderList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getAllHeaders() {
|
||||
Map<String, List<String>> map = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
for (Map.Entry<String, String> entry : responseHeaderList) {
|
||||
List<String> values = new ArrayList<>();
|
||||
if (map.containsKey(entry.getKey())) {
|
||||
values.addAll(map.get(entry.getKey()));
|
||||
}
|
||||
values.add(entry.getValue());
|
||||
map.put(entry.getKey(), Collections.unmodifiableList(values));
|
||||
}
|
||||
return Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wasCached() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNegotiatedProtocol() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProxyServer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getReceivedByteCount() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in a new issue