mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c40c6845eb | ||
|
|
8e31e07380 | ||
|
|
5ccceed827 | ||
|
|
6e581c9a56 | ||
|
|
756cd4eae9 | ||
|
|
d31ad1c279 | ||
|
|
e090db2d58 | ||
|
|
a97ade6a67 | ||
|
|
89f90812f8 |
No files matched your search
@@ -349,7 +349,9 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
|||||||
releaseChecking = true
|
releaseChecking = true
|
||||||
autoStatus = activity.getString(R.string.drivers_checking_latest)
|
autoStatus = activity.getString(R.string.drivers_checking_latest)
|
||||||
Thread({
|
Thread({
|
||||||
val problem = if (force || releasesStale()) runCatching { TurnipReleases.refresh(activity) }.exceptionOrNull()?.message else null
|
val failure = if (force || releasesStale()) runCatching { TurnipReleases.refresh(activity) }.exceptionOrNull() else null
|
||||||
|
val problem = failure?.message
|
||||||
|
val checkFailed = failure != null
|
||||||
val holdBack = !force && com.droiddeck.launcher.frontend.AutoComponents.constrained(activity)
|
val holdBack = !force && com.droiddeck.launcher.frontend.AutoComponents.constrained(activity)
|
||||||
runCatching { com.droiddeck.launcher.gpu.VulkanInfo.query() }
|
runCatching { com.droiddeck.launcher.gpu.VulkanInfo.query() }
|
||||||
ui.post {
|
ui.post {
|
||||||
@@ -367,8 +369,19 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
|||||||
SessionPrefs.maliFallbackByAuto(activity), gpu.family.mali,
|
SessionPrefs.maliFallbackByAuto(activity), gpu.family.mali,
|
||||||
pair?.key?.let { DriverPairs.isNonAdreno(it) } == true,
|
pair?.key?.let { DriverPairs.isNonAdreno(it) } == true,
|
||||||
)) endMaliFallback()
|
)) endMaliFallback()
|
||||||
autoStatus = problem?.let { activity.getString(R.string.drivers_up_to_date_check_failed, it) }
|
autoStatus = if (checkFailed || TurnipReleases.cached(activity)?.failed?.contains(TurnipReleases.NON_ADRENO_LABEL) == true)
|
||||||
?: activity.getString(R.string.upd_current_status)
|
activity.getString(R.string.drivers_up_to_date_check_failed, problem ?: TurnipReleases.NON_ADRENO_LABEL)
|
||||||
|
else activity.getString(R.string.upd_current_status)
|
||||||
|
}
|
||||||
|
gpu.family == GpuInfo.Family.POWERVR && (pair == null || !pair.complete) &&
|
||||||
|
(checkFailed || TurnipReleases.cached(activity)?.failed?.contains(TurnipReleases.NON_ADRENO_LABEL) == true) -> {
|
||||||
|
if (gpu.name.contains("Xclipse", ignoreCase = true) && DriverPairs.xclipseNeedsUpstream(gpu.name)) {
|
||||||
|
if (!SessionState.running) SessionPrefs.ensurePowerVrAutoDrivers(activity, powerVr = true, autoOwnedOnly = true)
|
||||||
|
} else {
|
||||||
|
SessionPrefs.ensurePowerVrAutoDrivers(activity)
|
||||||
|
}
|
||||||
|
autoStatus = activity.getString(R.string.upd_couldnt_check, problem ?: TurnipReleases.NON_ADRENO_LABEL)
|
||||||
|
refreshDrivers()
|
||||||
}
|
}
|
||||||
gpu.family == GpuInfo.Family.POWERVR && (pair == null || !pair.complete) -> {
|
gpu.family == GpuInfo.Family.POWERVR && (pair == null || !pair.complete) -> {
|
||||||
// RADV is not published right now: the Xclipse falls back to the system route.
|
// RADV is not published right now: the Xclipse falls back to the system route.
|
||||||
@@ -381,7 +394,7 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
|||||||
refreshDrivers()
|
refreshDrivers()
|
||||||
}
|
}
|
||||||
gpu.family.mali && (pair == null || !pair.complete) &&
|
gpu.family.mali && (pair == null || !pair.complete) &&
|
||||||
(problem != null || TurnipReleases.cached(activity)?.failed?.contains(TurnipReleases.NON_ADRENO_LABEL) == true) -> {
|
(checkFailed || TurnipReleases.cached(activity)?.failed?.contains(TurnipReleases.NON_ADRENO_LABEL) == true) -> {
|
||||||
// The list could not be read: nothing is known to be missing, so a working route stays.
|
// The list could not be read: nothing is known to be missing, so a working route stays.
|
||||||
// With no open driver, Venus or bridge the session would run the runtime's Turnip,
|
// With no open driver, Venus or bridge the session would run the runtime's Turnip,
|
||||||
// which finds no GPU on a Mali, so the stand-in goes on anyway.
|
// which finds no GPU on a Mali, so the stand-in goes on anyway.
|
||||||
|
|||||||
@@ -2,16 +2,24 @@ package com.droiddeck.launcher
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import com.droiddeck.launcher.session.QuestExperimental
|
import com.droiddeck.launcher.gpu.DriverBundle
|
||||||
import com.droiddeck.launcher.session.SessionPrefs
|
import com.droiddeck.launcher.gpu.DriverPairs
|
||||||
|
import com.droiddeck.launcher.gpu.GpuInfo
|
||||||
|
import com.droiddeck.launcher.gpu.GpuInfo.Family
|
||||||
|
import com.droiddeck.launcher.gpu.LinuxVulkanDriverManager
|
||||||
import com.droiddeck.launcher.gpu.TpUbwcHint
|
import com.droiddeck.launcher.gpu.TpUbwcHint
|
||||||
import com.droiddeck.launcher.gpu.TurnipDriver
|
import com.droiddeck.launcher.gpu.TurnipDriver
|
||||||
import com.droiddeck.launcher.gpu.TurnipReleases
|
import com.droiddeck.launcher.gpu.TurnipReleases
|
||||||
import com.droiddeck.launcher.gpu.VulkanInfo
|
import com.droiddeck.launcher.gpu.VulkanInfo
|
||||||
import com.droiddeck.launcher.gpu.SystemVulkanDriver
|
import com.droiddeck.launcher.gpu.SystemVulkanDriver
|
||||||
|
import com.droiddeck.launcher.session.QuestExperimental
|
||||||
|
import com.droiddeck.launcher.session.SessionPrefs
|
||||||
import com.droiddeck.launcher.wayland.CompositorHost
|
import com.droiddeck.launcher.wayland.CompositorHost
|
||||||
|
import org.json.JSONArray
|
||||||
|
import org.json.JSONObject
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertFalse
|
import org.junit.Assert.assertFalse
|
||||||
import org.junit.Assert.assertNull
|
import org.junit.Assert.assertNull
|
||||||
@@ -22,12 +30,16 @@ import org.junit.runner.RunWith
|
|||||||
import org.robolectric.Robolectric
|
import org.robolectric.Robolectric
|
||||||
import org.robolectric.RobolectricTestRunner
|
import org.robolectric.RobolectricTestRunner
|
||||||
import org.robolectric.RuntimeEnvironment
|
import org.robolectric.RuntimeEnvironment
|
||||||
|
import org.robolectric.Shadows.shadowOf
|
||||||
import org.robolectric.annotation.Config
|
import org.robolectric.annotation.Config
|
||||||
import org.robolectric.shadows.ShadowBuild
|
import org.robolectric.shadows.ShadowBuild
|
||||||
import org.robolectric.shadows.ShadowLooper
|
import org.robolectric.shadows.ShadowLooper
|
||||||
import org.robolectric.annotation.Implementation
|
import org.robolectric.annotation.Implementation
|
||||||
import org.robolectric.annotation.Implements
|
import org.robolectric.annotation.Implements
|
||||||
import org.robolectric.util.ReflectionHelpers
|
import org.robolectric.util.ReflectionHelpers
|
||||||
|
import java.io.File
|
||||||
|
import java.util.zip.ZipEntry
|
||||||
|
import java.util.zip.ZipOutputStream
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner::class)
|
@RunWith(RobolectricTestRunner::class)
|
||||||
@Config(sdk = [28], manifest = Config.NONE, shadows = [DriverMenusAutoTest.XclipseDriver::class])
|
@Config(sdk = [28], manifest = Config.NONE, shadows = [DriverMenusAutoTest.XclipseDriver::class])
|
||||||
@@ -171,4 +183,118 @@ class DriverMenusAutoTest {
|
|||||||
menus.refreshDrivers()
|
menus.refreshDrivers()
|
||||||
assertTrue(menus.tpUbwcRestartRequired())
|
assertTrue(menus.tpUbwcRestartRequired())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun library(libc: String) = ByteArray(64).also {
|
||||||
|
byteArrayOf(0x7f, 'E'.code.toByte(), 'L'.code.toByte(), 'F'.code.toByte(), 2, 1).copyInto(it)
|
||||||
|
it[18] = 0xB7.toByte()
|
||||||
|
} + libc.toByteArray() + ByteArray(1)
|
||||||
|
|
||||||
|
private fun bundleZip(context: Context): Uri {
|
||||||
|
val manifest = JSONObject()
|
||||||
|
.put("package", "PanVK Mali JM").put("version", "1.0").put("tag", "panvk-mali-jm")
|
||||||
|
.put("drivers", JSONObject()
|
||||||
|
.put("android", JSONObject().put("path", "android"))
|
||||||
|
.put("linux", JSONObject().put("path", "linux")))
|
||||||
|
val file = File.createTempFile("bundle", ".zip", context.cacheDir)
|
||||||
|
ZipOutputStream(file.outputStream()).use { z ->
|
||||||
|
fun put(name: String, data: ByteArray) { z.putNextEntry(ZipEntry(name)); z.write(data); z.closeEntry() }
|
||||||
|
put("manifest.json", manifest.toString().toByteArray())
|
||||||
|
put("android/meta.json", JSONObject().put("name", "PanVK Mali JM").put("libraryName", "libvulkan_freedreno.so").toString().toByteArray())
|
||||||
|
put("android/libvulkan_freedreno.so", library("libc.so"))
|
||||||
|
put("linux/meta.json", JSONObject().put("name", "PanVK Mali JM").toString().toByteArray())
|
||||||
|
put("linux/libvulkan_freedreno.so", library("libc.so.6"))
|
||||||
|
}
|
||||||
|
return Uri.fromFile(file)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setCachedMaliJmPair(context: Context, assetName: String = "PanVK-JM-Pair.zip") {
|
||||||
|
val asset = JSONObject()
|
||||||
|
.put("source", TurnipReleases.NON_ADRENO_LABEL).put("tag", "panvk-mali-jm")
|
||||||
|
.put("name", assetName).put("url", "https://example/$assetName")
|
||||||
|
.put("size", 1L).put("linux", false).put("label", "Android + Linux · PanVK Mali JM")
|
||||||
|
.put("sha256", "0".repeat(64)).put("pair", DriverPairs.NAD_MALI_JM)
|
||||||
|
.put("bundle", true).put("id", 1L).put("updated_at", "2026-01-01T00:00:00Z")
|
||||||
|
val stored = JSONObject().put("assets", JSONArray().put(asset))
|
||||||
|
.put("latest", JSONArray()).put("failed", JSONArray())
|
||||||
|
.put("checkedAt", System.currentTimeMillis())
|
||||||
|
context.getSharedPreferences("turnip_releases", Context.MODE_PRIVATE)
|
||||||
|
.edit().putString("latest", stored.toString()).commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun prepareActiveMaliJmPair(assetName: String = "PanVK-JM-Pair.zip"): Pair<Activity, DriverMenus> {
|
||||||
|
ShadowBuild.setModel("Generic phone")
|
||||||
|
ShadowBuild.setDevice("generic")
|
||||||
|
val activity = Robolectric.buildActivity(Activity::class.java).setup().get()
|
||||||
|
val bundle = DriverBundle.install(activity, bundleZip(activity))
|
||||||
|
setCachedMaliJmPair(activity, assetName)
|
||||||
|
TurnipReleases.recordDownload(activity, TurnipReleases.cached(activity)!!.assets.first(), bundle.id)
|
||||||
|
SessionPrefs.setGpuDriverMode(activity, SessionPrefs.GPU_DRIVERS_AUTO)
|
||||||
|
SessionPrefs.setAndroidDriver(activity, TurnipDriver.AUTO)
|
||||||
|
SessionPrefs.setLinuxDriver(activity, bundle.linuxId)
|
||||||
|
val menus = DriverMenus(activity, Handler(Looper.getMainLooper()))
|
||||||
|
ReflectionHelpers.setField(menus, "gpu", GpuInfo("Mali-G78", 78, Family.MALI_JM, "", false))
|
||||||
|
menus.refreshDrivers()
|
||||||
|
return activity to menus
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun activeRecommendedPairWithNullRefreshFailureShowsCheckFailureStatus() {
|
||||||
|
val (activity, menus) = prepareActiveMaliJmPair()
|
||||||
|
val original = TurnipReleases.fetch
|
||||||
|
TurnipReleases.fetch = { _, _, _ -> throw java.io.IOException(null as String?) }
|
||||||
|
try {
|
||||||
|
menus.ensureAuto(force = true)
|
||||||
|
for (i in 0..40) {
|
||||||
|
shadowOf(Looper.getMainLooper()).idle()
|
||||||
|
Thread.sleep(50)
|
||||||
|
shadowOf(Looper.getMainLooper()).idle()
|
||||||
|
if (!menus.releaseChecking) break
|
||||||
|
}
|
||||||
|
assertEquals(activity.getString(R.string.drivers_up_to_date_check_failed, TurnipReleases.NON_ADRENO_LABEL), menus.autoStatus)
|
||||||
|
} finally { TurnipReleases.fetch = original }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun activeRecommendedPairWithSuccessfulRefreshShowsCurrentStatus() {
|
||||||
|
val (activity, menus) = prepareActiveMaliJmPair()
|
||||||
|
menus.ensureAuto(force = false)
|
||||||
|
for (i in 0..40) {
|
||||||
|
shadowOf(Looper.getMainLooper()).idle()
|
||||||
|
Thread.sleep(50)
|
||||||
|
shadowOf(Looper.getMainLooper()).idle()
|
||||||
|
if (!menus.releaseChecking) break
|
||||||
|
}
|
||||||
|
assertEquals(activity.getString(R.string.upd_current_status), menus.autoStatus)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun activeRecommendedPairWithSuccessfulForcedRefreshShowsCurrentStatus() {
|
||||||
|
val (activity, menus) = prepareActiveMaliJmPair("PanVK-Mali-JM-Pair.zip")
|
||||||
|
val asset = TurnipReleases.cached(activity)!!.assets.single()
|
||||||
|
val releases = JSONArray().put(JSONObject()
|
||||||
|
.put("tag_name", asset.tag)
|
||||||
|
.put("assets", JSONArray().put(JSONObject()
|
||||||
|
.put("name", asset.name).put("browser_download_url", asset.url)
|
||||||
|
.put("digest", "sha256:" + asset.sha256).put("size", 1L)
|
||||||
|
.put("id", 1L).put("updated_at", "2026-01-01T00:00:00Z"))))
|
||||||
|
val original = TurnipReleases.fetch
|
||||||
|
val requests = java.util.concurrent.atomic.AtomicInteger()
|
||||||
|
TurnipReleases.fetch = { _, _, url ->
|
||||||
|
if (url.contains("droiddeck-nonadreno-drivers/releases")) {
|
||||||
|
requests.incrementAndGet()
|
||||||
|
releases.toString()
|
||||||
|
} else "[]"
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
menus.ensureAuto(force = true)
|
||||||
|
for (i in 0..40) {
|
||||||
|
shadowOf(Looper.getMainLooper()).idle()
|
||||||
|
Thread.sleep(50)
|
||||||
|
shadowOf(Looper.getMainLooper()).idle()
|
||||||
|
if (!menus.releaseChecking) break
|
||||||
|
}
|
||||||
|
assertFalse(menus.releaseChecking)
|
||||||
|
assertTrue(requests.get() > 0)
|
||||||
|
assertTrue(TurnipReleases.cached(activity)!!.failed.isEmpty())
|
||||||
|
assertEquals(activity.getString(R.string.upd_current_status), menus.autoStatus)
|
||||||
|
} finally { TurnipReleases.fetch = original }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Vendored
+1
-1
Submodule external/MaliBridge updated: 64a3f22354...95a1e600a5.
Reference in new issue
Block a user