1,更新okhttp到4.9.3

2,更新Cronet版本到最新稳定版96.0.4664.104
3,修复一些过时方法
pull/1487/head
ag2s20150909 3 years ago
parent afd262be8b
commit 5be99c5db2
  1. 2
      app/build.gradle
  2. BIN
      app/cronetlib/cronet_api.jar
  3. BIN
      app/cronetlib/cronet_impl_common_java.jar
  4. BIN
      app/cronetlib/cronet_impl_native_java.jar
  5. 2
      app/src/main/assets/cronet.json
  6. 4
      app/src/main/java/io/legado/app/help/exoplayer/ExoPlayerHelper.kt
  7. 2
      app/src/main/java/io/legado/app/help/http/cronet/CronetRequestCallback.kt
  8. 6
      app/src/main/java/io/legado/app/service/AudioPlayService.kt
  9. 8
      epublib/build.gradle
  10. 2
      epublib/src/main/java/me/ag2s/umdlib/domain/UmdBook.java
  11. 4
      epublib/src/main/java/me/ag2s/umdlib/domain/UmdChapters.java
  12. 3
      epublib/src/main/java/me/ag2s/umdlib/domain/UmdHeader.java
  13. 2
      epublib/src/main/java/me/ag2s/umdlib/tool/StreamReader.java
  14. 12
      epublib/src/main/java/me/ag2s/umdlib/tool/UmdUtils.java
  15. 2
      epublib/src/main/java/me/ag2s/umdlib/tool/WrapOutputStream.java
  16. 12
      epublib/src/main/java/me/ag2s/umdlib/umd/UmdReader.java
  17. 2
      gradle.properties

@ -188,7 +188,7 @@ dependencies {
implementation('com.github.gedoor:rhino-android:1.6') implementation('com.github.gedoor:rhino-android:1.6')
// //
implementation('com.squareup.okhttp3:okhttp:4.9.2') implementation('com.squareup.okhttp3:okhttp:4.9.3')
implementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar'])) implementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar']))
//Glide //Glide

Binary file not shown.

@ -1 +1 @@
{"arm64-v8a":"9717593e18b283ac23a0be548c5aeea6","armeabi-v7a":"44c83d10c4a32ff20466bd7ef363c264","x86":"ce4ad637ead52aa3761e4ce3083f6453","x86_64":"a9924d9d2a31510d7335f6c6af32abc0","version":"93.0.4577.82"} {"arm64-v8a":"690c212d9bbad4b09b9e1ba450b273bb","armeabi-v7a":"4dbb88e5229abef7d84138218772f872","x86":"3f2421e040147da48abb07cfc6c7c87e","x86_64":"730a71ef4f03a27d1c8c8a77e7d09ff5","version":"96.0.4664.104"}

@ -2,7 +2,7 @@ package io.legado.app.help.exoplayer
import android.net.Uri import android.net.Uri
import com.google.android.exoplayer2.MediaItem import com.google.android.exoplayer2.MediaItem
import com.google.android.exoplayer2.database.ExoDatabaseProvider import com.google.android.exoplayer2.database.StandaloneDatabaseProvider
import com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource import com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource
import com.google.android.exoplayer2.source.MediaSource import com.google.android.exoplayer2.source.MediaSource
import com.google.android.exoplayer2.source.ProgressiveMediaSource import com.google.android.exoplayer2.source.ProgressiveMediaSource
@ -49,7 +49,7 @@ object ExoPlayerHelper {
* Exoplayer 内置的缓存 * Exoplayer 内置的缓存
*/ */
private val cache: Cache by lazy { private val cache: Cache by lazy {
val databaseProvider = ExoDatabaseProvider(appCtx) val databaseProvider = StandaloneDatabaseProvider(appCtx)
return@lazy SimpleCache( return@lazy SimpleCache(
//Exoplayer的缓存路径 //Exoplayer的缓存路径
File(appCtx.externalCacheDir, "exoplayer"), File(appCtx.externalCacheDir, "exoplayer"),

@ -157,8 +157,6 @@ class CronetRequestCallback @JvmOverloads internal constructor(
private fun protocolFromNegotiatedProtocol(responseInfo: UrlResponseInfo): Protocol { private fun protocolFromNegotiatedProtocol(responseInfo: UrlResponseInfo): Protocol {
val negotiatedProtocol = responseInfo.negotiatedProtocol.lowercase(Locale.getDefault()) val negotiatedProtocol = responseInfo.negotiatedProtocol.lowercase(Locale.getDefault())
// Log.e("Cronet", responseInfo.url)
// Log.e("Cronet", negotiatedProtocol)
return when { return when {
negotiatedProtocol.contains("h3") -> { negotiatedProtocol.contains("h3") -> {
return Protocol.QUIC return Protocol.QUIC

@ -13,9 +13,9 @@ import android.support.v4.media.session.MediaSessionCompat
import android.support.v4.media.session.PlaybackStateCompat import android.support.v4.media.session.PlaybackStateCompat
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.media.AudioFocusRequestCompat import androidx.media.AudioFocusRequestCompat
import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.PlaybackException import com.google.android.exoplayer2.PlaybackException
import com.google.android.exoplayer2.Player import com.google.android.exoplayer2.Player
import com.google.android.exoplayer2.SimpleExoPlayer
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseService import io.legado.app.base.BaseService
import io.legado.app.constant.* import io.legado.app.constant.*
@ -56,8 +56,8 @@ class AudioPlayService : BaseService(),
private val mFocusRequest: AudioFocusRequestCompat by lazy { private val mFocusRequest: AudioFocusRequestCompat by lazy {
MediaHelp.getFocusRequest(this) MediaHelp.getFocusRequest(this)
} }
private val exoPlayer: SimpleExoPlayer by lazy { private val exoPlayer: ExoPlayer by lazy {
SimpleExoPlayer.Builder(this).build() ExoPlayer.Builder(this).build()
} }
private var title: String = "" private var title: String = ""
private var subtitle: String = "" private var subtitle: String = ""

@ -3,12 +3,12 @@ plugins {
} }
android { android {
compileSdkVersion 30 compileSdkVersion 31
buildToolsVersion "30.0.3" buildToolsVersion '31.0.0'
defaultConfig { defaultConfig {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 30 targetSdkVersion 31
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro" consumerProguardFiles "consumer-rules.pro"
@ -29,5 +29,5 @@ android {
} }
dependencies { dependencies {
implementation "androidx.annotation:annotation:1.3.0"
} }

@ -34,7 +34,7 @@ public class UmdBook {
/** /**
* Build the UMD file. * Build the UMD file.
* @param os * @param os OutputStream
* @throws IOException * @throws IOException
*/ */
public void buildUmd(OutputStream os) throws IOException { public void buildUmd(OutputStream os) throws IOException {

@ -27,7 +27,7 @@ public class UmdChapters {
return titles; return titles;
} }
private List<byte[]> titles = new ArrayList<>(); private final List<byte[]> titles = new ArrayList<>();
public List<Integer> contentLengths = new ArrayList<>(); public List<Integer> contentLengths = new ArrayList<>();
public ByteArrayOutputStream contents = new ByteArrayOutputStream(); public ByteArrayOutputStream contents = new ByteArrayOutputStream();
@ -129,7 +129,7 @@ public class UmdChapters {
while(startPos < allContents.length) { while(startPos < allContents.length) {
left = allContents.length - startPos; left = allContents.length - startPos;
len = DEFAULT_CHUNK_INIT_SIZE < left ? DEFAULT_CHUNK_INIT_SIZE : left; len = Math.min(DEFAULT_CHUNK_INIT_SIZE, left);
bos.reset(); bos.reset();
DeflaterOutputStream zos = new DeflaterOutputStream(bos); DeflaterOutputStream zos = new DeflaterOutputStream(bos);

@ -1,6 +1,8 @@
package me.ag2s.umdlib.domain; package me.ag2s.umdlib.domain;
import androidx.annotation.NonNull;
import java.io.IOException; import java.io.IOException;
import me.ag2s.umdlib.tool.UmdUtils; import me.ag2s.umdlib.tool.UmdUtils;
@ -146,6 +148,7 @@ public class UmdHeader {
} }
@Override @Override
@NonNull
public String toString() { public String toString() {
return "UmdHeader{" + return "UmdHeader{" +
"umdType=" + umdType + "umdType=" + umdType +

@ -1,6 +1,6 @@
package me.ag2s.umdlib.tool; package me.ag2s.umdlib.tool;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;

@ -117,19 +117,15 @@ public class UmdUtils {
public static void saveFile(File f, byte[] content) throws IOException { public static void saveFile(File f, byte[] content) throws IOException {
FileOutputStream fos = new FileOutputStream(f); try (FileOutputStream fos = new FileOutputStream(f)) {
try {
BufferedOutputStream bos = new BufferedOutputStream(fos); BufferedOutputStream bos = new BufferedOutputStream(fos);
bos.write(content); bos.write(content);
bos.flush(); bos.flush();
} finally {
fos.close();
} }
} }
public static byte[] readFile(File f) throws IOException { public static byte[] readFile(File f) throws IOException {
FileInputStream fis = new FileInputStream(f); try (FileInputStream fis = new FileInputStream(f)) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedInputStream bis = new BufferedInputStream(fis); BufferedInputStream bis = new BufferedInputStream(fis);
int ch; int ch;
@ -138,12 +134,10 @@ public class UmdUtils {
} }
baos.flush(); baos.flush();
return baos.toByteArray(); return baos.toByteArray();
} finally {
fis.close();
} }
} }
private static Random random = new Random(); private static final Random random = new Random();
public static byte[] genRandomBytes(int len) { public static byte[] genRandomBytes(int len) {
if (len <= 0) { if (len <= 0) {

@ -5,7 +5,7 @@ import java.io.OutputStream;
public class WrapOutputStream extends OutputStream { public class WrapOutputStream extends OutputStream {
private OutputStream os; private final OutputStream os;
private int written; private int written;
public WrapOutputStream(OutputStream os) { public WrapOutputStream(OutputStream os) {

@ -1,5 +1,8 @@
package me.ag2s.umdlib.umd; package me.ag2s.umdlib.umd;
import androidx.annotation.NonNull;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -46,7 +49,7 @@ public class UmdReader {
System.out.println("块标识:" + segType); System.out.println("块标识:" + segType);
//short length1 = reader.readByte(); //short length1 = reader.readByte();
ReadSection(segType, segFlag, len, reader, umdHeader); readSection(segType, segFlag, len, reader, umdHeader);
if ((int) segType == 241 || (int) segType == 10) { if ((int) segType == 241 || (int) segType == 10) {
segType = num1; segType = num1;
@ -56,7 +59,7 @@ public class UmdReader {
System.out.println(ch); System.out.println(ch);
int additionalCheckNumber = reader.readIntLe(); int additionalCheckNumber = reader.readIntLe();
int length2 = (reader.readIntLe() - 9); int length2 = (reader.readIntLe() - 9);
ReadAdditionalSection(segType, additionalCheckNumber, length2, reader); readAdditionalSection(segType, additionalCheckNumber, length2, reader);
} }
num1 = segType; num1 = segType;
@ -66,7 +69,7 @@ public class UmdReader {
} }
private void ReadAdditionalSection(short segType, int additionalCheckNumber, int length, StreamReader reader) throws Exception { private void readAdditionalSection(short segType, int additionalCheckNumber, int length, StreamReader reader) throws Exception {
switch (segType) { switch (segType) {
case 14: case 14:
//this._TotalImageList.Add((object) Image.FromStream((Stream) new MemoryStream(reader.ReadBytes((int) length)))); //this._TotalImageList.Add((object) Image.FromStream((Stream) new MemoryStream(reader.ReadBytes((int) length))));
@ -118,7 +121,7 @@ public class UmdReader {
} }
} }
public void ReadSection(short segType, byte segFlag, short length, StreamReader reader, UmdHeader header) throws IOException { public void readSection(short segType, byte segFlag, short length, StreamReader reader, UmdHeader header) throws IOException {
switch (segType) { switch (segType) {
case 1://umd文件头 DCTS_CMD_ID_VERSION case 1://umd文件头 DCTS_CMD_ID_VERSION
header.setUmdType(reader.readByte()); header.setUmdType(reader.readByte());
@ -214,6 +217,7 @@ public class UmdReader {
@Override @Override
@NonNull
public String toString() { public String toString() {
return "UmdReader{" + return "UmdReader{" +
"book=" + book + "book=" + book +

@ -22,4 +22,4 @@ kotlin.code.style=official
android.enableResourceOptimizations=true android.enableResourceOptimizations=true
CronetVersion=93.0.4577.82 CronetVersion=96.0.4664.104

Loading…
Cancel
Save