mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 20:45:43 +00:00
Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed7f532db4 | ||
|
|
ba59724632 | ||
|
|
705a5e7b2a | ||
|
|
e60eae3646 | ||
|
|
b04900b1b2 | ||
|
|
6357543b44 | ||
|
|
67fb338e5d | ||
|
|
ba140c4ab5 | ||
|
|
f5fdbc7941 | ||
|
|
90ae85da4d | ||
|
|
2d8befe1cb |
No files matched your search
@@ -0,0 +1,2 @@
|
||||
# Patch context includes the indentation and blank lines of the source being patched.
|
||||
tools/gamescope/patches/*.patch -whitespace
|
||||
@@ -73,6 +73,7 @@ class AgentBridgeProvider : ContentProvider() {
|
||||
.put("steamUi", SessionState.steamUi ?: JSONObject.NULL)
|
||||
.put("steamUrl", SessionState.steamUrl ?: JSONObject.NULL)
|
||||
.put("suspended", SessionState.suspended)
|
||||
.put("pip", SessionState.pipActive)
|
||||
.put("firstFrame", SessionState.firstFrameSeen)
|
||||
.put("output", JSONArray().put(SessionState.outputSize.first).put(SessionState.outputSize.second))
|
||||
.put("refreshHz", SessionState.refreshHz.toDouble())
|
||||
|
||||
@@ -126,7 +126,8 @@
|
||||
<activity
|
||||
android:name=".SessionActivity"
|
||||
android:exported="false"
|
||||
android:launchMode="singleTop"
|
||||
android:supportsPictureInPicture="true"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/SessionTheme"
|
||||
android:preferMinimalPostProcessing="true"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
|
||||
@@ -3478,7 +3478,8 @@ int banner_wayland_run(void) {
|
||||
/* libdecor binds wl_output at 4; a lower version is a protocol error for the client. */
|
||||
wl_global_create(display, &wl_output_interface, 4, NULL, bind_output);
|
||||
wl_global_create(display, &xdg_wm_base_interface, 1, NULL, bind_xdg_wm_base);
|
||||
wl_global_create(display, &zwp_linux_dmabuf_v1_interface, 4, NULL, bind_dmabuf);
|
||||
if (vkp_dmabuf_supported())
|
||||
wl_global_create(display, &zwp_linux_dmabuf_v1_interface, 4, NULL, bind_dmabuf);
|
||||
/* gamescope's Wayland backend refuses a seat older than 8. */
|
||||
wl_global_create(display, &wl_seat_interface, 9, NULL, bind_seat);
|
||||
wl_global_create(display, &banner_desktop_v1_interface, 1, NULL, bind_desktop);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define VK_USE_PLATFORM_ANDROID_KHR
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#define VK_GLOBAL_FUNCS(X) X(CreateInstance) X(EnumerateInstanceExtensionProperties)
|
||||
#define VK_GLOBAL_FUNCS(X) X(CreateInstance) X(EnumerateInstanceExtensionProperties) X(EnumerateInstanceVersion)
|
||||
|
||||
#define VK_INSTANCE_FUNCS(X) \
|
||||
X(EnumeratePhysicalDevices) X(GetPhysicalDeviceProperties) \
|
||||
|
||||
@@ -40,6 +40,7 @@ struct vkp_image {
|
||||
static ANativeWindow *g_window; /* the window frames go to; compositor thread only */
|
||||
static char *g_driver_path, *g_library_name, *g_native_lib_dir;
|
||||
static int g_dev_state; /* 0 = not yet, 1 = ok, -1 = failed, -2 = lost (VK_ERROR_DEVICE_LOST) */
|
||||
static int g_dmabuf_import;
|
||||
static VkInstance g_inst;
|
||||
static VkPhysicalDevice g_pd;
|
||||
static VkDevice g_dev;
|
||||
@@ -411,11 +412,18 @@ static int dev_init(void) {
|
||||
"generation %s)", g_colorspace_ext ? "enables" : "has no",
|
||||
g_colorspace_ext ? "is possible where the screen surface offers one" : "is not possible: tone-mapped instead");
|
||||
}
|
||||
/* 1.3 like the X11 renderer's instance: the frame-generation probe (framegen_engine.cpp)
|
||||
* queries VkPhysicalDeviceVulkan12Features, and a 1.1 instance may be answered as 1.1. */
|
||||
/* Prefer 1.3 for the frame-generation feature probe, but respect older system loaders. */
|
||||
uint32_t loader_api = VK_API_VERSION_1_0;
|
||||
if (g_vk.EnumerateInstanceVersion &&
|
||||
g_vk.EnumerateInstanceVersion(&loader_api) != VK_SUCCESS) {
|
||||
LOGE("present: cannot query the Vulkan loader version"); g_dev_state = -1; return -1;
|
||||
}
|
||||
if (loader_api < VK_API_VERSION_1_1) {
|
||||
LOGE("present: Vulkan 1.1 or newer is required"); g_dev_state = -1; return -1;
|
||||
}
|
||||
VkApplicationInfo app = {.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
||||
.pApplicationName = "banner-wayland-present",
|
||||
.apiVersion = VK_API_VERSION_1_3};
|
||||
.apiVersion = loader_api < VK_API_VERSION_1_3 ? loader_api : VK_API_VERSION_1_3};
|
||||
VkInstanceCreateInfo ici = {.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||
.pApplicationInfo = &app,
|
||||
.enabledExtensionCount = n_inst_exts,
|
||||
@@ -450,18 +458,26 @@ static int dev_init(void) {
|
||||
}
|
||||
g_vk.GetPhysicalDeviceMemoryProperties(g_pd, &g_memprops);
|
||||
|
||||
/* Verify the dmabuf-import extensions are present, and log any that are missing. */
|
||||
const char *dev_exts[7] = {VK_KHR_SWAPCHAIN_EXTENSION_NAME, "VK_KHR_external_memory_fd",
|
||||
"VK_EXT_external_memory_dma_buf", "VK_EXT_image_drm_format_modifier",
|
||||
"VK_KHR_image_format_list", NULL, NULL};
|
||||
uint32_t n_dev_exts = 5;
|
||||
/* Shared-memory clients need only a swapchain. Advertise dma-buf import only when its
|
||||
* complete extension set is available, rather than failing device creation on older GPUs. */
|
||||
const char *import_exts[] = {"VK_KHR_external_memory_fd", "VK_EXT_external_memory_dma_buf",
|
||||
"VK_EXT_image_drm_format_modifier", "VK_KHR_image_format_list"};
|
||||
const char *dev_exts[7] = {VK_KHR_SWAPCHAIN_EXTENSION_NAME};
|
||||
uint32_t n_dev_exts = 1;
|
||||
uint32_t ne = 0;
|
||||
g_vk.EnumerateDeviceExtensionProperties(g_pd, NULL, &ne, NULL);
|
||||
VkExtensionProperties *exts = calloc(ne ? ne : 1, sizeof(*exts));
|
||||
g_vk.EnumerateDeviceExtensionProperties(g_pd, NULL, &ne, exts);
|
||||
for (unsigned i = 0; i < 5; i++)
|
||||
if (!has_ext(exts, ne, dev_exts[i]))
|
||||
LOGE("present: driver MISSING %s (dmabuf import will fail)", dev_exts[i]);
|
||||
g_dmabuf_import = 1;
|
||||
for (unsigned i = 0; i < sizeof(import_exts) / sizeof(import_exts[0]); i++) {
|
||||
if (!has_ext(exts, ne, import_exts[i])) {
|
||||
g_dmabuf_import = 0;
|
||||
banner_log("gpu", "driver has no %s; shared-memory clients remain available", import_exts[i]);
|
||||
}
|
||||
}
|
||||
if (g_dmabuf_import)
|
||||
for (unsigned i = 0; i < sizeof(import_exts) / sizeof(import_exts[0]); i++)
|
||||
dev_exts[n_dev_exts++] = import_exts[i];
|
||||
/* HDR sessions only: the HDR10 swapchain (frame generation) can carry the game's metadata. */
|
||||
int want_hdr_md = 0;
|
||||
if (banner_color_requested()) {
|
||||
@@ -538,6 +554,7 @@ static int dev_init(void) {
|
||||
}
|
||||
|
||||
int vkp_ready(void) { return dev_init(); }
|
||||
int vkp_dmabuf_supported(void) { return dev_init() == 0 && g_dmabuf_import; }
|
||||
|
||||
static int swap_init_locked(void);
|
||||
|
||||
@@ -899,7 +916,7 @@ static int modifier_importable(VkFormat fmt, uint64_t modifier, VkImageUsageFlag
|
||||
}
|
||||
|
||||
int vkp_dmabuf_modifiers(uint32_t drm_format, uint64_t *out, int max) {
|
||||
if (max <= 0 || dev_init() != 0 || !g_vk.GetPhysicalDeviceFormatProperties2) return 0;
|
||||
if (max <= 0 || !vkp_dmabuf_supported() || !g_vk.GetPhysicalDeviceFormatProperties2) return 0;
|
||||
VkFormat fmt = drm_to_vk(drm_format);
|
||||
VkDrmFormatModifierPropertiesListEXT list = {
|
||||
.sType = VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT};
|
||||
@@ -941,7 +958,7 @@ int vkp_image_is_dmabuf(const struct vkp_image *img) { return img && img->dmabuf
|
||||
struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t modifier, int w, int h,
|
||||
uint32_t stride, uint32_t offset, int as_blit_dst) {
|
||||
if (modifier == MOD_INVALID || w <= 0 || h <= 0) return NULL;
|
||||
if (dev_init() != 0) return NULL;
|
||||
if (!vkp_dmabuf_supported()) return NULL;
|
||||
|
||||
struct vkp_image *img = calloc(1, sizeof(*img));
|
||||
if (!img) return NULL;
|
||||
|
||||
@@ -87,6 +87,8 @@ const char *vkp_gpu_name(void);
|
||||
|
||||
// 0 if the renderer can create images (device up), -1 otherwise.
|
||||
int vkp_ready(void);
|
||||
/* Whether the selected driver supports the complete dma-buf import extension set. */
|
||||
int vkp_dmabuf_supported(void);
|
||||
/* Whether an output window is attached (or requested); without one vkp_render() draws nothing. */
|
||||
int vkp_has_window(void);
|
||||
/* 1 once the Vulkan device was lost: nothing is presented any more (the session must restart). */
|
||||
|
||||
@@ -1064,6 +1064,8 @@ class MainActivity : ComponentActivity() {
|
||||
gpuDrivers = drivers.summary(),
|
||||
touchMode = touchMode,
|
||||
suspendPolicy = suspendPolicy,
|
||||
pipSupported = com.droiddeck.launcher.session.SessionPipController.supported(this),
|
||||
pipAutoEnter = pipAutoEnter,
|
||||
oscMode = if (mode == SessionService.MODE_STEAM) oscMode else null,
|
||||
backActionsInverted = backActionsInverted,
|
||||
directAudio = if (mode == SessionService.MODE_STEAM) directAudio else null,
|
||||
@@ -1119,6 +1121,7 @@ class MainActivity : ComponentActivity() {
|
||||
onUpscaleSharpness = { pct -> SessionPrefs.setUpscaleSharpness(this, pct); upscaleSharpness = pct },
|
||||
onTouch = { t -> SessionPrefs.setTouchMode(this, t); touchMode = t },
|
||||
onSuspendPolicy = { policy -> SessionPrefs.setSuspendPolicy(this, mode, policy); suspendPolicy = policy },
|
||||
onPipAutoEnter = { on -> SessionPrefs.setPipAutoEnter(this, on); pipAutoEnter = on },
|
||||
onOsc = { o -> SessionPrefs.setOscMode(this, o); oscMode = o },
|
||||
onBackActionsInverted = { inverted ->
|
||||
SessionPrefs.setBackActionsInverted(this, inverted)
|
||||
@@ -1238,7 +1241,10 @@ class MainActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private var pipAutoEnter by mutableStateOf(false)
|
||||
|
||||
private fun openModeSettings(mode: String) {
|
||||
pipAutoEnter = SessionPrefs.pipAutoEnter(this)
|
||||
showPerformance = false
|
||||
showProtons = false
|
||||
showComponents = false
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.droiddeck.launcher
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import android.hardware.input.InputManager
|
||||
import android.hardware.display.DisplayManager
|
||||
@@ -90,6 +92,10 @@ import kotlin.math.abs
|
||||
* the HUD line, the loading overlay, the drawer and its dialogs.
|
||||
*/
|
||||
class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
private lateinit var pip: com.droiddeck.launcher.session.SessionPipController
|
||||
private var pipUi by mutableStateOf(false)
|
||||
private var pipAutoEnter by mutableStateOf(false)
|
||||
private val guestKeysDown = mutableSetOf<Int>()
|
||||
private lateinit var surfaceView: SurfaceView
|
||||
private lateinit var sessionOverlay: ComposeView
|
||||
private lateinit var loading: LoadingState
|
||||
@@ -122,7 +128,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
/** Motion is read while the session shows and only if the pad is a Deck controller - which
|
||||
* the service can decide after this activity has resumed (SessionState.deckPadListener). */
|
||||
private fun updatePadMotion() {
|
||||
if (resumed && SessionState.deckPad) padMotion?.start() else padMotion?.stop()
|
||||
if (resumed && !pipUi && SessionState.deckPad) padMotion?.start() else padMotion?.stop()
|
||||
}
|
||||
private var onScreenControls: OnScreenControls? = null
|
||||
private var keyboard: KeyboardHost? = null
|
||||
@@ -354,6 +360,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
sessionOverlay = createSessionOverlay()
|
||||
root.addView(sessionOverlay)
|
||||
setContentView(root)
|
||||
pip = com.droiddeck.launcher.session.SessionPipController(this, ::pipBounds, ::showPipUi)
|
||||
surfaceView.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> pip.refresh() }
|
||||
pip.refresh()
|
||||
handleHomeGuideIntent(intent)
|
||||
|
||||
updateOnScreenControls()
|
||||
@@ -364,6 +373,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
// The single action waits out the double-press window so the two actions stay distinct.
|
||||
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
if (pipUi) return
|
||||
// The PC keyboard closes first (B on a controller), then Back is the drawer again.
|
||||
when {
|
||||
::loading.isInitialized && loading.ended -> finish()
|
||||
@@ -388,6 +398,15 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
defaultFocusHighlightEnabled = false
|
||||
setContent {
|
||||
DroidDeckTheme {
|
||||
if (pipUi) {
|
||||
if (SessionState.suspended) androidx.compose.foundation.layout.Box(
|
||||
Modifier.fillMaxSize(), contentAlignment = androidx.compose.ui.Alignment.Center,
|
||||
) {
|
||||
androidx.compose.material3.Text(getString(R.string.pip_suspended),
|
||||
color = androidx.compose.ui.graphics.Color.White,
|
||||
modifier = Modifier.background(androidx.compose.ui.graphics.Color.Black.copy(alpha = 0.7f)).padding(6.dp))
|
||||
}
|
||||
} else {
|
||||
com.droiddeck.launcher.ui.FocusGlideHost(androidx.compose.ui.Modifier.fillMaxSize()) {
|
||||
CursorOverlay(cursorPos, cursorVisible, resources.displayMetrics.density,
|
||||
cursorImage, cursorHotX, cursorHotY, cursorImageScale)
|
||||
@@ -422,7 +441,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
// The PC keyboard takes it too, for moving over the keys; the drawer opens over it.
|
||||
androidx.compose.runtime.LaunchedEffect(pcKeyboardOpen) { if (pcKeyboardOpen) padBridge?.releaseAll() }
|
||||
if (pcKeyboardOpen) com.droiddeck.launcher.ui.PcKeyboard(
|
||||
sendKey = { code, down -> if (CompositorHost.isStarted) WaylandCompositor.nativeSendKey(code, if (down) 1 else 0) },
|
||||
sendKey = { code, down -> if (CompositorHost.isStarted) sendGuestKey(code, down) },
|
||||
onAndroidKeyboard = { pcKeyboardOpen = false; keyboard?.toggle() },
|
||||
onClose = { pcKeyboardOpen = false },
|
||||
)
|
||||
@@ -502,7 +521,15 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
Toast.makeText(this@SessionActivity, "Could not open ${app.label} on $target", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
},
|
||||
onBackground = { drawerOpen = false; moveTaskToBack(true) },
|
||||
pipSupported = com.droiddeck.launcher.session.SessionPipController.supported(this@SessionActivity),
|
||||
pipAutoEnter = pipAutoEnter,
|
||||
onPip = { pip.enter() },
|
||||
onPipAutoEnter = { on ->
|
||||
SessionPrefs.setPipAutoEnter(this@SessionActivity, on)
|
||||
pipAutoEnter = on
|
||||
pip.refresh(true)
|
||||
},
|
||||
onBackground = { drawerOpen = false; pip.background(); moveTaskToBack(true) },
|
||||
onShareLogs = { drawerOpen = false; shareCurrentSessionLogs() },
|
||||
onStop = { drawerOpen = false; SessionService.stop(this@SessionActivity); finish() },
|
||||
onStopFrom = { onScreen ->
|
||||
@@ -538,6 +565,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun refreshHomeApp() {
|
||||
@@ -670,6 +698,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
|
||||
private fun readPrefs() {
|
||||
pipAutoEnter = SessionPrefs.pipAutoEnter(this)
|
||||
hudOn = SessionPrefs.hudEnabled(this)
|
||||
fillScreen = SessionPrefs.forceFullscreen(this)
|
||||
upscaler = SessionPrefs.upscaler(this)
|
||||
@@ -1019,6 +1048,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
val poll = object : Runnable {
|
||||
override fun run() {
|
||||
if (!watching) return
|
||||
if (::pip.isInitialized) pip.refresh()
|
||||
if (SessionState.stopRequested && !SessionState.running && !installingRuntime) {
|
||||
SessionState.stopRequested = false
|
||||
SessionEvents.transition(SessionPhase.IDLE, "session.cancelled")
|
||||
@@ -1037,6 +1067,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
|
||||
private fun onSessionEnded(status: Int) {
|
||||
if (isInPictureInPictureMode) {
|
||||
runOnUiThread { finish() }
|
||||
return
|
||||
}
|
||||
closeSecondScreen(reset = true)
|
||||
if (status == 0) {
|
||||
runOnUiThread {
|
||||
@@ -1138,6 +1172,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
KeyEvent.KEYCODE_VOLUME_UP, KeyEvent.KEYCODE_VOLUME_DOWN, KeyEvent.KEYCODE_VOLUME_MUTE ->
|
||||
return super.dispatchKeyEvent(event)
|
||||
}
|
||||
if (pipUi) return true
|
||||
val fromController = event.device != null && PadBridge.isFromController(event.device)
|
||||
if (fromController && event.action == KeyEvent.ACTION_DOWN) {
|
||||
if (drawerOpen && !drawerControllerActive) sessionOverlay.requestFocus()
|
||||
@@ -1217,11 +1252,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
if (evdev <= 0 && event.scanCode > 0) evdev = event.scanCode
|
||||
if (evdev > 0) {
|
||||
if (down) {
|
||||
if (shiftEvdev != 0) WaylandCompositor.nativeSendKey(shiftEvdev, 1)
|
||||
WaylandCompositor.nativeSendKey(evdev, 1)
|
||||
if (shiftEvdev != 0) sendGuestKey(shiftEvdev, true)
|
||||
sendGuestKey(evdev, true)
|
||||
} else {
|
||||
WaylandCompositor.nativeSendKey(evdev, 0)
|
||||
if (shiftEvdev != 0) WaylandCompositor.nativeSendKey(shiftEvdev, 0)
|
||||
sendGuestKey(evdev, false)
|
||||
if (shiftEvdev != 0) sendGuestKey(shiftEvdev, false)
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -1231,6 +1266,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
|
||||
override fun dispatchGenericMotionEvent(event: MotionEvent): Boolean {
|
||||
if (pipUi) return true
|
||||
if (drawerOpen && event.device != null && PadBridge.isFromController(event.device)) {
|
||||
if (!drawerControllerActive) sessionOverlay.requestFocus()
|
||||
drawerControllerActive = true
|
||||
@@ -1249,6 +1285,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
|
||||
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
|
||||
if (pipUi) return true
|
||||
if (event.actionMasked == MotionEvent.ACTION_DOWN && event.isFromSource(InputDevice.SOURCE_TOUCHSCREEN)) {
|
||||
drawerControllerActive = false
|
||||
}
|
||||
@@ -1450,6 +1487,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
|
||||
private fun showSecondScreen(mode: SecondScreenMode) {
|
||||
if (pipUi || !started) return
|
||||
val target = displayManager.getDisplay(selectedSecondScreenDisplay)
|
||||
if (target == null || !target.isValid || (target.flags and Display.FLAG_PRESENTATION) == 0) {
|
||||
// Not there right now - a panel still waking, say. The choice is kept; the display
|
||||
@@ -1555,6 +1593,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
// the compositor still holds (an up lost to the drawer opening mid-touch) goes first.
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
WaylandCompositor.nativeSendTouch(3, -1, 0, 0)
|
||||
listOf(PointerGestures.BTN_LEFT, PointerGestures.BTN_RIGHT, PointerGestures.BTN_MIDDLE).forEach {
|
||||
WaylandCompositor.nativeSendSceneInput(3, it, 0)
|
||||
}
|
||||
sendTouch(0, event.actionIndex)
|
||||
}
|
||||
MotionEvent.ACTION_POINTER_DOWN -> sendTouch(0, event.actionIndex)
|
||||
@@ -1606,6 +1647,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
?.let { FileUtils.readString(it)?.trim()?.lowercase() }
|
||||
?: SessionPrefs.oscMode(this)
|
||||
val controls = onScreenControls ?: return
|
||||
if (pipUi) {
|
||||
controls.releaseAll()
|
||||
controls.visibility = View.GONE
|
||||
return
|
||||
}
|
||||
val buttonsOnly = forced == SessionPrefs.OSC_STEAM_QAM
|
||||
controls.setButtonsOnly(buttonsOnly)
|
||||
val show = when (forced) {
|
||||
@@ -1627,6 +1673,76 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
})
|
||||
}
|
||||
|
||||
private fun sendGuestKey(code: Int, down: Boolean) {
|
||||
if (down && pipUi) return
|
||||
if (down) guestKeysDown.add(code) else guestKeysDown.remove(code)
|
||||
WaylandCompositor.nativeSendKey(code, if (down) 1 else 0)
|
||||
}
|
||||
|
||||
private fun pipBounds(): android.graphics.Rect {
|
||||
val rect = android.graphics.Rect()
|
||||
if (!::surfaceView.isInitialized || !surfaceView.getGlobalVisibleRect(rect)) return rect
|
||||
val (w, h) = SessionState.outputSize
|
||||
if (w <= 0 || h <= 0) return rect
|
||||
val scale = minOf(rect.width().toFloat() / w, rect.height().toFloat() / h)
|
||||
val fittedW = (w * scale).toInt()
|
||||
val fittedH = (h * scale).toInt()
|
||||
rect.inset((rect.width() - fittedW) / 2, (rect.height() - fittedH) / 2)
|
||||
return rect
|
||||
}
|
||||
|
||||
private fun showPipUi(show: Boolean) {
|
||||
pipUi = show
|
||||
if (show) {
|
||||
drawerOpen = false
|
||||
pcKeyboardOpen = false
|
||||
pendingBackAction?.let(uiHandler::removeCallbacks)
|
||||
pendingBackAction = null
|
||||
releaseDrawerDirection()
|
||||
onScreenControls?.releaseAll()
|
||||
padBridge?.releaseAll()
|
||||
touchpad.cancel()
|
||||
guestKeysDown.toList().forEach { sendGuestKey(it, false) }
|
||||
keyboard?.hide()
|
||||
sessionClipboard.stop()
|
||||
padMotion?.stop()
|
||||
cursorVisible = false
|
||||
closeSecondScreen(reset = false)
|
||||
onScreenControls?.visibility = View.GONE
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
if (CompositorHost.isStarted) {
|
||||
WaylandCompositor.nativeSendTouch(3, -1, 0, 0)
|
||||
listOf(PointerGestures.BTN_LEFT, PointerGestures.BTN_RIGHT, PointerGestures.BTN_MIDDLE).forEach {
|
||||
WaylandCompositor.nativeSendSceneInput(3, it, 0)
|
||||
}
|
||||
WaylandCompositor.nativeSetScaleMode(SCALE_FIT, ALIGN_CENTER)
|
||||
}
|
||||
} else if (!isFinishing && !isDestroyed) {
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
updateOnScreenControls()
|
||||
if (resumed) { sessionClipboard.start(); updatePadMotion() }
|
||||
if (started) refreshSecondScreenDisplays()
|
||||
if (CompositorHost.isStarted) applyFrameGen()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUserLeaveHint() {
|
||||
if (::pip.isInitialized) pip.leaving()
|
||||
super.onUserLeaveHint()
|
||||
}
|
||||
|
||||
override fun onPictureInPictureModeChanged(inPip: Boolean, newConfig: android.content.res.Configuration) {
|
||||
super.onPictureInPictureModeChanged(inPip, newConfig)
|
||||
if (::pip.isInitialized) pip.changed(inPip)
|
||||
}
|
||||
|
||||
override fun startActivityForResult(intent: Intent, requestCode: Int, options: Bundle?) {
|
||||
if (::pip.isInitialized && (requestCode >= 0 || intent.component?.packageName == packageName ||
|
||||
intent.action in setOf(Intent.ACTION_CHOOSER, Intent.ACTION_SEND, Intent.ACTION_OPEN_DOCUMENT,
|
||||
Intent.ACTION_GET_CONTENT, "android.settings.PICTURE_IN_PICTURE_SETTINGS"))) pip.background()
|
||||
super.startActivityForResult(intent, requestCode, options)
|
||||
}
|
||||
|
||||
// ── Lifecycle ───────────────────────────────────────────────────────────────────────────
|
||||
|
||||
override fun onStart() {
|
||||
@@ -1681,9 +1797,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
onScreenControls?.reload()
|
||||
updateOnScreenControls()
|
||||
resumed = true
|
||||
sessionClipboard.start()
|
||||
if (!pipUi) sessionClipboard.start()
|
||||
updatePadMotion()
|
||||
readPrefs()
|
||||
if (::pip.isInitialized) pip.resumed()
|
||||
if (CompositorHost.isStarted) applyFrameGen()
|
||||
}
|
||||
|
||||
@@ -1713,7 +1830,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
|
||||
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||
super.onWindowFocusChanged(hasFocus)
|
||||
if (hasFocus) {
|
||||
if (hasFocus && !pipUi) {
|
||||
goFullscreen()
|
||||
refreshClipboard()
|
||||
}
|
||||
@@ -1757,7 +1874,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
releaseDrawerDirection()
|
||||
pendingBackAction?.let(uiHandler::removeCallbacks)
|
||||
pendingBackAction = null
|
||||
closeSecondScreen(reset = true)
|
||||
if (::pip.isInitialized) pip.destroyed()
|
||||
closeSecondScreen(reset = false)
|
||||
if (::hud.isInitialized) hud.stop()
|
||||
padBridge?.stop()
|
||||
padMotion?.stop()
|
||||
|
||||
@@ -338,6 +338,12 @@ public final class TurnipDriver {
|
||||
if (forced.startsWith("a7")) return DRIVER_A7XX;
|
||||
}
|
||||
String model = gpuModel();
|
||||
// A Mali kbase node is positive evidence. Unknown hardware keeps the existing default.
|
||||
if (model == null && new File("/dev/mali0").exists()
|
||||
&& !com.droiddeck.launcher.core.DeviceSupport.INSTANCE.adreno()) {
|
||||
Log.i(TAG, "Mali kbase GPU: using system Vulkan for the compositor");
|
||||
return null;
|
||||
}
|
||||
Log.i(TAG, "gpu model: " + (model == null ? "unknown" : model));
|
||||
if (model != null) {
|
||||
// "Adreno750", "adreno_830" - the generation is the first digit of the three.
|
||||
|
||||
@@ -66,6 +66,17 @@ class TouchpadGestures(
|
||||
listener.onButton(PointerGestures.BTN_LEFT, true, x, y)
|
||||
}
|
||||
|
||||
fun cancel() {
|
||||
handler.removeCallbacks(longPress)
|
||||
if (dragging) listener.onButton(PointerGestures.BTN_LEFT, false, x, y)
|
||||
dragging = false
|
||||
held = false
|
||||
holdDrag = false
|
||||
anchorId = -1
|
||||
moverId = -1
|
||||
lastTapAt = 0L
|
||||
}
|
||||
|
||||
fun place(px: Float, py: Float) {
|
||||
x = px.coerceIn(bounds.left, bounds.right)
|
||||
y = py.coerceIn(bounds.top, bounds.bottom)
|
||||
|
||||
@@ -229,6 +229,17 @@ public final class LinuxRuntime {
|
||||
// It then fails the isFile() test below and the session runs as it did before.
|
||||
}
|
||||
}
|
||||
// protonfixes, which GE-Proton and proton-cachyos run before every game, opens this to
|
||||
// check the esync file limit and dies on the PermissionError, so no game starts with them.
|
||||
// The value is the 64-bit kernel default.
|
||||
File fileMax = new File(fakeProc, "file-max");
|
||||
if (!fileMax.isFile()) {
|
||||
try {
|
||||
Files.write(fileMax.toPath(), "9223372036854775807\n".getBytes(StandardCharsets.US_ASCII));
|
||||
} catch (IOException e) {
|
||||
// Left unbound, as above.
|
||||
}
|
||||
}
|
||||
String[][] procFiles = {
|
||||
{"pci_devices", "/proc/bus/pci/devices"},
|
||||
{"stat", "/proc/stat"},
|
||||
@@ -239,6 +250,7 @@ public final class LinuxRuntime {
|
||||
{"cap_last_cap", "/proc/sys/kernel/cap_last_cap"},
|
||||
{"overflowuid", "/proc/sys/kernel/overflowuid"},
|
||||
{"overflowgid", "/proc/sys/kernel/overflowgid"},
|
||||
{"file-max", "/proc/sys/fs/file-max"},
|
||||
};
|
||||
for (String[] entry : procFiles) {
|
||||
File fake = new File(fakeProc, entry[0]);
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
/** Platform-independent eligibility; a service existing alone does not mean it has a picture. */
|
||||
object PipPolicy {
|
||||
fun eligible(running: Boolean, frameSeen: Boolean, phase: SessionPhase, suspended: Boolean, automatic: Boolean): Boolean =
|
||||
running && frameSeen && phase in setOf(SessionPhase.READY, SessionPhase.SUSPENDED) &&
|
||||
(!automatic || !suspended)
|
||||
|
||||
fun aspect(width: Int, height: Int): Pair<Int, Int> = when {
|
||||
width <= 0 || height <= 0 -> 16 to 9
|
||||
width.toDouble() / height > 2.39 -> 239 to 100
|
||||
height.toDouble() / width > 2.39 -> 100 to 239
|
||||
else -> width to height
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.app.AppOpsManager
|
||||
import android.app.PictureInPictureParams
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Rect
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.util.Rational
|
||||
import android.widget.Toast
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.SessionActivity
|
||||
|
||||
/** Owns Android's PiP parameters, while the service continues to own the session. */
|
||||
class SessionPipController(
|
||||
private val activity: SessionActivity,
|
||||
private val bounds: () -> Rect,
|
||||
private val showPipUi: (Boolean) -> Unit,
|
||||
) {
|
||||
var transitioning = false
|
||||
private set
|
||||
private var suppressAuto = false
|
||||
private var visit = false
|
||||
private var lastParams = ""
|
||||
val floating get() = transitioning || activity.isInPictureInPictureMode
|
||||
|
||||
fun eligible(automatic: Boolean = false) = supported(activity) && !activity.isFinishing &&
|
||||
PipPolicy.eligible(SessionState.running, SessionState.firstFrameSeen, SessionState.phase,
|
||||
SessionState.suspended, automatic)
|
||||
|
||||
fun automatic() = !suppressAuto && SessionPrefs.pipAutoEnter(activity) && eligible(true)
|
||||
|
||||
fun refresh(force: Boolean = false) {
|
||||
if (!supported(activity)) return
|
||||
val rect = bounds()
|
||||
val key = "$rect:${SessionState.outputSize}:${automatic()}:${SessionState.suspended}"
|
||||
if (!force && key == lastParams) return
|
||||
lastParams = key
|
||||
runCatching { activity.setPictureInPictureParams(params(rect)) }
|
||||
}
|
||||
|
||||
private fun params(rect: Rect): PictureInPictureParams {
|
||||
val (w, h) = PipPolicy.aspect(SessionState.outputSize.first, SessionState.outputSize.second)
|
||||
val builder = PictureInPictureParams.Builder().setAspectRatio(Rational(w, h))
|
||||
if (!rect.isEmpty) builder.setSourceRectHint(rect)
|
||||
if (Build.VERSION.SDK_INT >= 31) builder.setAutoEnterEnabled(automatic()).setSeamlessResizeEnabled(false)
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
fun enter() {
|
||||
if (!eligible()) {
|
||||
Toast.makeText(activity, R.string.pip_not_ready, Toast.LENGTH_SHORT).show()
|
||||
return
|
||||
}
|
||||
if (!allowed()) {
|
||||
Toast.makeText(activity, R.string.pip_permission, Toast.LENGTH_SHORT).show()
|
||||
runCatching { activity.startActivity(Intent("android.settings.PICTURE_IN_PICTURE_SETTINGS",
|
||||
Uri.parse("package:${activity.packageName}"))) }
|
||||
return
|
||||
}
|
||||
prepare()
|
||||
val entered = runCatching { activity.enterPictureInPictureMode(params(bounds())) }.getOrDefault(false)
|
||||
if (!entered) {
|
||||
restore()
|
||||
Toast.makeText(activity, R.string.pip_unavailable, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
fun leaving() {
|
||||
if (!automatic() || !allowed()) return
|
||||
if (Build.VERSION.SDK_INT < 31) enter() else prepare()
|
||||
}
|
||||
|
||||
private fun prepare() {
|
||||
if (floating) return
|
||||
transitioning = true
|
||||
showPipUi(true)
|
||||
}
|
||||
|
||||
fun changed(inPip: Boolean) {
|
||||
if (inPip) {
|
||||
transitioning = false
|
||||
visit = true
|
||||
SessionState.pipActive = true
|
||||
showPipUi(true)
|
||||
SessionService.beginPip(activity)
|
||||
SessionService.setActivityVisible(activity, true)
|
||||
} else restore()
|
||||
refresh(true)
|
||||
}
|
||||
|
||||
private fun restore() {
|
||||
val needsRestore = transitioning || visit
|
||||
transitioning = false
|
||||
if (visit) {
|
||||
SessionState.pipActive = false
|
||||
visit = false
|
||||
}
|
||||
if (needsRestore) showPipUi(false)
|
||||
}
|
||||
|
||||
fun resumed() {
|
||||
suppressAuto = false
|
||||
if (!activity.isInPictureInPictureMode) {
|
||||
restore()
|
||||
if (SessionState.running) SessionService.setActivityVisible(activity, true)
|
||||
}
|
||||
refresh(true)
|
||||
}
|
||||
|
||||
fun background() { suppressAuto = true; refresh(true) }
|
||||
fun destroyed() { if (visit) restore() }
|
||||
|
||||
private fun allowed(): Boolean {
|
||||
val ops = activity.getSystemService(AppOpsManager::class.java)
|
||||
@Suppress("DEPRECATION")
|
||||
return ops.checkOpNoThrow(AppOpsManager.OPSTR_PICTURE_IN_PICTURE,
|
||||
android.os.Process.myUid(), activity.packageName) == AppOpsManager.MODE_ALLOWED
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun supported(context: android.content.Context) = context.packageManager
|
||||
.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)
|
||||
}
|
||||
}
|
||||
@@ -627,6 +627,12 @@ object SessionPrefs {
|
||||
*/
|
||||
fun prefMode(mode: String): String = if (mode == SessionService.MODE_RUN) SessionService.MODE_STEAM else mode
|
||||
|
||||
fun pipAutoEnter(context: Context): Boolean = prefs(context).getBoolean("pipAutoEnter", false)
|
||||
|
||||
fun setPipAutoEnter(context: Context, enabled: Boolean) {
|
||||
prefs(context).edit().putBoolean("pipAutoEnter", enabled).apply()
|
||||
}
|
||||
|
||||
fun suspendPolicy(context: Context, mode: String): String =
|
||||
prefs(context).getString("suspendPolicy.${prefMode(mode)}", SUSPEND_MANUAL)
|
||||
?.takeIf { it == SUSPEND_AUTO || it == SUSPEND_MANUAL || it == SUSPEND_NEVER }
|
||||
|
||||
@@ -78,6 +78,7 @@ class SessionService : Service() {
|
||||
/** An explicit Steam sleep request is independent of the background policy. */
|
||||
private var steamSleepToken: String? = null
|
||||
private var suspendOperationPending = false
|
||||
private var pipTask = false
|
||||
private var suspendAttemptFailed = false
|
||||
/** One validated game request waiting for this Steam session to reach a usable state. */
|
||||
private var pendingSteamGameId: String? = null
|
||||
@@ -151,7 +152,12 @@ class SessionService : Service() {
|
||||
stopSession(0)
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
ACTION_PIP_BEGIN -> {
|
||||
pipTask = true
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
ACTION_ACTIVITY_VISIBLE -> {
|
||||
if (!SessionState.pipActive) pipTask = false
|
||||
activityVisible = true
|
||||
resumeSteamSleepOnReturn()
|
||||
suspendAttemptFailed = false
|
||||
@@ -193,6 +199,8 @@ class SessionService : Service() {
|
||||
suspendAttemptFailed = false
|
||||
suspendController = null
|
||||
SessionState.suspended = false
|
||||
SessionState.pipActive = false
|
||||
pipTask = false
|
||||
SessionState.program = intent?.getStringExtra(EXTRA_PROGRAM)
|
||||
SessionState.programArgs = intent?.getStringArrayExtra(EXTRA_PROGRAM_ARGS)?.toList().orEmpty()
|
||||
SessionState.steamUi = intent?.getStringExtra(EXTRA_STEAM_UI)
|
||||
@@ -1158,6 +1166,8 @@ class SessionService : Service() {
|
||||
return@post
|
||||
}
|
||||
SessionState.suspended = false
|
||||
SessionState.pipActive = false
|
||||
pipTask = false
|
||||
SessionState.guestPid = -1
|
||||
releaseLocks()
|
||||
if (status == 0) {
|
||||
@@ -1267,6 +1277,12 @@ class SessionService : Service() {
|
||||
* guest would survive as an orphan holding the rootfs and the GPU. Treat the swipe as "quit".
|
||||
*/
|
||||
override fun onTaskRemoved(rootIntent: Intent?) {
|
||||
if (pipTask) {
|
||||
Log.i(TAG, "PiP task dismissed - retaining the session under its background policy")
|
||||
activityVisible = false
|
||||
updateSuspendPolicy()
|
||||
return
|
||||
}
|
||||
Log.i(TAG, "task removed - ending the session")
|
||||
stopSession(0)
|
||||
super.onTaskRemoved(rootIntent)
|
||||
@@ -1407,6 +1423,7 @@ class SessionService : Service() {
|
||||
private const val NOTIFICATION_ID = 1001
|
||||
const val ACTION_STOP = "com.droiddeck.launcher.STOP_SESSION"
|
||||
const val ACTION_RESUME = "com.droiddeck.launcher.RESUME_SESSION"
|
||||
private const val ACTION_PIP_BEGIN = "com.droiddeck.launcher.PIP_BEGIN"
|
||||
const val ACTION_LAUNCH_GAME = "com.droiddeck.launcher.LAUNCH_STEAM_GAME"
|
||||
const val ACTION_HOME_GUIDE = "com.droiddeck.launcher.HOME_GUIDE"
|
||||
const val ACTION_AGENT_START = "com.droiddeck.launcher.AGENT_START"
|
||||
@@ -1467,6 +1484,10 @@ class SessionService : Service() {
|
||||
context.startService(Intent(context, SessionService::class.java).setAction(ACTION_STOP))
|
||||
}
|
||||
|
||||
fun beginPip(context: Context) {
|
||||
context.startService(Intent(context, SessionService::class.java).setAction(ACTION_PIP_BEGIN))
|
||||
}
|
||||
|
||||
fun setActivityVisible(context: Context, visible: Boolean) {
|
||||
if (!SessionState.running) return
|
||||
val action = if (visible) ACTION_ACTIVITY_VISIBLE else ACTION_ACTIVITY_HIDDEN
|
||||
|
||||
@@ -47,6 +47,7 @@ object SessionState {
|
||||
@Volatile
|
||||
var running = false
|
||||
var suspended by mutableStateOf(false)
|
||||
@Volatile var pipActive = false
|
||||
/** MODE_RUN: the program inside the runtime the session was started for. */
|
||||
@Volatile
|
||||
var program: String? = null
|
||||
|
||||
@@ -58,6 +58,8 @@ class ModeSettings(
|
||||
val upscaleSharpness: Int = 75,
|
||||
val touchMode: String,
|
||||
val suspendPolicy: String,
|
||||
val pipSupported: Boolean = false,
|
||||
val pipAutoEnter: Boolean = false,
|
||||
/** Steam only. */
|
||||
val oscMode: String?,
|
||||
/** Steam only: whether single and double Back actions are swapped. */
|
||||
@@ -119,6 +121,7 @@ class ModeSettingsActions(
|
||||
val onUpscaleSharpness: (Int) -> Unit = {},
|
||||
val onTouch: (String) -> Unit,
|
||||
val onSuspendPolicy: (String) -> Unit,
|
||||
val onPipAutoEnter: (Boolean) -> Unit = {},
|
||||
val onOsc: (String) -> Unit,
|
||||
val onBackActionsInverted: (Boolean) -> Unit = {},
|
||||
val onDirectAudio: (Boolean) -> Unit,
|
||||
@@ -271,6 +274,10 @@ fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) {
|
||||
onPick = a.onSuspendPolicy,
|
||||
)
|
||||
}
|
||||
if (s.pipSupported) SettingsGroup(stringResource(R.string.pip_title)) {
|
||||
ToggleRow(host, "pip-auto", stringResource(R.string.pip_auto), null,
|
||||
s.pipAutoEnter, onChange = a.onPipAutoEnter)
|
||||
}
|
||||
if (steam) SettingsGroup(stringResource(R.string.mode_startup)) {
|
||||
ToggleRow(
|
||||
host, "steam-startup", stringResource(R.string.mode_steam_startup),
|
||||
|
||||
@@ -200,6 +200,10 @@ class DrawerActions(
|
||||
val onSecondScreenDisplay: (Int) -> Unit,
|
||||
val onLaunchAndroidApp: (HomeApp.LaunchableApp, Int?) -> Unit,
|
||||
val onBackground: () -> Unit,
|
||||
val pipSupported: Boolean = false,
|
||||
val pipAutoEnter: Boolean = false,
|
||||
val onPip: () -> Unit = {},
|
||||
val onPipAutoEnter: (Boolean) -> Unit = {},
|
||||
val onShareLogs: () -> Unit,
|
||||
val onStop: () -> Unit,
|
||||
/** Stop with the dialog's button's bounds on screen, for the flood to grow out of; null falls back to [onStop]. */
|
||||
@@ -472,7 +476,14 @@ fun SessionDrawer(open: Boolean, page: Int, controllerActive: Boolean, onPageCha
|
||||
}
|
||||
}
|
||||
}
|
||||
if (a.pipSupported) SettingsGroup(stringResource(R.string.pip_title)) {
|
||||
ToggleRow(host, "pip-auto", stringResource(R.string.pip_auto), null,
|
||||
a.pipAutoEnter, onChange = a.onPipAutoEnter)
|
||||
}
|
||||
Spacer(Modifier.height(18.dp))
|
||||
if (a.pipSupported) DrawerOutlineButton(stringResource(R.string.pip_title), modifier = focus.track(page, "pip")) {
|
||||
host.open = null; a.onPip()
|
||||
}
|
||||
if (!a.isHomeApp) DrawerOutlineButton(stringResource(R.string.drawer_background), modifier = focus.track(page, "background")) {
|
||||
host.open = null; a.onBackground()
|
||||
}
|
||||
|
||||
@@ -202,6 +202,9 @@ private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, m
|
||||
if (s.sessionRunning && (offered || offer == Offer.AHEAD)) {
|
||||
Text(stringResource(R.string.upd_stop_session), fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(top = 8.dp))
|
||||
}
|
||||
if (u.follow.channel == Channel.NIGHTLY) {
|
||||
PreviewHistory(catalog, me)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,6 +289,63 @@ private fun ChannelPicker(u: UpdatesState, ua: UpdatesActions) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Read-only Preview history below the status card action; only the latest build is installable. */
|
||||
@Composable
|
||||
private fun PreviewHistory(catalog: AppUpdates.Catalog?, me: AppUpdates.Installed) {
|
||||
val history = catalog?.let { AppUpdates.previewHistory(it, me) } ?: return
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val key = catalog?.recentPreviews?.firstOrNull()?.commit
|
||||
var expanded by rememberSaveable(key) { mutableStateOf(false) }
|
||||
val heading = when (history.kind) {
|
||||
AppUpdates.PreviewHistoryKind.CURRENT -> stringResource(R.string.upd_preview_current)
|
||||
AppUpdates.PreviewHistoryKind.BEHIND -> pluralStringResource(
|
||||
R.plurals.upd_preview_behind, history.buildsBehind, history.buildsBehind,
|
||||
)
|
||||
AppUpdates.PreviewHistoryKind.RECENT -> pluralStringResource(
|
||||
R.plurals.upd_preview_recent, history.changes.size, history.changes.size,
|
||||
)
|
||||
}
|
||||
Column(Modifier.fillMaxWidth().padding(top = 18.dp)) {
|
||||
Text(heading, fontSize = 11.5.sp, fontWeight = FontWeight.Medium, color = colors.onSurfaceVariant)
|
||||
if (history.changes.isNotEmpty()) {
|
||||
val visible = if (expanded) history.changes else history.changes.take(3)
|
||||
Column(Modifier.padding(top = 3.dp), verticalArrangement = Arrangement.spacedBy(3.dp)) {
|
||||
visible.forEach { change ->
|
||||
Column {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
Text(
|
||||
changeTitle(change.title.ifBlank { change.commit.take(7) }),
|
||||
fontSize = 12.5.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground,
|
||||
maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f),
|
||||
)
|
||||
Text(ago(change.publishedAt), fontSize = 11.sp, color = colors.onSurfaceVariant)
|
||||
}
|
||||
if (change.summary.isNotBlank()) Text(
|
||||
change.summary, fontSize = 11.5.sp, color = colors.onSurfaceVariant,
|
||||
maxLines = 1, overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (history.changes.size > 3 || expanded) {
|
||||
val src = remember { MutableInteractionSource() }
|
||||
val hot = rememberHot(src)
|
||||
val toggle = { expanded = !expanded }
|
||||
Text(
|
||||
if (expanded) stringResource(R.string.upd_less) else stringResource(R.string.upd_more),
|
||||
fontSize = 12.sp, fontWeight = FontWeight.SemiBold, color = pal.signal,
|
||||
modifier = Modifier.padding(top = 1.dp).offset(x = (-6).dp).paneItem("preview:history:more")
|
||||
.clip(Shape12).glideBorder(hot, Shape12, pal.signal)
|
||||
.hoverable(src).clickable(interactionSource = src, indication = null, role = Role.Button, onClick = toggle)
|
||||
.controllerConfirm(onClick = toggle)
|
||||
.padding(horizontal = 6.dp, vertical = 4.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ChannelCard(
|
||||
icon: ImageVector, title: String, hint: String, latest: String?, selected: Boolean,
|
||||
|
||||
@@ -54,11 +54,19 @@ object AppUpdates {
|
||||
val apk: Apk?,
|
||||
)
|
||||
|
||||
class PreviewChange(
|
||||
val commit: String,
|
||||
val title: String,
|
||||
val summary: String,
|
||||
val publishedAt: Long,
|
||||
)
|
||||
|
||||
class Catalog(
|
||||
val stable: Release?,
|
||||
val preview: Release?,
|
||||
val tests: List<Release>,
|
||||
val checkedAt: Long,
|
||||
val recentPreviews: List<PreviewChange> = emptyList(),
|
||||
)
|
||||
|
||||
class Installed(
|
||||
@@ -68,6 +76,15 @@ object AppUpdates {
|
||||
val versionCode: Int,
|
||||
val updatable: Boolean,
|
||||
val committedAt: Long = 0L,
|
||||
val ciBuild: Boolean = BuildConfig.CI_BUILD,
|
||||
)
|
||||
|
||||
enum class PreviewHistoryKind { CURRENT, BEHIND, RECENT }
|
||||
|
||||
class PreviewHistory(
|
||||
val kind: PreviewHistoryKind,
|
||||
val buildsBehind: Int,
|
||||
val changes: List<PreviewChange>,
|
||||
)
|
||||
|
||||
enum class Offer {
|
||||
@@ -146,6 +163,37 @@ object AppUpdates {
|
||||
r.commit.startsWith(me.commit, ignoreCase = true)
|
||||
}
|
||||
|
||||
/** Recent Preview changes relative to a CI-installed commit, when its position is known. */
|
||||
fun previewHistory(catalog: Catalog, me: Installed = installed()): PreviewHistory? {
|
||||
if (!me.ciBuild || catalog.recentPreviews.isEmpty()) return null
|
||||
val stable = catalog.stable
|
||||
if (
|
||||
me.pr != 0 || stable?.let { isRunning(it, me) } == true ||
|
||||
stable?.version?.let { compareVersions(me.version, it) <= 0 } == true
|
||||
) {
|
||||
return PreviewHistory(PreviewHistoryKind.RECENT, 0, catalog.recentPreviews)
|
||||
}
|
||||
|
||||
val matching = catalog.recentPreviews.indices.filter {
|
||||
matchesInstalledCommit(catalog.recentPreviews[it].commit, me.commit)
|
||||
}
|
||||
if (matching.size != 1) {
|
||||
return PreviewHistory(PreviewHistoryKind.RECENT, 0, catalog.recentPreviews)
|
||||
}
|
||||
val index = matching.single()
|
||||
return if (index == 0) {
|
||||
PreviewHistory(PreviewHistoryKind.CURRENT, 0, emptyList())
|
||||
} else {
|
||||
PreviewHistory(PreviewHistoryKind.BEHIND, index, catalog.recentPreviews.take(index))
|
||||
}
|
||||
}
|
||||
|
||||
private fun matchesInstalledCommit(published: String, installed: String): Boolean {
|
||||
if (!Regex("^[0-9a-fA-F]{7,40}$").matches(installed)) return false
|
||||
return published.equals(installed, ignoreCase = true) ||
|
||||
(installed.length < 40 && published.startsWith(installed, ignoreCase = true))
|
||||
}
|
||||
|
||||
/** Why Android cannot install this published build over [me], before downloading anything. */
|
||||
fun installBlock(r: Release, me: Installed = installed()): String? = when {
|
||||
r.apk == null -> "This build has no download for this copy of DroidDeck."
|
||||
@@ -218,6 +266,7 @@ object AppUpdates {
|
||||
)
|
||||
}
|
||||
val tests = root.optJSONArray("tests") ?: JSONArray()
|
||||
val recentPreviews = root.optJSONArray("recentPreviews") ?: JSONArray()
|
||||
return Catalog(
|
||||
root.optJSONObject("stable")?.let { readPublishedRelease(it, packageName) },
|
||||
root.optJSONObject("preview")?.let { readPublishedRelease(it, packageName) },
|
||||
@@ -226,9 +275,20 @@ object AppUpdates {
|
||||
.filter { it.pr > 0 }
|
||||
.sortedByDescending { it.publishedAt },
|
||||
checkedAt,
|
||||
(0 until recentPreviews.length())
|
||||
.mapNotNull { recentPreviews.optJSONObject(it)?.let(::readPublishedPreviewChange) }
|
||||
.sortedByDescending { it.publishedAt }
|
||||
.distinctBy { it.commit.lowercase() }
|
||||
.take(10),
|
||||
)
|
||||
}
|
||||
|
||||
private fun readPublishedPreviewChange(o: JSONObject): PreviewChange? {
|
||||
val commit = o.optString("commit")
|
||||
if (!Regex("^[0-9a-fA-F]{40}$").matches(commit)) return null
|
||||
return PreviewChange(commit.lowercase(), o.optString("title"), o.optString("summary"), o.optLong("publishedAt"))
|
||||
}
|
||||
|
||||
private fun readPublishedRelease(o: JSONObject, packageName: String): Release {
|
||||
val commit = o.getString("commit")
|
||||
if (!Regex("^[0-9a-fA-F]{7,40}$").matches(commit)) {
|
||||
@@ -358,23 +418,42 @@ object AppUpdates {
|
||||
},
|
||||
)
|
||||
|
||||
private fun writeCatalog(c: Catalog): JSONObject = JSONObject()
|
||||
internal fun writeCatalog(c: Catalog): JSONObject = JSONObject()
|
||||
.put("stable", c.stable?.let(::writeRelease))
|
||||
.put("preview", c.preview?.let(::writeRelease))
|
||||
.put("tests", JSONArray().apply { c.tests.forEach { put(writeRelease(it)) } })
|
||||
.put("recentPreviews", JSONArray().apply { c.recentPreviews.forEach { put(writePreviewChange(it)) } })
|
||||
.put("checkedAt", c.checkedAt)
|
||||
|
||||
private fun readCachedCatalog(o: JSONObject): Catalog {
|
||||
private fun writePreviewChange(c: PreviewChange): JSONObject = JSONObject()
|
||||
.put("commit", c.commit)
|
||||
.put("title", c.title)
|
||||
.put("summary", c.summary)
|
||||
.put("publishedAt", c.publishedAt)
|
||||
|
||||
internal fun readCachedCatalog(o: JSONObject): Catalog {
|
||||
val tests = o.optJSONArray("tests") ?: JSONArray()
|
||||
val preview = o.optJSONObject("preview") ?: o.optJSONObject("nightly")
|
||||
val recentPreviews = o.optJSONArray("recentPreviews") ?: JSONArray()
|
||||
return Catalog(
|
||||
o.optJSONObject("stable")?.let(::readCachedRelease),
|
||||
preview?.let(::readCachedRelease),
|
||||
(0 until tests.length()).map { readCachedRelease(tests.getJSONObject(it)) },
|
||||
o.optLong("checkedAt"),
|
||||
(0 until recentPreviews.length())
|
||||
.mapNotNull { recentPreviews.optJSONObject(it)?.let(::readCachedPreviewChange) }
|
||||
.sortedByDescending { it.publishedAt }
|
||||
.distinctBy { it.commit.lowercase() }
|
||||
.take(10),
|
||||
)
|
||||
}
|
||||
|
||||
private fun readCachedPreviewChange(o: JSONObject): PreviewChange? {
|
||||
val commit = o.optString("commit")
|
||||
if (!Regex("^[0-9a-fA-F]{40}$").matches(commit)) return null
|
||||
return PreviewChange(commit.lowercase(), o.optString("title"), o.optString("summary"), o.optLong("publishedAt"))
|
||||
}
|
||||
|
||||
private fun prefs(context: Context) =
|
||||
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
|
||||
}
|
||||
@@ -598,6 +598,7 @@
|
||||
<string name="upd_channel">CANAL DE ACTUALIZACIÓN</string>
|
||||
<string name="upd_stable_hint">Versiones probadas, para la mayoría</string>
|
||||
<string name="upd_preview_hint">Las correcciones más recientes, antes que Stable</string>
|
||||
<string name="upd_preview_current">Al día</string>
|
||||
<string name="upd_tests">Versiones de prueba</string>
|
||||
<string name="upd_tests_hint">Prueba una corrección antes de su publicación</string>
|
||||
<string name="upd_tests_none">Ninguna por ahora</string>
|
||||
@@ -610,6 +611,14 @@
|
||||
<item quantity="one">%1$d para probar</item>
|
||||
<item quantity="other">%1$d para probar</item>
|
||||
</plurals>
|
||||
<plurals name="upd_preview_behind">
|
||||
<item quantity="one">Cambios desde tu versión · %1$d versión atrás</item>
|
||||
<item quantity="other">Cambios desde tu versión · %1$d versiones atrás</item>
|
||||
</plurals>
|
||||
<plurals name="upd_preview_recent">
|
||||
<item quantity="one">Cambios recientes · %1$d versión</item>
|
||||
<item quantity="other">Cambios recientes · %1$d versiones</item>
|
||||
</plurals>
|
||||
<string name="gate_title">Un ajuste de Android por cambiar</string>
|
||||
<string name="gate_lede">Android detiene las apps que inician muchos procesos en segundo plano, y Steam inicia decenas. Hasta que esto cambie, los juegos se cierran sin mostrar ningún error.</string>
|
||||
<string name="gate_fix_for_me">Solucionarlo por mí</string>
|
||||
|
||||
@@ -647,6 +647,7 @@
|
||||
<string name="upd_version_ago">%1$s · %2$s</string>
|
||||
<string name="upd_preview">Preview</string>
|
||||
<string name="upd_preview_hint">Newest fixes, before Stable</string>
|
||||
<string name="upd_preview_current">Up to date</string>
|
||||
<string name="upd_tests">Test builds</string>
|
||||
<string name="upd_tests_hint">Try a fix before it\'s released</string>
|
||||
<string name="upd_tests_none">None right now</string>
|
||||
@@ -660,6 +661,14 @@
|
||||
<item quantity="one">%1$d to try</item>
|
||||
<item quantity="other">%1$d to try</item>
|
||||
</plurals>
|
||||
<plurals name="upd_preview_behind">
|
||||
<item quantity="one">Changes since your build · %1$d build behind</item>
|
||||
<item quantity="other">Changes since your build · %1$d builds behind</item>
|
||||
</plurals>
|
||||
<plurals name="upd_preview_recent">
|
||||
<item quantity="one">Recent changes · %1$d build</item>
|
||||
<item quantity="other">Recent changes · %1$d builds</item>
|
||||
</plurals>
|
||||
<string name="gate_title">One Android setting to change</string>
|
||||
<string name="gate_eyebrow">Steam</string>
|
||||
<string name="gate_lede">Android stops apps that start many background processes, and Steam starts dozens. Until this changes, games close without an error.</string>
|
||||
@@ -909,6 +918,12 @@
|
||||
<string name="game_env_change_title">Change variable</string>
|
||||
<string name="game_env_restore_default">Back to default</string>
|
||||
<string name="game_env_eyebrow">Proton games</string>
|
||||
<string name="pip_title">Picture in picture</string>
|
||||
<string name="pip_auto">Automatically enter PiP</string>
|
||||
<string name="pip_suspended">Suspended</string>
|
||||
<string name="pip_not_ready">Picture in picture is available once the session is ready.</string>
|
||||
<string name="pip_permission">Allow picture in picture for DroidDeck in Android settings.</string>
|
||||
<string name="pip_unavailable">Android could not open picture in picture.</string>
|
||||
<string name="game_shortcut">Shortcut</string>
|
||||
<string name="game_shortcut_add">Add to home screen</string>
|
||||
<string name="game_shortcut_choose">Choose game</string>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
class PipPolicyTest {
|
||||
@Test fun automaticEntryNeverOpensStartingFailedOrSuspendedSessions() {
|
||||
for (phase in SessionPhase.entries) {
|
||||
assertEquals(phase == SessionPhase.READY,
|
||||
PipPolicy.eligible(true, true, phase, phase == SessionPhase.SUSPENDED, true))
|
||||
}
|
||||
assertFalse(PipPolicy.eligible(true, false, SessionPhase.READY, false, true))
|
||||
assertFalse(PipPolicy.eligible(false, true, SessionPhase.READY, false, true))
|
||||
}
|
||||
|
||||
@Test fun manualEntryAllowsAVisibleSuspendedPicture() {
|
||||
assertTrue(PipPolicy.eligible(true, true, SessionPhase.SUSPENDED, true, false))
|
||||
assertFalse(PipPolicy.eligible(true, false, SessionPhase.SUSPENDED, true, false))
|
||||
}
|
||||
|
||||
@Test fun aspectRatiosStayWithinAndroidLimitsWithoutChangingNormalContent() {
|
||||
assertEquals(1920 to 1080, PipPolicy.aspect(1920, 1080))
|
||||
assertEquals(239 to 100, PipPolicy.aspect(5760, 1080))
|
||||
assertEquals(100 to 239, PipPolicy.aspect(1080, 5760))
|
||||
assertEquals(16 to 9, PipPolicy.aspect(0, 0))
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,12 @@ import com.droiddeck.launcher.update.AppUpdates.Channel
|
||||
import com.droiddeck.launcher.update.AppUpdates.Follow
|
||||
import com.droiddeck.launcher.update.AppUpdates.Installed
|
||||
import com.droiddeck.launcher.update.AppUpdates.Offer
|
||||
import com.droiddeck.launcher.update.AppUpdates.PreviewChange
|
||||
import com.droiddeck.launcher.update.AppUpdates.PreviewHistoryKind
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Assert.fail
|
||||
@@ -63,7 +66,17 @@ class AppUpdatesTest {
|
||||
pr: Int = 0,
|
||||
version: String = "0.2.0",
|
||||
versionCode: Int = 9,
|
||||
) = Installed(commit, pr, version, versionCode, updatable = true)
|
||||
ciBuild: Boolean = true,
|
||||
) = Installed(commit, pr, version, versionCode, updatable = true, ciBuild = ciBuild)
|
||||
|
||||
private fun change(commit: String, title: String, publishedAt: Long) =
|
||||
PreviewChange(commit, title, "Summary for $title", publishedAt)
|
||||
|
||||
private val recentPreview = listOf(
|
||||
change("1".repeat(40), "Newest", 300L),
|
||||
change("2".repeat(40), "Middle", 200L),
|
||||
change("3".repeat(40), "Oldest", 100L),
|
||||
)
|
||||
|
||||
@Test
|
||||
fun theStableBuildIsCurrentOnStable() {
|
||||
@@ -122,6 +135,76 @@ class AppUpdatesTest {
|
||||
assertNotNull(AppUpdates.installBlock(missing, me("eeeeeee")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun previewHistoryCountsOnlyAnUnambiguousPublishedPreviewCommit() {
|
||||
val withHistory = AppUpdates.Catalog(stable, release("1111111"), emptyList(), 0L, recentPreview)
|
||||
val result = AppUpdates.previewHistory(withHistory, me("2".repeat(40), version = "0.3.0"))!!
|
||||
assertEquals(PreviewHistoryKind.BEHIND, result.kind)
|
||||
assertEquals(1, result.buildsBehind)
|
||||
assertEquals(listOf("Newest"), result.changes.map { it.title })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun currentPreviewHasNoRedundantChangeRows() {
|
||||
val withHistory = AppUpdates.Catalog(stable, release("1111111"), emptyList(), 0L, recentPreview)
|
||||
val result = AppUpdates.previewHistory(withHistory, me("1".repeat(40), version = "0.3.0"))!!
|
||||
assertEquals(PreviewHistoryKind.CURRENT, result.kind)
|
||||
assertTrue(result.changes.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun missingOrAmbiguousPreviewCommitsUseNeutralRecentHistory() {
|
||||
val withHistory = AppUpdates.Catalog(stable, release("1111111"), emptyList(), 0L, recentPreview)
|
||||
assertEquals(
|
||||
PreviewHistoryKind.RECENT,
|
||||
AppUpdates.previewHistory(withHistory, me("9".repeat(40), version = "0.3.0"))!!.kind,
|
||||
)
|
||||
|
||||
val ambiguous = listOf(
|
||||
change("abcdef0" + "1".repeat(33), "First", 300L),
|
||||
change("abcdef0" + "2".repeat(33), "Second", 200L),
|
||||
)
|
||||
val ambiguousCatalog = AppUpdates.Catalog(stable, release("abcdef0"), emptyList(), 0L, ambiguous)
|
||||
val result = AppUpdates.previewHistory(ambiguousCatalog, me("abcdef0", version = "0.3.0"))!!
|
||||
assertEquals(PreviewHistoryKind.RECENT, result.kind)
|
||||
assertEquals(2, result.changes.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun prStableAndLocalBuildsDoNotGetPreviewDistance() {
|
||||
val withHistory = AppUpdates.Catalog(stable, release("1111111"), emptyList(), 0L, recentPreview)
|
||||
assertEquals(
|
||||
PreviewHistoryKind.RECENT,
|
||||
AppUpdates.previewHistory(withHistory, me("2".repeat(40), pr = 93, version = "0.3.0"))!!.kind,
|
||||
)
|
||||
assertEquals(
|
||||
PreviewHistoryKind.RECENT,
|
||||
AppUpdates.previewHistory(withHistory, me(stable.commit))!!.kind,
|
||||
)
|
||||
assertNull(AppUpdates.previewHistory(withHistory, me("2".repeat(40), version = "0.3.0", ciBuild = false)))
|
||||
assertEquals(
|
||||
PreviewHistoryKind.RECENT,
|
||||
AppUpdates.previewHistory(withHistory, me("2".repeat(40), version = "0.1.0"))!!.kind,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cachedPreviewHistorySurvivesRoundTrip() {
|
||||
val withHistory = AppUpdates.Catalog(stable, release("1111111"), emptyList(), 123L, recentPreview)
|
||||
val cached = AppUpdates.readCachedCatalog(AppUpdates.writeCatalog(withHistory))
|
||||
assertEquals(123L, cached.checkedAt)
|
||||
assertEquals(3, cached.recentPreviews.size)
|
||||
assertEquals("Newest", cached.recentPreviews.first().title)
|
||||
assertEquals(recentPreview.first().commit, cached.recentPreviews.first().commit)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun oldCachedCatalogWithoutPreviewHistoryRemainsReadable() {
|
||||
val cached = AppUpdates.readCachedCatalog(JSONObject().put("tests", JSONArray()).put("checkedAt", 123L))
|
||||
assertEquals(123L, cached.checkedAt)
|
||||
assertTrue(cached.recentPreviews.isEmpty())
|
||||
}
|
||||
|
||||
private fun publishedCatalog(signer: String = BuildConfig.RELEASE_SIGNER): JSONObject {
|
||||
val raw = """
|
||||
{
|
||||
@@ -169,6 +252,25 @@ class AppUpdatesTest {
|
||||
assertEquals(9, parsed.preview!!.apk!!.versionCode)
|
||||
assertNull(parsed.preview!!.version)
|
||||
assertEquals(123L, parsed.checkedAt)
|
||||
assertTrue(parsed.recentPreviews.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun publishedCatalogReadsOptionalPreviewHistoryAndDeduplicates() {
|
||||
val first = "a".repeat(40)
|
||||
val newest = "b".repeat(40)
|
||||
val raw = publishedCatalog().put(
|
||||
"recentPreviews",
|
||||
JSONArray()
|
||||
.put(JSONObject().put("commit", first).put("title", "Older").put("summary", "Old").put("publishedAt", 1L))
|
||||
.put(JSONObject().put("commit", newest).put("title", "Newest").put("summary", "New").put("publishedAt", 2L))
|
||||
.put(JSONObject().put("commit", first).put("title", "Duplicate").put("summary", "Again").put("publishedAt", 3L))
|
||||
.put(JSONObject().put("commit", "shortsha").put("title", "Invalid")),
|
||||
)
|
||||
val parsed = AppUpdates.readPublishedCatalog(raw, "com.droiddeck.launcher", 123L)
|
||||
assertEquals(2, parsed.recentPreviews.size)
|
||||
assertEquals("Duplicate", parsed.recentPreviews.first().title)
|
||||
assertEquals(newest, parsed.recentPreviews.last().commit)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
# Opt-in software Steam compatibility
|
||||
|
||||
This change provides an explicit software fallback for the Linux Steam/Gamescope
|
||||
session. It does not enable fallback automatically or install a Mali Linux ICD.
|
||||
The Android presenter still uses Vulkan; a positively identified Mali kbase
|
||||
GPU uses the system Android driver. Adreno and unknown devices keep the existing
|
||||
selection, and explicit Android driver choices retain precedence.
|
||||
|
||||
## Enable and recover
|
||||
|
||||
Set `/sdcard/Download/droiddeck-env` to include:
|
||||
|
||||
```sh
|
||||
BL_STEAM_SOFTWARE=1
|
||||
```
|
||||
|
||||
Remove that entry or set it to `0` to return to normal session rendering. No
|
||||
preference is migrated or enabled by this branch. Only the exact value `1`
|
||||
activates the fallback in the scripts and native Gamescope.
|
||||
|
||||
The fallback selects Lavapipe/llvmpipe, Gamescope's SDL Wayland swapchain,
|
||||
software Steam CEF/SDL rendering, and disables mangoapp for that session.
|
||||
An explicitly requested software session takes precedence over `BL_VK_DRIVER`;
|
||||
with the mode off, imported Linux drivers retain their existing behavior.
|
||||
Desktop Steam can also use this mode on a pixman desktop.
|
||||
|
||||
The optional present timing, local texture allocation, SHM refresh and ready
|
||||
fence handling in the new Gamescope patches apply only in this mode. Normal
|
||||
sessions retain the original dma-buf, buffer-cache and presentation paths.
|
||||
The Android presenter requests at most its loader's Vulkan API (minimum 1.1)
|
||||
and advertises dma-buf import only when the complete extension set is available.
|
||||
|
||||
## Validation
|
||||
|
||||
`tools/tests/test_software_graphics.py` exercises the actual outer session
|
||||
launcher with a capturing Gamescope executable: default accelerated backend,
|
||||
custom-driver selection, software-only activation, precedence, overlay, HDR,
|
||||
refresh rate and argument preservation. The native component is built against
|
||||
all existing patches and checked against the runtime's shared-library list.
|
||||
|
||||
Earlier experiment validation on the wired Unisoc T618 / Mali-G52 MC2 device
|
||||
(Android 12, kbase JM 11.31) reached Steam Big Picture sign-in and downloaded
|
||||
Geometry Wars: Retro Evolved. Its software-rendered menu, movement, shooting and
|
||||
pause worked, at roughly 3–5 displayed FPS. The per-game workaround was:
|
||||
|
||||
```sh
|
||||
DISABLE_GAMESCOPE_WSI=1 %command%
|
||||
```
|
||||
|
||||
This option is not applied globally. Software gameplay remains too slow for
|
||||
normal play. The previous experimental branch `mali-software-steam` retains
|
||||
the private PanVK build and GPU proof: compute, draw/readback, indexed draw and
|
||||
visible VKCube worked, but accelerated Geometry Wars lost the GPU device.
|
||||
That driver lab is intentionally outside this compatibility change.
|
||||
|
||||
Before a PR, validate default rendering on supported Adreno devices, explicit
|
||||
Android/Linux driver choices, overlays and supported HDR/frame-generation
|
||||
behavior as well as the opted-in wired Mali session. Passing launcher checks
|
||||
alone is not proof of physical Adreno regression safety.
|
||||
@@ -49,3 +49,13 @@ library list, before anything is published.
|
||||
|
||||
Sixteen more of Armada's patches are DRM/lease/HDR-on-KMS work for a native display, which this
|
||||
app's Wayland-hosted gamescope never reaches, or need a newer gamescope than the runtime has.
|
||||
|
||||
- `0114-software-swapchain-compat.patch` - this app: only with
|
||||
`BL_STEAM_SOFTWARE=1`, allow the SDL Vulkan swapchain to run without present-ID/wait
|
||||
support and keep local textures private. Explicit exports and dma-buf imports retain
|
||||
their allocation requirements. With the mode unset, extension requests, feature chains,
|
||||
texture allocation and present-wait pacing follow the existing path.
|
||||
- `0115-software-shm-commits.patch` - this app: only in that compatibility mode,
|
||||
refresh reused shared-memory buffers on every commit and treat their completed
|
||||
synchronous uploads as ready. Normal sessions retain buffer memoization and fence
|
||||
handling; dma-buf commits retain both in either mode.
|
||||
@@ -0,0 +1,157 @@
|
||||
diff --git a/src/rendervulkan.cpp b/src/rendervulkan.cpp
|
||||
index 54e4efc..4777f7c 100644
|
||||
--- a/src/rendervulkan.cpp
|
||||
+++ b/src/rendervulkan.cpp
|
||||
@@ -57,6 +57,12 @@
|
||||
|
||||
#include "reshade_effect_manager.hpp"
|
||||
|
||||
+// Opt-in compatibility mode; an unset or other value preserves the normal backend.
|
||||
+const bool g_bSoftwareCompat = [] {
|
||||
+ const char *value = getenv( "BL_STEAM_SOFTWARE" );
|
||||
+ return value && strcmp( value, "1" ) == 0;
|
||||
+}();
|
||||
+
|
||||
extern bool g_bWasPartialComposite;
|
||||
extern bool g_bAllowDeferredBackend;
|
||||
|
||||
@@ -450,7 +456,16 @@ bool CVulkanDevice::createDevice()
|
||||
bool hasDrmProps = vulkan_has_drm_props();
|
||||
bool supportsForeignQueue = false;
|
||||
bool supportsHDRMetadata = false;
|
||||
+ bool supportsPresentId = false;
|
||||
+ bool supportsPresentWait = false;
|
||||
for (const auto& ext : m_supportedExts) {
|
||||
+ if ( g_bSoftwareCompat )
|
||||
+ {
|
||||
+ if ( strcmp(ext.extensionName, VK_KHR_PRESENT_ID_EXTENSION_NAME) == 0 )
|
||||
+ supportsPresentId = true;
|
||||
+ if ( strcmp(ext.extensionName, VK_KHR_PRESENT_WAIT_EXTENSION_NAME) == 0 )
|
||||
+ supportsPresentWait = true;
|
||||
+ }
|
||||
if ( strcmp(ext.extensionName, VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME) == 0 )
|
||||
m_bSupportsModifiers = true;
|
||||
|
||||
@@ -518,6 +533,26 @@ bool CVulkanDevice::createDevice()
|
||||
m_bSupportsModifiers = false;
|
||||
}
|
||||
|
||||
+ m_bSupportsPresentWait = !g_bSoftwareCompat;
|
||||
+ if ( g_bSoftwareCompat && supportsPresentId && supportsPresentWait )
|
||||
+ {
|
||||
+ VkPhysicalDevicePresentWaitFeaturesKHR waitFeatures = {
|
||||
+ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_WAIT_FEATURES_KHR,
|
||||
+ };
|
||||
+ VkPhysicalDevicePresentIdFeaturesKHR idFeatures = {
|
||||
+ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR,
|
||||
+ .pNext = &waitFeatures,
|
||||
+ };
|
||||
+ VkPhysicalDeviceFeatures2 features = {
|
||||
+ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
|
||||
+ .pNext = &idFeatures,
|
||||
+ };
|
||||
+ vk.GetPhysicalDeviceFeatures2( physDev(), &features );
|
||||
+ m_bSupportsPresentWait = idFeatures.presentId && waitFeatures.presentWait;
|
||||
+ }
|
||||
+ if ( GetBackend()->UsesVulkanSwapchain() && !m_bSupportsPresentWait )
|
||||
+ vk_log.infof( "Present ID/wait unavailable; using timer-based pacing." );
|
||||
+
|
||||
{
|
||||
VkPhysicalDeviceVulkan12Features vulkan12Features = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES,
|
||||
@@ -570,8 +605,11 @@ bool CVulkanDevice::createDevice()
|
||||
enabledExtensions.push_back( VK_KHR_SWAPCHAIN_EXTENSION_NAME );
|
||||
enabledExtensions.push_back( VK_KHR_SWAPCHAIN_MUTABLE_FORMAT_EXTENSION_NAME );
|
||||
|
||||
- enabledExtensions.push_back( VK_KHR_PRESENT_ID_EXTENSION_NAME );
|
||||
- enabledExtensions.push_back( VK_KHR_PRESENT_WAIT_EXTENSION_NAME );
|
||||
+ if ( m_bSupportsPresentWait )
|
||||
+ {
|
||||
+ enabledExtensions.push_back( VK_KHR_PRESENT_ID_EXTENSION_NAME );
|
||||
+ enabledExtensions.push_back( VK_KHR_PRESENT_WAIT_EXTENSION_NAME );
|
||||
+ }
|
||||
|
||||
if ( supportsHDRMetadata )
|
||||
enabledExtensions.push_back( VK_EXT_HDR_METADATA_EXTENSION_NAME );
|
||||
@@ -646,7 +684,7 @@ bool CVulkanDevice::createDevice()
|
||||
|
||||
VkPhysicalDeviceFeatures2 features2 = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
|
||||
- .pNext = &presentIdFeatures,
|
||||
+ .pNext = m_bSupportsPresentWait ? static_cast<void *>( &presentIdFeatures ) : static_cast<void *>( &features13 ),
|
||||
.features = {
|
||||
.shaderInt16 = m_bSupportsFp16,
|
||||
},
|
||||
@@ -2082,6 +2120,11 @@ static VkImageViewType VulkanImageTypeToViewType(VkImageType type)
|
||||
|
||||
bool CVulkanTexture::BInit( uint32_t width, uint32_t height, uint32_t depth, uint32_t drmFormat, createFlags flags, wlr_dmabuf_attributes *pDMA /* = nullptr */, uint32_t contentWidth /* = 0 */, uint32_t contentHeight /* = 0 */, CVulkanTexture *pExistingImageToReuseMemory, gamescope::OwningRc<gamescope::IBackendFb> pBackendFb )
|
||||
{
|
||||
+ // Software swapchains need local cursor, blank and wl_shm textures, not scan-out.
|
||||
+ // Explicit exports and dma-buf imports retain their original allocation requirements.
|
||||
+ if ( g_bSoftwareCompat && GetBackend()->UsesVulkanSwapchain() && !pDMA && !flags.bExportable )
|
||||
+ flags.bFlippable = false;
|
||||
+
|
||||
m_pBackendFb = std::move( pBackendFb );
|
||||
m_drmFormat = drmFormat;
|
||||
VkResult res = VK_ERROR_INITIALIZATION_FAILED;
|
||||
@@ -3086,7 +3129,7 @@ void vulkan_present_to_window( void )
|
||||
|
||||
VkPresentInfoKHR presentInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
|
||||
- .pNext = &presentIdInfo,
|
||||
+ .pNext = g_device.supportsPresentWait() ? &presentIdInfo : nullptr,
|
||||
.swapchainCount = 1,
|
||||
.pSwapchains = &g_output.swapChain,
|
||||
.pImageIndices = &g_output.nOutImage,
|
||||
@@ -3094,8 +3137,11 @@ void vulkan_present_to_window( void )
|
||||
|
||||
if ( g_device.vk.QueuePresentKHR( g_device.queue(), &presentInfo ) == VK_SUCCESS )
|
||||
{
|
||||
- g_currentPresentWaitId = presentId;
|
||||
- g_currentPresentWaitId.notify_all();
|
||||
+ if ( g_device.supportsPresentWait() )
|
||||
+ {
|
||||
+ g_currentPresentWaitId = presentId;
|
||||
+ g_currentPresentWaitId.notify_all();
|
||||
+ }
|
||||
}
|
||||
else
|
||||
vulkan_remake_swapchain();
|
||||
@@ -3662,7 +3708,7 @@ bool vulkan_init( VkInstance instance, VkSurfaceKHR surface )
|
||||
if (!init_nis_data())
|
||||
return false;
|
||||
|
||||
- if ( GetBackend()->UsesVulkanSwapchain() )
|
||||
+ if ( GetBackend()->UsesVulkanSwapchain() && g_device.supportsPresentWait() )
|
||||
{
|
||||
std::thread present_wait_thread( present_wait_thread_func );
|
||||
present_wait_thread.detach();
|
||||
diff --git a/src/rendervulkan.hpp b/src/rendervulkan.hpp
|
||||
index fa519db..a784c29 100644
|
||||
--- a/src/rendervulkan.hpp
|
||||
+++ b/src/rendervulkan.hpp
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "shaders/descriptor_set_constants.h"
|
||||
|
||||
+extern const bool g_bSoftwareCompat;
|
||||
+
|
||||
class CVulkanCmdBuffer;
|
||||
|
||||
// 1: Fade Plane (Fade outs between switching focus)
|
||||
@@ -862,6 +864,7 @@ public:
|
||||
inline VkPipelineLayout pipelineLayout() {return m_pipelineLayout;}
|
||||
inline int drmRenderFd() {return m_drmRendererFd;}
|
||||
inline bool supportsModifiers() {return m_bSupportsModifiers;}
|
||||
+ inline bool supportsPresentWait() {return m_bSupportsPresentWait;}
|
||||
inline bool hasDrmPrimaryDevId() {return m_bHasDrmPrimaryDevId;}
|
||||
inline dev_t primaryDevId() {return m_drmPrimaryDevId;}
|
||||
inline bool supportsFp16() {return m_bSupportsFp16;}
|
||||
@@ -930,6 +933,7 @@ protected:
|
||||
uint32_t m_uVendorID = 0;
|
||||
bool m_bHasDrmPrimaryDevId = false;
|
||||
bool m_bSupportsModifiers = false;
|
||||
+ bool m_bSupportsPresentWait = true;
|
||||
bool m_bInitialized = false;
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp
|
||||
index 18b799e..d854a68 100644
|
||||
--- a/src/steamcompmgr.cpp
|
||||
+++ b/src/steamcompmgr.cpp
|
||||
@@ -1850,30 +1850,32 @@ import_commit (
|
||||
commit->fifo = false;
|
||||
}
|
||||
|
||||
- if ( gamescope::OwningRc<CVulkanTexture> pTexture = s_BufferMemos.LookupVulkanTexture( buf ) )
|
||||
+ struct wlr_dmabuf_attributes dmabuf = {0};
|
||||
+ // Only the software compatibility path refreshes private wl_shm copies.
|
||||
+ // Normal sessions retain the original memo lookup before probing the buffer.
|
||||
+ const bool bRefreshShm = g_bSoftwareCompat && !wlr_buffer_get_dmabuf( buf, &dmabuf );
|
||||
+ if ( !bRefreshShm )
|
||||
{
|
||||
- // Going from OwningRc -> Rc now.
|
||||
- commit->vulkanTex = pTexture;
|
||||
- return commit;
|
||||
+ if ( gamescope::OwningRc<CVulkanTexture> pTexture = s_BufferMemos.LookupVulkanTexture( buf ) )
|
||||
+ {
|
||||
+ commit->vulkanTex = pTexture;
|
||||
+ return commit;
|
||||
+ }
|
||||
}
|
||||
|
||||
- struct wlr_dmabuf_attributes dmabuf = {0};
|
||||
gamescope::OwningRc<gamescope::IBackendFb> pBackendFb;
|
||||
if ( wlr_buffer_get_dmabuf( buf, &dmabuf ) )
|
||||
- {
|
||||
pBackendFb = GetBackend()->ImportDmabufToBackend( &dmabuf );
|
||||
- }
|
||||
|
||||
gamescope::OwningRc<CVulkanTexture> pOwnedTexture = vulkan_create_texture_from_wlr_buffer( buf, std::move( pBackendFb ) );
|
||||
|
||||
if ( pOwnedTexture == nullptr ) {
|
||||
- // Failed to create Vulkan texture from Wayland buffer for some reason.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
commit->vulkanTex = pOwnedTexture;
|
||||
-
|
||||
- s_BufferMemos.MemoizeBuffer( buf, std::move( pOwnedTexture ) );
|
||||
+ if ( !bRefreshShm )
|
||||
+ s_BufferMemos.MemoizeBuffer( buf, std::move( pOwnedTexture ) );
|
||||
|
||||
return commit;
|
||||
}
|
||||
@@ -8504,6 +8506,13 @@ void update_wayland_res(CommitDoneList_t *doneCommits, steamcompmgr_win_t *w, Re
|
||||
{
|
||||
fence = dup( dmabuf.fd[0] );
|
||||
}
|
||||
+ else if ( g_bSoftwareCompat && GetBackend()->UsesVulkanSwapchain() &&
|
||||
+ !newCommit->vulkanTex->externalImage() )
|
||||
+ {
|
||||
+ // wl_shm uploads wait for their copy to finish in vulkan_create_texture_from_wlr_buffer.
|
||||
+ // A private swapchain texture has no dma-buf to poll; it is already ready.
|
||||
+ bKnownReady = true;
|
||||
+ }
|
||||
else
|
||||
{
|
||||
fence = newCommit->vulkanTex->memoryFence();
|
||||
@@ -55,7 +55,6 @@ class LoginManager:
|
||||
GLib.Variant("(sa{sv}as)", (INTERFACE, {
|
||||
"PreparingForSleep": GLib.Variant("b", sleeping),
|
||||
}, [])))
|
||||
self.bus.flush_sync(None)
|
||||
print("== login1: " + ("pausing the session" if sleeping else "session resumed"), flush=True)
|
||||
|
||||
def method(self, connection, sender, path, interface, name, args, reply):
|
||||
@@ -67,11 +66,19 @@ class LoginManager:
|
||||
return
|
||||
self.pending = uuid.uuid4().hex
|
||||
self.notify(True)
|
||||
# Complete the D-Bus call before the host can freeze this service and
|
||||
# its caller. Publishing on the next main-loop turn avoids that race.
|
||||
reply.return_value(None)
|
||||
self.bus.flush_sync(None)
|
||||
GLib.idle_add(self.publish)
|
||||
# Flush the signal and method reply without blocking this D-Bus callback. Once both are
|
||||
# on the wire, publishing the request lets the host safely freeze this service.
|
||||
self.bus.flush_async(None, self.publish_after_flush, None)
|
||||
|
||||
def publish_after_flush(self, connection, result, _data):
|
||||
try:
|
||||
connection.flush_finish(result)
|
||||
except GLib.Error as error:
|
||||
print("== login1: cannot complete suspend handshake: " + str(error), file=sys.stderr)
|
||||
self.resume()
|
||||
return
|
||||
self.publish()
|
||||
|
||||
def publish(self):
|
||||
try:
|
||||
|
||||
@@ -53,7 +53,15 @@ trap 'collect_steam_logs 2>/dev/null || true' TERM INT HUP
|
||||
# VK_DRIVER_FILES REPLACES the loader's search, so a manifest whose library is unreadable would
|
||||
# leave the session with no Vulkan at all - check both before setting it, and say so in the log
|
||||
# rather than fail silently half a minute later.
|
||||
if [ -n "${BL_VK_DRIVER:-}" ]; then
|
||||
# Compatibility mode: the Android presenter still uses its selected Vulkan driver, while the
|
||||
# Linux session renders on the CPU. Gamescope's SDL swapchain can carry these frames as wl_shm;
|
||||
# its Wayland backend requires exportable dma-bufs even for its dummy black texture.
|
||||
if [ "${BL_STEAM_SOFTWARE:-0}" = 1 ]; then
|
||||
export VK_DRIVER_FILES=/usr/share/vulkan/icd.d/lvp_icd.json
|
||||
export VK_ICD_FILENAMES=$VK_DRIVER_FILES
|
||||
export LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=llvmpipe MESA_LOADER_DRIVER_OVERRIDE=swrast
|
||||
echo "== linux graphics: software rendering requested (Lavapipe/llvmpipe)"
|
||||
elif [ -n "${BL_VK_DRIVER:-}" ]; then
|
||||
bl_icd_lib=$(sed -n 's/.*"library_path"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$BL_VK_DRIVER" 2>/dev/null | head -1)
|
||||
# JSON may escape the separator: org.json writes "\/data\/user\/0\/...". The Vulkan loader
|
||||
# parses that correctly; this check has to as well, or an absolute path looks relative and gets
|
||||
@@ -148,7 +156,13 @@ if [ -z "${BL_INSIDE:-}" ]; then
|
||||
echo "== gamescope: games at ${nested}x${height} stretched to the ${width}x${height} output"
|
||||
fi
|
||||
fi
|
||||
args=(--backend wayland --expose-wayland -f -W "$width" -H "$height" -w "$nested" -h "$height")
|
||||
backend=wayland
|
||||
if [ "${BL_STEAM_SOFTWARE:-0}" = 1 ]; then
|
||||
backend=sdl
|
||||
export SDL_VIDEODRIVER=wayland
|
||||
echo "== gamescope: SDL Wayland swapchain for software rendering"
|
||||
fi
|
||||
args=(--backend "$backend" --expose-wayland -f -W "$width" -H "$height" -w "$nested" -h "$height")
|
||||
[ "$nested" != "$width" ] && args+=(-S stretch)
|
||||
# -r is what gamescope advertises as the refresh rate, and what a game reads as the display's.
|
||||
# Left unset it defaults to 60, so a 120 Hz panel offers only 60 Hz in game settings. The FPS
|
||||
@@ -179,7 +193,8 @@ if [ -z "${BL_INSIDE:-}" ]; then
|
||||
# MANGOHUD_CONFIGFILE. The apk stages Valve's aarch64 build (tools/mangoapp) - without it the menu
|
||||
# still offers the levels and nothing appears. Starts hidden until the client writes a level.
|
||||
# BL_MANGOAPP=0 turns it off (one community build found Valve's mangoapp crashing on Turnip).
|
||||
if [ "$mode" = steam ] && [ "${BL_STEAMDECK:-0}" = 1 ] && [ "${BL_MANGOAPP:-1}" = 1 ] \
|
||||
if [ "$mode" = steam ] && [ "${BL_STEAM_SOFTWARE:-0}" != 1 ] \
|
||||
&& [ "${BL_STEAMDECK:-0}" = 1 ] && [ "${BL_MANGOAPP:-1}" = 1 ] \
|
||||
&& [ "${BL_STEAM_UI:-}" != desktop ] && command -v mangoapp >/dev/null 2>&1; then
|
||||
MANGOHUD_CONFIGFILE=$(mktemp /tmp/mangohud.XXXXXXXX)
|
||||
echo no_display > "$MANGOHUD_CONFIGFILE"
|
||||
@@ -639,6 +654,15 @@ BUSCONF
|
||||
# desktop's launchers ask for; gamescope shows one window at a time and the game takes over.
|
||||
_bl_ui=(-gamepadui)
|
||||
[ "${BL_STEAM_UI:-}" = desktop ] && _bl_ui=()
|
||||
# Software compatibility mode: CEF and Steam use CPU frames through Xwayland,
|
||||
# inside either the desktop or the software Gamescope session.
|
||||
_bl_cef=(-cef-force-gpu -cef-use-gl=angle -cef-use-angle=vulkan)
|
||||
if [ "${BL_STEAM_SOFTWARE:-0}" = 1 ]; then
|
||||
_bl_cef=(-cef-disable-gpu -cef-disable-gpu-compositing)
|
||||
export LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=llvmpipe
|
||||
export MESA_LOADER_DRIVER_OVERRIDE=swrast SDL_RENDER_DRIVER=software SDL_VIDEODRIVER=x11
|
||||
echo "== steam: software rendering requested"
|
||||
fi
|
||||
# Deck mode (BL_STEAMDECK=1, the Steam page's Client settings): -steamdeck is the flag that puts
|
||||
# the Quick Access Menu and the Deck settings pages on screen; the QAM's performance overlay
|
||||
# controls stay greyed out without -steamos3, as SteamOS and Armada launch it. -steamos3 makes
|
||||
@@ -698,7 +722,7 @@ BUSCONF
|
||||
done
|
||||
) &
|
||||
fi
|
||||
echo "== steam args: ${_bl_ui[*]} -clientbeta $steam_channel -no-cef-sandbox -cef-force-gpu -cef-ozone-platform=x11 -cef-use-gl=angle -cef-use-angle=vulkan $*"
|
||||
echo "== steam args: ${_bl_ui[*]} -clientbeta $steam_channel -no-cef-sandbox -cef-ozone-platform=x11 ${_bl_cef[*]} $*"
|
||||
# An update that cannot install asks for a restart (rc=42) every time; the count is capped so a
|
||||
# session can never again loop in silence, which reads as a menu opening and closing by itself.
|
||||
steam_updates=0
|
||||
@@ -745,8 +769,7 @@ BUSCONF
|
||||
fi
|
||||
step "starting the Steam client${BL_STEAM_UI:+ ($BL_STEAM_UI UI)}"
|
||||
"$steam_root/steamrtarm64/steam" "${_bl_ui[@]}" -clientbeta "$steam_channel" \
|
||||
-no-cef-sandbox -cef-force-gpu -cef-ozone-platform=x11 \
|
||||
-cef-use-gl=angle -cef-use-angle=vulkan "$@"
|
||||
-no-cef-sandbox -cef-ozone-platform=x11 "${_bl_cef[@]}" "$@"
|
||||
rc=$?
|
||||
echo "== steam exited rc=$rc"
|
||||
collect_steam_logs
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
# On a software desktop (pixman: the GPU renderers failed on this device) there is no dma-buf, so a
|
||||
# game - or the client's own Vulkan window - would die at its first frame. There the request goes
|
||||
# to the app, which ends the desktop and starts a Steam session under gamescope in its place.
|
||||
# BL_STEAM_SOFTWARE=1 opts into a CPU-rendered client on that desktop for compatibility testing.
|
||||
set -u
|
||||
ui=${1:-desktop}
|
||||
target=${2:-}
|
||||
@@ -28,7 +29,8 @@ esac
|
||||
steam_root=${XDG_DATA_HOME:-${HOME:-/root}/.local/share}/Steam
|
||||
client=$steam_root/steamrtarm64/steam
|
||||
|
||||
if [ "${BL_DESKTOP:-}" = 1 ] && [ -n "${WLR_RENDERER:-}" ] && [ "$WLR_RENDERER" != pixman ]; then
|
||||
if [ "${BL_DESKTOP:-}" = 1 ] && [ -n "${WLR_RENDERER:-}" ] \
|
||||
&& { [ "$WLR_RENDERER" != pixman ] || [ "${BL_STEAM_SOFTWARE:-0}" = 1 ]; }; then
|
||||
log=${BL_DEBUG_DIR:-$HOME/.cache/droiddeck}/steam-desktop.log
|
||||
mkdir -p "$(dirname "$log")" 2>/dev/null
|
||||
if pgrep -f 'steamrtarm64/steam( |$)' >/dev/null 2>&1 && [ -x "$client" ]; then
|
||||
|
||||
@@ -229,6 +229,50 @@ def release_entry(
|
||||
}
|
||||
|
||||
|
||||
def preview_history_entry(release: dict, preview: dict, variants: list[tuple[str, str]]):
|
||||
"""Return compact history metadata for one complete, signed main build."""
|
||||
tag = release.get("tag_name") or ""
|
||||
tag_match = MAIN_TAG.fullmatch(tag)
|
||||
commit = (preview.get("commit") or "").lower()
|
||||
expected_packages = {package for package, _ in variants}
|
||||
apks = preview.get("apks") or {}
|
||||
if (
|
||||
release.get("draft")
|
||||
or not release.get("prerelease")
|
||||
or not tag_match
|
||||
or not re.fullmatch(r"[0-9a-f]{40}", commit)
|
||||
or not commit.startswith(tag_match.group(1))
|
||||
or set(apks) != expected_packages
|
||||
or any(
|
||||
not SHA256.fullmatch((apk.get("sha256") or "").lower())
|
||||
or not SHA256.fullmatch((apk.get("signerSha256") or "").lower())
|
||||
for apk in apks.values()
|
||||
)
|
||||
):
|
||||
return None
|
||||
return {
|
||||
"commit": commit,
|
||||
"title": preview["title"],
|
||||
"summary": preview["summary"][:400],
|
||||
"publishedAt": preview["publishedAt"],
|
||||
}
|
||||
|
||||
|
||||
def recent_previews(entries: list[dict], limit: int = 10) -> list[dict]:
|
||||
"""Keep the newest distinct Preview commits, newest first."""
|
||||
result = []
|
||||
seen = set()
|
||||
for entry in sorted(entries, key=lambda item: item["publishedAt"], reverse=True):
|
||||
commit = entry["commit"].lower()
|
||||
if commit in seen:
|
||||
continue
|
||||
seen.add(commit)
|
||||
result.append({**entry, "commit": commit})
|
||||
if len(result) >= limit:
|
||||
break
|
||||
return result
|
||||
|
||||
|
||||
def release_body_value(body: str, key: str):
|
||||
match = re.search(rf"(?mi)^\s*{re.escape(key)}:\s*`?([^\s`]+)", body or "")
|
||||
return match.group(1) if match else None
|
||||
@@ -276,6 +320,7 @@ def build_catalog(source: GitHub, ci: GitHub, source_repo: str, ci_repo: str) ->
|
||||
|
||||
releases = ci.get(f"/repos/{ci_repo}/releases?per_page=100")
|
||||
previews = []
|
||||
preview_history = []
|
||||
tests = []
|
||||
for release in releases:
|
||||
if release.get("draft"):
|
||||
@@ -291,9 +336,11 @@ def build_catalog(source: GitHub, ci: GitHub, source_repo: str, ci_repo: str) ->
|
||||
except ApiError:
|
||||
continue
|
||||
title, summary = ci_description(release)
|
||||
previews.append(
|
||||
release_entry(release, commit, 0, None, code, variants, signer, title, summary)
|
||||
)
|
||||
preview = release_entry(release, commit, 0, None, code, variants, signer, title, summary)
|
||||
previews.append(preview)
|
||||
history_entry = preview_history_entry(release, preview, variants)
|
||||
if history_entry:
|
||||
preview_history.append(history_entry)
|
||||
continue
|
||||
|
||||
pr_match = PR_TAG.fullmatch(tag)
|
||||
@@ -356,6 +403,7 @@ def build_catalog(source: GitHub, ci: GitHub, source_repo: str, ci_repo: str) ->
|
||||
"generatedAt": int(time.time() * 1000),
|
||||
"stable": stable,
|
||||
"preview": previews[0] if previews else None,
|
||||
"recentPreviews": recent_previews(preview_history),
|
||||
"tests": tests,
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,15 @@ class SleepHandshakeTest(unittest.TestCase):
|
||||
self.wait_for(lambda: self.signals == [True, False])
|
||||
self.assertFalse(self.preparing())
|
||||
|
||||
def test_suspend_after_service_was_frozen(self):
|
||||
os.kill(self.process.pid, signal.SIGSTOP)
|
||||
time.sleep(0.1)
|
||||
os.kill(self.process.pid, signal.SIGCONT)
|
||||
token = self.suspend()
|
||||
self.state(token, "awake")
|
||||
self.wait_for(lambda: self.signals == [True, False])
|
||||
self.assertFalse(self.preparing())
|
||||
|
||||
def test_failed_pause_recovers_and_duplicate_is_rejected(self):
|
||||
token = self.suspend()
|
||||
with self.assertRaises(GLib.Error):
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
SESSION = Path(__file__).resolve().parents[1] / 'linuxfs/overlay/usr/local/bin/bannerlator-session'
|
||||
GRAPHICS_ENV = ('VK_DRIVER_FILES', 'VK_ICD_FILENAMES', 'LIBGL_ALWAYS_SOFTWARE',
|
||||
'GALLIUM_DRIVER', 'MESA_LOADER_DRIVER_OVERRIDE', 'SDL_VIDEODRIVER')
|
||||
|
||||
|
||||
class SoftwareGraphicsTest(unittest.TestCase):
|
||||
def launch(self, **settings):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
home = Path(tmp)
|
||||
binary = home / 'bin'
|
||||
binary.mkdir()
|
||||
capture = home / 'capture.json'
|
||||
gamescope = binary / 'gamescope'
|
||||
gamescope.write_text(f'#!{sys.executable}\nimport json, os, sys\n'
|
||||
'from pathlib import Path\n'
|
||||
'Path(os.environ["TEST_CAPTURE"]).write_text(json.dumps({"argv": sys.argv[1:], "env": dict(os.environ)}))\n')
|
||||
gamescope.chmod(0o755)
|
||||
for name in ('wayland-info', 'mangoapp'):
|
||||
probe = binary / name
|
||||
probe.write_text('#!/bin/sh\nexit 0\n')
|
||||
probe.chmod(0o755)
|
||||
library = home / 'custom.so'
|
||||
library.touch()
|
||||
manifest = home / 'icd.json'
|
||||
manifest.write_text(json.dumps({'ICD': {'library_path': str(library)}}))
|
||||
env = {'PATH': str(binary) + os.pathsep + os.defpath, 'HOME': str(home),
|
||||
'TEST_CAPTURE': str(capture), 'BL_WIDTH': '960', 'BL_HEIGHT': '544',
|
||||
'BL_STEAMDECK': '1', 'BL_REFRESH': '120', 'BL_HDR': '1'}
|
||||
env.update(settings)
|
||||
if env.pop('TEST_CUSTOM_DRIVER', ''):
|
||||
env['BL_VK_DRIVER'] = str(manifest)
|
||||
subprocess.run([shutil.which('bash'), str(SESSION), 'steam', 'argument with spaces'],
|
||||
env=env, check=True, capture_output=True, text=True)
|
||||
result = json.loads(capture.read_text())
|
||||
config = result['env'].get('MANGOHUD_CONFIGFILE')
|
||||
if config:
|
||||
Path(config).unlink()
|
||||
return result, str(manifest)
|
||||
|
||||
def test_default_keeps_accelerated_backend_overlay_and_session_options(self):
|
||||
result, _ = self.launch(VK_DRIVER_FILES='/selected/turnip.json', GALLIUM_DRIVER='zink')
|
||||
args, env = result['argv'], result['env']
|
||||
self.assertEqual(args[:2], ['--backend', 'wayland'])
|
||||
self.assertEqual(env['VK_DRIVER_FILES'], '/selected/turnip.json')
|
||||
self.assertEqual(env['GALLIUM_DRIVER'], 'zink')
|
||||
self.assertNotIn('LIBGL_ALWAYS_SOFTWARE', env)
|
||||
self.assertNotIn('MESA_LOADER_DRIVER_OVERRIDE', env)
|
||||
self.assertNotIn('SDL_VIDEODRIVER', env)
|
||||
self.assertIn('--mangoapp', args)
|
||||
self.assertIn('--hdr-enabled', args)
|
||||
self.assertEqual(args[args.index('-r') + 1], '120')
|
||||
self.assertEqual(args[-1], 'argument with spaces')
|
||||
|
||||
def test_only_explicit_one_selects_software(self):
|
||||
for value in ('', '0', 'true', 'yes'):
|
||||
with self.subTest(value=value):
|
||||
result, _ = self.launch(BL_STEAM_SOFTWARE=value)
|
||||
self.assertEqual(result['argv'][:2], ['--backend', 'wayland'])
|
||||
self.assertNotIn('LIBGL_ALWAYS_SOFTWARE', result['env'])
|
||||
self.assertIn('--mangoapp', result['argv'])
|
||||
result, _ = self.launch(BL_STEAM_SOFTWARE='1')
|
||||
env = result['env']
|
||||
self.assertEqual(result['argv'][:2], ['--backend', 'sdl'])
|
||||
self.assertNotIn('--mangoapp', result['argv'])
|
||||
self.assertEqual(env['VK_DRIVER_FILES'], '/usr/share/vulkan/icd.d/lvp_icd.json')
|
||||
self.assertEqual(env['VK_ICD_FILENAMES'], env['VK_DRIVER_FILES'])
|
||||
self.assertEqual(env['LIBGL_ALWAYS_SOFTWARE'], '1')
|
||||
self.assertEqual(env['GALLIUM_DRIVER'], 'llvmpipe')
|
||||
self.assertEqual(env['SDL_VIDEODRIVER'], 'wayland')
|
||||
|
||||
def test_custom_driver_is_preserved_except_when_software_is_requested(self):
|
||||
for software in ('0', '1'):
|
||||
result, manifest = self.launch(TEST_CUSTOM_DRIVER='1', BL_STEAM_SOFTWARE=software)
|
||||
expected = manifest if software == '0' else '/usr/share/vulkan/icd.d/lvp_icd.json'
|
||||
self.assertEqual(result['env']['VK_DRIVER_FILES'], expected)
|
||||
self.assertEqual(result['env']['VK_ICD_FILENAMES'], expected)
|
||||
|
||||
def test_invalid_custom_driver_does_not_replace_inherited_selection(self):
|
||||
result, _ = self.launch(BL_VK_DRIVER='/missing/manifest.json', VK_DRIVER_FILES='/selected/turnip.json')
|
||||
self.assertEqual(result['env']['VK_DRIVER_FILES'], '/selected/turnip.json')
|
||||
self.assertEqual(result['argv'][:2], ['--backend', 'wayland'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -6,6 +6,8 @@ from tools.release.update_catalog import (
|
||||
parse_gradle,
|
||||
parse_variants,
|
||||
published_millis,
|
||||
preview_history_entry,
|
||||
recent_previews,
|
||||
release_body_value,
|
||||
stable_app_release,
|
||||
)
|
||||
@@ -87,6 +89,53 @@ pubg com.tencent.ig -pubg
|
||||
published_millis(release, prefer_updated=True),
|
||||
)
|
||||
|
||||
def test_preview_history_keeps_only_complete_signed_main_releases(self):
|
||||
variants = [("com.droiddeck.launcher", ""), ("com.example.variant", "-variant")]
|
||||
commit = "a" * 40
|
||||
entry = {
|
||||
"commit": commit,
|
||||
"title": "Fix Steam resume",
|
||||
"summary": "Steam stays open after resuming.",
|
||||
"publishedAt": 123,
|
||||
"apks": {
|
||||
package: {"sha256": "a" * 64, "signerSha256": "b" * 64}
|
||||
for package, _ in variants
|
||||
},
|
||||
}
|
||||
release = {"tag_name": "main-aaaaaaa", "draft": False, "prerelease": True}
|
||||
self.assertEqual(
|
||||
{
|
||||
"commit": commit,
|
||||
"title": "Fix Steam resume",
|
||||
"summary": "Steam stays open after resuming.",
|
||||
"publishedAt": 123,
|
||||
},
|
||||
preview_history_entry(release, entry, variants),
|
||||
)
|
||||
|
||||
for invalid_release in (
|
||||
{**release, "draft": True},
|
||||
{**release, "prerelease": False},
|
||||
{**release, "tag_name": "pr-42"},
|
||||
):
|
||||
self.assertIsNone(preview_history_entry(invalid_release, entry, variants))
|
||||
self.assertIsNone(preview_history_entry(release, {**entry, "commit": "a" * 12}, variants))
|
||||
self.assertIsNone(preview_history_entry(release, {**entry, "apks": {"com.droiddeck.launcher": {}}}, variants))
|
||||
unsigned = {**entry, "apks": {package: {"sha256": "a" * 64} for package, _ in variants}}
|
||||
self.assertIsNone(preview_history_entry(release, unsigned, variants))
|
||||
|
||||
def test_preview_history_is_newest_first_deduplicated_and_limited(self):
|
||||
entries = [
|
||||
{"commit": f"{i:040x}", "title": str(i), "summary": "", "publishedAt": i}
|
||||
for i in range(12)
|
||||
]
|
||||
entries.append({**entries[-1], "title": "duplicate", "publishedAt": 99})
|
||||
recent = recent_previews(entries)
|
||||
self.assertEqual(10, len(recent))
|
||||
self.assertEqual("duplicate", recent[0]["title"])
|
||||
self.assertEqual("000000000000000000000000000000000000000a", recent[1]["commit"])
|
||||
self.assertEqual(1, len([item for item in recent if item["commit"].endswith("000b")]))
|
||||
|
||||
def test_stable_is_the_newest_app_release_not_github_latest(self):
|
||||
def release(tag, at, *assets, **flags):
|
||||
return {"tag_name": tag, "published_at": at, "assets": [{"name": a} for a in assets], **flags}
|
||||
|
||||
Reference in new issue
Block a user