Compare commits

...
34 Commits
Author SHA1 Message Date
FooIbar 019b961461 Merge branch '1.8.9.x' into 1.8.9.x-gms
Releases / Build (push) Has been cancelled
# Conflicts:
#	app/build.gradle.kts
2023-10-01 23:01:17 +08:00
FooIbar 97f988991e Release 1.8.9.7
Releases / Build (push) Has been cancelled
2023-10-01 22:59:52 +08:00
FooIbar 0dbc3b7ea7 Merge branch '1.8.x.x' into 1.8.9.x 2023-10-01 22:59:17 +08:00
FooIbar d974cb56df Use versionNameSuffix for the gms variant 2023-09-23 16:44:56 +08:00
FooIbar 13f255529b Release 1.8.9.6-gms
Releases / Build (push) Has been cancelled
2023-09-20 19:51:04 +08:00
FooIbar 16e912c9ae Merge branch '1.8.x.x' into 1.8.9.x-gms 2023-09-20 19:50:40 +08:00
FooIbar d58e08e24c Release 1.8.9.6
Releases / Build (push) Has been cancelled
2023-09-20 19:49:48 +08:00
FooIbar e111ec74be Merge branch '1.8.x.x' into 1.8.9.x 2023-09-20 19:49:25 +08:00
FooIbar 01742ac6b9 Refine AppUpdater for the gms variant 2023-09-15 12:40:02 +08:00
FooIbar e94424a83e Release 1.8.9.5-gms
Releases / Build (push) Has been cancelled
2023-09-10 21:22:18 +08:00
FooIbar 56d30aa413 Merge branch '1.8.x.x' into 1.8.9.x-gms
# Conflicts:
#	app/build.gradle.kts
2023-09-10 21:21:59 +08:00
FooIbar 2c01acb4a6 Release 1.8.9.5
Releases / Build (push) Has been cancelled
2023-09-10 21:20:49 +08:00
FooIbar c0f6d0ab04 Merge branch '1.8.x.x' into 1.8.9.x
# Conflicts:
#	app/build.gradle.kts
2023-09-10 21:20:31 +08:00
FooIbar a6d215a0bf Release 1.8.9.4-gms
Releases / Build (push) Has been cancelled
2023-08-30 16:43:42 +08:00
FooIbar cf9441adb5 Merge branch '1.8.x.x' into 1.8.9.x-gms
# Conflicts:
#	app/build.gradle.kts
2023-08-30 16:43:28 +08:00
FooIbar 9746f20b60 Release 1.8.9.4
Releases / Build (push) Has been cancelled
2023-08-30 16:41:26 +08:00
FooIbar 501148179b Merge branch '1.8.x.x' into 1.8.9.x 2023-08-30 16:40:48 +08:00
FooIbar 36b16d7be8 Release 1.8.9.3-gms
Releases / Build (push) Has been cancelled
2023-08-17 23:00:54 +08:00
FooIbar fab5532407 Revert "Remove embedded Cronet library"
This reverts commit 9c5eddb9
2023-08-17 23:00:08 +08:00
FooIbar 8ad4e8640f Merge branch '1.8.x.x' into 1.8.9.x-gms
# Conflicts:
#	app/build.gradle.kts
#	app/src/main/java/com/hippo/ehviewer/util/CronetUtils.kt
2023-08-17 22:59:37 +08:00
FooIbar d08491bf7e Release 1.8.9.3
Releases / Build (push) Has been cancelled
2023-08-17 22:54:38 +08:00
FooIbar 12f6f08d81 Merge branch '1.8.x.x' into 1.8.9.x 2023-08-17 22:53:52 +08:00
FooIbar 5b5a2a9a33 Release 1.8.9.2-gms
Releases / Build (push) Has been cancelled
2023-08-15 17:49:53 +08:00
FooIbar 7719312355 Merge branch '1.8.x.x' into 1.8.9.x-gms 2023-08-15 17:49:46 +08:00
FooIbar e2345cc756 Release 1.8.9.2
Releases / Build (push) Has been cancelled
2023-08-15 17:48:26 +08:00
FooIbar 8d0b8534b2 Merge branch '1.8.x.x' into 1.8.9.x 2023-08-15 17:48:11 +08:00
FooIbar 48f1b0a958 Release 1.8.9.1-gms
Releases / Build (push) Has been cancelled
2023-08-14 23:18:57 +08:00
FooIbar 9abeba6b15 Merge branch '1.8.x.x' into 1.8.9.x-gms 2023-08-14 23:18:34 +08:00
FooIbar 63f9c8de79 Release 1.8.9.1
Releases / Build (push) Has been cancelled
2023-08-14 23:17:22 +08:00
FooIbar f792f2c968 Merge branch '1.8.x.x' into 1.8.9.x 2023-08-14 23:16:13 +08:00
FooIbar 75bec4314e Release 1.8.9.0-gms
Releases / Build (push) Has been cancelled
2023-08-11 16:03:44 +08:00
FooIbar b767c041b9 Load Cronet from Google Play services 2023-08-11 15:56:21 +08:00
FooIbar 4e916731b3 Release 1.8.9.0
Releases / Build (push) Has been cancelled
2023-08-11 14:29:52 +08:00
FooIbar 6c24407fb7 Update releases.yml 2023-08-11 14:29:52 +08:00
8 changed files with 35 additions and 40 deletions

No files matched your search

+11 -1
View File
@@ -46,6 +46,10 @@ android {
enableV4Signing = true enableV4Signing = true
} }
val branch = providers.exec {
commandLine = "git branch --show-current".split(' ')
}.standardOutput.asText.get().trim()
val commitSha = providers.exec { val commitSha = providers.exec {
commandLine = "git rev-parse --short=7 HEAD".split(' ') commandLine = "git rev-parse --short=7 HEAD".split(' ')
}.standardOutput.asText.get().trim() }.standardOutput.asText.get().trim()
@@ -65,7 +69,8 @@ android {
minSdk = 28 minSdk = 28
targetSdk = 34 targetSdk = 34
versionCode = 180043 versionCode = 180043
versionName = "1.8.10.0-SNAPSHOT" versionName = "1.8.9.7"
versionNameSuffix = "-gms"
resourceConfigurations.addAll( resourceConfigurations.addAll(
listOf( listOf(
"zh", "zh",
@@ -82,8 +87,10 @@ android {
"nb-rNO", "nb-rNO",
), ),
) )
buildConfigField("String", "BRANCH", "\"$branch\"")
buildConfigField("String", "COMMIT_SHA", "\"$commitSha\"") buildConfigField("String", "COMMIT_SHA", "\"$commitSha\"")
buildConfigField("String", "REPO_NAME", "\"$repoName\"") buildConfigField("String", "REPO_NAME", "\"$repoName\"")
buildConfigField("String", "VERSION_NAME_SUFFIX", "\"$versionNameSuffix\"")
} }
externalNativeBuild { externalNativeBuild {
@@ -252,6 +259,9 @@ dependencies {
implementation("io.ktor:ktor-io-jvm:$ktor") implementation("io.ktor:ktor-io-jvm:$ktor")
implementation("io.ktor:ktor-utils-jvm:$ktor") implementation("io.ktor:ktor-utils-jvm:$ktor")
implementation("org.chromium.net:cronet-api:113.5672.61")
implementation("com.google.android.gms:play-services-cronet:18.0.1")
val serialization = "1.6.0" val serialization = "1.6.0"
implementation("org.jetbrains.kotlinx:kotlinx-serialization-cbor:$serialization") implementation("org.jetbrains.kotlinx:kotlinx-serialization-cbor:$serialization")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization") implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization")
@@ -25,6 +25,7 @@ import androidx.lifecycle.coroutineScope
import coil.ImageLoaderFactory import coil.ImageLoaderFactory
import coil.decode.ImageDecoderDecoder import coil.decode.ImageDecoderDecoder
import coil.util.DebugLogger import coil.util.DebugLogger
import com.google.android.gms.net.CronetProviderInstaller
import com.hippo.ehviewer.client.EhCookieStore import com.hippo.ehviewer.client.EhCookieStore
import com.hippo.ehviewer.client.EhTagDatabase import com.hippo.ehviewer.client.EhTagDatabase
import com.hippo.ehviewer.client.data.GalleryDetail import com.hippo.ehviewer.client.data.GalleryDetail
@@ -77,6 +78,7 @@ class EhApplication : Application(), ImageLoaderFactory {
handler?.uncaughtException(t, e) handler?.uncaughtException(t, e)
} }
super.onCreate() super.onCreate()
CronetProviderInstaller.installProvider(appCtx)
System.loadLibrary("ehviewer") System.loadLibrary("ehviewer")
System.loadLibrary("ehviewer_rust") System.loadLibrary("ehviewer_rust")
ReadableTime.initialize(this) ReadableTime.initialize(this)
@@ -1,12 +1,9 @@
@file:Suppress("BlockingMethodInNonBlockingContext") @file:Suppress("BlockingMethodInNonBlockingContext")
@file:RequiresExtension(extension = Build.VERSION_CODES.S, version = 7)
package com.hippo.ehviewer.coil package com.hippo.ehviewer.coil
import android.net.Uri import android.net.Uri
import android.os.Build
import android.webkit.MimeTypeMap import android.webkit.MimeTypeMap
import androidx.annotation.RequiresExtension
import coil.ComponentRegistry import coil.ComponentRegistry
import coil.ImageLoader import coil.ImageLoader
import coil.decode.DataSource import coil.decode.DataSource
@@ -30,7 +27,7 @@ class CronetHttpUriFetcher(private val data: String, private val options: Option
val diskCache = requireNotNull(imageLoader.diskCache) val diskCache = requireNotNull(imageLoader.diskCache)
val snapshot = diskCache.openSnapshot(diskCacheKey) ?: run { val snapshot = diskCache.openSnapshot(diskCacheKey) ?: run {
val success = cronetRequest(data) { val success = cronetRequest(data) {
setCacheDisabled(true) disableCache()
}.execute { }.execute {
diskCache.suspendEdit(diskCacheKey) { diskCache.suspendEdit(diskCacheKey) {
RandomAccessFile(data.toFile(), "rw").use { RandomAccessFile(data.toFile(), "rw").use {
@@ -1,13 +1,5 @@
@file:RequiresExtension(extension = Build.VERSION_CODES.S, version = 7)
package com.hippo.ehviewer.cronet package com.hippo.ehviewer.cronet
import android.net.http.HttpEngine
import android.net.http.HttpException
import android.net.http.UrlRequest
import android.net.http.UrlResponseInfo
import android.os.Build
import androidx.annotation.RequiresExtension
import com.hippo.ehviewer.EhApplication import com.hippo.ehviewer.EhApplication
import com.hippo.ehviewer.client.CHROME_ACCEPT import com.hippo.ehviewer.client.CHROME_ACCEPT
import com.hippo.ehviewer.client.CHROME_ACCEPT_LANGUAGE import com.hippo.ehviewer.client.CHROME_ACCEPT_LANGUAGE
@@ -20,6 +12,10 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.suspendCancellableCoroutine import kotlinx.coroutines.suspendCancellableCoroutine
import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl
import okio.Path.Companion.toOkioPath import okio.Path.Companion.toOkioPath
import org.chromium.net.CronetEngine
import org.chromium.net.CronetException
import org.chromium.net.UrlRequest
import org.chromium.net.UrlResponseInfo
import splitties.init.appCtx import splitties.init.appCtx
import java.nio.ByteBuffer import java.nio.ByteBuffer
import java.nio.channels.FileChannel import java.nio.channels.FileChannel
@@ -32,23 +28,24 @@ import kotlin.coroutines.resumeWithException
private const val TAG = "CronetRequest" private const val TAG = "CronetRequest"
val pool = DirectByteBufferPool(32) val pool = DirectByteBufferPool(32)
val cronetHttpClient: HttpEngine = HttpEngine.Builder(appCtx).apply { val cronetHttpClient: CronetEngine = CronetEngine.Builder(appCtx).apply {
setEnableBrotli(true) enableBrotli(true)
val cache = (appCtx.cacheDir.toOkioPath() / "http_cache").toFile().apply { mkdirs() } val cache = (appCtx.cacheDir.toOkioPath() / "http_cache").toFile().apply { mkdirs() }
setStoragePath(cache.absolutePath) setStoragePath(cache.absolutePath)
setEnableHttpCache(HttpEngine.Builder.HTTP_CACHE_DISK_NO_HTTP, 100 * 1024) enableHttpCache(CronetEngine.Builder.HTTP_CACHE_DISK_NO_HTTP, 100 * 1024)
setUserAgent(CHROME_USER_AGENT) setUserAgent(CHROME_USER_AGENT)
}.build() }.build()
val cronetHttpClientExecutor = EhApplication.baseOkHttpClient.dispatcher.executorService val cronetHttpClientExecutor = EhApplication.baseOkHttpClient.dispatcher.executorService
// TODO: Rewrite this to use android.net.http.HttpEngine and make it Android 14 only when released
class CronetRequest { class CronetRequest {
lateinit var consumer: (ByteBuffer) -> Unit lateinit var consumer: (ByteBuffer) -> Unit
lateinit var onResponse: CronetRequest.(UrlResponseInfo) -> Unit lateinit var onResponse: CronetRequest.(UrlResponseInfo) -> Unit
lateinit var request: UrlRequest lateinit var request: UrlRequest
lateinit var onError: (Throwable) -> Unit lateinit var onError: (Throwable) -> Unit
lateinit var readerCont: Continuation<Unit> lateinit var readerCont: Continuation<Unit>
val callback = object : UrlRequest.Callback { val callback = object : UrlRequest.Callback() {
override fun onRedirectReceived(req: UrlRequest, info: UrlResponseInfo, url: String) { override fun onRedirectReceived(req: UrlRequest, info: UrlResponseInfo, url: String) {
logcat(tag = TAG) { "Redirected to $url" } logcat(tag = TAG) { "Redirected to $url" }
req.followRedirect() req.followRedirect()
@@ -67,18 +64,14 @@ class CronetRequest {
readerCont.resume(Unit) readerCont.resume(Unit)
} }
override fun onFailed(req: UrlRequest, info: UrlResponseInfo?, e: HttpException) { override fun onFailed(req: UrlRequest, info: UrlResponseInfo?, e: CronetException) {
onError(e) onError(e)
} }
override fun onCanceled(req: UrlRequest, info: UrlResponseInfo?) {
// No-op
}
} }
} }
inline fun cronetRequest(url: String, referer: String? = null, conf: UrlRequest.Builder.() -> Unit = {}) = CronetRequest().apply { inline fun cronetRequest(url: String, referer: String? = null, conf: UrlRequest.Builder.() -> Unit = {}) = CronetRequest().apply {
request = cronetHttpClient.newUrlRequestBuilder(url, cronetHttpClientExecutor, callback).apply { request = cronetHttpClient.newUrlRequestBuilder(url, callback, cronetHttpClientExecutor).apply {
addHeader("Cookie", EhCookieStore.getCookieHeader(url.toHttpUrl())) addHeader("Cookie", EhCookieStore.getCookieHeader(url.toHttpUrl()))
addHeader("Accept", CHROME_ACCEPT) addHeader("Accept", CHROME_ACCEPT)
addHeader("Accept-Language", CHROME_ACCEPT_LANGUAGE) addHeader("Accept-Language", CHROME_ACCEPT_LANGUAGE)
@@ -135,9 +135,9 @@ class SpiderDen(mGalleryInfo: GalleryInfo) {
): Boolean { ): Boolean {
return if (isCronetSupported) { return if (isCronetSupported) {
cronetRequest(url, referer) { cronetRequest(url, referer) {
setCacheDisabled(true) disableCache()
}.execute { info -> }.execute { info ->
val headers = info.headers.asMap val headers = info.allHeaders
val type = headers["Content-Type"]?.first()?.toMediaType()?.subtype ?: "jpg" val type = headers["Content-Type"]?.first()?.toMediaType()?.subtype ?: "jpg"
val length = headers["Content-Length"]!!.first().toLong() val length = headers["Content-Length"]!!.first().toLong()
saveResponseMeta(index, type, length) { file -> saveResponseMeta(index, type, length) { file ->
@@ -9,7 +9,6 @@ import io.ktor.util.encodeBase64
import moe.tarsin.coroutines.runSuspendCatching import moe.tarsin.coroutines.runSuspendCatching
import okhttp3.Request import okhttp3.Request
import okio.sink import okio.sink
import org.json.JSONObject
import tachiyomi.data.release.GithubArtifacts import tachiyomi.data.release.GithubArtifacts
import tachiyomi.data.release.GithubCommitComparison import tachiyomi.data.release.GithubCommitComparison
import tachiyomi.data.release.GithubRelease import tachiyomi.data.release.GithubRelease
@@ -20,7 +19,8 @@ import java.time.temporal.ChronoUnit
import java.util.zip.ZipInputStream import java.util.zip.ZipInputStream
private const val API_URL = "https://api.github.com/repos/${BuildConfig.REPO_NAME}" private const val API_URL = "https://api.github.com/repos/${BuildConfig.REPO_NAME}"
private const val LATEST_RELEASE_URL = "$API_URL/releases/latest" private const val RELEASE_URL = "$API_URL/releases"
private const val LATEST_RELEASE_URL = "$RELEASE_URL/latest"
object AppUpdater { object AppUpdater {
suspend fun checkForUpdate(forceCheck: Boolean = false): Release? { suspend fun checkForUpdate(forceCheck: Boolean = false): Release? {
@@ -31,10 +31,7 @@ object AppUpdater {
Settings.lastUpdateDay = now.epochSecond Settings.lastUpdateDay = now.epochSecond
if (Settings.useCIUpdateChannel) { if (Settings.useCIUpdateChannel) {
val curSha = BuildConfig.COMMIT_SHA val curSha = BuildConfig.COMMIT_SHA
val branch = ghRequest(API_URL).execute { val workflowRunsUrl = "$API_URL/actions/workflows/ci.yml/runs?branch=${BuildConfig.BRANCH}&status=success&per_page=1"
JSONObject(body.string()).getString("default_branch")
}
val workflowRunsUrl = "$API_URL/actions/workflows/ci.yml/runs?branch=$branch&status=success&per_page=1"
val workflowRun = ghRequest(workflowRunsUrl).executeAndParseAs<GithubWorkflowRuns>().workflowRuns[0] val workflowRun = ghRequest(workflowRunsUrl).executeAndParseAs<GithubWorkflowRuns>().workflowRuns[0]
val shortSha = workflowRun.headSha.take(7) val shortSha = workflowRun.headSha.take(7)
if (shortSha != curSha) { if (shortSha != curSha) {
@@ -51,10 +48,11 @@ object AppUpdater {
} else { } else {
val curVersion = BuildConfig.VERSION_NAME val curVersion = BuildConfig.VERSION_NAME
val release = ghRequest(LATEST_RELEASE_URL).executeAndParseAs<GithubRelease>() val release = ghRequest(LATEST_RELEASE_URL).executeAndParseAs<GithubRelease>()
val latestVersion = release.version val latestVersion = release.version + BuildConfig.VERSION_NAME_SUFFIX
val description = release.info val description = release.info
val downloadUrl = release.getDownloadLink()
if (latestVersion != curVersion) { if (latestVersion != curVersion) {
val downloadUrl = ghRequest("$RELEASE_URL/tags/$latestVersion")
.executeAndParseAs<GithubRelease>().getDownloadLink()
return Release(latestVersion, description, downloadUrl) return Release(latestVersion, description, downloadUrl)
} }
} }
@@ -1,8 +1,6 @@
package com.hippo.ehviewer.util package com.hippo.ehviewer.util
import android.os.Build import com.google.android.gms.net.CronetProviderInstaller
import androidx.annotation.ChecksSdkIntAtLeast
@get:ChecksSdkIntAtLeast(Build.VERSION_CODES.S, extension = 7)
val isCronetSupported: Boolean val isCronetSupported: Boolean
get() = isAtLeastSExtension7 get() = isAtLeastQ && CronetProviderInstaller.isInstalled()
@@ -1,8 +1,5 @@
package com.hippo.ehviewer.util package com.hippo.ehviewer.util
import android.os.Build import android.os.Build
import android.os.ext.SdkExtensions
val isAtLeastQ = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q val isAtLeastQ = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
val isAtLeastR = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
val isAtLeastSExtension7 = isAtLeastR && SdkExtensions.getExtensionVersion(Build.VERSION_CODES.S) >= 7