Skip to content
Merged
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
25 changes: 25 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

import com.android.build.api.artifact.ScopedArtifact
import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.variant.ScopedArtifacts
import org.gradle.api.tasks.testing.Test
import org.gradle.jvm.toolchain.JavaToolchainService

Expand Down Expand Up @@ -248,12 +250,18 @@ val pluginRuntimeConfiguration by configurations.creating {
isCanBeConsumed = false
isTransitive = false
}
val pluginApiCompiler by configurations.creating {
isCanBeConsumed = false
isTransitive = false
}
val pluginRuntimeJavaLauncher = extensions.getByType<JavaToolchainService>().launcherFor {
languageVersion.set(JavaLanguageVersion.of(21))
}
dependencies {
pluginRuntimeLibraries("com.android.tools:desugar_jdk_libs:${libs.versions.desugar.get()}")
pluginRuntimeConfiguration("com.android.tools:desugar_jdk_libs_configuration:${libs.versions.desugar.get()}")
// Read the same compiler embedded in AGP without changing Gradle's plugin classpath.
pluginApiCompiler("com.android.tools.build:builder:${libs.versions.agp.get()}")
}
val generatePluginRuntime = tasks.register<GeneratePluginRuntime>("generatePluginRuntime") {
group = "plugin development"
Expand All @@ -268,6 +276,23 @@ val generatePluginRuntime = tasks.register<GeneratePluginRuntime>("generatePlugi
}
androidComponents.onVariants { variant ->
variant.sources.assets?.addGeneratedSourceDirectory(generatePluginRuntime, GeneratePluginRuntime::outputDirectory)
if (variant.buildType == "release" || variant.buildType == "pluginCompatibility") {
val preservePluginApi = tasks.register<DesugarPluginApi>(variant.computeTaskName("desugar", "PluginApi")) {
compileClasspath.from(variant.compileClasspath)
androidLibraries.from(androidComponents.sdkComponents.bootClasspath)
compilerJar.set(layout.file(pluginApiCompiler.elements.map { it.single().asFile }))
// Existing signed plugin DEX calls API-23 companions even if the host's
// minimum Android version eventually rises above 23.
minimumApi.set(23)
}
variant.artifacts.forScope(ScopedArtifacts.Scope.PROJECT).use(preservePluginApi)
.toTransform(
ScopedArtifact.CLASSES,
DesugarPluginApi::inputJars,
DesugarPluginApi::inputDirectories,
DesugarPluginApi::outputJar
)
}
}

// A compile-only SDK for the standalone template. Providers remain in the host APK;
Expand Down
3 changes: 3 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@

# External service packages link against these public APIs at runtime. Their callers
# are absent from the app's R8 input, so retain the complete published plugin surface.
# DesugarPluginApi materializes API-23 interface companions before R8. These rules
# must keep those real inputs too: R8 9 no longer keeps compiler-generated $-CC
# methods merely because the original interface is kept.
-keep class org.schabi.newpipe.extractor.** { *; }
-keep interface org.schabi.newpipe.extractor.** { *; }
-keep class com.grack.nanojson.** { *; }
Expand Down
22 changes: 22 additions & 0 deletions app/src/androidTest/assets/plugin-fixtures/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,25 @@ This is an unmodified published package: compatibility tests must not repair or
replace its DEX. The publisher repository provides version 1.2.1, including its
Android 7 URL-encoding fix. The community catalog still listed older version 1.2.0
when this fixture was recorded; the publisher signing key is unchanged.

Native WizeStream API 2.0 compatibility fixture

Plugin: PornHub 1.0.5, version code 6, by WizeStream
Package source:
https://github.com/wizdom13/PornHub-WizeStream-Plugin/releases/download/repo/pornhub-wizestream-6.ppp
Package SHA-256:
b7be7de4cf12ce09e01ecdc66a593463129fec78249e1e524841b3bc017d4470
Package size: 141797 bytes
Source revision:
https://github.com/wizdom13/PornHub-WizeStream-Plugin/tree/cc182d0a451fb60024625b0aa068816a9303e89d
License: GPL-3.0-or-later; the preparation script includes the source LICENSE.
The catalog signature/key were recorded from the publisher's repo/index.json.

This package is included only in generated instrumentation test assets, never in
the production application. Its original signed DEX exercises real native
interface defaults, shared Kotlin/jsoup/nanojson dependencies, date/time APIs and
async downloader callbacks against the minified host. The checked-in HTML is
synthetic non-explicit metadata and uses reserved example.com media URLs. The
provider deliberately rejects .invalid hostnames, so those are not valid fixtures.
All extraction requests are answered offline; the test never fetches or renders
provider content. Package signatures are verified without rewriting the bytes.
11 changes: 11 additions & 0 deletions app/src/androidTest/assets/plugin-fixtures/native-search.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html><head><title>Synthetic native plugin fixture</title></head><body>
<ul id="videoSearchResult"><li class="videoblock">
<a class="linkVideoThumb" href="/view_video.php?viewkey=phfixture123" title="Native fixture lesson">
<img src="https://media.example.com/native-poster.jpg" alt="Synthetic fixture">
</a>
<span class="duration">2:05</span><span class="views"><var>1,250</var> views</span>
<span class="usernameWrap"><a href="/model/fixture-uploader">Fixture uploader</a></span>
<time datetime="2026-01-02T03:04:05Z">Fixture date</time>
</li></ul>
</body></html>
13 changes: 13 additions & 0 deletions app/src/androidTest/assets/plugin-fixtures/native-stream.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html><head>
<title>Synthetic native plugin fixture</title>
<link rel="canonical" href="https://www.pornhub.com/view_video.php?viewkey=phfixture123">
<meta property="twitter:title" content="Native fixture lesson">
<script type="application/ld+json">{"@type":"VideoObject","name":"Native fixture lesson","description":"Synthetic fixture only","uploadDate":"2026-01-02T03:04:05Z"}</script>
<script>var flashvars_1 = {"video_title":"Native fixture lesson","video_duration":125,"image_url":"https://media.example.com/native-poster.jpg","mediaDefinitions":[{"videoUrl":"https://media.example.com/native-video.mp4?token=fixture","format":"mp4","quality":"720"}],"closedCaptionsFile":"https://media.example.com/native-captions.vtt","closedCaptionsLanguage":"en"};</script>
</head><body>
<h1 class="title">Native fixture lesson</h1>
<div class="userInfoBlock"><span class="usernameWrap"><a href="/model/fixture-uploader">Fixture uploader</a></span></div>
<span class="views"><span class="count">1,250</span></span>
<span class="votesUp">12</span><span class="votesDown">1</span>
</body></html>
24 changes: 24 additions & 0 deletions app/src/androidTest/assets/plugin-fixtures/pornhub-6-index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"formatVersion": 1,
"name": "PornHub WizeStream Plugin",
"plugins": [
{
"pluginId": "org.wizestream.plugin.pornhub",
"name": "PornHub",
"versionCode": 6,
"versionName": "1.0.5",
"host": "wizestream",
"apiVersion": "2.0",
"author": "WizeStream",
"description": "Native WizeStream service for public PornHub videos. Adults only.",
"minHostVersionCode": 1052002,
"minAndroidSdk": 24,
"requiredCapabilities": [],
"package": "pornhub-wizestream-6.ppp",
"sha256": "b7be7de4cf12ce09e01ecdc66a593463129fec78249e1e524841b3bc017d4470",
"signature": "HXoI0k5H1hfusZyzuCU0CIdh5pf9MZjavmIrJY7AFuehHbDqbp3yK2pHppSJiqZVT7w7lLcg3YNlpiRo/6HkDA==",
"publicKey": "5y7De9xj9hpiU/+XFqJm70eBoUPAZRaSoyvj8QBxxFY=",
"nsfw": true
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ import java.io.Serializable
import java.lang.reflect.Field
import java.lang.reflect.Proxy
import java.time.Duration
import org.jsoup.Jsoup
import org.jsoup.nodes.Element
import org.junit.After
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertSame
import org.junit.Assert.assertThrows
import org.junit.Assert.assertTrue
Expand Down Expand Up @@ -60,6 +63,7 @@ import org.schabi.newpipe.extractor.plugin.PluginPackage
import org.schabi.newpipe.extractor.plugin.PluginPreferences
import org.schabi.newpipe.extractor.plugin.PluginRepository
import org.schabi.newpipe.extractor.search.SearchInfo
import org.schabi.newpipe.extractor.stream.ContentAvailability
import org.schabi.newpipe.extractor.stream.DeliveryMethod
import org.schabi.newpipe.extractor.stream.StreamInfo
import org.schabi.newpipe.extractor.stream.StreamInfoItem
Expand Down Expand Up @@ -349,6 +353,77 @@ class PipePipePackageCompatibilityTest {
assertEquals(listOf("home", "stream", "channel", "sidebar", "token", "hls"), offline.requests)
}

@Test
fun publishedNativeDexCanCallAllItsApi23InterfaceCompanions() {
val fixture = loadPublishedNative()
val html = assets.open("plugin-fixtures/native-search.html").bufferedReader().use { it.readText() }
val card = requireNotNull(Jsoup.parse(html, "https://www.pornhub.com/").selectFirst(".videoblock"))
val type = Class.forName(
"org.wizestream.plugin.pornhub.PornHubStreamItemExtractor",
true,
fixture.service.javaClass.classLoader
)
val extractor = type.getConstructor(Element::class.java).newInstance(card) as StreamInfoItemExtractor
// These methods are concrete D8 forwarding methods in the unmodified signed
// package. Call them directly, outside the host's compatibility adapters.
assertEquals("https://media.example.com/native-poster.jpg", extractor.thumbnailUrl)
assertNull(extractor.albumUrl)
assertNull(extractor.shortDescription)
assertNull(extractor.upcomingStatus)
assertNull(extractor.uploaderAvatarUrl)
assertNull(extractor.uploaderId)
assertEquals(ContentAvailability.UNKNOWN, extractor.contentAvailability)
assertFalse(extractor.isRoundPlayStream)
assertFalse(extractor.isShortFormContent)
assertFalse(extractor.isUploaderVerified)
assertFalse(extractor.requiresMembership())
assertTrue(offline.requests.isEmpty())
}

@Test
fun publishedNativePluginExtractsSearchWithSharedInterfaceDefaults() {
val fixture = loadPublishedNative()
val query = fixture.service.searchQHFactory.fromQuery("fixture query", emptyList(), emptyList())
val info = SearchInfo.getInfo(fixture.service, query)
assertTrue(info.errors.toString(), info.errors.isEmpty())
val item = info.relatedItems.single() as StreamInfoItem
assertEquals("Native fixture lesson", item.name)
assertEquals(NATIVE_STREAM_URL, item.url)
assertEquals("Fixture uploader", item.uploaderName)
assertEquals("https://www.pornhub.com/model/fixture-uploader", item.uploaderUrl)
assertEquals(125L, item.duration)
assertEquals(1_250L, item.viewCount)
assertEquals("https://media.example.com/native-poster.jpg", item.thumbnailUrl)
assertNotNull(item.uploadDate)
assertFalse(item.isShortFormContent)
assertFalse(item.requiresMembership())
assertEquals(listOf("native-search"), offline.requests)
}

@Test
fun publishedNativePluginExtractsStreamAndPreservesMediaHeaders() {
val fixture = loadPublishedNative()
val info = StreamInfo.getInfo(fixture.service, NATIVE_STREAM_URL)
assertTrue(info.errors.toString(), info.errors.isEmpty())
assertEquals("Native fixture lesson", info.name)
assertEquals("Fixture uploader", info.uploaderName)
assertEquals(125L, info.duration)
assertEquals(StreamType.VIDEO_STREAM, info.streamType)
assertEquals(fixture.service.serviceId, info.serviceId)
assertNotNull(info.uploadDate)
val video = info.videoStreams.single()
assertEquals(DeliveryMethod.PROGRESSIVE_HTTP, video.deliveryMethod)
assertEquals("https://media.example.com/native-video.mp4?token=fixture", video.content)
assertEquals("720p", video.resolution)
assertEquals(false, video.cacheable)
assertEquals(NATIVE_STREAM_URL, requireNotNull(video.requestHeaders)["Referer"])
assertEquals("https://www.pornhub.com", requireNotNull(video.requestHeaders)["Origin"])
val caption = info.subtitles.single()
assertEquals(NATIVE_STREAM_URL, requireNotNull(caption.requestHeaders)["Referer"])
assertEquals(false, caption.cacheable)
assertEquals(listOf("native-stream"), offline.requests)
}

@Test
fun nativePluginUsesProfileContextAndRejectsPipePipeOnlyContext() {
val nativePresent = assets.list("").orEmpty().contains("native-example.ppp")
Expand Down Expand Up @@ -387,6 +462,12 @@ class PipePipePackageCompatibilityTest {
return fixture
}

private fun loadPublishedNative(): LoadedFixture = loadFixture(
"pornhub-6.ppp",
"plugin-fixtures/pornhub-6-index.json",
PUBLISHED_NATIVE_REPOSITORY
)

// Class.forName literals can be rewritten to desugared types in the minified test APK.
private fun platformClass(name: String): Class<*> = ClassLoader.getSystemClassLoader().loadClass(name)

Expand Down Expand Up @@ -503,6 +584,14 @@ class PipePipePackageCompatibilityTest {

override fun execute(request: Request): Response {
val url = request.url()
if (url == "https://www.pornhub.com/video/search?search=fixture+query&page=1") {
requests += "native-search"
return response(request, "native-search.html")
}
if (url == NATIVE_STREAM_URL) {
requests += "native-stream"
return response(request, "native-stream.html")
}
if (url == "https://twitch.tv") {
requests += "home"
return Response(
Expand Down Expand Up @@ -540,7 +629,17 @@ class PipePipePackageCompatibilityTest {
return Response(200, "OK", emptyMap(), bytes.toString(Charsets.UTF_8), bytes, request.url())
}

override fun executeAsync(request: Request, callback: AsyncCallback): CancellableCall = throw AssertionError("Unexpected asynchronous request in offline plugin test")
override fun executeAsync(request: Request, callback: AsyncCallback): CancellableCall {
assertTrue("Unexpected asynchronous request: ${request.url()}", request.url().startsWith("https://www.pornhub.com/"))
callback.onSuccess(execute(request))
// Complete synchronously without constructing a network client. A timeout or
// cancellation would be a test failure, never a real network operation.
return object : CancellableCall(null) {
override fun cancel() = throw AssertionError("A completed fixture request was cancelled")

override fun isCancelled(): Boolean = false
}.apply { setFinished() }
}
}

/** Test-only restoration; no production reset/install-verification bypass is exposed. */
Expand Down Expand Up @@ -576,6 +675,8 @@ class PipePipePackageCompatibilityTest {
companion object {
private const val TWITCH_REPOSITORY = "https://github.com/MohrJonas/TwitchPipePipePlugin/releases/download/repo/index.json"
private const val NATIVE_REPOSITORY = "https://example.invalid/native-fixtures/index.json"
private const val PUBLISHED_NATIVE_REPOSITORY = "https://github.com/wizdom13/PornHub-WizeStream-Plugin/releases/download/repo/index.json"
private const val NATIVE_STREAM_URL = "https://www.pornhub.com/view_video.php?viewkey=phfixture123"
private const val SEARCH_URL = "https://twitch.tv/search?term=fixture"
private const val STREAM_URL = "https://twitch.tv/fixture?_type=stream&_channelId=42&_pagination=eyJvZmZzZXQiOjAsInNpemUiOjIwfQ=="
private const val HLS_URL = "https://media.example.invalid/live/720p.m3u8"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/assets/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,10 @@ <h3>Home tab chooser</h3>
<ul>
<li>Keep the Customize home tab chooser open with an empty list when a search has no matches, and restore the available tabs when the query is cleared.</li>
</ul>
<h3>Plugin import errors</h3>
<h3>Plugins</h3>
<ul>
<li>Show complete, copyable plugin import errors in a Material 3 dialog, including package and catalog versions, checksum comparisons and metadata rejection details.</li>
<li>Fix release-only failures when native plugins load search results and video details, including existing signed plugin packages.</li>
</ul>
<h3>Library navigation</h3>
<ul>
Expand Down
Loading
Loading