mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-02 11:05:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a8efce905 | ||
|
|
c10369ed99 | ||
|
|
39d8149a16 | ||
|
|
9ddb52c5fc | ||
|
|
b0904cc65b | ||
|
|
e309280b65 | ||
|
|
4283fd810e | ||
|
|
296b4586a4 | ||
|
|
60b22a826a | ||
|
|
3512eb942d | ||
|
|
2ae51a1e6a |
No files matched your search
@@ -33,9 +33,6 @@
|
||||
<uses-permission android:name="android.permission.REORDER_TASKS" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
|
||||
<!-- Granted only with adb shell pm grant; lets the agent turn Wireless debugging on where Settings hides it (Quest). -->
|
||||
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
|
||||
@@ -4130,20 +4130,13 @@ EXPORT ssize_t read(int fd, void *buf, size_t count) {
|
||||
return read_input(fd, buf, count);
|
||||
}
|
||||
|
||||
// glibc's fortify failure; bionic (DroidDeck-Bionic preloads this library into its Wine processes) has no
|
||||
// __chk_fail, and a library naming it there cannot be loaded, which stops every Wine program from starting.
|
||||
#if defined(__BIONIC__)
|
||||
[[noreturn]] static void fakeinput_chk_fail(void) { abort(); }
|
||||
#else
|
||||
extern "C" [[noreturn]] void __chk_fail(void);
|
||||
[[noreturn]] static void fakeinput_chk_fail(void) { __chk_fail(); }
|
||||
#endif
|
||||
|
||||
/* Programs built with _FORTIFY_SOURCE (Flatpak runtimes among them) call these instead of read, poll
|
||||
* and ppoll, and glibc's versions go straight to the kernel. */
|
||||
EXPORT ssize_t __read_chk(int fd, void *buf, size_t count, size_t buflen) {
|
||||
static auto next_read_chk = reinterpret_cast<ssize_t (*)(int, void *, size_t, size_t)>(dlsym(RTLD_NEXT, "__read_chk"));
|
||||
if (count > buflen) fakeinput_chk_fail();
|
||||
if (count > buflen) __chk_fail();
|
||||
if (next_read_chk && !is_fake_input_fd(fd)) return next_read_chk(fd, buf, count, buflen);
|
||||
return read_input(fd, buf, count);
|
||||
}
|
||||
@@ -4397,13 +4390,13 @@ EXPORT int ppoll(struct pollfd *fds, nfds_t nfds,
|
||||
}
|
||||
|
||||
EXPORT int __poll_chk(struct pollfd *fds, nfds_t nfds, int timeout, size_t fdslen) {
|
||||
if (fdslen / sizeof(*fds) < nfds) fakeinput_chk_fail();
|
||||
if (fdslen / sizeof(*fds) < nfds) __chk_fail();
|
||||
return poll(fds, nfds, timeout);
|
||||
}
|
||||
|
||||
EXPORT int __ppoll_chk(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
|
||||
const sigset_t *sigmask, size_t fdslen) {
|
||||
if (fdslen / sizeof(*fds) < nfds) fakeinput_chk_fail();
|
||||
if (fdslen / sizeof(*fds) < nfds) __chk_fail();
|
||||
return ppoll(fds, nfds, timeout, sigmask);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,31 +27,7 @@ VkImageMemoryBarrier bar(VkImage img, VkImageLayout from, VkImageLayout to,
|
||||
}
|
||||
|
||||
Engine::Engine() = default;
|
||||
Engine::~Engine() { (void)destroy(); }
|
||||
|
||||
bool Engine::destroy() {
|
||||
if (!fg_.destroy()) {
|
||||
DDFG_LOGE("native: retaining the input ring because GPU completion is unknown");
|
||||
return false;
|
||||
}
|
||||
if (!destroyRing(true)) {
|
||||
DDFG_LOGE("native: could not release the input ring during teardown");
|
||||
return false;
|
||||
}
|
||||
dev_ = VK_NULL_HANDLE;
|
||||
unavailable_ = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Engine::abandon() {
|
||||
fg_.abandon();
|
||||
ring_[0] = Slot{};
|
||||
ring_[1] = Slot{};
|
||||
dev_ = VK_NULL_HANDLE;
|
||||
queue_ = VK_NULL_HANDLE;
|
||||
phys_ = VK_NULL_HANDLE;
|
||||
unavailable_ = true;
|
||||
}
|
||||
Engine::~Engine() { destroyRing(); fg_.destroy(); }
|
||||
|
||||
bool Engine::init(const VkTable& table, VkPhysicalDevice phys, VkDevice dev,
|
||||
uint32_t queueFamily, VkQueue queue) {
|
||||
@@ -83,29 +59,15 @@ bool Engine::prepare(uint32_t w, uint32_t h, VkFormat fmt) {
|
||||
if (unavailable_ || w == 0 || h == 0 || fmt == VK_FORMAT_UNDEFINED) return false;
|
||||
if (builtW_ == w && builtH_ == h && builtFmt_ == fmt && fg_.valid()) return true;
|
||||
|
||||
const bool formatChanged = fmt != builtFmt_;
|
||||
if (!fg_.onResize(VkExtent2D{w, h}, fmt, formatChanged)) {
|
||||
|
||||
if (!fg_.onResize(VkExtent2D{w, h}, fmt, false)) {
|
||||
DDFG_LOGE("native: onResize %ux%u failed; frame generation unavailable", w, h);
|
||||
unavailable_ = true;
|
||||
return false;
|
||||
}
|
||||
bool deviceLost = false;
|
||||
if (!destroyRing(false, &deviceLost)) {
|
||||
DDFG_LOGE("native: could not safely release the previous input ring");
|
||||
unavailable_ = true;
|
||||
return false;
|
||||
}
|
||||
if (deviceLost) {
|
||||
DDFG_LOGE("native: device lost while releasing the input ring");
|
||||
unavailable_ = true;
|
||||
return false;
|
||||
}
|
||||
destroyRing();
|
||||
for (Slot& s : ring_) {
|
||||
if (!makeSlot(s, w, h, fmt)) {
|
||||
destroyRing(true);
|
||||
unavailable_ = true;
|
||||
return false;
|
||||
}
|
||||
if (!makeSlot(s, w, h, fmt)) { destroyRing(); unavailable_ = true; return false; }
|
||||
}
|
||||
builtW_ = w; builtH_ = h; builtFmt_ = fmt;
|
||||
history_ = 0; curr_ = 0; frames_ = 0;
|
||||
@@ -216,37 +178,11 @@ void Engine::destroySlot(Slot& s) {
|
||||
s = Slot{};
|
||||
}
|
||||
|
||||
bool Engine::destroyRing(bool deviceIdleConfirmed, bool* deviceLost) {
|
||||
if (deviceLost) *deviceLost = false;
|
||||
const bool hasResources = ring_[0].img || ring_[0].mem || ring_[0].view ||
|
||||
ring_[1].img || ring_[1].mem || ring_[1].view;
|
||||
if (!hasResources) {
|
||||
history_ = 0;
|
||||
return true;
|
||||
}
|
||||
if (dev_ == VK_NULL_HANDLE) {
|
||||
DDFG_LOGE("native: cannot release the input ring without a valid device");
|
||||
return false;
|
||||
}
|
||||
if (!deviceIdleConfirmed) {
|
||||
if (!dd_.DeviceWaitIdle) {
|
||||
DDFG_LOGE("native: cannot release the input ring without vkDeviceWaitIdle");
|
||||
return false;
|
||||
}
|
||||
const VkResult result = dd_.DeviceWaitIdle(dev_);
|
||||
if (result == VK_ERROR_DEVICE_LOST) {
|
||||
if (deviceLost) *deviceLost = true;
|
||||
unavailable_ = true;
|
||||
} else if (result != VK_SUCCESS) {
|
||||
DDFG_LOGE("native: DeviceWaitIdle failed (%d); retaining the input ring", (int)result);
|
||||
unavailable_ = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
destroySlot(ring_[0]);
|
||||
destroySlot(ring_[1]);
|
||||
void Engine::destroyRing() {
|
||||
if (dev_ == VK_NULL_HANDLE || !dd_.DeviceWaitIdle) return;
|
||||
if (ring_[0].img || ring_[1].img) dd_.DeviceWaitIdle(dev_);
|
||||
destroySlot(ring_[0]); destroySlot(ring_[1]);
|
||||
history_ = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,15 +36,13 @@ public:
|
||||
uint32_t width, uint32_t height);
|
||||
|
||||
void reset();
|
||||
bool destroy();
|
||||
void abandon();
|
||||
|
||||
private:
|
||||
struct Slot { VkImage img = VK_NULL_HANDLE; VkDeviceMemory mem = VK_NULL_HANDLE;
|
||||
VkImageView view = VK_NULL_HANDLE; bool valid = false; };
|
||||
bool makeSlot(Slot& s, uint32_t w, uint32_t h, VkFormat fmt);
|
||||
void destroySlot(Slot& s);
|
||||
bool destroyRing(bool deviceIdleConfirmed = false, bool* deviceLost = nullptr);
|
||||
void destroyRing();
|
||||
uint32_t memType(uint32_t bits, VkMemoryPropertyFlags props) const;
|
||||
|
||||
DeviceDispatch dd_{};
|
||||
|
||||
@@ -7,31 +7,6 @@
|
||||
|
||||
namespace ddfg {
|
||||
|
||||
struct ScratchState {
|
||||
VkDevice ownerDevice = VK_NULL_HANDLE;
|
||||
VkBuffer synthUbo[ddfg::FrameGen::kSynthSlots]{};
|
||||
VkDeviceMemory synthUboMem[ddfg::FrameGen::kSynthSlots]{};
|
||||
void* synthUboPtr[ddfg::FrameGen::kSynthSlots]{};
|
||||
std::vector<VkBuffer> flowUbo; std::vector<VkDeviceMemory> flowUboMem; std::vector<void*> flowUboPtr;
|
||||
VkBuffer expandUbo = VK_NULL_HANDLE; VkDeviceMemory expandUboMem = VK_NULL_HANDLE; void* expandUboPtr = nullptr;
|
||||
VkBuffer flowRegUbo = VK_NULL_HANDLE; VkDeviceMemory flowRegUboMem = VK_NULL_HANDLE; void* flowRegUboPtr = nullptr;
|
||||
VkBuffer gmUbo[ddfg::FrameGen::kGmSlots]{};
|
||||
VkDeviceMemory gmUboMem[ddfg::FrameGen::kGmSlots]{};
|
||||
void* gmUboPtr[ddfg::FrameGen::kGmSlots]{};
|
||||
VkDescriptorSet sLumaCurr = VK_NULL_HANDLE, sLumaPrev = VK_NULL_HANDLE;
|
||||
std::vector<VkDescriptorSet> sDownA, sDownB, sFlow;
|
||||
VkDescriptorSet sExpand[ddfg::FrameGen::kGmSlots]{};
|
||||
VkDescriptorSet sFlowReg0 = VK_NULL_HANDLE, sFlowRegAB = VK_NULL_HANDLE, sFlowRegBA = VK_NULL_HANDLE;
|
||||
VkDescriptorSet sSynth[ddfg::FrameGen::kSynthSlots]{};
|
||||
VkDescriptorSet sGmReduce[ddfg::FrameGen::kGmSlots]{};
|
||||
std::vector<VkDescriptorSet> sGmPrewarp[ddfg::FrameGen::kGmSlots];
|
||||
VkExtent2D builtFor{0,0};
|
||||
uint64_t builtGeneration = 0;
|
||||
bool built = false;
|
||||
bool flowInited = false;
|
||||
bool flowReady = false;
|
||||
};
|
||||
|
||||
#define VKOK(x) do { if ((x) != VK_SUCCESS) { DDFG_LOGE("vk fail: %s", #x); return false; } } while (0)
|
||||
|
||||
uint32_t FrameGen::findMemType(uint32_t bits, VkMemoryPropertyFlags props) const {
|
||||
@@ -133,10 +108,6 @@ static bool buildSetLayout(const DeviceDispatch* dd, VkDevice dev,
|
||||
|
||||
bool FrameGen::init(const DeviceDispatch* dd, const InstanceDispatch* id,
|
||||
VkPhysicalDevice phys, VkDevice dev, uint32_t queueFamily, VkQueue queue) {
|
||||
if (device_ || completionUnknown_ || deviceLost_) {
|
||||
DDFG_LOGE("framegen: refusing to initialize an instance that still owns device resources");
|
||||
return false;
|
||||
}
|
||||
dd_ = dd; id_ = id; phys_ = phys; device_ = dev; queueFamily_ = queueFamily; queue_ = queue;
|
||||
id_->GetPhysicalDeviceMemoryProperties(phys_, &memProps_);
|
||||
|
||||
@@ -195,19 +166,16 @@ static VkExtent2D levelExtent(VkExtent2D e, int l) {
|
||||
}
|
||||
|
||||
bool FrameGen::onResize(VkExtent2D extent, VkFormat , bool force) {
|
||||
if (completionUnknown_ || deviceLost_) return false;
|
||||
if (!device_) {
|
||||
DDFG_LOGE("framegen: cannot resize before device initialization");
|
||||
return false;
|
||||
}
|
||||
if (!force && ready_ && extent.width == extent_.width && extent.height == extent_.height) return true;
|
||||
if (ready_ && !waitIdle("resize")) return false;
|
||||
if (scratch_ && scratch_->ownerDevice != VK_NULL_HANDLE && !destroyScratchResources()) {
|
||||
DDFG_LOGE("framegen resize: scratch cleanup failed; retaining the previous image set");
|
||||
return false;
|
||||
}
|
||||
|
||||
ready_ = false;
|
||||
|
||||
if (!force && ready_ && extent.width == extent_.width && extent.height == extent_.height) return true;
|
||||
if (ready_) {
|
||||
const VkResult idleResult = dd_->DeviceWaitIdle(device_);
|
||||
if (idleResult != VK_SUCCESS) {
|
||||
DDFG_LOGE("framegen resize: DeviceWaitIdle failed (%d); keeping existing images", (int)idleResult);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
++imageGeneration_;
|
||||
for (auto& i : pyrA_) destroyImage(i); pyrA_.clear();
|
||||
for (auto& i : pyrB_) destroyImage(i); pyrB_.clear();
|
||||
@@ -215,17 +183,7 @@ bool FrameGen::onResize(VkExtent2D extent, VkFormat , bool force) {
|
||||
for (auto& i : flowLvl_) destroyImage(i); flowLvl_.clear();
|
||||
destroyImage(flowExpA_); destroyImage(flowExpB_);
|
||||
destroyImage(flowRegA_); destroyImage(flowRegB_);
|
||||
extent_ = extent;
|
||||
|
||||
for (int i = 0; i < 6; ++i) gmRun_[i] = 0.0;
|
||||
for (int s = 0; s < kGmSlots; ++s) {
|
||||
gmSlotValid_[s] = false;
|
||||
for (int i = 0; i < 6; ++i) gmLinAt_[s][i] = 0.0;
|
||||
}
|
||||
gmHaveEst_ = false;
|
||||
gmEngaged_ = false;
|
||||
gmStableCount_ = 0;
|
||||
gmLastTransPx_ = 0.0f;
|
||||
extent_ = extent; ready_ = false;
|
||||
|
||||
const VkImageUsageFlags lumaUsage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT;
|
||||
const VkImageUsageFlags flowUsage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||
@@ -276,37 +234,21 @@ void FrameGen::initializeImage(VkCommandBuffer cmd, VkImage img, VkImageLayout t
|
||||
}
|
||||
|
||||
|
||||
bool FrameGen::destroy() {
|
||||
if (!device_) return true;
|
||||
if (!deviceLost_) {
|
||||
// A previous wait failure leaves completion unknown, but a later
|
||||
// teardown attempt may safely retry the wait before releasing resources.
|
||||
if (!dd_ || !dd_->DeviceWaitIdle) {
|
||||
ready_ = false;
|
||||
completionUnknown_ = true;
|
||||
DDFG_LOGE("framegen destroy: vkDeviceWaitIdle is unavailable; preserving GPU resources");
|
||||
return false;
|
||||
}
|
||||
const VkResult idleResult = dd_->DeviceWaitIdle(device_);
|
||||
if (idleResult == VK_SUCCESS) completionUnknown_ = false;
|
||||
if (idleResult != VK_SUCCESS) {
|
||||
ready_ = false;
|
||||
if (idleResult == VK_ERROR_DEVICE_LOST) {
|
||||
deviceLost_ = true;
|
||||
DDFG_LOGE("framegen destroy: device lost; releasing owned resources without waiting");
|
||||
} else {
|
||||
completionUnknown_ = true;
|
||||
DDFG_LOGE("framegen destroy: DeviceWaitIdle failed (%d); preserving resources because GPU completion is unknown",
|
||||
(int)idleResult);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
void FrameGen::destroy() {
|
||||
if (!device_) return;
|
||||
const VkResult idleResult = dd_->DeviceWaitIdle(device_);
|
||||
if (idleResult != VK_SUCCESS && idleResult != VK_ERROR_DEVICE_LOST) {
|
||||
DDFG_LOGE("framegen destroy: DeviceWaitIdle failed (%d); preserving resources for safe retry", (int)idleResult);
|
||||
return;
|
||||
}
|
||||
if (idleResult == VK_ERROR_DEVICE_LOST) {
|
||||
// A lost device cannot become idle again. Still explicitly destroy its
|
||||
// child objects; skip descriptor-pool reset and release scratch ownership.
|
||||
DDFG_LOGE("framegen destroy: device lost; releasing owned resources without waiting");
|
||||
destroyScratchResources(false);
|
||||
} else {
|
||||
destroyScratchResources();
|
||||
}
|
||||
|
||||
ready_ = false;
|
||||
if (descPool_) dd_->DestroyDescriptorPool(device_, descPool_, nullptr);
|
||||
descPool_ = VK_NULL_HANDLE;
|
||||
releaseScratch();
|
||||
for (auto& i : pyrA_) destroyImage(i); pyrA_.clear();
|
||||
for (auto& i : pyrB_) destroyImage(i); pyrB_.clear();
|
||||
for (auto& i : pyrAs_) destroyImage(i); pyrAs_.clear();
|
||||
@@ -318,45 +260,15 @@ bool FrameGen::destroy() {
|
||||
destroyPipe(pGmReduce_); destroyPipe(pGmPrewarp_);
|
||||
destroyPipe(pFlowReg_);
|
||||
for (int s = 0; s < kGmSlots; ++s) {
|
||||
if (gmSsboPtr_[s] && gmSsboMem_[s]) dd_->UnmapMemory(device_, gmSsboMem_[s]);
|
||||
if (gmSsboMem_[s]) dd_->UnmapMemory(device_, gmSsboMem_[s]);
|
||||
if (gmSsbo_[s]) dd_->DestroyBuffer(device_, gmSsbo_[s], nullptr);
|
||||
if (gmSsboMem_[s]) dd_->FreeMemory(device_, gmSsboMem_[s], nullptr);
|
||||
gmSsbo_[s] = VK_NULL_HANDLE; gmSsboMem_[s] = VK_NULL_HANDLE; gmSsboPtr_[s] = nullptr;
|
||||
}
|
||||
gmBuffersReady_ = false;
|
||||
if (descPool_) dd_->DestroyDescriptorPool(device_, descPool_, nullptr);
|
||||
if (linear_) dd_->DestroySampler(device_, linear_, nullptr);
|
||||
linear_ = VK_NULL_HANDLE;
|
||||
device_ = VK_NULL_HANDLE;
|
||||
ready_ = false;
|
||||
deviceLost_ = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void FrameGen::abandon() {
|
||||
device_ = VK_NULL_HANDLE;
|
||||
dd_ = nullptr;
|
||||
id_ = nullptr;
|
||||
phys_ = VK_NULL_HANDLE;
|
||||
queue_ = VK_NULL_HANDLE;
|
||||
linear_ = VK_NULL_HANDLE;
|
||||
descPool_ = VK_NULL_HANDLE;
|
||||
scratch_.reset();
|
||||
pyrA_.clear(); pyrB_.clear(); pyrAs_.clear(); flowLvl_.clear();
|
||||
flowExpA_ = Img{}; flowExpB_ = Img{};
|
||||
flowRegA_ = Img{}; flowRegB_ = Img{};
|
||||
pLuma_ = Pipe{}; pDown_ = Pipe{}; pFlow_ = Pipe{}; pFlowM4_ = Pipe{};
|
||||
pExpand_ = Pipe{}; pExpandM4_ = Pipe{}; pSynth_ = Pipe{};
|
||||
pGmReduce_ = Pipe{}; pGmPrewarp_ = Pipe{}; pFlowReg_ = Pipe{};
|
||||
for (int s = 0; s < kGmSlots; ++s) {
|
||||
gmSsbo_[s] = VK_NULL_HANDLE;
|
||||
gmSsboMem_[s] = VK_NULL_HANDLE;
|
||||
gmSsboPtr_[s] = nullptr;
|
||||
gmSlotValid_[s] = false;
|
||||
}
|
||||
gmBuffersReady_ = false;
|
||||
ready_ = false;
|
||||
completionUnknown_ = false;
|
||||
deviceLost_ = false;
|
||||
descPool_ = VK_NULL_HANDLE; linear_ = VK_NULL_HANDLE; device_ = VK_NULL_HANDLE; ready_ = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +1,12 @@
|
||||
#pragma once
|
||||
#include "vk_dispatch.hpp"
|
||||
#include "config.hpp"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace ddfg {
|
||||
|
||||
struct ScratchState;
|
||||
|
||||
class FrameGen {
|
||||
public:
|
||||
FrameGen();
|
||||
~FrameGen();
|
||||
FrameGen(const FrameGen&) = delete;
|
||||
FrameGen& operator=(const FrameGen&) = delete;
|
||||
|
||||
bool init(const DeviceDispatch* dd, const InstanceDispatch* id,
|
||||
VkPhysicalDevice phys, VkDevice dev, uint32_t queueFamily, VkQueue queue);
|
||||
void configure(const Config& c);
|
||||
@@ -22,8 +14,7 @@ public:
|
||||
void record(VkCommandBuffer cmd, VkImageView prevView, VkImageView currView,
|
||||
VkImageView outView, float alpha, uint32_t gmSlot = 0,
|
||||
uint32_t synthSlot = 0, bool reuseFlow = false);
|
||||
bool destroy();
|
||||
void abandon();
|
||||
void destroy();
|
||||
bool valid() const { return device_ != VK_NULL_HANDLE && ready_; }
|
||||
const Config& config() const { return cfg_; }
|
||||
|
||||
@@ -73,9 +64,7 @@ private:
|
||||
void destroyPipe(Pipe& p);
|
||||
void barrier(VkCommandBuffer cmd, VkImage img, VkImageLayout from, VkImageLayout to);
|
||||
void initializeImage(VkCommandBuffer cmd, VkImage img, VkImageLayout to);
|
||||
bool waitIdle(const char* operation);
|
||||
bool destroyScratchResources(bool resetPool = true);
|
||||
void releaseScratch();
|
||||
void destroyScratchResources(bool resetPool = true);
|
||||
|
||||
const DeviceDispatch* dd_ = nullptr;
|
||||
const InstanceDispatch* id_ = nullptr;
|
||||
@@ -91,10 +80,7 @@ private:
|
||||
VkExtent2D extent_{};
|
||||
uint64_t imageGeneration_ = 0;
|
||||
bool ready_ = false;
|
||||
bool completionUnknown_ = false;
|
||||
bool deviceLost_ = false;
|
||||
int flowFinest_ = kFlowFinestDefault;
|
||||
std::unique_ptr<ScratchState> scratch_;
|
||||
|
||||
Pipe pLuma_, pDown_, pFlow_, pFlowM4_, pExpand_, pExpandM4_, pSynth_;
|
||||
Pipe pGmReduce_, pGmPrewarp_;
|
||||
|
||||
@@ -1,7 +1,33 @@
|
||||
|
||||
namespace ddfg {
|
||||
FrameGen::FrameGen() : scratch_(std::make_unique<ScratchState>()) {}
|
||||
FrameGen::~FrameGen() { (void)destroy(); }
|
||||
namespace {
|
||||
struct ScratchState {
|
||||
VkDevice ownerDevice = VK_NULL_HANDLE;
|
||||
VkBuffer synthUbo[ddfg::FrameGen::kSynthSlots]{};
|
||||
VkDeviceMemory synthUboMem[ddfg::FrameGen::kSynthSlots]{};
|
||||
void* synthUboPtr[ddfg::FrameGen::kSynthSlots]{};
|
||||
std::vector<VkBuffer> flowUbo; std::vector<VkDeviceMemory> flowUboMem; std::vector<void*> flowUboPtr;
|
||||
VkBuffer expandUbo = VK_NULL_HANDLE; VkDeviceMemory expandUboMem = VK_NULL_HANDLE; void* expandUboPtr = nullptr;
|
||||
VkBuffer flowRegUbo = VK_NULL_HANDLE; VkDeviceMemory flowRegUboMem = VK_NULL_HANDLE; void* flowRegUboPtr = nullptr;
|
||||
VkBuffer gmUbo[ddfg::FrameGen::kGmSlots]{};
|
||||
VkDeviceMemory gmUboMem[ddfg::FrameGen::kGmSlots]{};
|
||||
void* gmUboPtr[ddfg::FrameGen::kGmSlots]{};
|
||||
VkDescriptorSet sLumaCurr = VK_NULL_HANDLE, sLumaPrev = VK_NULL_HANDLE;
|
||||
std::vector<VkDescriptorSet> sDownA, sDownB, sFlow;
|
||||
VkDescriptorSet sExpand[ddfg::FrameGen::kGmSlots]{};
|
||||
|
||||
|
||||
|
||||
VkDescriptorSet sFlowReg0 = VK_NULL_HANDLE, sFlowRegAB = VK_NULL_HANDLE, sFlowRegBA = VK_NULL_HANDLE;
|
||||
VkDescriptorSet sSynth[ddfg::FrameGen::kSynthSlots]{};
|
||||
VkDescriptorSet sGmReduce[ddfg::FrameGen::kGmSlots]{};
|
||||
std::vector<VkDescriptorSet> sGmPrewarp[ddfg::FrameGen::kGmSlots];
|
||||
VkExtent2D builtFor{0,0};
|
||||
uint64_t builtGeneration = 0;
|
||||
bool built = false;
|
||||
bool flowInited = false;
|
||||
bool flowReady = false;
|
||||
};
|
||||
ScratchState g_scratch;
|
||||
}
|
||||
|
||||
static bool makeUbo(const ddfg::DeviceDispatch* dd, VkDevice dev,
|
||||
@@ -118,7 +144,7 @@ static void mulAff(const double A[3][3], const double B[3][3], double out[3][3])
|
||||
|
||||
namespace ddfg {
|
||||
|
||||
static bool ensureScratch(ScratchState& S, FrameGen* fg, const DeviceDispatch* dd, VkDevice dev,
|
||||
static bool ensureScratch(FrameGen* fg, const DeviceDispatch* dd, VkDevice dev,
|
||||
const VkPhysicalDeviceMemoryProperties& mp, VkDescriptorPool pool,
|
||||
VkSampler samp, VkExtent2D ext,
|
||||
std::vector<FrameGen::Img>& pyrA, std::vector<FrameGen::Img>& pyrB,
|
||||
@@ -131,72 +157,30 @@ static bool ensureScratch(ScratchState& S, FrameGen* fg, const DeviceDispatch* d
|
||||
FrameGen::Img& flowRegA, FrameGen::Img& flowRegB, VkBuffer* gmSsbo,
|
||||
int kLevels, const Config& cfg, uint64_t imageGeneration);
|
||||
|
||||
bool FrameGen::waitIdle(const char* operation) {
|
||||
if (completionUnknown_ || deviceLost_ || !device_) return false;
|
||||
if (!dd_ || !dd_->DeviceWaitIdle) {
|
||||
completionUnknown_ = true;
|
||||
ready_ = false;
|
||||
DDFG_LOGE("framegen: %s cannot confirm GPU completion; this instance is stopped and its resources are retained",
|
||||
operation);
|
||||
return false;
|
||||
}
|
||||
const VkResult result = dd_->DeviceWaitIdle(device_);
|
||||
if (result == VK_SUCCESS) return true;
|
||||
ready_ = false;
|
||||
if (result == VK_ERROR_DEVICE_LOST) {
|
||||
deviceLost_ = true;
|
||||
DDFG_LOGE("framegen: %s reported device loss; cleanup will skip further waits", operation);
|
||||
} else {
|
||||
completionUnknown_ = true;
|
||||
DDFG_LOGE("framegen: %s vkDeviceWaitIdle failed (%d); this instance is stopped and its GPU resources retained",
|
||||
operation, (int)result);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FrameGen::destroyScratchResources(bool resetPool) {
|
||||
if (!scratch_) return true;
|
||||
if (resetPool && descPool_ && !deviceLost_) {
|
||||
if (!dd_ || !dd_->ResetDescriptorPool) {
|
||||
ready_ = false;
|
||||
DDFG_LOGE("framegen: descriptor-pool reset is unavailable; retaining scratch resources");
|
||||
return false;
|
||||
}
|
||||
const VkResult result = dd_->ResetDescriptorPool(device_, descPool_, 0);
|
||||
if (result != VK_SUCCESS) {
|
||||
ready_ = false;
|
||||
if (result == VK_ERROR_DEVICE_LOST) deviceLost_ = true;
|
||||
DDFG_LOGE("framegen: descriptor-pool reset failed (%d); retaining scratch resources",
|
||||
(int)result);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
releaseScratch();
|
||||
return true;
|
||||
}
|
||||
|
||||
void FrameGen::releaseScratch() {
|
||||
if (!scratch_) return;
|
||||
auto& S = *scratch_;
|
||||
static void destroyScratch(const DeviceDispatch* dd, VkDevice dev, VkDescriptorPool pool,
|
||||
bool resetPool = true) {
|
||||
if (g_scratch.ownerDevice != VK_NULL_HANDLE && g_scratch.ownerDevice != dev) return;
|
||||
auto freeUbo = [&](VkBuffer& b, VkDeviceMemory& m, void*& p) {
|
||||
if (p && m) dd_->UnmapMemory(device_, m);
|
||||
if (b) dd_->DestroyBuffer(device_, b, nullptr);
|
||||
if (m) dd_->FreeMemory(device_, m, nullptr);
|
||||
b = VK_NULL_HANDLE;
|
||||
m = VK_NULL_HANDLE;
|
||||
p = nullptr;
|
||||
if (m) dd->UnmapMemory(dev, m);
|
||||
if (b) dd->DestroyBuffer(dev, b, nullptr);
|
||||
if (m) dd->FreeMemory(dev, m, nullptr);
|
||||
b = VK_NULL_HANDLE; m = VK_NULL_HANDLE; p = nullptr;
|
||||
};
|
||||
auto& S = g_scratch;
|
||||
for (int s = 0; s < FrameGen::kSynthSlots; ++s) freeUbo(S.synthUbo[s], S.synthUboMem[s], S.synthUboPtr[s]);
|
||||
freeUbo(S.expandUbo, S.expandUboMem, S.expandUboPtr);
|
||||
freeUbo(S.expandUbo, S.expandUboMem, S.expandUboPtr);
|
||||
freeUbo(S.flowRegUbo, S.flowRegUboMem, S.flowRegUboPtr);
|
||||
for (size_t i = 0; i < S.flowUbo.size(); ++i) freeUbo(S.flowUbo[i], S.flowUboMem[i], S.flowUboPtr[i]);
|
||||
for (int s = 0; s < FrameGen::kGmSlots; ++s) freeUbo(S.gmUbo[s], S.gmUboMem[s], S.gmUboPtr[s]);
|
||||
if (resetPool && pool && dd->ResetDescriptorPool) dd->ResetDescriptorPool(dev, pool, 0);
|
||||
S = ScratchState{};
|
||||
}
|
||||
|
||||
void FrameGen::destroyScratchResources(bool resetPool) {
|
||||
destroyScratch(dd_, device_, descPool_, resetPool);
|
||||
}
|
||||
|
||||
void FrameGen::configure(const Config& c) {
|
||||
if (completionUnknown_ || deviceLost_) return;
|
||||
Config nextCfg = c;
|
||||
nextCfg.sanitize();
|
||||
int want = flowFinestForPreset(nextCfg.perfPreset);
|
||||
@@ -219,12 +203,16 @@ void FrameGen::configure(const Config& c) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!waitIdle("live preset rebuild")) return;
|
||||
if (scratch_ && scratch_->ownerDevice != VK_NULL_HANDLE && !destroyScratchResources()) {
|
||||
DDFG_LOGE("perf-preset live rebuild: scratch cleanup failed; keeping the previous configuration");
|
||||
// Keep the previous configuration and image set if the device cannot idle.
|
||||
const VkResult idleResult = dd_->DeviceWaitIdle(device_);
|
||||
if (idleResult != VK_SUCCESS) {
|
||||
DDFG_LOGE("framegen configure: DeviceWaitIdle failed (%d); keeping previous configuration and images",
|
||||
(int)idleResult);
|
||||
return;
|
||||
}
|
||||
|
||||
// The device is idle, so reset motion history before rebuilding. This
|
||||
// also leaves the predictor reset if onResize fails.
|
||||
for (int i = 0; i < 6; ++i) gmRun_[i] = 0.0;
|
||||
for (int s = 0; s < kGmSlots; ++s) {
|
||||
gmSlotValid_[s] = false;
|
||||
@@ -235,17 +223,20 @@ void FrameGen::configure(const Config& c) {
|
||||
gmStableCount_ = 0;
|
||||
gmLastTransPx_ = 0.0f;
|
||||
|
||||
// Prevent onResize from issuing a second wait.
|
||||
destroyScratch(dd_, device_, descPool_);
|
||||
cfg_ = nextCfg;
|
||||
flowFinest_ = want;
|
||||
ready_ = false;
|
||||
if (!onResize(extent_, VK_FORMAT_UNDEFINED, true)) {
|
||||
ready_ = false;
|
||||
DDFG_LOGE("perf-preset live rebuild: onResize FAILED at %ux%u - frame generation unavailable",
|
||||
DDFG_LOGE("perf-preset live rebuild: onResize FAILED at %ux%u - FG disabled until next resize",
|
||||
extent_.width, extent_.height);
|
||||
return;
|
||||
}
|
||||
DDFG_LOGI("perf-preset live rebuild DONE (kFlowFinest=%d, flow predictor reset)", flowFinest_);
|
||||
}
|
||||
|
||||
bool FrameGen::updateGlobalMotion(uint32_t gmSlot, VkExtent2D fullExtent) {
|
||||
++gmFrames_;
|
||||
if (!gmBuffersReady_ || cfg_.gmMode == 2 ) {
|
||||
@@ -315,33 +306,35 @@ bool FrameGen::updateGlobalMotion(uint32_t gmSlot, VkExtent2D fullExtent) {
|
||||
void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView currView,
|
||||
VkImageView outView, float alpha, uint32_t gmSlot, uint32_t synthSlot, bool reuseFlow) {
|
||||
if (!valid()) return;
|
||||
auto& S = *scratch_;
|
||||
if (gmSlot >= (uint32_t)kGmSlots) gmSlot = 0;
|
||||
if (synthSlot >= (uint32_t)kSynthSlots) synthSlot = 0;
|
||||
const bool m4 = (cfg_.model == 4);
|
||||
const Pipe& flowP = m4 ? pFlowM4_ : pFlow_;
|
||||
const Pipe& expandP = m4 ? pExpandM4_ : pExpand_;
|
||||
|
||||
if (!S.built || S.builtFor.width != extent_.width ||
|
||||
S.builtFor.height != extent_.height ||
|
||||
S.builtGeneration != imageGeneration_) {
|
||||
if (S.built && !waitIdle("scratch rebuild")) return;
|
||||
if (S.ownerDevice != VK_NULL_HANDLE && !destroyScratchResources()) {
|
||||
DDFG_LOGE("framegen record: scratch cleanup failed; skipping this frame");
|
||||
return;
|
||||
if (!g_scratch.built || g_scratch.builtFor.width != extent_.width ||
|
||||
g_scratch.builtFor.height != extent_.height ||
|
||||
g_scratch.builtGeneration != imageGeneration_) {
|
||||
if (g_scratch.built) {
|
||||
const VkResult idleResult = dd_->DeviceWaitIdle(device_);
|
||||
if (idleResult != VK_SUCCESS) {
|
||||
DDFG_LOGE("framegen record: DeviceWaitIdle failed (%d); skipping scratch rebuild", (int)idleResult);
|
||||
return;
|
||||
}
|
||||
destroyScratch(dd_, device_, descPool_);
|
||||
}
|
||||
if (!ensureScratch(S, this, dd_, device_, memProps_, descPool_, linear_, extent_,
|
||||
if (!ensureScratch(this, dd_, device_, memProps_, descPool_, linear_, extent_,
|
||||
pyrA_, pyrB_, pyrAs_, flowLvl_, flowExpA_, flowExpB_,
|
||||
pLuma_, pDown_, flowP, expandP, pSynth_, pGmReduce_, pGmPrewarp_,
|
||||
pFlowReg_, flowRegA_, flowRegB_, gmSsbo_, kLevels, cfg_, imageGeneration_))
|
||||
return;
|
||||
}
|
||||
|
||||
if (S.ownerDevice != device_) return;
|
||||
if (reuseFlow && !S.flowReady) return;
|
||||
if (g_scratch.ownerDevice != device_) return;
|
||||
if (reuseFlow && !g_scratch.flowReady) return;
|
||||
if (!reuseFlow) {
|
||||
bool gmEngaged = updateGlobalMotion(gmSlot, extent_);
|
||||
if (S.gmUboPtr[gmSlot]) {
|
||||
if (g_scratch.gmUboPtr[gmSlot]) {
|
||||
GMUBO g{};
|
||||
g.lin[0]=(float)gmRun_[0]; g.lin[1]=(float)gmRun_[1]; g.lin[2]=(float)gmRun_[2]; g.lin[3]=(float)gmRun_[3];
|
||||
g.linT[0]=(float)gmRun_[4]; g.linT[1]=(float)gmRun_[5]; g.linT[2]=gmEngaged?1.0f:0.0f; g.linT[3]=0.0f;
|
||||
@@ -349,7 +342,7 @@ void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView cur
|
||||
g.app[0]=(float)gmRun_[0]; g.app[1]=(float)gmRun_[1]; g.app[2]=(float)gmRun_[2]; g.app[3]=(float)gmRun_[3];
|
||||
g.appT[0]=(float)gmRun_[4]; g.appT[1]=(float)gmRun_[5];
|
||||
}
|
||||
std::memcpy(S.gmUboPtr[gmSlot], &g, sizeof(g));
|
||||
std::memcpy(g_scratch.gmUboPtr[gmSlot], &g, sizeof(g));
|
||||
}
|
||||
{
|
||||
static int lastEng = -1;
|
||||
@@ -360,7 +353,7 @@ void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView cur
|
||||
}
|
||||
}
|
||||
|
||||
const VkDescriptorSet lumaSets[] = {S.sLumaCurr, S.sLumaPrev};
|
||||
const VkDescriptorSet lumaSets[] = {g_scratch.sLumaCurr, g_scratch.sLumaPrev};
|
||||
const uint32_t lumaBindings[] = {32, 32};
|
||||
const VkDescriptorType lumaTypes[] = {
|
||||
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER};
|
||||
@@ -374,9 +367,9 @@ void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView cur
|
||||
|
||||
SynthUBO su{cfg_.flowScale, alpha, cfg_.beta, cfg_.lambda, cfg_.epsilon, cfg_.photoScale, 0, 0,
|
||||
cfg_.hudX0, cfg_.hudY0, cfg_.hudX1, cfg_.hudY1};
|
||||
if (S.synthUboPtr[synthSlot]) std::memcpy(S.synthUboPtr[synthSlot], &su, sizeof(su));
|
||||
if (g_scratch.synthUboPtr[synthSlot]) std::memcpy(g_scratch.synthUboPtr[synthSlot], &su, sizeof(su));
|
||||
|
||||
const VkDescriptorSet synthSet = S.sSynth[synthSlot];
|
||||
const VkDescriptorSet synthSet = g_scratch.sSynth[synthSlot];
|
||||
const VkDescriptorSet synthSets[] = {synthSet, synthSet, synthSet};
|
||||
const uint32_t synthBindings[] = {32, 33, 48};
|
||||
const VkDescriptorType synthTypes[] = {
|
||||
@@ -475,17 +468,17 @@ void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView cur
|
||||
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &b);
|
||||
}
|
||||
|
||||
disp(pLuma_, S.sLumaCurr, levelExtent(extent_, 0));
|
||||
disp(pLuma_, S.sLumaPrev, levelExtent(extent_, 0));
|
||||
disp(pLuma_, g_scratch.sLumaCurr, levelExtent(extent_, 0));
|
||||
disp(pLuma_, g_scratch.sLumaPrev, levelExtent(extent_, 0));
|
||||
barPair(pyrA_[0], pyrB_[0]);
|
||||
for (int l = 1; l < kLevels; ++l) {
|
||||
disp(pDown_, S.sDownA[l - 1], levelExtent(extent_, l));
|
||||
disp(pDown_, S.sDownB[l - 1], levelExtent(extent_, l));
|
||||
disp(pDown_, g_scratch.sDownA[l - 1], levelExtent(extent_, l));
|
||||
disp(pDown_, g_scratch.sDownB[l - 1], levelExtent(extent_, l));
|
||||
barPair(pyrA_[l], pyrB_[l]);
|
||||
}
|
||||
if (gmBuffersReady_ && S.sGmReduce[gmSlot]) {
|
||||
if (gmBuffersReady_ && g_scratch.sGmReduce[gmSlot]) {
|
||||
dd_->CmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, pGmReduce_.pipeline);
|
||||
dd_->CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, pGmReduce_.layout, 0, 1, &S.sGmReduce[gmSlot], 0, nullptr);
|
||||
dd_->CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, pGmReduce_.layout, 0, 1, &g_scratch.sGmReduce[gmSlot], 0, nullptr);
|
||||
dd_->CmdDispatch(cmd, (uint32_t)(kGmThreads / 64), 1, 1);
|
||||
VkMemoryBarrier mb{VK_STRUCTURE_TYPE_MEMORY_BARRIER};
|
||||
mb.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT; mb.dstAccessMask = VK_ACCESS_HOST_READ_BIT;
|
||||
@@ -493,27 +486,27 @@ void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView cur
|
||||
0, 1, &mb, 0, nullptr, 0, nullptr);
|
||||
}
|
||||
for (int l = flowFinest_; l < kLevels; ++l) {
|
||||
disp(pGmPrewarp_, S.sGmPrewarp[gmSlot][l], levelExtent(extent_, l));
|
||||
disp(pGmPrewarp_, g_scratch.sGmPrewarp[gmSlot][l], levelExtent(extent_, l));
|
||||
bar(pyrAs_[l]);
|
||||
}
|
||||
for (int l = kLevels - 1; l >= flowFinest_; --l) {
|
||||
disp(flowP, S.sFlow[l], levelExtent(extent_, l));
|
||||
disp(flowP, g_scratch.sFlow[l], levelExtent(extent_, l));
|
||||
bar(flowLvl_[l]);
|
||||
}
|
||||
|
||||
if (frEngaged) {
|
||||
const int F = flowFinest_;
|
||||
const VkExtent2D fe = levelExtent(extent_, F);
|
||||
if (S.flowRegUboPtr) {
|
||||
if (g_scratch.flowRegUboPtr) {
|
||||
FlowRegUBO fu{cfg_.frDt, cfg_.frLambda, cfg_.frEdge, cfg_.frEps};
|
||||
std::memcpy(S.flowRegUboPtr, &fu, sizeof(fu));
|
||||
std::memcpy(g_scratch.flowRegUboPtr, &fu, sizeof(fu));
|
||||
}
|
||||
FrameGen::Img* last = nullptr;
|
||||
for (int it = 0; it < cfg_.frIters; ++it) {
|
||||
VkDescriptorSet set; FrameGen::Img* outImg;
|
||||
if (it == 0) { set = S.sFlowReg0; outImg = &flowRegA_; }
|
||||
else if (it % 2 == 1) { set = S.sFlowRegAB; outImg = &flowRegB_; }
|
||||
else { set = S.sFlowRegBA; outImg = &flowRegA_; }
|
||||
if (it == 0) { set = g_scratch.sFlowReg0; outImg = &flowRegA_; }
|
||||
else if (it % 2 == 1) { set = g_scratch.sFlowRegAB; outImg = &flowRegB_; }
|
||||
else { set = g_scratch.sFlowRegBA; outImg = &flowRegA_; }
|
||||
dd_->CmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, pFlowReg_.pipeline);
|
||||
dd_->CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, pFlowReg_.layout, 0, 1, &set, 0, nullptr);
|
||||
dd_->CmdDispatch(cmd, (fe.width + 15) / 16, (fe.height + 15) / 16, 1);
|
||||
@@ -547,14 +540,14 @@ void FrameGen::record(VkCommandBuffer cmd, VkImageView prevView, VkImageView cur
|
||||
}
|
||||
}
|
||||
|
||||
disp(expandP, S.sExpand[gmSlot], levelExtent(extent_, 0));
|
||||
disp(expandP, g_scratch.sExpand[gmSlot], levelExtent(extent_, 0));
|
||||
barPair(flowExpA_, flowExpB_);
|
||||
S.flowReady = true;
|
||||
g_scratch.flowReady = true;
|
||||
}
|
||||
disp(pSynth_, synthSet, levelExtent(extent_, 0));
|
||||
}
|
||||
|
||||
static bool ensureScratch(ScratchState& S, FrameGen* fg, const DeviceDispatch* dd, VkDevice dev,
|
||||
static bool ensureScratch(FrameGen* fg, const DeviceDispatch* dd, VkDevice dev,
|
||||
const VkPhysicalDeviceMemoryProperties& mp, VkDescriptorPool pool,
|
||||
VkSampler samp, VkExtent2D ext,
|
||||
std::vector<FrameGen::Img>& pyrA, std::vector<FrameGen::Img>& pyrB,
|
||||
@@ -566,6 +559,7 @@ static bool ensureScratch(ScratchState& S, FrameGen* fg, const DeviceDispatch* d
|
||||
const FrameGen::Pipe& pGmPrewarp, const FrameGen::Pipe& pFlowReg,
|
||||
FrameGen::Img& flowRegA, FrameGen::Img& flowRegB, VkBuffer* gmSsbo,
|
||||
int kLevels, const Config& cfg, uint64_t imageGeneration) {
|
||||
auto& S = g_scratch;
|
||||
if (S.ownerDevice != VK_NULL_HANDLE && S.ownerDevice != dev) return false;
|
||||
S = ScratchState{};
|
||||
S.ownerDevice = dev;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
// - Same push constants as cas.frag: ndc, input size, sharpness [0..1].
|
||||
// CasSetup's const1.x = -1 / lerp(8, 5, sharpness) is computed here.
|
||||
// - The input is the effect chain's previous target at the same size, so the
|
||||
// output pixel reads the input pixel 1:1 (texel centres, edges clamped).
|
||||
// output pixel reads the input pixel 1:1 (texelFetch, edges clamped).
|
||||
// =============================================================================
|
||||
|
||||
// DD_HALF is set for the *_half_frag.h build (gen_shaders.sh): colour and
|
||||
@@ -64,8 +64,8 @@ layout(location = 0) in highp vec2 fragTexCoord;
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
vec3 CasLoad(ivec2 p) {
|
||||
highp vec2 uv = (vec2(p) + 0.5) / pc.resolution;
|
||||
return textureLod(InputTexture, uv, 0.0).rgb;
|
||||
ivec2 sz = textureSize(InputTexture, 0);
|
||||
return texelFetch(InputTexture, clamp(p, ivec2(0), sz - ivec2(1)), 0).rgb;
|
||||
}
|
||||
|
||||
float AMin3F1(float x, float y, float z) { return min(x, min(y, z)); }
|
||||
|
||||
@@ -1,213 +1,214 @@
|
||||
// 1115.1.0
|
||||
// 1116.2.0
|
||||
#pragma once
|
||||
const uint32_t cas_ffx_half_code[] = {
|
||||
0x07230203,0x00010000,0x0008000b,0x000000d7,0x00000000,0x00020011,0x00000001,0x0006000b,
|
||||
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
||||
0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000047,0x000000d1,0x00030010,
|
||||
0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,
|
||||
0x00000000,0x00060005,0x0000000d,0x4c736143,0x2864616f,0x3b326976,0x00000000,0x00030005,
|
||||
0x0000000c,0x00000070,0x00070005,0x00000014,0x6e694d41,0x28314633,0x663b3166,0x31663b31,
|
||||
0x0000003b,0x00030005,0x00000011,0x00000078,0x00030005,0x00000012,0x00000079,0x00030005,
|
||||
0x00000013,0x0000007a,0x00070005,0x00000019,0x78614d41,0x28314633,0x663b3166,0x31663b31,
|
||||
0x0000003b,0x00030005,0x00000016,0x00000078,0x00030005,0x00000017,0x00000079,0x00030005,
|
||||
0x00000018,0x0000007a,0x00030005,0x0000001d,0x00007675,0x00030005,0x00000024,0x00004350,
|
||||
0x00040006,0x00000024,0x00000000,0x0063646e,0x00060006,0x00000024,0x00000001,0x6f736572,
|
||||
0x6974756c,0x00006e6f,0x00060006,0x00000024,0x00000002,0x72616873,0x73656e70,0x00000073,
|
||||
0x00030005,0x00000026,0x00006370,0x00060005,0x0000002f,0x75706e49,0x78655474,0x65727574,
|
||||
0x00000000,0x00030005,0x00000045,0x00007073,0x00060005,0x00000047,0x67617266,0x43786554,
|
||||
0x64726f6f,0x00000000,0x00040005,0x0000004d,0x6b616570,0x00000000,0x00030005,0x0000005a,
|
||||
0x00000062,0x00040005,0x00000060,0x61726170,0x0000006d,0x00030005,0x00000062,0x00000064,
|
||||
0x00040005,0x00000066,0x61726170,0x0000006d,0x00030005,0x00000068,0x00000065,0x00040005,
|
||||
0x00000069,0x61726170,0x0000006d,0x00030005,0x0000006c,0x00000066,0x00040005,0x00000070,
|
||||
0x61726170,0x0000006d,0x00030005,0x00000072,0x00000068,0x00040005,0x00000076,0x61726170,
|
||||
0x0000006d,0x00030005,0x00000078,0x00476e6d,0x00040005,0x00000079,0x61726170,0x0000006d,
|
||||
0x00040005,0x0000007e,0x61726170,0x0000006d,0x00040005,0x00000081,0x61726170,0x0000006d,
|
||||
0x00040005,0x00000085,0x61726170,0x0000006d,0x00040005,0x00000086,0x61726170,0x0000006d,
|
||||
0x00040005,0x00000089,0x61726170,0x0000006d,0x00030005,0x0000008d,0x0047786d,0x00040005,
|
||||
0x0000008e,0x61726170,0x0000006d,0x00040005,0x00000091,0x61726170,0x0000006d,0x00040005,
|
||||
0x00000094,0x61726170,0x0000006d,0x00040005,0x00000098,0x61726170,0x0000006d,0x00040005,
|
||||
0x00000099,0x61726170,0x0000006d,0x00040005,0x0000009c,0x61726170,0x0000006d,0x00040005,
|
||||
0x000000a0,0x4d706372,0x00000047,0x00040005,0x000000a5,0x47706d61,0x00000000,0x00030005,
|
||||
0x000000af,0x00004777,0x00050005,0x000000b3,0x57706372,0x68676965,0x00000074,0x00030005,
|
||||
0x000000b9,0x00786970,0x00050005,0x000000d1,0x4374756f,0x726f6c6f,0x00000000,0x00030047,
|
||||
0x0000000d,0x00000000,0x00030047,0x00000011,0x00000000,0x00030047,0x00000012,0x00000000,
|
||||
0x00030047,0x00000013,0x00000000,0x00030047,0x00000014,0x00000000,0x00030047,0x00000016,
|
||||
0x00000000,0x00030047,0x00000017,0x00000000,0x00030047,0x00000018,0x00000000,0x00030047,
|
||||
0x00000019,0x00000000,0x00030047,0x00000024,0x00000002,0x00050048,0x00000024,0x00000000,
|
||||
0x00000023,0x00000000,0x00050048,0x00000024,0x00000001,0x00000023,0x00000010,0x00040048,
|
||||
0x00000024,0x00000002,0x00000000,0x00050048,0x00000024,0x00000002,0x00000023,0x00000018,
|
||||
0x00030047,0x0000002f,0x00000000,0x00040047,0x0000002f,0x00000021,0x00000000,0x00040047,
|
||||
0x0000002f,0x00000022,0x00000000,0x00030047,0x00000030,0x00000000,0x00030047,0x00000033,
|
||||
0x00000000,0x00030047,0x00000034,0x00000000,0x00030047,0x00000037,0x00000000,0x00030047,
|
||||
0x00000038,0x00000000,0x00030047,0x00000039,0x00000000,0x00030047,0x0000003a,0x00000000,
|
||||
0x00030047,0x0000003b,0x00000000,0x00030047,0x0000003e,0x00000000,0x00030047,0x0000003f,
|
||||
0x00000000,0x00030047,0x00000040,0x00000000,0x00030047,0x00000041,0x00000000,0x00030047,
|
||||
0x00000042,0x00000000,0x00040047,0x00000047,0x0000001e,0x00000000,0x00030047,0x0000004d,
|
||||
0x00000000,0x00030047,0x00000054,0x00000000,0x00030047,0x00000056,0x00000000,0x00030047,
|
||||
0x00000057,0x00000000,0x00030047,0x00000058,0x00000000,0x00030047,0x0000005a,0x00000000,
|
||||
0x00030047,0x00000061,0x00000000,0x00030047,0x00000062,0x00000000,0x00030047,0x00000067,
|
||||
0x00000000,0x00030047,0x00000068,0x00000000,0x00030047,0x0000006b,0x00000000,0x00030047,
|
||||
0x0000006c,0x00000000,0x00030047,0x00000071,0x00000000,0x00030047,0x00000072,0x00000000,
|
||||
0x00030047,0x00000077,0x00000000,0x00030047,0x00000078,0x00000000,0x00030047,0x00000079,
|
||||
0x00000000,0x00030047,0x0000007d,0x00000000,0x00030047,0x0000007e,0x00000000,0x00030047,
|
||||
0x00000080,0x00000000,0x00030047,0x00000081,0x00000000,0x00030047,0x00000083,0x00000000,
|
||||
0x00030047,0x00000084,0x00000000,0x00030047,0x00000085,0x00000000,0x00030047,0x00000086,
|
||||
0x00000000,0x00030047,0x00000088,0x00000000,0x00030047,0x00000089,0x00000000,0x00030047,
|
||||
0x0000008b,0x00000000,0x00030047,0x0000008c,0x00000000,0x00030047,0x0000008d,0x00000000,
|
||||
0x00030047,0x0000008e,0x00000000,0x00030047,0x00000090,0x00000000,0x00030047,0x00000091,
|
||||
0x00000000,0x00030047,0x00000093,0x00000000,0x00030047,0x00000094,0x00000000,0x00030047,
|
||||
0x00000096,0x00000000,0x00030047,0x00000097,0x00000000,0x00030047,0x00000098,0x00000000,
|
||||
0x00030047,0x00000099,0x00000000,0x00030047,0x0000009b,0x00000000,0x00030047,0x0000009c,
|
||||
0x00000000,0x00030047,0x0000009e,0x00000000,0x00030047,0x0000009f,0x00000000,0x00030047,
|
||||
0x000000a0,0x00000000,0x00030047,0x000000a1,0x00000000,0x00030047,0x000000a3,0x00000000,
|
||||
0x00030047,0x000000a4,0x00000000,0x00030047,0x000000a5,0x00000000,0x00030047,0x000000a6,
|
||||
0x00000000,0x00030047,0x000000a7,0x00000000,0x00030047,0x000000a8,0x00000000,0x00030047,
|
||||
0x000000a9,0x00000000,0x00030047,0x000000aa,0x00000000,0x00030047,0x000000ab,0x00000000,
|
||||
0x00030047,0x000000ac,0x00000000,0x00030047,0x000000ad,0x00000000,0x00030047,0x000000ae,
|
||||
0x00000000,0x00030047,0x000000af,0x00000000,0x00030047,0x000000b0,0x00000000,0x00030047,
|
||||
0x000000b1,0x00000000,0x00030047,0x000000b2,0x00000000,0x00030047,0x000000b3,0x00000000,
|
||||
0x00030047,0x000000b5,0x00000000,0x00030047,0x000000b6,0x00000000,0x00030047,0x000000b7,
|
||||
0x00000000,0x00030047,0x000000b8,0x00000000,0x00030047,0x000000b9,0x00000000,0x00030047,
|
||||
0x000000ba,0x00000000,0x00030047,0x000000bb,0x00000000,0x00030047,0x000000bc,0x00000000,
|
||||
0x00030047,0x000000bd,0x00000000,0x00030047,0x000000be,0x00000000,0x00030047,0x000000bf,
|
||||
0x00000000,0x00030047,0x000000c0,0x00000000,0x00030047,0x000000c1,0x00000000,0x00030047,
|
||||
0x000000c2,0x00000000,0x00030047,0x000000c3,0x00000000,0x00030047,0x000000c4,0x00000000,
|
||||
0x00030047,0x000000c5,0x00000000,0x00030047,0x000000c6,0x00000000,0x00030047,0x000000c7,
|
||||
0x00000000,0x00030047,0x000000c8,0x00000000,0x00030047,0x000000c9,0x00000000,0x00030047,
|
||||
0x000000ca,0x00000000,0x00030047,0x000000cb,0x00000000,0x00030047,0x000000cc,0x00000000,
|
||||
0x00030047,0x000000cd,0x00000000,0x00030047,0x000000ce,0x00000000,0x00030047,0x000000cf,
|
||||
0x00000000,0x00030047,0x000000d1,0x00000000,0x00040047,0x000000d1,0x0000001e,0x00000000,
|
||||
0x00030047,0x000000d2,0x00000000,0x00030047,0x000000d3,0x00000000,0x00030047,0x000000d4,
|
||||
0x00000000,0x00030047,0x000000d5,0x00000000,0x00030047,0x000000d6,0x00000000,0x00020013,
|
||||
0x00000002,0x00030021,0x00000003,0x00000002,0x00040015,0x00000006,0x00000020,0x00000001,
|
||||
0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,
|
||||
0x00030016,0x00000009,0x00000020,0x00040017,0x0000000a,0x00000009,0x00000003,0x00040021,
|
||||
0x0000000b,0x0000000a,0x00000008,0x00040020,0x0000000f,0x00000007,0x00000009,0x00060021,
|
||||
0x00000010,0x00000009,0x0000000f,0x0000000f,0x0000000f,0x00040017,0x0000001b,0x00000009,
|
||||
0x00000002,0x00040020,0x0000001c,0x00000007,0x0000001b,0x0004002b,0x00000009,0x00000020,
|
||||
0x3f000000,0x00040017,0x00000023,0x00000009,0x00000004,0x0005001e,0x00000024,0x00000023,
|
||||
0x0000001b,0x00000009,0x00040020,0x00000025,0x00000009,0x00000024,0x0004003b,0x00000025,
|
||||
0x00000026,0x00000009,0x0004002b,0x00000006,0x00000027,0x00000001,0x00040020,0x00000028,
|
||||
0x00000009,0x0000001b,0x00090019,0x0000002c,0x00000009,0x00000001,0x00000000,0x00000000,
|
||||
0x00000000,0x00000001,0x00000000,0x0003001b,0x0000002d,0x0000002c,0x00040020,0x0000002e,
|
||||
0x00000000,0x0000002d,0x0004003b,0x0000002e,0x0000002f,0x00000000,0x0004002b,0x00000009,
|
||||
0x00000032,0x00000000,0x00040020,0x00000046,0x00000001,0x0000001b,0x0004003b,0x00000046,
|
||||
0x00000047,0x00000001,0x0004002b,0x00000009,0x0000004e,0xbf800000,0x0004002b,0x00000009,
|
||||
0x0000004f,0x41000000,0x0004002b,0x00000009,0x00000050,0x40a00000,0x0004002b,0x00000006,
|
||||
0x00000051,0x00000002,0x00040020,0x00000052,0x00000009,0x00000009,0x0004002b,0x00000009,
|
||||
0x00000055,0x3f800000,0x00040020,0x00000059,0x00000007,0x0000000a,0x0004002b,0x00000006,
|
||||
0x0000005c,0x00000000,0x0004002b,0x00000006,0x0000005d,0xffffffff,0x0005002c,0x00000007,
|
||||
0x0000005e,0x0000005c,0x0000005d,0x0005002c,0x00000007,0x00000064,0x0000005d,0x0000005c,
|
||||
0x0005002c,0x00000007,0x0000006e,0x00000027,0x0000005c,0x0005002c,0x00000007,0x00000074,
|
||||
0x0000005c,0x00000027,0x00040015,0x0000007a,0x00000020,0x00000000,0x0004002b,0x0000007a,
|
||||
0x0000007b,0x00000001,0x0004002b,0x00000009,0x000000a2,0x3a800000,0x0004002b,0x00000009,
|
||||
0x000000b4,0x40800000,0x00040020,0x000000d0,0x00000003,0x00000023,0x0004003b,0x000000d0,
|
||||
0x000000d1,0x00000003,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,
|
||||
0x00000005,0x0004003b,0x00000008,0x00000045,0x00000007,0x0004003b,0x0000000f,0x0000004d,
|
||||
0x00000007,0x0004003b,0x00000059,0x0000005a,0x00000007,0x0004003b,0x00000008,0x00000060,
|
||||
0x00000007,0x0004003b,0x00000059,0x00000062,0x00000007,0x0004003b,0x00000008,0x00000066,
|
||||
0x00000007,0x0004003b,0x00000059,0x00000068,0x00000007,0x0004003b,0x00000008,0x00000069,
|
||||
0x00000007,0x0004003b,0x00000059,0x0000006c,0x00000007,0x0004003b,0x00000008,0x00000070,
|
||||
0x00000007,0x0004003b,0x00000059,0x00000072,0x00000007,0x0004003b,0x00000008,0x00000076,
|
||||
0x00000007,0x0004003b,0x0000000f,0x00000078,0x00000007,0x0004003b,0x0000000f,0x00000079,
|
||||
0x00000007,0x0004003b,0x0000000f,0x0000007e,0x00000007,0x0004003b,0x0000000f,0x00000081,
|
||||
0x00000007,0x0004003b,0x0000000f,0x00000085,0x00000007,0x0004003b,0x0000000f,0x00000086,
|
||||
0x00000007,0x0004003b,0x0000000f,0x00000089,0x00000007,0x0004003b,0x0000000f,0x0000008d,
|
||||
0x00000007,0x0004003b,0x0000000f,0x0000008e,0x00000007,0x0004003b,0x0000000f,0x00000091,
|
||||
0x00000007,0x0004003b,0x0000000f,0x00000094,0x00000007,0x0004003b,0x0000000f,0x00000098,
|
||||
0x00000007,0x0004003b,0x0000000f,0x00000099,0x00000007,0x0004003b,0x0000000f,0x0000009c,
|
||||
0x00000007,0x0004003b,0x0000000f,0x000000a0,0x00000007,0x0004003b,0x0000000f,0x000000a5,
|
||||
0x00000007,0x0004003b,0x0000000f,0x000000af,0x00000007,0x0004003b,0x0000000f,0x000000b3,
|
||||
0x00000007,0x0004003b,0x00000059,0x000000b9,0x00000007,0x0004003d,0x0000001b,0x00000048,
|
||||
0x00000047,0x00050041,0x00000028,0x00000049,0x00000026,0x00000027,0x0004003d,0x0000001b,
|
||||
0x0000004a,0x00000049,0x00050085,0x0000001b,0x0000004b,0x00000048,0x0000004a,0x0004006e,
|
||||
0x00000007,0x0000004c,0x0000004b,0x0003003e,0x00000045,0x0000004c,0x00050041,0x00000052,
|
||||
0x00000053,0x00000026,0x00000051,0x0004003d,0x00000009,0x00000054,0x00000053,0x0008000c,
|
||||
0x00000009,0x00000056,0x00000001,0x0000002b,0x00000054,0x00000032,0x00000055,0x0008000c,
|
||||
0x00000009,0x00000057,0x00000001,0x0000002e,0x0000004f,0x00000050,0x00000056,0x00050088,
|
||||
0x00000009,0x00000058,0x0000004e,0x00000057,0x0003003e,0x0000004d,0x00000058,0x0004003d,
|
||||
0x00000007,0x0000005b,0x00000045,0x00050080,0x00000007,0x0000005f,0x0000005b,0x0000005e,
|
||||
0x0003003e,0x00000060,0x0000005f,0x00050039,0x0000000a,0x00000061,0x0000000d,0x00000060,
|
||||
0x0003003e,0x0000005a,0x00000061,0x0004003d,0x00000007,0x00000063,0x00000045,0x00050080,
|
||||
0x00000007,0x00000065,0x00000063,0x00000064,0x0003003e,0x00000066,0x00000065,0x00050039,
|
||||
0x0000000a,0x00000067,0x0000000d,0x00000066,0x0003003e,0x00000062,0x00000067,0x0004003d,
|
||||
0x00000007,0x0000006a,0x00000045,0x0003003e,0x00000069,0x0000006a,0x00050039,0x0000000a,
|
||||
0x0000006b,0x0000000d,0x00000069,0x0003003e,0x00000068,0x0000006b,0x0004003d,0x00000007,
|
||||
0x0000006d,0x00000045,0x00050080,0x00000007,0x0000006f,0x0000006d,0x0000006e,0x0003003e,
|
||||
0x00000070,0x0000006f,0x00050039,0x0000000a,0x00000071,0x0000000d,0x00000070,0x0003003e,
|
||||
0x0000006c,0x00000071,0x0004003d,0x00000007,0x00000073,0x00000045,0x00050080,0x00000007,
|
||||
0x00000075,0x00000073,0x00000074,0x0003003e,0x00000076,0x00000075,0x00050039,0x0000000a,
|
||||
0x00000077,0x0000000d,0x00000076,0x0003003e,0x00000072,0x00000077,0x00050041,0x0000000f,
|
||||
0x0000007c,0x00000062,0x0000007b,0x0004003d,0x00000009,0x0000007d,0x0000007c,0x0003003e,
|
||||
0x00000079,0x0000007d,0x00050041,0x0000000f,0x0000007f,0x00000068,0x0000007b,0x0004003d,
|
||||
0x00000009,0x00000080,0x0000007f,0x0003003e,0x0000007e,0x00000080,0x00050041,0x0000000f,
|
||||
0x00000082,0x0000006c,0x0000007b,0x0004003d,0x00000009,0x00000083,0x00000082,0x0003003e,
|
||||
0x00000081,0x00000083,0x00070039,0x00000009,0x00000084,0x00000014,0x00000079,0x0000007e,
|
||||
0x00000081,0x0003003e,0x00000085,0x00000084,0x00050041,0x0000000f,0x00000087,0x0000005a,
|
||||
0x0000007b,0x0004003d,0x00000009,0x00000088,0x00000087,0x0003003e,0x00000086,0x00000088,
|
||||
0x00050041,0x0000000f,0x0000008a,0x00000072,0x0000007b,0x0004003d,0x00000009,0x0000008b,
|
||||
0x0000008a,0x0003003e,0x00000089,0x0000008b,0x00070039,0x00000009,0x0000008c,0x00000014,
|
||||
0x00000085,0x00000086,0x00000089,0x0003003e,0x00000078,0x0000008c,0x00050041,0x0000000f,
|
||||
0x0000008f,0x00000062,0x0000007b,0x0004003d,0x00000009,0x00000090,0x0000008f,0x0003003e,
|
||||
0x0000008e,0x00000090,0x00050041,0x0000000f,0x00000092,0x00000068,0x0000007b,0x0004003d,
|
||||
0x00000009,0x00000093,0x00000092,0x0003003e,0x00000091,0x00000093,0x00050041,0x0000000f,
|
||||
0x00000095,0x0000006c,0x0000007b,0x0004003d,0x00000009,0x00000096,0x00000095,0x0003003e,
|
||||
0x00000094,0x00000096,0x00070039,0x00000009,0x00000097,0x00000019,0x0000008e,0x00000091,
|
||||
0x00000094,0x0003003e,0x00000098,0x00000097,0x00050041,0x0000000f,0x0000009a,0x0000005a,
|
||||
0x0000007b,0x0004003d,0x00000009,0x0000009b,0x0000009a,0x0003003e,0x00000099,0x0000009b,
|
||||
0x00050041,0x0000000f,0x0000009d,0x00000072,0x0000007b,0x0004003d,0x00000009,0x0000009e,
|
||||
0x0000009d,0x0003003e,0x0000009c,0x0000009e,0x00070039,0x00000009,0x0000009f,0x00000019,
|
||||
0x00000098,0x00000099,0x0000009c,0x0003003e,0x0000008d,0x0000009f,0x0004003d,0x00000009,
|
||||
0x000000a1,0x0000008d,0x0007000c,0x00000009,0x000000a3,0x00000001,0x00000028,0x000000a1,
|
||||
0x000000a2,0x00050088,0x00000009,0x000000a4,0x00000055,0x000000a3,0x0003003e,0x000000a0,
|
||||
0x000000a4,0x0004003d,0x00000009,0x000000a6,0x00000078,0x0004003d,0x00000009,0x000000a7,
|
||||
0x0000008d,0x00050083,0x00000009,0x000000a8,0x00000055,0x000000a7,0x0007000c,0x00000009,
|
||||
0x000000a9,0x00000001,0x00000025,0x000000a6,0x000000a8,0x0004003d,0x00000009,0x000000aa,
|
||||
0x000000a0,0x00050085,0x00000009,0x000000ab,0x000000a9,0x000000aa,0x0008000c,0x00000009,
|
||||
0x000000ac,0x00000001,0x0000002b,0x000000ab,0x00000032,0x00000055,0x0003003e,0x000000a5,
|
||||
0x000000ac,0x0004003d,0x00000009,0x000000ad,0x000000a5,0x0006000c,0x00000009,0x000000ae,
|
||||
0x00000001,0x0000001f,0x000000ad,0x0003003e,0x000000a5,0x000000ae,0x0004003d,0x00000009,
|
||||
0x000000b0,0x000000a5,0x0004003d,0x00000009,0x000000b1,0x0000004d,0x00050085,0x00000009,
|
||||
0x000000b2,0x000000b0,0x000000b1,0x0003003e,0x000000af,0x000000b2,0x0004003d,0x00000009,
|
||||
0x000000b5,0x000000af,0x00050085,0x00000009,0x000000b6,0x000000b4,0x000000b5,0x00050081,
|
||||
0x00000009,0x000000b7,0x00000055,0x000000b6,0x00050088,0x00000009,0x000000b8,0x00000055,
|
||||
0x000000b7,0x0003003e,0x000000b3,0x000000b8,0x0004003d,0x0000000a,0x000000ba,0x0000005a,
|
||||
0x0004003d,0x00000009,0x000000bb,0x000000af,0x0005008e,0x0000000a,0x000000bc,0x000000ba,
|
||||
0x000000bb,0x0004003d,0x0000000a,0x000000bd,0x00000062,0x0004003d,0x00000009,0x000000be,
|
||||
0x000000af,0x0005008e,0x0000000a,0x000000bf,0x000000bd,0x000000be,0x00050081,0x0000000a,
|
||||
0x000000c0,0x000000bc,0x000000bf,0x0004003d,0x0000000a,0x000000c1,0x0000006c,0x0004003d,
|
||||
0x00000009,0x000000c2,0x000000af,0x0005008e,0x0000000a,0x000000c3,0x000000c1,0x000000c2,
|
||||
0x00050081,0x0000000a,0x000000c4,0x000000c0,0x000000c3,0x0004003d,0x0000000a,0x000000c5,
|
||||
0x00000072,0x0004003d,0x00000009,0x000000c6,0x000000af,0x0005008e,0x0000000a,0x000000c7,
|
||||
0x000000c5,0x000000c6,0x00050081,0x0000000a,0x000000c8,0x000000c4,0x000000c7,0x0004003d,
|
||||
0x0000000a,0x000000c9,0x00000068,0x00050081,0x0000000a,0x000000ca,0x000000c8,0x000000c9,
|
||||
0x0004003d,0x00000009,0x000000cb,0x000000b3,0x0005008e,0x0000000a,0x000000cc,0x000000ca,
|
||||
0x000000cb,0x00060050,0x0000000a,0x000000cd,0x00000032,0x00000032,0x00000032,0x00060050,
|
||||
0x0000000a,0x000000ce,0x00000055,0x00000055,0x00000055,0x0008000c,0x0000000a,0x000000cf,
|
||||
0x00000001,0x0000002b,0x000000cc,0x000000cd,0x000000ce,0x0003003e,0x000000b9,0x000000cf,
|
||||
0x0004003d,0x0000000a,0x000000d2,0x000000b9,0x00050051,0x00000009,0x000000d3,0x000000d2,
|
||||
0x00000000,0x00050051,0x00000009,0x000000d4,0x000000d2,0x00000001,0x00050051,0x00000009,
|
||||
0x000000d5,0x000000d2,0x00000002,0x00070050,0x00000023,0x000000d6,0x000000d3,0x000000d4,
|
||||
0x000000d5,0x00000055,0x0003003e,0x000000d1,0x000000d6,0x000100fd,0x00010038,0x00050036,
|
||||
0x0000000a,0x0000000d,0x00000000,0x0000000b,0x00030037,0x00000008,0x0000000c,0x000200f8,
|
||||
0x0000000e,0x0004003b,0x0000001c,0x0000001d,0x00000007,0x0004003d,0x00000007,0x0000001e,
|
||||
0x0000000c,0x0004006f,0x0000001b,0x0000001f,0x0000001e,0x00050050,0x0000001b,0x00000021,
|
||||
0x00000020,0x00000020,0x00050081,0x0000001b,0x00000022,0x0000001f,0x00000021,0x00050041,
|
||||
0x00000028,0x00000029,0x00000026,0x00000027,0x0004003d,0x0000001b,0x0000002a,0x00000029,
|
||||
0x00050088,0x0000001b,0x0000002b,0x00000022,0x0000002a,0x0003003e,0x0000001d,0x0000002b,
|
||||
0x0004003d,0x0000002d,0x00000030,0x0000002f,0x0004003d,0x0000001b,0x00000031,0x0000001d,
|
||||
0x00070058,0x00000023,0x00000033,0x00000030,0x00000031,0x00000002,0x00000032,0x0008004f,
|
||||
0x0000000a,0x00000034,0x00000033,0x00000033,0x00000000,0x00000001,0x00000002,0x000200fe,
|
||||
0x00000034,0x00010038,0x00050036,0x00000009,0x00000014,0x00000000,0x00000010,0x00030037,
|
||||
0x0000000f,0x00000011,0x00030037,0x0000000f,0x00000012,0x00030037,0x0000000f,0x00000013,
|
||||
0x000200f8,0x00000015,0x0004003d,0x00000009,0x00000037,0x00000011,0x0004003d,0x00000009,
|
||||
0x00000038,0x00000012,0x0004003d,0x00000009,0x00000039,0x00000013,0x0007000c,0x00000009,
|
||||
0x0000003a,0x00000001,0x00000025,0x00000038,0x00000039,0x0007000c,0x00000009,0x0000003b,
|
||||
0x00000001,0x00000025,0x00000037,0x0000003a,0x000200fe,0x0000003b,0x00010038,0x00050036,
|
||||
0x00000009,0x00000019,0x00000000,0x00000010,0x00030037,0x0000000f,0x00000016,0x00030037,
|
||||
0x0000000f,0x00000017,0x00030037,0x0000000f,0x00000018,0x000200f8,0x0000001a,0x0004003d,
|
||||
0x00000009,0x0000003e,0x00000016,0x0004003d,0x00000009,0x0000003f,0x00000017,0x0004003d,
|
||||
0x00000009,0x00000040,0x00000018,0x0007000c,0x00000009,0x00000041,0x00000001,0x00000028,
|
||||
0x0000003f,0x00000040,0x0007000c,0x00000009,0x00000042,0x00000001,0x00000028,0x0000003e,
|
||||
0x00000041,0x000200fe,0x00000042,0x00010038
|
||||
0x07230203,0x00010000,0x0008000b,0x000000d7,0x00000000,0x00020011,0x00000001,0x00020011,
|
||||
0x00000032,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,
|
||||
0x00000000,0x00000001,0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000043,
|
||||
0x000000d1,0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,
|
||||
0x00000004,0x6e69616d,0x00000000,0x00060005,0x0000000d,0x4c736143,0x2864616f,0x3b326976,
|
||||
0x00000000,0x00030005,0x0000000c,0x00000070,0x00070005,0x00000014,0x6e694d41,0x28314633,
|
||||
0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000011,0x00000078,0x00030005,0x00000012,
|
||||
0x00000079,0x00030005,0x00000013,0x0000007a,0x00070005,0x00000019,0x78614d41,0x28314633,
|
||||
0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000016,0x00000078,0x00030005,0x00000017,
|
||||
0x00000079,0x00030005,0x00000018,0x0000007a,0x00030005,0x0000001b,0x00007a73,0x00060005,
|
||||
0x0000001f,0x75706e49,0x78655474,0x65727574,0x00000000,0x00030005,0x00000040,0x00007073,
|
||||
0x00060005,0x00000043,0x67617266,0x43786554,0x64726f6f,0x00000000,0x00030005,0x00000045,
|
||||
0x00004350,0x00040006,0x00000045,0x00000000,0x0063646e,0x00060006,0x00000045,0x00000001,
|
||||
0x6f736572,0x6974756c,0x00006e6f,0x00060006,0x00000045,0x00000002,0x72616873,0x73656e70,
|
||||
0x00000073,0x00030005,0x00000047,0x00006370,0x00040005,0x0000004d,0x6b616570,0x00000000,
|
||||
0x00030005,0x0000005b,0x00000062,0x00040005,0x00000060,0x61726170,0x0000006d,0x00030005,
|
||||
0x00000062,0x00000064,0x00040005,0x00000066,0x61726170,0x0000006d,0x00030005,0x00000068,
|
||||
0x00000065,0x00040005,0x00000069,0x61726170,0x0000006d,0x00030005,0x0000006c,0x00000066,
|
||||
0x00040005,0x00000070,0x61726170,0x0000006d,0x00030005,0x00000072,0x00000068,0x00040005,
|
||||
0x00000076,0x61726170,0x0000006d,0x00030005,0x00000078,0x00476e6d,0x00040005,0x00000079,
|
||||
0x61726170,0x0000006d,0x00040005,0x0000007e,0x61726170,0x0000006d,0x00040005,0x00000081,
|
||||
0x61726170,0x0000006d,0x00040005,0x00000085,0x61726170,0x0000006d,0x00040005,0x00000086,
|
||||
0x61726170,0x0000006d,0x00040005,0x00000089,0x61726170,0x0000006d,0x00030005,0x0000008d,
|
||||
0x0047786d,0x00040005,0x0000008e,0x61726170,0x0000006d,0x00040005,0x00000091,0x61726170,
|
||||
0x0000006d,0x00040005,0x00000094,0x61726170,0x0000006d,0x00040005,0x00000098,0x61726170,
|
||||
0x0000006d,0x00040005,0x00000099,0x61726170,0x0000006d,0x00040005,0x0000009c,0x61726170,
|
||||
0x0000006d,0x00040005,0x000000a0,0x4d706372,0x00000047,0x00040005,0x000000a5,0x47706d61,
|
||||
0x00000000,0x00030005,0x000000af,0x00004777,0x00050005,0x000000b3,0x57706372,0x68676965,
|
||||
0x00000074,0x00030005,0x000000b9,0x00786970,0x00050005,0x000000d1,0x4374756f,0x726f6c6f,
|
||||
0x00000000,0x00030047,0x0000000d,0x00000000,0x00030047,0x00000011,0x00000000,0x00030047,
|
||||
0x00000012,0x00000000,0x00030047,0x00000013,0x00000000,0x00030047,0x00000014,0x00000000,
|
||||
0x00030047,0x00000016,0x00000000,0x00030047,0x00000017,0x00000000,0x00030047,0x00000018,
|
||||
0x00000000,0x00030047,0x00000019,0x00000000,0x00030047,0x0000001f,0x00000000,0x00040047,
|
||||
0x0000001f,0x00000021,0x00000000,0x00040047,0x0000001f,0x00000022,0x00000000,0x00030047,
|
||||
0x00000020,0x00000000,0x00030047,0x00000024,0x00000000,0x00030047,0x0000002e,0x00000000,
|
||||
0x00030047,0x0000002f,0x00000000,0x00030047,0x00000032,0x00000000,0x00030047,0x00000033,
|
||||
0x00000000,0x00030047,0x00000034,0x00000000,0x00030047,0x00000035,0x00000000,0x00030047,
|
||||
0x00000036,0x00000000,0x00030047,0x00000039,0x00000000,0x00030047,0x0000003a,0x00000000,
|
||||
0x00030047,0x0000003b,0x00000000,0x00030047,0x0000003c,0x00000000,0x00030047,0x0000003d,
|
||||
0x00000000,0x00040047,0x00000043,0x0000001e,0x00000000,0x00030047,0x00000045,0x00000002,
|
||||
0x00050048,0x00000045,0x00000000,0x00000023,0x00000000,0x00050048,0x00000045,0x00000001,
|
||||
0x00000023,0x00000010,0x00040048,0x00000045,0x00000002,0x00000000,0x00050048,0x00000045,
|
||||
0x00000002,0x00000023,0x00000018,0x00030047,0x0000004d,0x00000000,0x00030047,0x00000054,
|
||||
0x00000000,0x00030047,0x00000057,0x00000000,0x00030047,0x00000058,0x00000000,0x00030047,
|
||||
0x00000059,0x00000000,0x00030047,0x0000005b,0x00000000,0x00030047,0x00000061,0x00000000,
|
||||
0x00030047,0x00000062,0x00000000,0x00030047,0x00000067,0x00000000,0x00030047,0x00000068,
|
||||
0x00000000,0x00030047,0x0000006b,0x00000000,0x00030047,0x0000006c,0x00000000,0x00030047,
|
||||
0x00000071,0x00000000,0x00030047,0x00000072,0x00000000,0x00030047,0x00000077,0x00000000,
|
||||
0x00030047,0x00000078,0x00000000,0x00030047,0x00000079,0x00000000,0x00030047,0x0000007d,
|
||||
0x00000000,0x00030047,0x0000007e,0x00000000,0x00030047,0x00000080,0x00000000,0x00030047,
|
||||
0x00000081,0x00000000,0x00030047,0x00000083,0x00000000,0x00030047,0x00000084,0x00000000,
|
||||
0x00030047,0x00000085,0x00000000,0x00030047,0x00000086,0x00000000,0x00030047,0x00000088,
|
||||
0x00000000,0x00030047,0x00000089,0x00000000,0x00030047,0x0000008b,0x00000000,0x00030047,
|
||||
0x0000008c,0x00000000,0x00030047,0x0000008d,0x00000000,0x00030047,0x0000008e,0x00000000,
|
||||
0x00030047,0x00000090,0x00000000,0x00030047,0x00000091,0x00000000,0x00030047,0x00000093,
|
||||
0x00000000,0x00030047,0x00000094,0x00000000,0x00030047,0x00000096,0x00000000,0x00030047,
|
||||
0x00000097,0x00000000,0x00030047,0x00000098,0x00000000,0x00030047,0x00000099,0x00000000,
|
||||
0x00030047,0x0000009b,0x00000000,0x00030047,0x0000009c,0x00000000,0x00030047,0x0000009e,
|
||||
0x00000000,0x00030047,0x0000009f,0x00000000,0x00030047,0x000000a0,0x00000000,0x00030047,
|
||||
0x000000a1,0x00000000,0x00030047,0x000000a3,0x00000000,0x00030047,0x000000a4,0x00000000,
|
||||
0x00030047,0x000000a5,0x00000000,0x00030047,0x000000a6,0x00000000,0x00030047,0x000000a7,
|
||||
0x00000000,0x00030047,0x000000a8,0x00000000,0x00030047,0x000000a9,0x00000000,0x00030047,
|
||||
0x000000aa,0x00000000,0x00030047,0x000000ab,0x00000000,0x00030047,0x000000ac,0x00000000,
|
||||
0x00030047,0x000000ad,0x00000000,0x00030047,0x000000ae,0x00000000,0x00030047,0x000000af,
|
||||
0x00000000,0x00030047,0x000000b0,0x00000000,0x00030047,0x000000b1,0x00000000,0x00030047,
|
||||
0x000000b2,0x00000000,0x00030047,0x000000b3,0x00000000,0x00030047,0x000000b5,0x00000000,
|
||||
0x00030047,0x000000b6,0x00000000,0x00030047,0x000000b7,0x00000000,0x00030047,0x000000b8,
|
||||
0x00000000,0x00030047,0x000000b9,0x00000000,0x00030047,0x000000ba,0x00000000,0x00030047,
|
||||
0x000000bb,0x00000000,0x00030047,0x000000bc,0x00000000,0x00030047,0x000000bd,0x00000000,
|
||||
0x00030047,0x000000be,0x00000000,0x00030047,0x000000bf,0x00000000,0x00030047,0x000000c0,
|
||||
0x00000000,0x00030047,0x000000c1,0x00000000,0x00030047,0x000000c2,0x00000000,0x00030047,
|
||||
0x000000c3,0x00000000,0x00030047,0x000000c4,0x00000000,0x00030047,0x000000c5,0x00000000,
|
||||
0x00030047,0x000000c6,0x00000000,0x00030047,0x000000c7,0x00000000,0x00030047,0x000000c8,
|
||||
0x00000000,0x00030047,0x000000c9,0x00000000,0x00030047,0x000000ca,0x00000000,0x00030047,
|
||||
0x000000cb,0x00000000,0x00030047,0x000000cc,0x00000000,0x00030047,0x000000cd,0x00000000,
|
||||
0x00030047,0x000000ce,0x00000000,0x00030047,0x000000cf,0x00000000,0x00030047,0x000000d1,
|
||||
0x00000000,0x00040047,0x000000d1,0x0000001e,0x00000000,0x00030047,0x000000d2,0x00000000,
|
||||
0x00030047,0x000000d3,0x00000000,0x00030047,0x000000d4,0x00000000,0x00030047,0x000000d5,
|
||||
0x00000000,0x00030047,0x000000d6,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,
|
||||
0x00000002,0x00040015,0x00000006,0x00000020,0x00000001,0x00040017,0x00000007,0x00000006,
|
||||
0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x00030016,0x00000009,0x00000020,
|
||||
0x00040017,0x0000000a,0x00000009,0x00000003,0x00040021,0x0000000b,0x0000000a,0x00000008,
|
||||
0x00040020,0x0000000f,0x00000007,0x00000009,0x00060021,0x00000010,0x00000009,0x0000000f,
|
||||
0x0000000f,0x0000000f,0x00090019,0x0000001c,0x00000009,0x00000001,0x00000000,0x00000000,
|
||||
0x00000000,0x00000001,0x00000000,0x0003001b,0x0000001d,0x0000001c,0x00040020,0x0000001e,
|
||||
0x00000000,0x0000001d,0x0004003b,0x0000001e,0x0000001f,0x00000000,0x0004002b,0x00000006,
|
||||
0x00000021,0x00000000,0x0005002c,0x00000007,0x00000026,0x00000021,0x00000021,0x0004002b,
|
||||
0x00000006,0x00000028,0x00000001,0x0005002c,0x00000007,0x00000029,0x00000028,0x00000028,
|
||||
0x00040017,0x0000002d,0x00000009,0x00000004,0x00040017,0x00000041,0x00000009,0x00000002,
|
||||
0x00040020,0x00000042,0x00000001,0x00000041,0x0004003b,0x00000042,0x00000043,0x00000001,
|
||||
0x0005001e,0x00000045,0x0000002d,0x00000041,0x00000009,0x00040020,0x00000046,0x00000009,
|
||||
0x00000045,0x0004003b,0x00000046,0x00000047,0x00000009,0x00040020,0x00000048,0x00000009,
|
||||
0x00000041,0x0004002b,0x00000009,0x0000004e,0xbf800000,0x0004002b,0x00000009,0x0000004f,
|
||||
0x41000000,0x0004002b,0x00000009,0x00000050,0x40a00000,0x0004002b,0x00000006,0x00000051,
|
||||
0x00000002,0x00040020,0x00000052,0x00000009,0x00000009,0x0004002b,0x00000009,0x00000055,
|
||||
0x00000000,0x0004002b,0x00000009,0x00000056,0x3f800000,0x00040020,0x0000005a,0x00000007,
|
||||
0x0000000a,0x0004002b,0x00000006,0x0000005d,0xffffffff,0x0005002c,0x00000007,0x0000005e,
|
||||
0x00000021,0x0000005d,0x0005002c,0x00000007,0x00000064,0x0000005d,0x00000021,0x0005002c,
|
||||
0x00000007,0x0000006e,0x00000028,0x00000021,0x0005002c,0x00000007,0x00000074,0x00000021,
|
||||
0x00000028,0x00040015,0x0000007a,0x00000020,0x00000000,0x0004002b,0x0000007a,0x0000007b,
|
||||
0x00000001,0x0004002b,0x00000009,0x000000a2,0x3a800000,0x0004002b,0x00000009,0x000000b4,
|
||||
0x40800000,0x00040020,0x000000d0,0x00000003,0x0000002d,0x0004003b,0x000000d0,0x000000d1,
|
||||
0x00000003,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,
|
||||
0x0004003b,0x00000008,0x00000040,0x00000007,0x0004003b,0x0000000f,0x0000004d,0x00000007,
|
||||
0x0004003b,0x0000005a,0x0000005b,0x00000007,0x0004003b,0x00000008,0x00000060,0x00000007,
|
||||
0x0004003b,0x0000005a,0x00000062,0x00000007,0x0004003b,0x00000008,0x00000066,0x00000007,
|
||||
0x0004003b,0x0000005a,0x00000068,0x00000007,0x0004003b,0x00000008,0x00000069,0x00000007,
|
||||
0x0004003b,0x0000005a,0x0000006c,0x00000007,0x0004003b,0x00000008,0x00000070,0x00000007,
|
||||
0x0004003b,0x0000005a,0x00000072,0x00000007,0x0004003b,0x00000008,0x00000076,0x00000007,
|
||||
0x0004003b,0x0000000f,0x00000078,0x00000007,0x0004003b,0x0000000f,0x00000079,0x00000007,
|
||||
0x0004003b,0x0000000f,0x0000007e,0x00000007,0x0004003b,0x0000000f,0x00000081,0x00000007,
|
||||
0x0004003b,0x0000000f,0x00000085,0x00000007,0x0004003b,0x0000000f,0x00000086,0x00000007,
|
||||
0x0004003b,0x0000000f,0x00000089,0x00000007,0x0004003b,0x0000000f,0x0000008d,0x00000007,
|
||||
0x0004003b,0x0000000f,0x0000008e,0x00000007,0x0004003b,0x0000000f,0x00000091,0x00000007,
|
||||
0x0004003b,0x0000000f,0x00000094,0x00000007,0x0004003b,0x0000000f,0x00000098,0x00000007,
|
||||
0x0004003b,0x0000000f,0x00000099,0x00000007,0x0004003b,0x0000000f,0x0000009c,0x00000007,
|
||||
0x0004003b,0x0000000f,0x000000a0,0x00000007,0x0004003b,0x0000000f,0x000000a5,0x00000007,
|
||||
0x0004003b,0x0000000f,0x000000af,0x00000007,0x0004003b,0x0000000f,0x000000b3,0x00000007,
|
||||
0x0004003b,0x0000005a,0x000000b9,0x00000007,0x0004003d,0x00000041,0x00000044,0x00000043,
|
||||
0x00050041,0x00000048,0x00000049,0x00000047,0x00000028,0x0004003d,0x00000041,0x0000004a,
|
||||
0x00000049,0x00050085,0x00000041,0x0000004b,0x00000044,0x0000004a,0x0004006e,0x00000007,
|
||||
0x0000004c,0x0000004b,0x0003003e,0x00000040,0x0000004c,0x00050041,0x00000052,0x00000053,
|
||||
0x00000047,0x00000051,0x0004003d,0x00000009,0x00000054,0x00000053,0x0008000c,0x00000009,
|
||||
0x00000057,0x00000001,0x0000002b,0x00000054,0x00000055,0x00000056,0x0008000c,0x00000009,
|
||||
0x00000058,0x00000001,0x0000002e,0x0000004f,0x00000050,0x00000057,0x00050088,0x00000009,
|
||||
0x00000059,0x0000004e,0x00000058,0x0003003e,0x0000004d,0x00000059,0x0004003d,0x00000007,
|
||||
0x0000005c,0x00000040,0x00050080,0x00000007,0x0000005f,0x0000005c,0x0000005e,0x0003003e,
|
||||
0x00000060,0x0000005f,0x00050039,0x0000000a,0x00000061,0x0000000d,0x00000060,0x0003003e,
|
||||
0x0000005b,0x00000061,0x0004003d,0x00000007,0x00000063,0x00000040,0x00050080,0x00000007,
|
||||
0x00000065,0x00000063,0x00000064,0x0003003e,0x00000066,0x00000065,0x00050039,0x0000000a,
|
||||
0x00000067,0x0000000d,0x00000066,0x0003003e,0x00000062,0x00000067,0x0004003d,0x00000007,
|
||||
0x0000006a,0x00000040,0x0003003e,0x00000069,0x0000006a,0x00050039,0x0000000a,0x0000006b,
|
||||
0x0000000d,0x00000069,0x0003003e,0x00000068,0x0000006b,0x0004003d,0x00000007,0x0000006d,
|
||||
0x00000040,0x00050080,0x00000007,0x0000006f,0x0000006d,0x0000006e,0x0003003e,0x00000070,
|
||||
0x0000006f,0x00050039,0x0000000a,0x00000071,0x0000000d,0x00000070,0x0003003e,0x0000006c,
|
||||
0x00000071,0x0004003d,0x00000007,0x00000073,0x00000040,0x00050080,0x00000007,0x00000075,
|
||||
0x00000073,0x00000074,0x0003003e,0x00000076,0x00000075,0x00050039,0x0000000a,0x00000077,
|
||||
0x0000000d,0x00000076,0x0003003e,0x00000072,0x00000077,0x00050041,0x0000000f,0x0000007c,
|
||||
0x00000062,0x0000007b,0x0004003d,0x00000009,0x0000007d,0x0000007c,0x0003003e,0x00000079,
|
||||
0x0000007d,0x00050041,0x0000000f,0x0000007f,0x00000068,0x0000007b,0x0004003d,0x00000009,
|
||||
0x00000080,0x0000007f,0x0003003e,0x0000007e,0x00000080,0x00050041,0x0000000f,0x00000082,
|
||||
0x0000006c,0x0000007b,0x0004003d,0x00000009,0x00000083,0x00000082,0x0003003e,0x00000081,
|
||||
0x00000083,0x00070039,0x00000009,0x00000084,0x00000014,0x00000079,0x0000007e,0x00000081,
|
||||
0x0003003e,0x00000085,0x00000084,0x00050041,0x0000000f,0x00000087,0x0000005b,0x0000007b,
|
||||
0x0004003d,0x00000009,0x00000088,0x00000087,0x0003003e,0x00000086,0x00000088,0x00050041,
|
||||
0x0000000f,0x0000008a,0x00000072,0x0000007b,0x0004003d,0x00000009,0x0000008b,0x0000008a,
|
||||
0x0003003e,0x00000089,0x0000008b,0x00070039,0x00000009,0x0000008c,0x00000014,0x00000085,
|
||||
0x00000086,0x00000089,0x0003003e,0x00000078,0x0000008c,0x00050041,0x0000000f,0x0000008f,
|
||||
0x00000062,0x0000007b,0x0004003d,0x00000009,0x00000090,0x0000008f,0x0003003e,0x0000008e,
|
||||
0x00000090,0x00050041,0x0000000f,0x00000092,0x00000068,0x0000007b,0x0004003d,0x00000009,
|
||||
0x00000093,0x00000092,0x0003003e,0x00000091,0x00000093,0x00050041,0x0000000f,0x00000095,
|
||||
0x0000006c,0x0000007b,0x0004003d,0x00000009,0x00000096,0x00000095,0x0003003e,0x00000094,
|
||||
0x00000096,0x00070039,0x00000009,0x00000097,0x00000019,0x0000008e,0x00000091,0x00000094,
|
||||
0x0003003e,0x00000098,0x00000097,0x00050041,0x0000000f,0x0000009a,0x0000005b,0x0000007b,
|
||||
0x0004003d,0x00000009,0x0000009b,0x0000009a,0x0003003e,0x00000099,0x0000009b,0x00050041,
|
||||
0x0000000f,0x0000009d,0x00000072,0x0000007b,0x0004003d,0x00000009,0x0000009e,0x0000009d,
|
||||
0x0003003e,0x0000009c,0x0000009e,0x00070039,0x00000009,0x0000009f,0x00000019,0x00000098,
|
||||
0x00000099,0x0000009c,0x0003003e,0x0000008d,0x0000009f,0x0004003d,0x00000009,0x000000a1,
|
||||
0x0000008d,0x0007000c,0x00000009,0x000000a3,0x00000001,0x00000028,0x000000a1,0x000000a2,
|
||||
0x00050088,0x00000009,0x000000a4,0x00000056,0x000000a3,0x0003003e,0x000000a0,0x000000a4,
|
||||
0x0004003d,0x00000009,0x000000a6,0x00000078,0x0004003d,0x00000009,0x000000a7,0x0000008d,
|
||||
0x00050083,0x00000009,0x000000a8,0x00000056,0x000000a7,0x0007000c,0x00000009,0x000000a9,
|
||||
0x00000001,0x00000025,0x000000a6,0x000000a8,0x0004003d,0x00000009,0x000000aa,0x000000a0,
|
||||
0x00050085,0x00000009,0x000000ab,0x000000a9,0x000000aa,0x0008000c,0x00000009,0x000000ac,
|
||||
0x00000001,0x0000002b,0x000000ab,0x00000055,0x00000056,0x0003003e,0x000000a5,0x000000ac,
|
||||
0x0004003d,0x00000009,0x000000ad,0x000000a5,0x0006000c,0x00000009,0x000000ae,0x00000001,
|
||||
0x0000001f,0x000000ad,0x0003003e,0x000000a5,0x000000ae,0x0004003d,0x00000009,0x000000b0,
|
||||
0x000000a5,0x0004003d,0x00000009,0x000000b1,0x0000004d,0x00050085,0x00000009,0x000000b2,
|
||||
0x000000b0,0x000000b1,0x0003003e,0x000000af,0x000000b2,0x0004003d,0x00000009,0x000000b5,
|
||||
0x000000af,0x00050085,0x00000009,0x000000b6,0x000000b4,0x000000b5,0x00050081,0x00000009,
|
||||
0x000000b7,0x00000056,0x000000b6,0x00050088,0x00000009,0x000000b8,0x00000056,0x000000b7,
|
||||
0x0003003e,0x000000b3,0x000000b8,0x0004003d,0x0000000a,0x000000ba,0x0000005b,0x0004003d,
|
||||
0x00000009,0x000000bb,0x000000af,0x0005008e,0x0000000a,0x000000bc,0x000000ba,0x000000bb,
|
||||
0x0004003d,0x0000000a,0x000000bd,0x00000062,0x0004003d,0x00000009,0x000000be,0x000000af,
|
||||
0x0005008e,0x0000000a,0x000000bf,0x000000bd,0x000000be,0x00050081,0x0000000a,0x000000c0,
|
||||
0x000000bc,0x000000bf,0x0004003d,0x0000000a,0x000000c1,0x0000006c,0x0004003d,0x00000009,
|
||||
0x000000c2,0x000000af,0x0005008e,0x0000000a,0x000000c3,0x000000c1,0x000000c2,0x00050081,
|
||||
0x0000000a,0x000000c4,0x000000c0,0x000000c3,0x0004003d,0x0000000a,0x000000c5,0x00000072,
|
||||
0x0004003d,0x00000009,0x000000c6,0x000000af,0x0005008e,0x0000000a,0x000000c7,0x000000c5,
|
||||
0x000000c6,0x00050081,0x0000000a,0x000000c8,0x000000c4,0x000000c7,0x0004003d,0x0000000a,
|
||||
0x000000c9,0x00000068,0x00050081,0x0000000a,0x000000ca,0x000000c8,0x000000c9,0x0004003d,
|
||||
0x00000009,0x000000cb,0x000000b3,0x0005008e,0x0000000a,0x000000cc,0x000000ca,0x000000cb,
|
||||
0x00060050,0x0000000a,0x000000cd,0x00000055,0x00000055,0x00000055,0x00060050,0x0000000a,
|
||||
0x000000ce,0x00000056,0x00000056,0x00000056,0x0008000c,0x0000000a,0x000000cf,0x00000001,
|
||||
0x0000002b,0x000000cc,0x000000cd,0x000000ce,0x0003003e,0x000000b9,0x000000cf,0x0004003d,
|
||||
0x0000000a,0x000000d2,0x000000b9,0x00050051,0x00000009,0x000000d3,0x000000d2,0x00000000,
|
||||
0x00050051,0x00000009,0x000000d4,0x000000d2,0x00000001,0x00050051,0x00000009,0x000000d5,
|
||||
0x000000d2,0x00000002,0x00070050,0x0000002d,0x000000d6,0x000000d3,0x000000d4,0x000000d5,
|
||||
0x00000056,0x0003003e,0x000000d1,0x000000d6,0x000100fd,0x00010038,0x00050036,0x0000000a,
|
||||
0x0000000d,0x00000000,0x0000000b,0x00030037,0x00000008,0x0000000c,0x000200f8,0x0000000e,
|
||||
0x0004003b,0x00000008,0x0000001b,0x00000007,0x0004003d,0x0000001d,0x00000020,0x0000001f,
|
||||
0x00040064,0x0000001c,0x00000022,0x00000020,0x00050067,0x00000007,0x00000023,0x00000022,
|
||||
0x00000021,0x0003003e,0x0000001b,0x00000023,0x0004003d,0x0000001d,0x00000024,0x0000001f,
|
||||
0x0004003d,0x00000007,0x00000025,0x0000000c,0x0004003d,0x00000007,0x00000027,0x0000001b,
|
||||
0x00050082,0x00000007,0x0000002a,0x00000027,0x00000029,0x0008000c,0x00000007,0x0000002b,
|
||||
0x00000001,0x0000002d,0x00000025,0x00000026,0x0000002a,0x00040064,0x0000001c,0x0000002c,
|
||||
0x00000024,0x0007005f,0x0000002d,0x0000002e,0x0000002c,0x0000002b,0x00000002,0x00000021,
|
||||
0x0008004f,0x0000000a,0x0000002f,0x0000002e,0x0000002e,0x00000000,0x00000001,0x00000002,
|
||||
0x000200fe,0x0000002f,0x00010038,0x00050036,0x00000009,0x00000014,0x00000000,0x00000010,
|
||||
0x00030037,0x0000000f,0x00000011,0x00030037,0x0000000f,0x00000012,0x00030037,0x0000000f,
|
||||
0x00000013,0x000200f8,0x00000015,0x0004003d,0x00000009,0x00000032,0x00000011,0x0004003d,
|
||||
0x00000009,0x00000033,0x00000012,0x0004003d,0x00000009,0x00000034,0x00000013,0x0007000c,
|
||||
0x00000009,0x00000035,0x00000001,0x00000025,0x00000033,0x00000034,0x0007000c,0x00000009,
|
||||
0x00000036,0x00000001,0x00000025,0x00000032,0x00000035,0x000200fe,0x00000036,0x00010038,
|
||||
0x00050036,0x00000009,0x00000019,0x00000000,0x00000010,0x00030037,0x0000000f,0x00000016,
|
||||
0x00030037,0x0000000f,0x00000017,0x00030037,0x0000000f,0x00000018,0x000200f8,0x0000001a,
|
||||
0x0004003d,0x00000009,0x00000039,0x00000016,0x0004003d,0x00000009,0x0000003a,0x00000017,
|
||||
0x0004003d,0x00000009,0x0000003b,0x00000018,0x0007000c,0x00000009,0x0000003c,0x00000001,
|
||||
0x00000028,0x0000003a,0x0000003b,0x0007000c,0x00000009,0x0000003d,0x00000001,0x00000028,
|
||||
0x00000039,0x0000003c,0x000200fe,0x0000003d,0x00010038
|
||||
};
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "droiddeck-ahb-v1-server-protocol.h"
|
||||
#include <android/hardware_buffer.h>
|
||||
#include <errno.h>
|
||||
#include <linux/sync_file.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <pthread.h>
|
||||
@@ -146,12 +145,6 @@ static void handle_released(uint64_t id, int fd) {
|
||||
if (poll(&p, 1, 0) > 0) {
|
||||
close(fd);
|
||||
} else {
|
||||
if (ab->fence_src) {
|
||||
struct sync_merge_data m = {.name = "droiddeck-release", .fd2 = fd};
|
||||
if (ioctl(ab->fence_fd, SYNC_IOC_MERGE, &m) == 0) { close(fd); fd = m.fence; }
|
||||
wl_event_source_remove(ab->fence_src);
|
||||
close(ab->fence_fd);
|
||||
}
|
||||
ab->fence_fd = fd;
|
||||
ab->fence_src = wl_event_loop_add_fd(g_loop, fd, WL_EVENT_READABLE, on_fence_readable, ab);
|
||||
if (!ab->fence_src) { close(fd); ab->fence_fd = -1; }
|
||||
@@ -159,7 +152,6 @@ static void handle_released(uint64_t id, int fd) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ab->fence_src) return;
|
||||
send_deferred_release(ab);
|
||||
maybe_free(ab);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "blend_pass.h"
|
||||
#include "vk_loader.h"
|
||||
#include "vk_present.h"
|
||||
#include "framegen_bridge.h"
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -70,7 +69,6 @@ static struct fx_settings g_set = {
|
||||
.gamma = 1.0f, .saturation = 1.0f, .s_raw = 100.0f, .look = "Off"};
|
||||
static volatile int g_changed;
|
||||
static struct fx_settings g_cur;
|
||||
static struct fx_settings g_generated_settings;
|
||||
static int g_cur_valid;
|
||||
|
||||
static void set_begin(void) { pthread_mutex_lock(&g_lock); }
|
||||
@@ -237,24 +235,13 @@ static VkDescriptorPool g_dpool;
|
||||
static VkSampler g_sampler;
|
||||
enum { P_SGSR, P_SGSR_HQ, P_NIS, P_EASU, P_RCAS, P_CAS, P_COLOR, P_FXAA, P_FXAA_TOON, P_SMAA_EDGE, P_SMAA_WEIGHTS, P_SMAA_BLEND, P_TOON, P_TOON_COLOR, P_HDR, P_NTSC, P_CRT, P_DEBAND, P_NIS_LUMA, P_COUNT };
|
||||
static VkPipeline g_pipe[P_COUNT];
|
||||
struct fx_context {
|
||||
struct fx_target targets[2], mid, nissrc;
|
||||
struct { VkImage img; VkImageView view; VkDescriptorSet ds; int w, h; } scene;
|
||||
};
|
||||
#define FX_CONTEXTS (VKP_FG_MAX_GENERATIONS + 2)
|
||||
static struct fx_context g_contexts[FX_CONTEXTS];
|
||||
static int g_context;
|
||||
#define g_t (g_contexts[g_context].targets)
|
||||
#define g_mid (g_contexts[g_context].mid)
|
||||
#define g_nissrc (g_contexts[g_context].nissrc)
|
||||
static struct fx_target g_smaa_edges, g_smaa_weights;
|
||||
static struct fx_target g_t[2], g_mid, g_smaa_edges, g_smaa_weights;
|
||||
/* Half set: NIS = nis_luma prepass (scene rgb + luma in alpha, scene size) into g_nissrc, then
|
||||
* nis3 gathers its luma from that alpha, its coefficient banks (nis_coef.h) in a uniform buffer
|
||||
* at descriptor set 1 (g_pl_nis = {g_dsl, g_coef_dsl}, same push-constant range as g_pl).
|
||||
* Old set (or no buffer): nis.frag on the scene, P_NIS_LUMA unused. */
|
||||
static struct fx_target g_nissrc;
|
||||
static int g_nis_fast;
|
||||
static int g_nis_attempted;
|
||||
static int g_upscale_half;
|
||||
static VkDescriptorSetLayout g_coef_dsl;
|
||||
static VkPipelineLayout g_pl_nis;
|
||||
static VkDescriptorPool g_coef_pool;
|
||||
@@ -262,7 +249,7 @@ static VkDescriptorSet g_coef_ds;
|
||||
static VkBuffer g_coef_buf;
|
||||
static VkDeviceMemory g_coef_mem;
|
||||
|
||||
#define g_scene (g_contexts[g_context].scene)
|
||||
static struct { VkImage img; VkImageView view; VkDescriptorSet ds; int w, h; } g_scene;
|
||||
|
||||
void vkp_effects_bind_device(VkDevice dev, VkPhysicalDevice pd,
|
||||
const VkPhysicalDeviceMemoryProperties *memprops) {
|
||||
@@ -360,15 +347,7 @@ static void scene_release(void) {
|
||||
}
|
||||
|
||||
void vkp_effects_forget_image(VkImage img) {
|
||||
int saved = g_context;
|
||||
for (g_context = 0; g_context < FX_CONTEXTS; g_context++)
|
||||
if (img && g_scene.img == img) scene_release();
|
||||
g_context = saved;
|
||||
}
|
||||
|
||||
void vkp_effects_release_generated_sources(void) {
|
||||
for (g_context = 1; g_context < FX_CONTEXTS; g_context++) scene_release();
|
||||
g_context = 0;
|
||||
if (img && g_scene.img == img) scene_release();
|
||||
}
|
||||
|
||||
static int scene_ensure(VkImage img, int w, int h) {
|
||||
@@ -494,14 +473,9 @@ static int upscale_half_set(void) {
|
||||
|
||||
static void objects_destroy(void) {
|
||||
if (!g_dev) return;
|
||||
int saved = g_context;
|
||||
for (g_context = 0; g_context < FX_CONTEXTS; g_context++) {
|
||||
scene_release();
|
||||
target_destroy(&g_t[0]); target_destroy(&g_t[1]); target_destroy(&g_mid);
|
||||
target_destroy(&g_nissrc);
|
||||
}
|
||||
g_context = saved;
|
||||
target_destroy(&g_smaa_edges); target_destroy(&g_smaa_weights);
|
||||
scene_release();
|
||||
target_destroy(&g_t[0]); target_destroy(&g_t[1]); target_destroy(&g_mid);
|
||||
target_destroy(&g_smaa_edges); target_destroy(&g_smaa_weights); target_destroy(&g_nissrc);
|
||||
for (int i = 0; i < P_COUNT; i++) { if (g_pipe[i]) g_vk.DestroyPipeline(g_dev, g_pipe[i], NULL); g_pipe[i] = VK_NULL_HANDLE; }
|
||||
if (g_dpool) g_vk.DestroyDescriptorPool(g_dev, g_dpool, NULL);
|
||||
if (g_pl) g_vk.DestroyPipelineLayout(g_dev, g_pl, NULL);
|
||||
@@ -512,7 +486,6 @@ static void objects_destroy(void) {
|
||||
if (g_rp) g_vk.DestroyRenderPass(g_dev, g_rp, NULL);
|
||||
g_dpool = VK_NULL_HANDLE; g_pl = VK_NULL_HANDLE; g_dsl = VK_NULL_HANDLE;
|
||||
g_sampler = VK_NULL_HANDLE; g_rp = VK_NULL_HANDLE; g_smaa_rp = VK_NULL_HANDLE;
|
||||
g_nis_fast = 0; g_nis_attempted = 0; g_upscale_half = 0;
|
||||
g_ready = 0;
|
||||
}
|
||||
|
||||
@@ -532,9 +505,7 @@ void vkp_effects_set_formats(VkFormat scene_fmt, VkFormat target_fmt, int scene_
|
||||
: target_fmt == VK_FORMAT_R16G16B16A16_SFLOAT ? "the HDR picture for frame generation"
|
||||
: "the HDR composition's picture: PQ, or tone-mapped SDR with HDR output off");
|
||||
} else if (scene_fmt != g_scene_fmt) {
|
||||
int saved = g_context;
|
||||
for (g_context = 0; g_context < FX_CONTEXTS; g_context++) scene_release();
|
||||
g_context = saved;
|
||||
scene_release();
|
||||
g_scene_fmt = scene_fmt;
|
||||
}
|
||||
}
|
||||
@@ -585,112 +556,81 @@ static int objects_ensure(void) {
|
||||
VkPipelineLayoutCreateInfo pli = {.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .setLayoutCount = 2, .pSetLayouts = set_layouts,
|
||||
.pushConstantRangeCount = 1, .pPushConstantRanges = &pcr};
|
||||
if (g_vk.CreatePipelineLayout(g_dev, &pli, NULL, &g_pl) != VK_SUCCESS) goto fail;
|
||||
VkDescriptorPoolSize ps = {VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, FX_CONTEXTS * 5 + 2};
|
||||
VkDescriptorPoolSize ps = {VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 10};
|
||||
VkDescriptorPoolCreateInfo dpi = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
||||
.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, .maxSets = FX_CONTEXTS * 5 + 2,
|
||||
.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, .maxSets = 10,
|
||||
.poolSizeCount = 1, .pPoolSizes = &ps};
|
||||
if (g_vk.CreateDescriptorPool(g_dev, &dpi, NULL, &g_dpool) != VK_SUCCESS) goto fail;
|
||||
|
||||
g_upscale_half = upscale_half_set();
|
||||
VkShaderModule vert = shader(upscale_vert_code, sizeof(upscale_vert_code));
|
||||
if (!vert) goto fail;
|
||||
#define MKL(slot, code, name, layout) do { g_pipe[slot] = post_pipeline_for_renderpass(vert, code, sizeof(code), g_rp, name, layout); if (!g_pipe[slot]) { g_vk.DestroyShaderModule(g_dev, vert, NULL); goto fail; } } while (0)
|
||||
#define MK(slot, code, name) MKL(slot, code, name, g_pl)
|
||||
const int half = upscale_half_set();
|
||||
g_nis_fast = 0;
|
||||
g_nis_attempted = 0;
|
||||
g_ready = 1;
|
||||
droiddeck_log("effects", "shared resources ready on %s; effect pipelines are created when needed", vkp_gpu_name());
|
||||
return 0;
|
||||
fail:
|
||||
objects_destroy();
|
||||
g_ready = -1;
|
||||
droiddeck_log("error", "effects: the screen-effect chain could not be built on this driver; effects are off for this session");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int chain_failed(void) {
|
||||
objects_destroy();
|
||||
g_ready = -1;
|
||||
droiddeck_log("error", "effects: the screen-effect chain could not be built on this driver; effects are off for this session");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int pipelines_ensure(int spatial, const struct fx_settings *s) {
|
||||
VkShaderModule vert = VK_NULL_HANDLE;
|
||||
#define MKL(needed, slot, code, name, render_pass, layout) do { \
|
||||
if ((needed) && !g_pipe[slot]) { \
|
||||
if (!vert && !(vert = shader(upscale_vert_code, sizeof(upscale_vert_code)))) goto fail; \
|
||||
g_pipe[slot] = post_pipeline_for_renderpass(vert, code, sizeof(code), render_pass, name, layout); \
|
||||
if (!g_pipe[slot]) goto fail; \
|
||||
} \
|
||||
} while (0)
|
||||
#define MK(needed, slot, code, name) MKL(needed, slot, code, name, g_rp, g_pl)
|
||||
if (spatial == 3) {
|
||||
if (g_upscale_half) MK(1, P_SGSR, sgsr_half_code, "sgsr_half");
|
||||
else MK(1, P_SGSR, sgsr_code, "sgsr");
|
||||
}
|
||||
if (spatial == 8) {
|
||||
if (g_upscale_half) MK(1, P_SGSR_HQ, sgsr_quality_half_code, "sgsr_quality_half");
|
||||
else MK(1, P_SGSR_HQ, sgsr_quality_code, "sgsr_quality");
|
||||
}
|
||||
if (spatial == 4 || spatial == 5) {
|
||||
if (g_upscale_half) MK(1, P_EASU, fsr_easu_half_code, "fsr_easu_half");
|
||||
else MK(1, P_EASU, fsr_easu_code, "fsr_easu");
|
||||
if (s->sharp_pct != 0) {
|
||||
if (g_upscale_half) MK(1, P_RCAS, fsr_rcas_half_code, "fsr_rcas_half");
|
||||
else MK(1, P_RCAS, fsr_rcas_code, "fsr_rcas");
|
||||
}
|
||||
}
|
||||
if (spatial == 6) {
|
||||
if (g_upscale_half) MK(1, P_RCAS, fsr_rcas_half_code, "fsr_rcas_half");
|
||||
else MK(1, P_RCAS, fsr_rcas_code, "fsr_rcas");
|
||||
}
|
||||
if (spatial == 7) {
|
||||
if (g_upscale_half && !g_nis_attempted) {
|
||||
g_nis_attempted = 1;
|
||||
if (!fx_alpha_holds_luma(g_fx_fmt))
|
||||
droiddeck_log("effects", "NIS uses nis.frag: the chain format has no 8-bit alpha for the luma prepass");
|
||||
else if (coef_create() != 0)
|
||||
droiddeck_log("effects", "NIS coefficient buffer unavailable; NIS uses nis.frag");
|
||||
else {
|
||||
if (!vert && !(vert = shader(upscale_vert_code, sizeof(upscale_vert_code)))) goto fail;
|
||||
g_pipe[P_NIS] = post_pipeline_for_renderpass(vert, nis3_half_code, sizeof(nis3_half_code), g_rp, "nis3_half", g_pl_nis);
|
||||
if (g_pipe[P_NIS])
|
||||
g_pipe[P_NIS_LUMA] = post_pipeline_for_renderpass(vert, nis_luma_half_code, sizeof(nis_luma_half_code), g_rp, "nis_luma_half", g_pl);
|
||||
if (g_pipe[P_NIS] && g_pipe[P_NIS_LUMA]) g_nis_fast = 1;
|
||||
else {
|
||||
if (g_pipe[P_NIS]) g_vk.DestroyPipeline(g_dev, g_pipe[P_NIS], NULL);
|
||||
if (g_pipe[P_NIS_LUMA]) g_vk.DestroyPipeline(g_dev, g_pipe[P_NIS_LUMA], NULL);
|
||||
g_pipe[P_NIS] = VK_NULL_HANDLE;
|
||||
g_pipe[P_NIS_LUMA] = VK_NULL_HANDLE;
|
||||
coef_destroy();
|
||||
droiddeck_log("effects", "fast NIS pipelines failed to build; NIS uses nis.frag");
|
||||
}
|
||||
if (half && !fx_alpha_holds_luma(g_fx_fmt))
|
||||
droiddeck_log("effects", "NIS uses nis.frag: the chain format has no 8-bit alpha for the luma prepass");
|
||||
else if (half && coef_create() != 0)
|
||||
droiddeck_log("effects", "NIS coefficient buffer unavailable; NIS uses nis.frag");
|
||||
else if (half)
|
||||
g_nis_fast = 1;
|
||||
if (half) {
|
||||
MK(P_SGSR, sgsr_half_code, "sgsr_half");
|
||||
MK(P_SGSR_HQ, sgsr_quality_half_code, "sgsr_quality_half");
|
||||
if (g_nis_fast) {
|
||||
/* optional: a driver that rejects either fast NIS pipeline gets nis.frag, not a dead chain */
|
||||
g_pipe[P_NIS] = post_pipeline_for_renderpass(vert, nis3_half_code, sizeof(nis3_half_code), g_rp, "nis3_half", g_pl_nis);
|
||||
g_pipe[P_NIS_LUMA] = g_pipe[P_NIS]
|
||||
? post_pipeline_for_renderpass(vert, nis_luma_half_code, sizeof(nis_luma_half_code), g_rp, "nis_luma_half", g_pl)
|
||||
: VK_NULL_HANDLE;
|
||||
if (!g_pipe[P_NIS] || !g_pipe[P_NIS_LUMA]) {
|
||||
if (g_pipe[P_NIS]) g_vk.DestroyPipeline(g_dev, g_pipe[P_NIS], NULL);
|
||||
g_pipe[P_NIS] = VK_NULL_HANDLE;
|
||||
coef_destroy();
|
||||
g_nis_fast = 0;
|
||||
droiddeck_log("effects", "fast NIS pipelines failed to build; NIS uses nis.frag");
|
||||
}
|
||||
}
|
||||
if (!g_nis_fast) MK(1, P_NIS, nis_code, "nis");
|
||||
else if (g_upscale_half) MK(1, P_SGSR, sgsr_half_code, "sgsr_half");
|
||||
if (!g_nis_fast) MK(P_NIS, nis_code, "nis");
|
||||
MK(P_EASU, fsr_easu_half_code, "fsr_easu_half");
|
||||
MK(P_RCAS, fsr_rcas_half_code, "fsr_rcas_half");
|
||||
MK(P_CAS, cas_ffx_half_code, "cas_ffx_half");
|
||||
} else {
|
||||
MK(P_SGSR, sgsr_code, "sgsr");
|
||||
MK(P_SGSR_HQ, sgsr_quality_code, "sgsr_quality");
|
||||
MK(P_NIS, nis_code, "nis");
|
||||
MK(P_EASU, fsr_easu_code, "fsr_easu");
|
||||
MK(P_RCAS, fsr_rcas_code, "fsr_rcas");
|
||||
MK(P_CAS, cas_code, "cas");
|
||||
}
|
||||
if (cas_active(s)) {
|
||||
if (g_upscale_half) MK(1, P_CAS, cas_ffx_half_code, "cas_ffx_half");
|
||||
else MK(1, P_CAS, cas_code, "cas");
|
||||
}
|
||||
if (s->color_on && !(s->toon && g_fx_fmt == FX_FORMAT)) MK(1, P_COLOR, color_code, "color");
|
||||
if (s->aa_mode == 1 || s->aa_mode == 2) MK(1, P_FXAA, fxaa_code, "fxaa");
|
||||
if (s->aa_mode == 2) {
|
||||
MKL(1, P_SMAA_EDGE, smaa_edge_code, "smaa_edge", g_smaa_rp, g_pl);
|
||||
MKL(1, P_SMAA_WEIGHTS, smaa_weights_code, "smaa_weights", g_smaa_rp, g_pl);
|
||||
MK(1, P_SMAA_BLEND, smaa_blend_code, "smaa_blend");
|
||||
}
|
||||
if (s->toon && s->color_on && g_fx_fmt == FX_FORMAT) MK(1, P_TOON_COLOR, toon_color_code, "toon_color");
|
||||
else if (s->toon) MK(1, P_TOON, toon_code, "toon");
|
||||
if (s->hdr_on) MK(1, P_HDR, hdr_code, "hdr");
|
||||
if (s->ntsc) MK(1, P_NTSC, ntsc_code, "ntsc");
|
||||
if (s->crt) MK(1, P_CRT, crt_code, "crt");
|
||||
if (deband_active(s)) MK(1, P_DEBAND, deband_code, "deband");
|
||||
MK(P_COLOR, color_code, "color");
|
||||
MK(P_FXAA, fxaa_code, "fxaa");
|
||||
MK(P_FXAA_TOON, fxaa_toon_code, "fxaa_toon");
|
||||
g_pipe[P_SMAA_EDGE] = post_pipeline_for_renderpass(
|
||||
vert, smaa_edge_code, sizeof(smaa_edge_code), g_smaa_rp, "smaa_edge", g_pl);
|
||||
if (!g_pipe[P_SMAA_EDGE]) { g_vk.DestroyShaderModule(g_dev, vert, NULL); goto fail; }
|
||||
g_pipe[P_SMAA_WEIGHTS] = post_pipeline_for_renderpass(
|
||||
vert, smaa_weights_code, sizeof(smaa_weights_code), g_smaa_rp, "smaa_weights", g_pl);
|
||||
if (!g_pipe[P_SMAA_WEIGHTS]) { g_vk.DestroyShaderModule(g_dev, vert, NULL); goto fail; }
|
||||
MK(P_SMAA_BLEND, smaa_blend_code, "smaa_blend");
|
||||
MK(P_TOON, toon_code, "toon");
|
||||
MK(P_TOON_COLOR, toon_color_code, "toon_color");
|
||||
MK(P_HDR, hdr_code, "hdr");
|
||||
MK(P_NTSC, ntsc_code, "ntsc");
|
||||
MK(P_CRT, crt_code, "crt");
|
||||
MK(P_DEBAND, deband_code, "deband");
|
||||
#undef MK
|
||||
#undef MKL
|
||||
if (vert) g_vk.DestroyShaderModule(g_dev, vert, NULL);
|
||||
g_vk.DestroyShaderModule(g_dev, vert, NULL);
|
||||
g_ready = 1;
|
||||
droiddeck_log("effects", "chain ready: 16 pipelines (SGSR, SGSR HQ, NIS, FSR EASU+RCAS, CAS, colour, FXAA, SMAA edge/weights/blend, Toon, HDR, NTSC, CRT, deband), %s upscalers%s, on %s",
|
||||
half ? "half-precision" : "old fp32", g_nis_fast ? " + NIS luma prepass" : "", vkp_gpu_name());
|
||||
return 0;
|
||||
fail:
|
||||
if (vert) g_vk.DestroyShaderModule(g_dev, vert, NULL);
|
||||
return chain_failed();
|
||||
objects_destroy();
|
||||
g_ready = -1;
|
||||
droiddeck_log("error", "effects: the screen-effect chain could not be built on this driver; effects are off for this session");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -741,26 +681,14 @@ static void pass_dual(VkCommandBuffer cmd, VkPipeline p, struct fx_target *dst,
|
||||
static const float FULL_NDC[4] = {-1.0f, -1.0f, 1.0f, 1.0f};
|
||||
#define SET_NDC(pc) memcpy((pc).ndc, FULL_NDC, sizeof(FULL_NDC))
|
||||
|
||||
struct fx_source_state {
|
||||
VkImageLayout layout;
|
||||
VkPipelineStageFlags stage;
|
||||
VkAccessFlags access;
|
||||
};
|
||||
|
||||
static VkImage effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h,
|
||||
int out_w, int out_h, int *res_w, int *res_h,
|
||||
VkImageLayout input_layout, const struct fx_settings *frozen,
|
||||
struct fx_source_state *source_state) {
|
||||
VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h,
|
||||
int out_w, int out_h, int *res_w, int *res_h) {
|
||||
struct fx_settings snapshot;
|
||||
const struct fx_settings *s;
|
||||
if (frozen) {
|
||||
snapshot = *frozen;
|
||||
} else {
|
||||
vkp_effects_sync();
|
||||
pthread_mutex_lock(&g_lock);
|
||||
snapshot = g_cur;
|
||||
pthread_mutex_unlock(&g_lock);
|
||||
}
|
||||
vkp_effects_sync();
|
||||
pthread_mutex_lock(&g_lock);
|
||||
snapshot = g_cur;
|
||||
pthread_mutex_unlock(&g_lock);
|
||||
s = &snapshot;
|
||||
*res_w = scene_w; *res_h = scene_h;
|
||||
|
||||
@@ -795,7 +723,7 @@ static VkImage effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int
|
||||
effect_count(s) - (fuse_toon_color ? 1 : 0) -
|
||||
(fuse_fxaa_toon ? 1 : 0);
|
||||
|
||||
if ((spatial || nfx) && objects_ensure() == 0 && pipelines_ensure(spatial, s) == 0 && scene_ensure(scene, scene_w, scene_h) == 0 &&
|
||||
if ((spatial || nfx) && objects_ensure() == 0 && scene_ensure(scene, scene_w, scene_h) == 0 &&
|
||||
target_ensure(&g_t[0], cw, ch, FX_TARGET_USAGE, "chain") == 0 && (chain_passes < 2 || target_ensure(&g_t[1], cw, ch, FX_TARGET_USAGE, "chain") == 0) &&
|
||||
(!(spatial == 4 || spatial == 5) || s->sharp_pct == 0 ||
|
||||
target_ensure(&g_mid, cw, ch, FX_SCRATCH_USAGE, "EASU") == 0)) {
|
||||
@@ -820,10 +748,8 @@ static VkImage effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int
|
||||
g_vk.CmdSetScissor(cmd, 0, 1, &chain_sc);
|
||||
|
||||
if (spatial) {
|
||||
if (source_state) *source_state = (struct fx_source_state){VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT};
|
||||
barrier(cmd, scene, input_layout, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_WRITE_BIT,
|
||||
barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT);
|
||||
struct fx_target *dst = FREE_TARGET();
|
||||
if (spatial == 3 || spatial == 8 || spatial == 7) {
|
||||
@@ -883,10 +809,8 @@ static VkImage effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int
|
||||
cur = dst; cur_ds = dst->ds;
|
||||
} else if (resize) {
|
||||
struct fx_target *dst = FREE_TARGET();
|
||||
if (source_state) *source_state = (struct fx_source_state){VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT};
|
||||
barrier(cmd, scene, input_layout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_WRITE_BIT,
|
||||
barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT);
|
||||
barrier(cmd, dst->img, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT);
|
||||
@@ -899,10 +823,8 @@ static VkImage effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int
|
||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT);
|
||||
cur = dst; cur_ds = dst->ds;
|
||||
} else {
|
||||
if (source_state) *source_state = (struct fx_source_state){VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT};
|
||||
barrier(cmd, scene, input_layout, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_WRITE_BIT,
|
||||
barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT);
|
||||
cur = NULL; cur_ds = g_scene.ds;
|
||||
}
|
||||
@@ -985,54 +907,8 @@ static VkImage effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int
|
||||
return scene;
|
||||
}
|
||||
|
||||
if (source_state) *source_state = (struct fx_source_state){VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT};
|
||||
barrier(cmd, scene, input_layout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_WRITE_BIT,
|
||||
barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT);
|
||||
return scene;
|
||||
}
|
||||
|
||||
VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h,
|
||||
int out_w, int out_h, int *res_w, int *res_h) {
|
||||
return effects_run(cmd, scene, scene_w, scene_h, out_w, out_h, res_w, res_h,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, NULL, NULL);
|
||||
}
|
||||
|
||||
int vkp_effects_prepare_generated(void) {
|
||||
vkp_effects_sync();
|
||||
pthread_mutex_lock(&g_lock);
|
||||
g_generated_settings = g_cur;
|
||||
pthread_mutex_unlock(&g_lock);
|
||||
return spatial_mode(g_generated_settings.scaling) && g_generated_settings.scaling != 6 &&
|
||||
effect_count(&g_generated_settings) == 0;
|
||||
}
|
||||
|
||||
VkImage vkp_effects_run_before_generated(VkCommandBuffer cmd, VkImage scene, int w, int h,
|
||||
int *res_w, int *res_h) {
|
||||
struct fx_settings settings = g_generated_settings;
|
||||
settings.scaling = 0;
|
||||
return effects_run(cmd, scene, w, h, w, h, res_w, res_h,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &settings, NULL);
|
||||
}
|
||||
|
||||
VkImage vkp_effects_run_generated(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h,
|
||||
int out_w, int out_h, int slot, int *res_w, int *res_h) {
|
||||
if (slot < 0 || slot > VKP_FG_MAX_GENERATIONS) {
|
||||
*res_w = scene_w; *res_h = scene_h;
|
||||
return scene;
|
||||
}
|
||||
g_context = slot + 1;
|
||||
struct fx_source_state source_state = {0};
|
||||
VkImage result = effects_run(cmd, scene, scene_w, scene_h, out_w, out_h, res_w, res_h,
|
||||
VK_IMAGE_LAYOUT_GENERAL, &g_generated_settings, &source_state);
|
||||
barrier(cmd, result, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
|
||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT);
|
||||
if (result != scene)
|
||||
barrier(cmd, scene, source_state.layout, VK_IMAGE_LAYOUT_GENERAL,
|
||||
source_state.stage, source_state.access,
|
||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT);
|
||||
g_context = 0;
|
||||
return result;
|
||||
}
|
||||
@@ -18,12 +18,6 @@ VkFilter vkp_effects_blit_filter(void);
|
||||
|
||||
VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h,
|
||||
int out_w, int out_h, int *res_w, int *res_h);
|
||||
int vkp_effects_prepare_generated(void);
|
||||
void vkp_effects_release_generated_sources(void);
|
||||
VkImage vkp_effects_run_before_generated(VkCommandBuffer cmd, VkImage scene, int w, int h,
|
||||
int *res_w, int *res_h);
|
||||
VkImage vkp_effects_run_generated(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h,
|
||||
int out_w, int out_h, int slot, int *res_w, int *res_h);
|
||||
|
||||
void vkp_effects_destroy(void);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include "framegen_bridge.h"
|
||||
#include "framegen_engine.h"
|
||||
#include "effects_chain.h"
|
||||
#include "vk_loader.h"
|
||||
#include <pthread.h>
|
||||
#include <stdatomic.h>
|
||||
@@ -227,10 +226,7 @@ static void destroy_ring(void) {
|
||||
if (vk.DeviceWaitIdle) vk.DeviceWaitIdle(g_dev);
|
||||
for (uint32_t i = 0; i < g_ring_n; i++) {
|
||||
if (g_ring[i].view) vk.DestroyImageView(g_dev, g_ring[i].view, NULL);
|
||||
if (g_ring[i].img) {
|
||||
vkp_effects_forget_image(g_ring[i].img);
|
||||
vk.DestroyImage(g_dev, g_ring[i].img, NULL);
|
||||
}
|
||||
if (g_ring[i].img) vk.DestroyImage(g_dev, g_ring[i].img, NULL);
|
||||
if (g_ring[i].mem) vk.FreeMemory(g_dev, g_ring[i].mem, NULL);
|
||||
memset(&g_ring[i], 0, sizeof(g_ring[i]));
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ bool g_probed = false, g_ready = false;
|
||||
|
||||
std::unique_ptr<lsfg::Engine> g_lsfg;
|
||||
std::unique_ptr<ddfg::Engine> g_ddfg;
|
||||
std::vector<std::unique_ptr<ddfg::Engine>> g_retained_ddfg;
|
||||
int g_kind = -1;
|
||||
char g_build[96] = "";
|
||||
|
||||
@@ -129,14 +128,7 @@ void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysica
|
||||
|
||||
void fge_device_lost(void) {
|
||||
g_lsfg.reset();
|
||||
if (g_ddfg) {
|
||||
if (g_ddfg->destroy()) g_ddfg.reset();
|
||||
else g_retained_ddfg.push_back(std::move(g_ddfg));
|
||||
}
|
||||
// The device is being torn down. Unknown-completion resources must not be
|
||||
// passed to Vulkan destruction calls; the VkDevice teardown reclaims them.
|
||||
for (auto& engine : g_retained_ddfg) engine->abandon();
|
||||
g_retained_ddfg.clear();
|
||||
g_ddfg.reset();
|
||||
g_kind = -1;
|
||||
g_dev = VK_NULL_HANDLE;
|
||||
g_queue = VK_NULL_HANDLE;
|
||||
@@ -201,21 +193,9 @@ int fge_start(int kind, const char *cache_path) {
|
||||
}
|
||||
|
||||
void fge_stop(void) {
|
||||
if (g_lsfg) {
|
||||
if (g_table.DeviceWaitIdle && g_dev) g_table.DeviceWaitIdle(g_dev);
|
||||
g_lsfg.reset();
|
||||
}
|
||||
for (auto it = g_retained_ddfg.begin(); it != g_retained_ddfg.end();) {
|
||||
if ((*it)->destroy()) it = g_retained_ddfg.erase(it);
|
||||
else ++it;
|
||||
}
|
||||
if (g_ddfg) {
|
||||
if (g_ddfg->destroy()) g_ddfg.reset();
|
||||
else {
|
||||
ELOGE("ddfg-native: retaining engine until GPU completion is known or device teardown");
|
||||
g_retained_ddfg.push_back(std::move(g_ddfg));
|
||||
}
|
||||
}
|
||||
if ((g_lsfg || g_ddfg) && g_table.DeviceWaitIdle && g_dev) g_table.DeviceWaitIdle(g_dev);
|
||||
g_lsfg.reset();
|
||||
g_ddfg.reset();
|
||||
g_kind = -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -2759,21 +2759,6 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
pass_n = 1;
|
||||
overlay_start = source_end;
|
||||
}
|
||||
const int upscale_w = (int)(scene_w * g_map.kx + 0.5f);
|
||||
const int upscale_h = (int)(scene_h * g_map.ky + 0.5f);
|
||||
const int post_upscale = fx && fg && !hf && !cb && vkp_effects_upscaling() &&
|
||||
vkp_effects_prepare_generated() &&
|
||||
(upscale_w > input_w || upscale_h > input_h);
|
||||
if (post_upscale) {
|
||||
static int last_input_w, last_input_h, last_output_w, last_output_h;
|
||||
if (input_w != last_input_w || input_h != last_input_h ||
|
||||
upscale_w != last_output_w || upscale_h != last_output_h) {
|
||||
droiddeck_log("framegen", "post-upscale: interpolate %dx%d, spatial filter each present to %dx%d",
|
||||
input_w, input_h, upscale_w, upscale_h);
|
||||
last_input_w = input_w; last_input_h = input_h;
|
||||
last_output_w = upscale_w; last_output_h = upscale_h;
|
||||
}
|
||||
}
|
||||
const int deep = hf && n > 0 && fg && g_swap_is_hdr && !hf->tonemap && vkp_framegen_format_ok(FG_HDR_FMT) &&
|
||||
ensure_img(&g_fgscene, scene_w, scene_h, FG_HDR_FMT,
|
||||
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT |
|
||||
@@ -2909,11 +2894,8 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
if (fx) {
|
||||
int mapped_w = (int)(scene_w * g_map.kx + 0.5f), mapped_h = (int)(scene_h * g_map.ky + 0.5f);
|
||||
if (fg && !vkp_effects_sharpening()) { mapped_w = scene_w; mapped_h = scene_h; }
|
||||
if (post_upscale) { mapped_w = input_w; mapped_h = input_h; }
|
||||
vkp_effects_set_formats(scene_fmt, scene_fmt, hdr_how == 1 || hdr_unconverted);
|
||||
result = post_upscale
|
||||
? vkp_effects_run_before_generated(cmd, scene_img, input_w, input_h, &rw, &rh)
|
||||
: vkp_effects_run(cmd, scene_img, input_w, input_h, mapped_w, mapped_h, &rw, &rh);
|
||||
result = vkp_effects_run(cmd, scene_img, input_w, input_h, mapped_w, mapped_h, &rw, &rh);
|
||||
effects_overlay_draws(cmd, result, rw, rh, scene_w, scene_h,
|
||||
draws ? draws + overlay_start : NULL, n - overlay_start);
|
||||
release_external_client_draws(cmd, draws, n);
|
||||
@@ -2936,12 +2918,7 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
if (ngen > VKP_FG_MAX_GENERATIONS) ngen = VKP_FG_MAX_GENERATIONS;
|
||||
}
|
||||
|
||||
VkImage screen = ngen ? gens[0] : result;
|
||||
int screen_w = rw, screen_h = rh;
|
||||
if (post_upscale)
|
||||
screen = vkp_effects_run_generated(cmd, screen, rw, rh, upscale_w, upscale_h,
|
||||
0, &screen_w, &screen_h);
|
||||
record_screen_blit(cmd, screen, screen_w, screen_h, scene_w, scene_h, img, blit_filter, cb);
|
||||
record_screen_blit(cmd, ngen ? gens[0] : result, rw, rh, scene_w, scene_h, img, blit_filter, cb);
|
||||
}
|
||||
g_vk.EndCommandBuffer(cmd);
|
||||
|
||||
@@ -2965,12 +2942,7 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
VkCommandBuffer ck = g_cmds[k];
|
||||
g_vk.ResetCommandBuffer(ck, 0);
|
||||
g_vk.BeginCommandBuffer(ck, &bi);
|
||||
VkImage screen = k < ngen ? gens[k] : result;
|
||||
int screen_w = rw, screen_h = rh;
|
||||
if (post_upscale)
|
||||
screen = vkp_effects_run_generated(ck, screen, rw, rh, upscale_w, upscale_h,
|
||||
k, &screen_w, &screen_h);
|
||||
record_screen_blit(ck, screen, screen_w, screen_h, scene_w, scene_h, img, blit_filter, cb);
|
||||
record_screen_blit(ck, k < ngen ? gens[k] : result, rw, rh, scene_w, scene_h, img, blit_filter, cb);
|
||||
g_vk.EndCommandBuffer(ck);
|
||||
}
|
||||
const int last = (k + 1 == presents);
|
||||
@@ -3016,7 +2988,6 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
VkResult fr = timed_wait(g_fence, UINT64_MAX);
|
||||
if (fr == VK_ERROR_DEVICE_LOST || pr == VK_ERROR_DEVICE_LOST) { device_lost("present"); return -1; }
|
||||
if (fr != VK_SUCCESS) return -1;
|
||||
vkp_effects_release_generated_sources();
|
||||
if (fg) vkp_framegen_presented(presented_gen);
|
||||
if (pr == VK_ERROR_OUT_OF_DATE_KHR || pr == VK_ERROR_SURFACE_LOST_KHR) {
|
||||
droiddeck_log("gpu", "screen surface %s on present: rebuilding the swapchain", vk_result_name(pr));
|
||||
|
||||
@@ -1129,7 +1129,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
}
|
||||
Thread({
|
||||
val added = if (com.droiddeck.launcher.session.NoSteamLaunch.needsAddedGame(game)) runCatching { com.droiddeck.launcher.session.NoSteamLaunch.addedGame(app, game) }.getOrNull() else null
|
||||
val command = com.droiddeck.launcher.session.NoSteamLaunch.command(game, added)
|
||||
val command = com.droiddeck.launcher.session.NoSteamLaunch.command(app, game, added)
|
||||
ui.post {
|
||||
onHandled()
|
||||
if (!launchCoordinator.isCurrent(request) || isFinishing || isDestroyed) {
|
||||
@@ -1138,7 +1138,12 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
}
|
||||
if (command == null) {
|
||||
launchCoordinator.releaseHandling(request)
|
||||
android.widget.Toast.makeText(this, R.string.game_link_failed, android.widget.Toast.LENGTH_LONG).show()
|
||||
val message = if (game.source == com.droiddeck.launcher.stores.Store.BATTLENET.id) {
|
||||
R.string.game_link_battlenet_missing
|
||||
} else {
|
||||
R.string.game_link_failed
|
||||
}
|
||||
android.widget.Toast.makeText(this, message, android.widget.Toast.LENGTH_LONG).show()
|
||||
return@post
|
||||
}
|
||||
com.droiddeck.launcher.session.NoSteamLaunch.remember(command)
|
||||
@@ -2264,10 +2269,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
!com.droiddeck.launcher.input.PadBridge.isControllerMotionEvent(event)) return
|
||||
val device = event.device ?: return
|
||||
val rxRy = com.droiddeck.launcher.input.PadBridge.rightStickUsesRxRy(event, device, rightStickLayouts)
|
||||
?: run {
|
||||
if (rightStickScrollDeviceId == event.deviceId) stopRightStickScroll()
|
||||
return
|
||||
}
|
||||
?: return
|
||||
val axis = if (rxRy) android.view.MotionEvent.AXIS_RY else android.view.MotionEvent.AXIS_RZ
|
||||
val value = event.getAxisValue(axis)
|
||||
if (kotlin.math.abs(value) < 0.55f) {
|
||||
|
||||
@@ -8,11 +8,8 @@ import androidx.compose.runtime.mutableStateListOf
|
||||
import androidx.compose.runtime.mutableStateMapOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.core.WirelessAdbFix
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import com.droiddeck.launcher.session.OrphanReaper
|
||||
import com.droiddeck.launcher.session.QuestExperimental
|
||||
import java.io.File
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@@ -91,8 +88,6 @@ object AgentSetup {
|
||||
private fun completedKey(harness: AgentHarness) = "setup_completed_${harness.id}"
|
||||
|
||||
private val main = Handler(Looper.getMainLooper())
|
||||
/** Advanced by every Allow, so a connection check started before it cannot overwrite what it found. */
|
||||
private var connectionGeneration = 0
|
||||
private const val REPO = "https://github.com/Droid-Deck/DroidDeck.git"
|
||||
private const val CHECKOUT = "/root/DroidDeck"
|
||||
private val HELPERS = listOf("android-open", "dd-gh-login", "droiddeckctl", "droiddeck-scenario")
|
||||
@@ -109,7 +104,6 @@ object AgentSetup {
|
||||
val harness = AgentHost.harness
|
||||
keys = harness.keys(LinuxRuntime.rootDir(app))
|
||||
val probes = mutableListOf<Pair<Step, List<String>>>()
|
||||
val generation = connectionGeneration
|
||||
for (step in Step.entries) if (status[step] != Status.WORKING) {
|
||||
when (step) {
|
||||
Step.INSTALL -> set(step, if (harness.files.all { AgentHost.guestFileExists(app, it) }) Status.DONE else Status.TODO)
|
||||
@@ -120,9 +114,7 @@ object AgentSetup {
|
||||
detail.remove(step)
|
||||
Thread({
|
||||
val live = com.droiddeck.launcher.core.WirelessAdbFix.liveConnectAddress(app) != null
|
||||
main.post {
|
||||
if (generation == connectionGeneration && status[step] != Status.WORKING) status[step] = if (live) Status.DONE else Status.TODO
|
||||
}
|
||||
set(step, if (live) Status.DONE else Status.TODO)
|
||||
}, "agent-connection").start()
|
||||
} else probes += step to listOf("sh", "-c",
|
||||
"for i in 1 2 3; do adb connect \"\$ADB_SERIAL\" >/dev/null 2>&1; " +
|
||||
@@ -131,7 +123,7 @@ object AgentSetup {
|
||||
Step.GITHUB -> probes += step to listOf("gh", "auth", "status")
|
||||
}
|
||||
}
|
||||
Thread({ for ((step, command) in probes) probe(app, harness, step, command, generation) }, "agent-checks").start()
|
||||
Thread({ for ((step, command) in probes) probe(app, harness, step, command) }, "agent-checks").start()
|
||||
}
|
||||
|
||||
/** The last failed refresh ends the script: the installs after it would run from stale indexes and could report success. */
|
||||
@@ -149,22 +141,6 @@ object AgentSetup {
|
||||
/** Runs [step]'s action. [CONNECTION] is the app's own pairing flow, so the caller opens it. */
|
||||
fun run(context: Context, step: Step) = run(context, step, null)
|
||||
|
||||
/** The [Step.CONNECTION] action on a Quest, which has no pairing screen; see [WirelessAdbFix.trustOnDevice]. */
|
||||
fun trustOnDevice(context: Context) {
|
||||
val app = context.applicationContext
|
||||
connectionGeneration++
|
||||
status[Step.CONNECTION] = Status.WORKING
|
||||
detail[Step.CONNECTION] = app.getString(R.string.agent_connection_quest_waiting)
|
||||
Thread({
|
||||
val ok = runCatching { WirelessAdbFix.trustOnDevice(app) }.isSuccess
|
||||
main.post {
|
||||
status[Step.CONNECTION] = if (ok) Status.DONE else Status.FAILED
|
||||
if (ok) detail.remove(Step.CONNECTION) else detail[Step.CONNECTION] = app.getString(R.string.agent_connection_quest_failed)
|
||||
if (ok) check(app)
|
||||
}
|
||||
}, "agent-quest-trust").start()
|
||||
}
|
||||
|
||||
/** Opens the page where a provider's key is made, as the sign-in of a harness that takes pasted keys. */
|
||||
fun openKeyPage(context: Context, page: String) = run(context, Step.SIGN_IN, listOf("/root/.local/bin/android-open", page))
|
||||
|
||||
@@ -240,7 +216,7 @@ object AgentSetup {
|
||||
detail.clear()
|
||||
}
|
||||
|
||||
private fun probe(app: Context, harness: AgentHarness, step: Step, command: List<String>, generation: Int) {
|
||||
private fun probe(app: Context, harness: AgentHarness, step: Step, command: List<String>) {
|
||||
var output = ""
|
||||
val ok = runCatching {
|
||||
val child = AgentHost.guest(app, command, connectAdb = step == Step.CONNECTION).start()
|
||||
@@ -256,14 +232,11 @@ object AgentSetup {
|
||||
}.onFailure { output = it.message.orEmpty() }.getOrDefault(false)
|
||||
main.post {
|
||||
if (AgentHost.harness != harness) return@post
|
||||
// A running or newer Allow owns the row, including the instructions it shows while it waits.
|
||||
if (step == Step.CONNECTION && (generation != connectionGeneration || status[step] == Status.WORKING)) return@post
|
||||
if (status[step] != Status.WORKING) status[step] = if (ok) Status.DONE else Status.TODO
|
||||
val last = output.lines().lastOrNull { it.isNotBlank() && !noise(it.trim()) }?.trim()?.take(160)
|
||||
when {
|
||||
ok -> detail.remove(step)
|
||||
step == Step.CONNECTION -> detail[step] = app.getString(
|
||||
if (QuestExperimental.isSupported()) R.string.agent_connection_quest_off else R.string.agent_connection_off)
|
||||
step == Step.CONNECTION -> detail[step] = app.getString(com.droiddeck.launcher.R.string.agent_connection_off)
|
||||
step.required && last != null -> detail[step] = last
|
||||
}
|
||||
if (ready) AgentHost.prefs(app).edit().putBoolean(completedKey(harness), true).apply()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.droiddeck.launcher.core
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.provider.Settings
|
||||
|
||||
@@ -20,14 +19,4 @@ object GlobalSettings {
|
||||
fun developerOptionsOn(context: Context): Boolean = isOn(context, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED)
|
||||
|
||||
fun wirelessDebuggingOn(context: Context): Boolean = isOn(context, "adb_wifi_enabled")
|
||||
|
||||
/**
|
||||
* True when it was off and is now on. Quest only, where Settings has no switch for it; it needs
|
||||
* WRITE_SECURE_SETTINGS granted over adb.
|
||||
*/
|
||||
fun turnOnWirelessDebugging(context: Context): Boolean {
|
||||
if (!com.droiddeck.launcher.session.QuestExperimental.isSupported() || wirelessDebuggingOn(context)) return false
|
||||
if (context.checkSelfPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) != PackageManager.PERMISSION_GRANTED) return false
|
||||
return runCatching { Settings.Global.putInt(context.contentResolver, "adb_wifi_enabled", 1) }.getOrDefault(false)
|
||||
}
|
||||
}
|
||||
@@ -22,9 +22,6 @@ object WirelessAdbFix {
|
||||
private const val HOST_FILE = "wireless-adb-host.txt"
|
||||
private const val CONNECTION_FILE = "wireless-adb-connection.txt"
|
||||
const val LOOPBACK = "127.0.0.1"
|
||||
private const val TCP_PORT = 5555
|
||||
private const val WIRELESS_START_MS = 2_000L
|
||||
private const val NETWORK_PROMPT_MS = 30_000L
|
||||
|
||||
private data class SavedConnection(val host: String, val port: Int?)
|
||||
|
||||
@@ -58,23 +55,6 @@ object WirelessAdbFix {
|
||||
writeAtomically(context, File(context.noBackupFilesDir, CONNECTION_FILE), ByteArray(0))
|
||||
}
|
||||
|
||||
/**
|
||||
* Quest has no pairing screen. adbd in TCP mode (`adb tcpip 5555`) asks "Allow debugging?" for an
|
||||
* unknown key, and Wireless debugging accepts a key allowed there, so this stands in for pairing.
|
||||
* Blocks until the prompt is answered or times out.
|
||||
*/
|
||||
fun trustOnDevice(context: Context) {
|
||||
val app = context.applicationContext
|
||||
// Already trusted, as after a reboot: Wireless debugging takes the key, and port 5555 is closed by then.
|
||||
val live = if (savedConnection(app) != null) liveConnectAddress(app) else null
|
||||
if (live != null && acceptsKey(app, live.substringBeforeLast(':').trim('[', ']'), live.substringAfterLast(':').toInt())) return
|
||||
GlobalSettings.turnOnWirelessDebugging(app)
|
||||
loadOrCreateIdentity(app)
|
||||
Kadb.create(LOOPBACK, TCP_PORT, 2_000, 120_000).use { check(it.shell("true").exitCode == 0) }
|
||||
writeAtomically(app, File(app.noBackupFilesDir, HOST_FILE), LOOPBACK.toByteArray())
|
||||
writeAtomically(app, File(app.noBackupFilesDir, CONNECTION_FILE), ByteArray(0))
|
||||
}
|
||||
|
||||
private fun savedConnection(context: Context): SavedConnection? {
|
||||
val directory = context.applicationContext.noBackupFilesDir
|
||||
if (!File(directory, CERT_FILE).isFile || !File(directory, KEY_FILE).isFile) return null
|
||||
@@ -98,17 +78,10 @@ object WirelessAdbFix {
|
||||
fun liveConnectAddress(context: Context): String? {
|
||||
val app = context.applicationContext
|
||||
val saved = savedConnection(app) ?: return null
|
||||
val turnedOn = GlobalSettings.turnOnWirelessDebugging(app)
|
||||
val host = if (':' in saved.host) "[${saved.host}]" else saved.host
|
||||
if (!turnedOn) saved.port?.takeIf { answers(saved.host, it) }?.let { return "$host:$it" }
|
||||
saved.port?.takeIf { answers(saved.host, it) }?.let { return "$host:$it" }
|
||||
val loopback = runCatching { InetAddress.getByName(saved.host).isLoopbackAddress }.getOrDefault(false)
|
||||
// Turning it on can first ask "Allow wireless debugging on this network?", so keep looking while that is answered.
|
||||
val deadline = android.os.SystemClock.elapsedRealtime() + if (turnedOn) NETWORK_PROMPT_MS else 0L
|
||||
var port: Int?
|
||||
do {
|
||||
if (turnedOn) Thread.sleep(WIRELESS_START_MS)
|
||||
port = if (loopback) loopbackAdbPort(app) else findConnectPort(app, saved.host, accept = { answers(saved.host, it) })
|
||||
} while (port == null && android.os.SystemClock.elapsedRealtime() < deadline)
|
||||
val port = if (loopback) loopbackAdbPort(app) else findConnectPort(app, saved.host, accept = { answers(saved.host, it) })
|
||||
port ?: return null
|
||||
saveConnection(app, saved.host, port)
|
||||
return "$host:$port"
|
||||
@@ -132,12 +105,10 @@ object WirelessAdbFix {
|
||||
}
|
||||
}.apply { start() }
|
||||
}.forEach { it.join() }
|
||||
return open.sorted().firstOrNull { port -> acceptsKey(app, LOOPBACK, port) }
|
||||
}
|
||||
|
||||
private fun acceptsKey(app: Context, host: String, port: Int): Boolean {
|
||||
loadOrCreateIdentity(app)
|
||||
return runCatching { Kadb.create(host, port, 1_000, 3_000).use { it.shell("true").exitCode == 0 } }.getOrDefault(false)
|
||||
return open.sorted().firstOrNull { port ->
|
||||
runCatching { Kadb.create(LOOPBACK, port, 1_000, 3_000).use { it.shell("true").exitCode == 0 } }.getOrDefault(false)
|
||||
}
|
||||
}
|
||||
|
||||
private val EPHEMERAL_PORTS = 32768..60999
|
||||
|
||||
@@ -42,8 +42,8 @@ object GameRemoval {
|
||||
val folder = game.gameFiles ?: return null
|
||||
val store = Store.byId(game.source)
|
||||
val id = game.storeId
|
||||
if (store != null && id != null) StoresState.installedGame(store, id)?.let { return it }
|
||||
val sidecar = StoreGameSidecar.read(folder)?.takeIf { it.isInstalled } ?: return null
|
||||
if (store != null && id != null) StoresState.installedGame(store, id, folder)?.let { return it }
|
||||
val sidecar = StoreGameSidecar.read(folder)?.takeIf { it.isInstalled && it.store == store && it.id == id } ?: return null
|
||||
return InstalledStoreGame(sidecar, folder)
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ object BattleNet {
|
||||
Title("wow_classic_anniversary", "World of Warcraft Classic", "WoWC", product = "wow_anniversary", flavor = "_anniversary_"),
|
||||
Title("wow_forever", "World of Warcraft: Forever", "WoWF", shop = "world-of-warcraft-forever", product = "wowf", flavor = "_forever_"),
|
||||
Title("diablo3", "Diablo III", "D3", shop = "diablo-iii", product = "d3"),
|
||||
Title("d3cn", "Diablo III", "D3CN", shop = "diablo-iii"),
|
||||
Title("s2", "StarCraft II", "S2", shop = "starcraft-ii", product = "s2"),
|
||||
Title("s1", "StarCraft", "S1", shop = "starcraft-remastered", product = "s1"),
|
||||
Title("hs_beta", "Hearthstone", "WTCG", shop = "hearthstone", product = "hsb"),
|
||||
@@ -56,10 +55,26 @@ object BattleNet {
|
||||
Title("aqua", "Avowed", "AQUA", 2457220, shop = "avowed", product = "aqua"),
|
||||
)
|
||||
|
||||
val STORE: List<Title> get() = TITLES.distinctBy { it.code }.filter { it.uid != "d3cn" && it.code != "WoWC" }
|
||||
// d3cn is not a store card of its own any more; it resolves to the Diablo III title through CN_UIDS.
|
||||
val STORE: List<Title> get() = TITLES.distinctBy { it.code }.filter { it.code != "WoWC" }
|
||||
|
||||
// Blizzard's China client installs some products under a CN uid; they are the same games and keep their store identity.
|
||||
private val CN_UIDS = mapOf("s2_cn" to "s2", "osic" to "osi", "anbs_cn" to "anbs")
|
||||
/**
|
||||
* Blizzard's China client installs some products under a CN uid; they are the same games and keep their store
|
||||
* identity. Only the launch code and the product served by the China repository can differ.
|
||||
*/
|
||||
private class Cnv(val uid: String, val code: String? = null, val product: String? = null)
|
||||
|
||||
private val CN_UIDS = mapOf(
|
||||
"s2_cn" to Cnv("s2", product = "s2c"),
|
||||
"osic" to Cnv("osi", product = "osic"),
|
||||
"anbs_cn" to Cnv("anbs"),
|
||||
"d3cn" to Cnv("diablo3", "D3CN", "d3cn"),
|
||||
)
|
||||
|
||||
private fun cn(alias: Cnv): Title? = TITLES.firstOrNull { it.uid == alias.uid }?.let { title ->
|
||||
if (alias.code == null && alias.product == null) title
|
||||
else Title(title.uid, title.name, alias.code ?: title.code, title.steam, title.shop, alias.product ?: title.product, title.flavor)
|
||||
}
|
||||
|
||||
fun notInstalled(title: Title, installedIds: Collection<String?>) =
|
||||
installedIds.mapNotNull { id -> id?.let(::title)?.code }.none { it == title.code }
|
||||
@@ -75,7 +90,7 @@ object BattleNet {
|
||||
|
||||
private val coverLock = Any()
|
||||
|
||||
fun fetchCovers(context: Context, titles: List<Title> = TITLES.distinctBy { it.code }.filter { it.uid != "d3cn" }): Boolean = synchronized(coverLock) {
|
||||
fun fetchCovers(context: Context, titles: List<Title> = TITLES.distinctBy { it.code }): Boolean = synchronized(coverLock) {
|
||||
val art = com.droiddeck.launcher.frontend.AddedGameArt
|
||||
val key = com.droiddeck.launcher.frontend.SteamGridDb.key(context)
|
||||
var got = false
|
||||
@@ -162,10 +177,10 @@ object BattleNet {
|
||||
internal fun title(uid: String): Title? {
|
||||
val id = uid.lowercase()
|
||||
TITLES.firstOrNull { it.uid == id }?.let { return it }
|
||||
CN_UIDS[id]?.let { alias -> TITLES.firstOrNull { it.uid == alias }?.let { return it } }
|
||||
CN_UIDS[id]?.let { return cn(it) }
|
||||
val base = id.substringBeforeLast('_', "")
|
||||
if (base.isEmpty() || id.substringAfterLast('_') !in LOCALES) return null
|
||||
return TITLES.firstOrNull { it.uid == base } ?: CN_UIDS[base]?.let { alias -> TITLES.firstOrNull { it.uid == alias } }
|
||||
return TITLES.firstOrNull { it.uid == base } ?: CN_UIDS[base]?.let { cn(it) }
|
||||
}
|
||||
|
||||
internal fun titleForProduct(product: String): Title? {
|
||||
@@ -202,6 +217,114 @@ object BattleNet {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The launch code of the copy installed in [folder]. The store card's code is not enough:
|
||||
* a China client installs Diablo III under `D3CN` while the store title is `D3`.
|
||||
*/
|
||||
fun launchCode(context: Context, uid: String, folder: File?): String? {
|
||||
if (folder == null) return runCatching { games(context) }.getOrNull()?.let { launchCode(it, uid, null) }
|
||||
if (!folder.isDirectory) return null
|
||||
return runCatching { installedRegistrationAt(context, uid, folder) }.getOrNull()?.second?.code
|
||||
}
|
||||
|
||||
/**
|
||||
* Two uids name the same store title: the China aliases fold into the store uid, and fen/fenris
|
||||
* share one product under uids of their own.
|
||||
*/
|
||||
internal fun sameTitle(left: String, right: String): Boolean {
|
||||
val a = title(left)
|
||||
val b = title(right)
|
||||
if (a == null || b == null) return left.equals(right, ignoreCase = true)
|
||||
return a.uid == b.uid || (a.code == b.code && a.product != null && a.product == b.product)
|
||||
}
|
||||
|
||||
/** False when a registration source exists but cannot be read: "no game here" is not a fact then. */
|
||||
internal fun registrationsReadable(context: Context): Boolean {
|
||||
val pfx = File(prefix(context), "pfx")
|
||||
val agent = File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db")
|
||||
val registry = File(pfx, "system.reg")
|
||||
if (agent.exists() && runCatching { productDbRegistrations(agent.readBytes()) }.getOrNull() == null) return false
|
||||
if (registry.isFile && runCatching { registry.useLines { uninstallEntries(it) } }.isFailure) return false
|
||||
return true
|
||||
}
|
||||
|
||||
internal fun launchCode(games: List<Game>, uid: String, folder: File?): String? {
|
||||
val canonical = title(uid)?.uid ?: uid
|
||||
val same = games.filter { it.uid == canonical }
|
||||
if (folder != null) return same.firstOrNull { it.folder.absolutePath == folder.absolutePath }?.code
|
||||
return same.singleOrNull()?.code ?: title(uid)?.code
|
||||
}
|
||||
|
||||
internal fun installedRegistrationAt(context: Context, id: String, folder: File): Pair<String, Title>? {
|
||||
if (!folder.isDirectory) return null
|
||||
val pfx = File(prefix(context), "pfx")
|
||||
val agentFile = File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db")
|
||||
val registryFile = File(pfx, "system.reg")
|
||||
val bytes = if (agentFile.exists()) agentFile.readBytes() else null
|
||||
val registrations = if (bytes != null) productDbRegistrations(bytes) ?: return null else emptyList()
|
||||
val agent = bytes?.let(::productDbInstalls).orEmpty()
|
||||
val registry = if (registryFile.exists()) registryFile.useLines { uninstallEntries(it) } else emptyList()
|
||||
// Agent rows take precedence for a UID, including unfinished installs.
|
||||
// Registry-only titles remain valid when Agent has no corresponding row.
|
||||
val registeredUids = registrations.map { it.uid.lowercase() }.toSet()
|
||||
val candidates = agent + registry.filter { (uid, _) ->
|
||||
uid.lowercase() !in registeredUids
|
||||
}.map { AgentInstall(it.first, it.second, "") }
|
||||
return candidates.firstNotNullOfOrNull { row ->
|
||||
val found = title(row.uid) ?: titleForProduct(row.product) ?: return@firstNotNullOfOrNull null
|
||||
if (!sameTitle(found.uid, id)) return@firstNotNullOfOrNull null
|
||||
val registered = hostFolder(context, row.path) ?: return@firstNotNullOfOrNull null
|
||||
if (registered.absolutePath != folder.absolutePath &&
|
||||
(found.flavor != folder.name || registered.absolutePath != folder.parentFile?.absolutePath)
|
||||
) return@firstNotNullOfOrNull null
|
||||
row.uid to found
|
||||
}
|
||||
}
|
||||
|
||||
/** A registration for any title in this tree makes recursive deletion unsafe. */
|
||||
internal fun folderHasRegistrations(context: Context, folder: File): Boolean? = runCatching {
|
||||
val pfx = File(prefix(context), "pfx")
|
||||
val agentFile = File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db")
|
||||
val registryFile = File(pfx, "system.reg")
|
||||
val agent = if (agentFile.exists()) productDbRegistrations(agentFile.readBytes()) ?: return null else emptyList()
|
||||
val registry = if (registryFile.exists()) registryFile.useLines { uninstallEntries(it) } else emptyList()
|
||||
val target = folder.canonicalFile.toPath()
|
||||
(agent.map { it.path } + registry.map { it.second }).any { path ->
|
||||
val registered = hostFolder(context, path)?.canonicalFile?.toPath() ?: return null
|
||||
registered.startsWith(target)
|
||||
}
|
||||
}.getOrNull()
|
||||
|
||||
internal fun registrationsAt(context: Context, id: String, folder: File): List<String>? {
|
||||
val pfx = File(prefix(context), "pfx")
|
||||
val agentFile = File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db")
|
||||
val registryFile = File(pfx, "system.reg")
|
||||
val agent = if (!agentFile.exists()) emptyList()
|
||||
else runCatching { productDbRegistrations(agentFile.readBytes()) }.getOrNull() ?: return null
|
||||
val registry = if (!registryFile.exists()) emptyList()
|
||||
else runCatching { registryFile.useLines { uninstallEntries(it) } }.getOrNull() ?: return null
|
||||
val products = agent.filter { it.product.isNotEmpty() }.associate { it.uid.lowercase() to it.product }
|
||||
val requested = title(id)
|
||||
val flavor = requested?.flavor
|
||||
val folders = buildSet {
|
||||
add(folder.absolutePath)
|
||||
if (flavor != null && folder.name == flavor) folder.parentFile?.let { add(it.absolutePath) }
|
||||
}
|
||||
if (agent.any { it.uid.isEmpty() && hostFolder(context, it.path)?.absolutePath in folders }) return null
|
||||
val agentFolders = agent.filter { it.uid.isNotEmpty() }.groupBy { it.uid.lowercase() }.mapValues { (_, rows) ->
|
||||
rows.mapNotNull { hostFolder(context, it.path)?.absolutePath }.toSet()
|
||||
}
|
||||
val registryRows = registry.filter { (uid, _) ->
|
||||
val recorded = agentFolders[uid.lowercase()] ?: return@filter true
|
||||
recorded.any { it in folders }
|
||||
}
|
||||
return (registryRows + agent.map { it.uid to it.path }).mapNotNull { (uid, path) ->
|
||||
if (hostFolder(context, path)?.absolutePath !in folders) return@mapNotNull null
|
||||
val title = title(uid) ?: products[uid.lowercase()]?.let(::titleForProduct)
|
||||
if (title != null && sameTitle(title.uid, id)) uid else null
|
||||
}.distinct()
|
||||
}
|
||||
|
||||
internal fun ownFolders(games: Map<String, Pair<Title, File>>, saved: Map<String, String?>): Map<String, File> {
|
||||
val out = HashMap<String, File>()
|
||||
val taken = HashSet<File>()
|
||||
@@ -317,6 +440,25 @@ object BattleNet {
|
||||
|
||||
internal fun productDbEntries(bytes: ByteArray): List<Pair<String, String>>? = productDbInstalls(bytes)?.map { it.uid to it.path }
|
||||
|
||||
/**
|
||||
* Every registration, including the one an unfinished install or update leaves behind:
|
||||
* `productDbInstalls()` drops entries whose installed flag is 0, which is the state a
|
||||
* cancelled download is in while its folder already holds data.
|
||||
*/
|
||||
internal fun productDbRegistrations(bytes: ByteArray): List<AgentInstall>? {
|
||||
val installs = runCatching { fields(bytes, 0, bytes.size) }.getOrNull()?.filter { it.first == 1 } ?: return null
|
||||
return installs.mapNotNull { (_, start, end) ->
|
||||
runCatching {
|
||||
val install = fields(bytes, start, end)
|
||||
val uid = install.firstOrNull { it.first == 1 }?.let { String(bytes, it.second, it.third - it.second) }
|
||||
val product = install.firstOrNull { it.first == 2 }?.let { String(bytes, it.second, it.third - it.second) }.orEmpty()
|
||||
val path = install.firstOrNull { it.first == 3 }?.let { s -> fields(bytes, s.second, s.third).firstOrNull { it.first == 1 } }
|
||||
?.let { String(bytes, it.second, it.third - it.second) }
|
||||
if (path.isNullOrEmpty()) null else AgentInstall(uid.orEmpty(), path, product)
|
||||
}.getOrElse { return null }
|
||||
}
|
||||
}
|
||||
|
||||
internal fun productDbInstalls(bytes: ByteArray): List<AgentInstall>? {
|
||||
val installs = runCatching { fields(bytes, 0, bytes.size) }.getOrNull()?.filter { it.first == 1 }?.takeIf { it.isNotEmpty() } ?: return null
|
||||
return installs.map { (_, start, end) ->
|
||||
|
||||
@@ -59,18 +59,13 @@ object GameStorage {
|
||||
return when {
|
||||
pref == SessionPrefs.GAME_STORAGE_OFF -> null
|
||||
pref.isEmpty() -> options(context).firstOrNull()?.let { Option(it.name, it.path) }
|
||||
else -> reachable(pref).let { path -> Option(SessionPrefs.gameStorageLabel(context), path).takeIf { attached(File(path)) } }
|
||||
else -> Option(SessionPrefs.gameStorageLabel(context), pref).takeIf { attached(File(pref)) }
|
||||
}
|
||||
}
|
||||
|
||||
fun disconnected(context: Context): Boolean {
|
||||
val pref = SessionPrefs.gameStorage(context)
|
||||
return pref.isNotEmpty() && pref != SessionPrefs.GAME_STORAGE_OFF && !attached(File(reachable(pref)))
|
||||
}
|
||||
|
||||
internal fun reachable(path: String, usable: (File) -> Boolean = { it.isDirectory && it.canWrite() }): String {
|
||||
val alias = UsbLink.storagePath(path)
|
||||
return if (alias != path && !usable(File(path)) && usable(File(alias))) alias else path
|
||||
return pref.isNotEmpty() && pref != SessionPrefs.GAME_STORAGE_OFF && !attached(File(pref))
|
||||
}
|
||||
|
||||
internal fun attached(
|
||||
|
||||
@@ -38,11 +38,13 @@ object NoSteamLaunch {
|
||||
else -> null
|
||||
}?.takeIf { it.isNotEmpty() && GameEnvironment.validScope(it) }
|
||||
|
||||
fun battleNetTitleScope(context: Context, code: String): String? =
|
||||
AddedGames.scan(context).firstOrNull { game ->
|
||||
fun battleNetTitleScope(context: Context, code: String): String? {
|
||||
val games = runCatching { com.droiddeck.launcher.runtime.BattleNet.games(context) }.getOrDefault(emptyList())
|
||||
return AddedGames.scan(context).firstOrNull { game ->
|
||||
game.source == com.droiddeck.launcher.stores.Store.BATTLENET.id &&
|
||||
game.storeId?.let(com.droiddeck.launcher.runtime.BattleNet::title)?.code == code
|
||||
game.storeId?.let { com.droiddeck.launcher.runtime.BattleNet.launchCode(games, it, game.folder) } == code
|
||||
}?.let { settingsId(it).toString() }
|
||||
}
|
||||
|
||||
fun resolution(config: GameEnvironment.Config, scope: String?, output: Pair<Int, Int>): Pair<Int, Int>? {
|
||||
val choice = scope?.let { GameEnvironment.gameResolution(config, it) } ?: return null
|
||||
@@ -54,10 +56,11 @@ object NoSteamLaunch {
|
||||
private fun viaBattleNet(game: Library.SteamGame): Boolean =
|
||||
game.library == Library.ADDED && game.source == com.droiddeck.launcher.stores.Store.BATTLENET.id
|
||||
|
||||
fun command(game: Library.SteamGame, added: AddedGames.Game?): Command? = when {
|
||||
fun command(context: Context, game: Library.SteamGame, added: AddedGames.Game?): Command? = when {
|
||||
game.library == Library.EPIC_LAUNCHER -> Command(EPIC, listOf("run"), game.name)
|
||||
viaBattleNet(game) ->
|
||||
game.storeId?.let(com.droiddeck.launcher.runtime.BattleNet::title)?.let { Command(BATTLENET, listOf("launch", it.code), game.name) }
|
||||
game.storeId?.let { com.droiddeck.launcher.runtime.BattleNet.launchCode(context, it, game.gameFiles) }
|
||||
?.let { Command(BATTLENET, listOf("launch", it), game.name) }
|
||||
game.library == Library.ADDED -> added?.let { a -> a.steamAppId?.let { Command(PROTON_RUN, listOf("--app", it.toString()), a.name) } ?: addedCommand(a) }
|
||||
game.appId > 0 -> Command(PROTON_RUN, listOf("--app", game.appId.toString()), game.name)
|
||||
else -> null
|
||||
|
||||
@@ -46,16 +46,7 @@ object SecondaryLibrary {
|
||||
}
|
||||
|
||||
fun privateRoot(files: File, library: File): File {
|
||||
val own = privateDir(files, library.canonicalPath)
|
||||
if (own.exists()) return own
|
||||
val raw = UsbLink.rawPath(library.absolutePath)
|
||||
val alias = if (raw != library.absolutePath) raw else UsbLink.storagePath(library.absolutePath)
|
||||
if (alias == library.absolutePath) return own
|
||||
return privateDir(files, runCatching { File(alias).canonicalPath }.getOrDefault(alias)).takeIf { it.exists() } ?: own
|
||||
}
|
||||
|
||||
private fun privateDir(files: File, path: String): File {
|
||||
val digest = MessageDigest.getInstance("SHA-256").digest(path.toByteArray())
|
||||
val digest = MessageDigest.getInstance("SHA-256").digest(library.canonicalPath.toByteArray())
|
||||
.joinToString("") { "%02x".format(it.toInt() and 255) }
|
||||
return File(files, "steam-libraries/$digest")
|
||||
}
|
||||
|
||||
@@ -10,23 +10,9 @@ import java.io.File
|
||||
// browser view placed outside the Big Picture window, composition capped at "notification" so gamescope keeps the game
|
||||
// focused, and gamepad focus on the main UI. The hold is a lease the app renews, so Steam recovers if the app goes away.
|
||||
object SteamQam {
|
||||
/** [mainPath] is Steam's main menu page, shown beside the quick access menu in the split layout. */
|
||||
data class Target(val port: Int, val path: String, val mainPath: String? = null)
|
||||
data class Target(val port: Int, val path: String)
|
||||
|
||||
const val MAIN_MENU = 1
|
||||
const val QUICK_ACCESS = 2
|
||||
|
||||
/** Height in CSS pixels both menus are laid out at in the split layout, so they show at one scale. */
|
||||
const val SPLIT_CSS_HEIGHT = 480
|
||||
|
||||
/** Steam's own width for the main menu; quick access takes the rest of the panel. */
|
||||
const val MAIN_CSS_WIDTH = 240
|
||||
|
||||
/** Holds the parked main menu in place and spreads its item rows (not dividers) over the full height, at most 80 px each. */
|
||||
private const val MAIN_PARKED_CSS =
|
||||
".BasicUI > .Panel { transform: none !important; width: 100% !important; height: 100% !important; margin: 0 !important; } " +
|
||||
".BasicUI > .Panel > :has(> .Focusable) { flex: 1 1 0 !important; height: auto !important; max-height: 80px; } " +
|
||||
".BasicUI > .Panel > :has(> .Focusable) > .Panel { height: 100% !important; }"
|
||||
const val LEASE_MS = 5_000
|
||||
private const val TAG = "SteamQam"
|
||||
private const val EVAL_MS = 6_000L
|
||||
@@ -40,54 +26,21 @@ object SteamQam {
|
||||
* Takes or renews the lease for [owner], or releases it. A live lease held by a newer panel is never taken back by an
|
||||
* older one, so a late request from a panel being torn down cannot end its replacement's lease or change its layout.
|
||||
*/
|
||||
internal fun leaseScript(on: Boolean, owner: Long, aspect: Float = 0f, split: Boolean = false): String =
|
||||
internal fun leaseScript(on: Boolean, owner: Long, aspect: Float = 0f): String =
|
||||
if (on) "if (!(g.__ddQamUntil > Date.now()) || !(g.__ddQamOwner > $owner)) { g.__ddQamOwner = $owner; g.__ddQamUntil = Date.now() + $LEASE_MS;" +
|
||||
(if (aspect > 0f) " g.__ddQamAspect = $aspect;" else "") + " g.__ddQamSplit = $split; }"
|
||||
(if (aspect > 0f) " g.__ddQamAspect = $aspect;" else "") + " }"
|
||||
else "if (g.__ddQamOwner === $owner) g.__ddQamUntil = 0;"
|
||||
|
||||
/**
|
||||
* [aspect] is the panel's width over height: the menu is laid out at that shape so every tab shows at one scale. With
|
||||
* [split], Steam's main menu is kept rendered at its own width beside the quick access menu, which gets the rest.
|
||||
*/
|
||||
internal fun script(on: Boolean, aspect: Float = 0f, owner: Long = 0, split: Boolean = false): String = """(() => {
|
||||
const g = globalThis, QAM = 2, MAIN = 1;
|
||||
/** [aspect] is the panel's width over height: the menu is laid out at that shape so every tab shows at one scale. */
|
||||
internal fun script(on: Boolean, aspect: Float = 0f, owner: Long = 0): String = """(() => {
|
||||
const g = globalThis, QAM = 2;
|
||||
const W = SteamUIStore.WindowStore.SteamUIWindows[0];
|
||||
const m = W.MenuStore, c = W.m_CompositionStateStore;
|
||||
const nav = W.m_FocusNavContext;
|
||||
const popup = g_PopupManager.GetExistingPopup("SP BPM_uid0");
|
||||
const held = () => g.__ddQamUntil > Date.now();
|
||||
const split = () => held() && g.__ddQamSplit === true;
|
||||
// Steam's views carry no names: the main menu's is the one Steam focuses while the main menu is open. Until Steam
|
||||
// has shown it, the main menu is opened once with its view parked like the quick access menu's.
|
||||
const probing = () => g.__ddMainProbe > Date.now();
|
||||
const ours = () => held() && !g.__ddQamTop && (m.m_eOpenSideMenu === QAM || (probing() && m.m_eOpenSideMenu === MAIN));
|
||||
const ours = () => held() && m.m_eOpenSideMenu === QAM && !g.__ddQamTop;
|
||||
const width = (h) => g.__ddQamAspect > 0 ? Math.round(h * g.__ddQamAspect) : 0;
|
||||
const parkX = () => popup.m_popup.innerWidth + 64;
|
||||
const mainSize = () => [$MAIN_CSS_WIDTH, $SPLIT_CSS_HEIGHT];
|
||||
const qamSplitSize = () => [Math.max(Math.round($SPLIT_CSS_HEIGHT * (g.__ddQamAspect > 0 ? g.__ddQamAspect : 1)) - $MAIN_CSS_WIDTH, 320), $SPLIT_CSS_HEIGHT];
|
||||
const size = (w, h) => split() ? qamSplitSize() : [width(h) || w, h];
|
||||
const mainView = () => views().find(v => v.__ddMain);
|
||||
// Only the quick access view is parked: the one Steam focuses while quick access is open. Before Steam has
|
||||
// focused it, any view but the main menu's and the header's web page (Store and other pages) may be it.
|
||||
const headerView = () => W.m_HeaderStore?.m_currentBrowserAndBackstack?.m_browserView;
|
||||
const isQam = (v) => !v.__ddMain && v !== headerView() &&
|
||||
(!!v.__ddQamView || !views().some(o => o.__ddQamView) || (probing() && m.m_eOpenSideMenu === MAIN));
|
||||
const mainParked = () => split() && (m.m_eOpenSideMenu !== MAIN || probing());
|
||||
const mainDoc = () => {
|
||||
for (const s of SteamUIStore.m_GamepadNavigationManager?.m_rgGamepadInputSources || []) {
|
||||
try { const d = s.m_targetWindow?.document; if (d?.title?.startsWith("MainMenu")) return d; } catch (e) {}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
// Steam slides the main menu out whenever it is not the open side menu; parked, it stays in place and fills its view.
|
||||
const mainStyle = (on) => {
|
||||
const d = mainDoc();
|
||||
let s = d?.getElementById("dd-main-split");
|
||||
if (!on) { s?.remove(); return; }
|
||||
if (!d?.head) return;
|
||||
if (!s) { s = d.createElement("style"); s.id = "dd-main-split"; d.head.appendChild(s); }
|
||||
if (s.textContent !== "$MAIN_PARKED_CSS") s.textContent = "$MAIN_PARKED_CSS";
|
||||
};
|
||||
if (!c.__ddQam) {
|
||||
c.__ddQam = c.ComputeOverallMinimumRequestedComposition;
|
||||
m.__ddQam = m.OnMenuDeactivated;
|
||||
@@ -106,18 +59,6 @@ object SteamQam {
|
||||
return without >= 2 ? v : 1;
|
||||
};
|
||||
}
|
||||
// Steam frosts its Store page while a side menu is open; a parked menu is not over it.
|
||||
const inst = m.m_Instance;
|
||||
if (inst?.SetStoreBrowserGlass && !inst.__ddQamGlass) {
|
||||
inst.__ddQamGlass = inst.SetStoreBrowserGlass;
|
||||
inst.SetStoreBrowserGlass = function (e) { return inst.__ddQamGlass.call(this, ours() ? 0 : e); };
|
||||
}
|
||||
const glass = () => {
|
||||
const on = !ours() && m.m_eOpenSideMenu !== 0;
|
||||
if (g.__ddQamGlassOn === on) return;
|
||||
g.__ddQamGlassOn = on;
|
||||
inst?.SetStoreBrowserGlass?.(m.m_eOpenSideMenu);
|
||||
};
|
||||
const views = () => popup?.m_rgChildBrowserViews || [];
|
||||
const backdrop = (hide) => {
|
||||
const doc = popup?.m_popup?.document;
|
||||
@@ -134,61 +75,16 @@ object SteamQam {
|
||||
};
|
||||
const keep = () => {
|
||||
for (const v of views()) {
|
||||
if (!v.__ddQam) v.__ddQam = v.SetBounds;
|
||||
if (v.__ddQamW === 4) continue;
|
||||
v.__ddQamW = 4;
|
||||
v.__ddQamVis = v.__ddQamVis || v.SetVisible;
|
||||
v.__ddQamFocus = v.__ddQamFocus || v.SetFocus;
|
||||
if (v.__ddQam) continue;
|
||||
v.__ddQam = v.SetBounds;
|
||||
v.SetBounds = function (x, y, w, h, ...r) {
|
||||
if (v.__ddMain && mainParked()) {
|
||||
if (w > 0) v.__ddMainAsked = [x, y, w, h];
|
||||
[w, h] = mainSize();
|
||||
v.__ddMainOn = true; v.__ddMainW = w; v.__ddMainH = h;
|
||||
return v.__ddQam.call(this, parkX(), 0, w, h, ...r);
|
||||
}
|
||||
if (v.__ddMain && w > 0) mainStyle(false);
|
||||
v.__ddAsked = [x, y, w, h];
|
||||
if (w > 0 && ours() && isQam(v)) { x = parkX(); [w, h] = size(w, h); }
|
||||
if (w > 0 && ours()) { x = popup.m_popup.innerWidth + 64; w = width(h) || w; }
|
||||
v.__ddAt = x;
|
||||
v.__ddW = w;
|
||||
v.__ddH = h;
|
||||
return v.__ddQam.call(this, x, y, w, h, ...r);
|
||||
};
|
||||
v.SetVisible = function (on, ...r) {
|
||||
return v.__ddQamVis.call(this, on || (!!v.__ddMain && mainParked()), ...r);
|
||||
};
|
||||
v.SetFocus = function (on, ...r) {
|
||||
if (on && m.m_eOpenSideMenu === MAIN && v !== headerView()) {
|
||||
for (const o of views()) if (o !== v) delete o.__ddMain;
|
||||
v.__ddMain = true;
|
||||
delete v.__ddQamView;
|
||||
}
|
||||
if (on && m.m_eOpenSideMenu === QAM && !v.__ddMain && v !== headerView()) {
|
||||
for (const o of views()) if (o !== v) delete o.__ddQamView;
|
||||
v.__ddQamView = true;
|
||||
}
|
||||
return v.__ddQamFocus.call(this, on, ...r);
|
||||
};
|
||||
}
|
||||
if (g.__ddMainProbe && !probing()) { g.__ddMainProbe = 0; g.__ddMainProbed = true; }
|
||||
if (probing() && mainView()) { g.__ddMainProbe = 0; g.__ddMainProbed = true; }
|
||||
const mv = mainView();
|
||||
if (mv && !probing()) {
|
||||
if (mainParked()) {
|
||||
const [w, h] = mainSize();
|
||||
if (!mv.__ddMainOn || mv.__ddMainW !== w || mv.__ddMainH !== h) {
|
||||
mv.__ddQam.call(mv, parkX(), 0, w, h);
|
||||
mv.__ddQamVis.call(mv, true);
|
||||
mv.__ddMainOn = true; mv.__ddMainW = w; mv.__ddMainH = h;
|
||||
}
|
||||
} else if (mv.__ddMainOn) {
|
||||
mv.__ddMainOn = false;
|
||||
if (m.m_eOpenSideMenu !== MAIN) { mv.__ddQamVis.call(mv, false); mv.__ddQam.call(mv, 0, 0, 0, 0); }
|
||||
else if (mv.__ddMainAsked) mv.__ddQam.call(mv, ...mv.__ddMainAsked);
|
||||
}
|
||||
}
|
||||
mainStyle(!!mv && mainParked() && !probing());
|
||||
glass();
|
||||
if (!held()) {
|
||||
const parked = !g.__ddQamTop;
|
||||
g.__ddQamTop = false;
|
||||
@@ -228,25 +124,6 @@ object SteamQam {
|
||||
}
|
||||
g.__ddQamTop = false;
|
||||
}
|
||||
// Each Split activation gets a fresh probe budget, and a spent one refills after a backoff, so a Steam that was
|
||||
// still loading does not leave the main menu undiscovered for good.
|
||||
if (split() !== !!g.__ddQamSplitOn) { g.__ddQamSplitOn = split(); if (split()) g.__ddMainProbes = 0; }
|
||||
if (split() && !mv) {
|
||||
if (probing()) return;
|
||||
if ((g.__ddMainProbes || 0) >= 3 && Date.now() - (g.__ddMainProbeLast || 0) > 30000) g.__ddMainProbes = 0;
|
||||
if ((g.__ddMainProbes || 0) < 3 && m.m_eOpenSideMenu !== MAIN) {
|
||||
g.__ddMainProbes = (g.__ddMainProbes || 0) + 1;
|
||||
g.__ddMainProbeLast = Date.now();
|
||||
g.__ddMainProbe = Date.now() + 1500;
|
||||
m.OpenMainMenu();
|
||||
c.EnsureCorrectComposition?.();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (g.__ddMainProbed) {
|
||||
g.__ddMainProbed = false;
|
||||
if (m.m_eOpenSideMenu === MAIN) m.OpenQuickAccessMenu(g.__ddQamTab ?? undefined);
|
||||
}
|
||||
const decky = !!g.DeckyPluginLoader?.tabsHook?.qamBrowserViewPatch;
|
||||
// Decky hooks the menu after Steam starts; the menu has to unmount for its tab to appear, so reopen on the next tick.
|
||||
if (m.m_eOpenSideMenu === QAM && decky && !g.__ddQamDecky) { g.__ddQamDecky = true; m.CloseSideMenus(); return; }
|
||||
@@ -259,26 +136,18 @@ object SteamQam {
|
||||
if (m.m_eQuickAccessTab != null) g.__ddQamTab = m.m_eQuickAccessTab;
|
||||
if (!g.__ddQamOn) { g.__ddQamOn = true; c.EnsureCorrectComposition?.(); }
|
||||
for (const v of views()) {
|
||||
if (v.__ddMain) continue;
|
||||
if (!isQam(v)) {
|
||||
// A view parked before the quick access view was known goes back where Steam asked for it.
|
||||
const a = v.__ddAsked;
|
||||
if (a?.[2] > 0 && v.__ddAt >= popup.m_popup.innerWidth) { v.__ddQam.call(v, ...a); v.__ddAt = a[0]; v.__ddW = a[2]; v.__ddH = a[3]; }
|
||||
continue;
|
||||
}
|
||||
if (!v.__ddAsked) {
|
||||
const b = v.GetBounds?.();
|
||||
if (b && b.width > 0) { v.__ddAsked = [b.x, b.y, b.width, b.height]; v.__ddAt = b.x; v.__ddW = b.width; v.__ddH = b.height; }
|
||||
if (b && b.width > 0) { v.__ddAsked = [b.x, b.y, b.width, b.height]; v.__ddAt = b.x; v.__ddW = b.width; }
|
||||
}
|
||||
const a = v.__ddAsked;
|
||||
const [w, h] = a?.[2] > 0 ? size(a[2], a[3]) : [0, 0];
|
||||
if (a?.[2] > 0 && (v.__ddAt < popup.m_popup.innerWidth || v.__ddW !== w || v.__ddH !== h)) v.SetBounds(...a);
|
||||
if (a?.[2] > 0 && (v.__ddAt < popup.m_popup.innerWidth || (width(a[3]) && v.__ddW !== width(a[3])))) v.SetBounds(...a);
|
||||
}
|
||||
const main = nav?.m_rgGamepadNavigationTrees?.find(t => t.m_ID === "GamepadUI_Full_Root");
|
||||
if (main && /^(QuickAccess|MainMenu)/.test(nav.m_LastActiveNavTree?.m_ID ?? "")) nav.SetActiveNavTree(main);
|
||||
if (main && nav.m_LastActiveNavTree?.m_ID?.startsWith("QuickAccess")) nav.SetActiveNavTree(main);
|
||||
backdrop(true);
|
||||
};
|
||||
${leaseScript(on, owner, aspect, split)}
|
||||
${leaseScript(on, owner, aspect)}
|
||||
keep();
|
||||
if (held() && !g.__ddQamTimer) {
|
||||
g.__ddQamTimer = setInterval(() => {
|
||||
@@ -292,8 +161,7 @@ object SteamQam {
|
||||
/** [open] is Steam's open side menu; [top] is true while the menu is shown on the top screen. */
|
||||
data class Hold(val open: Int, val top: Boolean)
|
||||
|
||||
fun hold(context: Context, aspect: Float, owner: Long, split: Boolean = false): Hold? =
|
||||
eval(context, script(true, aspect, owner, split))?.let(::parseHold)
|
||||
fun hold(context: Context, aspect: Float, owner: Long): Hold? = eval(context, script(true, aspect, owner))?.let(::parseHold)
|
||||
|
||||
internal fun parseHold(text: String): Hold? = runCatching {
|
||||
val a = JSONArray(text)
|
||||
@@ -313,9 +181,7 @@ object SteamQam {
|
||||
fun target(context: Context): Target? = runCatching {
|
||||
val devtools = File(AgentGuest.dir(context), "cdp-port").readText().trim().toInt()
|
||||
val (relay, secret) = parseRelay(helper(context, "start", devtools.toString())) ?: return null
|
||||
val found = runCatching {
|
||||
parseTarget(relay, get(relay, "/$secret/json"))?.let { t -> t.copy(path = "/$secret${t.path}", mainPath = t.mainPath?.let { "/$secret$it" }) }
|
||||
}
|
||||
val found = runCatching { parseTarget(relay, get(relay, "/$secret/json"))?.let { it.copy(path = "/$secret${it.path}") } }
|
||||
if (found.getOrNull() == null) helper(context, "stop", relay.toString())
|
||||
found.getOrThrow()
|
||||
}.onFailure { android.util.Log.e(TAG, "no quick access target: $it") }.getOrNull()
|
||||
@@ -366,16 +232,14 @@ object SteamQam {
|
||||
|
||||
internal fun parseTarget(port: Int, json: String): Target? {
|
||||
val list = JSONArray(json)
|
||||
fun page(prefix: String): String? {
|
||||
for (i in 0 until list.length()) {
|
||||
val t = list.optJSONObject(i) ?: continue
|
||||
if (!t.optString("title").startsWith(prefix)) continue
|
||||
val ws = t.optString("webSocketDebuggerUrl")
|
||||
Regex("^ws://[^/]+(/devtools/page/[A-Za-z0-9-]+)$").find(ws)?.groupValues?.get(1)?.let { return it }
|
||||
}
|
||||
return null
|
||||
for (i in 0 until list.length()) {
|
||||
val t = list.optJSONObject(i) ?: continue
|
||||
if (!t.optString("title").startsWith("QuickAccess")) continue
|
||||
val ws = t.optString("webSocketDebuggerUrl")
|
||||
val path = Regex("^ws://[^/]+(/devtools/page/[A-Za-z0-9-]+)$").find(ws)?.groupValues?.get(1) ?: continue
|
||||
return Target(port, path)
|
||||
}
|
||||
return page("QuickAccess")?.let { Target(port, it, page("MainMenu")) }
|
||||
return null
|
||||
}
|
||||
|
||||
private fun eval(context: Context, expression: String): String? = runCatching {
|
||||
|
||||
@@ -79,6 +79,7 @@ object StoresState {
|
||||
fun refresh(context: Context) {
|
||||
val app = context.applicationContext
|
||||
com.droiddeck.launcher.stores.download.SavedQueue.restore(app)
|
||||
com.droiddeck.launcher.stores.battlenet.BattleNetInstall.reconcile(app)
|
||||
if (refreshRequests.getAndIncrement() > 0) return
|
||||
var seen = 0
|
||||
background("stores-refresh", onFailure = { if (refreshRequests.getAndSet(0) > seen) main.post { refresh(app) } }) {
|
||||
@@ -103,6 +104,8 @@ object StoresState {
|
||||
accountsLoaded = true
|
||||
}
|
||||
com.droiddeck.launcher.stores.gog.GogMaintenance.checkInstalled(app, onDisk)
|
||||
onDisk.filter { it.sidecar.store == Store.BATTLENET }
|
||||
.forEach { com.droiddeck.launcher.stores.battlenet.BattleNetInstall.checkUpdate(app, it) }
|
||||
}
|
||||
} while (!refreshRequests.compareAndSet(seen, 0))
|
||||
}
|
||||
@@ -137,7 +140,16 @@ object StoresState {
|
||||
StoreInstalls.discard(app, folder, listOf(java.io.File(folder, ".chunks"), java.io.File(folder, ".gog_chunks"), StoreInstallRoot.scratchDir(app, item.store, item.id)))
|
||||
}
|
||||
|
||||
fun installedGame(store: Store, id: String): InstalledStoreGame? = installed.firstOrNull { it.sidecar.store == store && it.sidecar.id == id }
|
||||
fun installedGame(store: Store, id: String, folder: java.io.File? = null): InstalledStoreGame? =
|
||||
pickInstalled(store, id, folder, installed)
|
||||
|
||||
internal fun pickInstalled(
|
||||
store: Store, id: String, folder: java.io.File?, candidates: List<InstalledStoreGame>,
|
||||
): InstalledStoreGame? {
|
||||
val matches = candidates.filter { it.sidecar.store == store && it.sidecar.id == id }
|
||||
if (folder != null) return matches.firstOrNull { it.folder.absolutePath == folder.absolutePath }
|
||||
return matches.firstOrNull()
|
||||
}
|
||||
|
||||
fun detailItem(store: Store, id: String): CatalogItem? = detailCatalogItem(
|
||||
store, id, library[store].orEmpty(),
|
||||
@@ -336,9 +348,13 @@ object StoresState {
|
||||
|
||||
private fun uninstallHeld(app: Context, game: InstalledStoreGame, key: String, onDone: () -> Unit) {
|
||||
runCatching { backends[game.sidecar.store]?.uninstall(app, game) }
|
||||
if (game.sidecar.store == Store.BATTLENET && com.droiddeck.launcher.runtime.BattleNet.games(app).any { it.folder.absolutePath == game.folder.absolutePath }) {
|
||||
main.post { uninstalling.remove(key); onDone() }
|
||||
return
|
||||
if (game.sidecar.store == Store.BATTLENET) {
|
||||
val listed = com.droiddeck.launcher.runtime.BattleNet.games(app).any { it.folder.absolutePath == game.folder.absolutePath }
|
||||
// A registration we could not read is not the same as no registration: keep the folder.
|
||||
if (listed || com.droiddeck.launcher.runtime.BattleNet.folderHasRegistrations(app, game.folder) != false) {
|
||||
main.post { uninstalling.remove(key); onDone() }
|
||||
return
|
||||
}
|
||||
}
|
||||
StoreInstalls.uninstall(app, game, progress = { f -> main.post { if (key in uninstalling) uninstalling[key] = f } }, removed = {
|
||||
main.post {
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.droiddeck.launcher.stores.battlenet
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.StandardCopyOption
|
||||
import java.security.MessageDigest
|
||||
|
||||
/**
|
||||
* A cancelled Battle.net install that could not be cleaned up yet. The marker is written before
|
||||
* the cleanup starts and removed only after the registration and the folder are both gone, so a
|
||||
* restart can reconcile a registration that the client writes late.
|
||||
*/
|
||||
internal object BattleNetCleanup {
|
||||
private const val TAG = "BattleNetCleanup"
|
||||
private const val DIR = "battlenet-cleanup"
|
||||
internal const val ACTIVE = "active"
|
||||
internal const val PENDING = "pending"
|
||||
internal const val WATCHING = "watching"
|
||||
|
||||
internal data class Pending(
|
||||
val folder: File,
|
||||
val id: String,
|
||||
val createdFolder: Boolean,
|
||||
val state: String,
|
||||
val attempts: Int,
|
||||
val nextAt: Long,
|
||||
val stamp: Long,
|
||||
)
|
||||
|
||||
internal fun dir(context: Context): File = File(context.filesDir, DIR)
|
||||
|
||||
@Synchronized
|
||||
internal fun mark(context: Context, folder: File, id: String, createdFolder: Boolean, state: String = ACTIVE) {
|
||||
val current = get(context, folder)
|
||||
write(
|
||||
context,
|
||||
Pending(folder, id, createdFolder || current?.createdFolder == true, state, current?.attempts ?: 0, current?.nextAt ?: 0L, System.nanoTime()),
|
||||
)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
internal fun markActive(context: Context, folder: File, id: String, createdFolder: Boolean) {
|
||||
val current = get(context, folder)
|
||||
write(
|
||||
context,
|
||||
Pending(
|
||||
folder, id, createdFolder || current?.createdFolder == true,
|
||||
current?.state?.takeIf { it != ACTIVE } ?: ACTIVE,
|
||||
current?.attempts ?: 0, current?.nextAt ?: 0L, System.nanoTime(),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
internal fun update(context: Context, folder: File, state: String, attempts: Int, nextAt: Long) {
|
||||
val current = get(context, folder) ?: return
|
||||
write(context, current.copy(state = state, attempts = attempts, nextAt = nextAt))
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
internal fun get(context: Context, folder: File): Pending? {
|
||||
val file = file(context, folder)
|
||||
val json = runCatching { JSONObject(file.readText()) }.getOrNull() ?: return null
|
||||
return runCatching {
|
||||
Pending(
|
||||
folder = File(json.getString("folder")),
|
||||
id = json.getString("id"),
|
||||
createdFolder = json.optBoolean("createdFolder"),
|
||||
state = json.optString("state", PENDING),
|
||||
attempts = json.optInt("attempts"),
|
||||
nextAt = json.optLong("nextAt"),
|
||||
stamp = json.optLong("stamp"),
|
||||
)
|
||||
}.getOrNull()
|
||||
}
|
||||
|
||||
internal fun pending(context: Context): List<Pending> = dir(context).listFiles()
|
||||
?.filter { it.isFile && it.name.endsWith(".json") }
|
||||
?.mapNotNull { file -> runCatching { JSONObject(file.readText()) }.getOrNull() }
|
||||
?.mapNotNull { json ->
|
||||
runCatching {
|
||||
Pending(
|
||||
folder = File(json.getString("folder")),
|
||||
id = json.getString("id"),
|
||||
createdFolder = json.optBoolean("createdFolder"),
|
||||
state = json.optString("state", PENDING),
|
||||
attempts = json.optInt("attempts"),
|
||||
nextAt = json.optLong("nextAt"),
|
||||
stamp = json.optLong("stamp"),
|
||||
)
|
||||
}.getOrNull()
|
||||
}
|
||||
?.filter { it.state != ACTIVE }
|
||||
?.sortedBy { it.nextAt }
|
||||
.orEmpty()
|
||||
|
||||
@Synchronized
|
||||
internal fun clear(context: Context, folder: File) {
|
||||
file(context, folder).delete()
|
||||
}
|
||||
|
||||
private fun file(context: Context, folder: File) =
|
||||
File(dir(context), MessageDigest.getInstance("SHA-256").run {
|
||||
update(folder.absolutePath.toByteArray())
|
||||
digest().joinToString("") { "%02x".format(it.toInt() and 0xff) }
|
||||
} + ".json")
|
||||
|
||||
private fun write(context: Context, pending: Pending) {
|
||||
val target = file(context, pending.folder)
|
||||
target.parentFile?.mkdirs()
|
||||
val json = JSONObject().apply {
|
||||
put("folder", pending.folder.absolutePath)
|
||||
put("id", pending.id)
|
||||
put("createdFolder", pending.createdFolder)
|
||||
put("state", pending.state)
|
||||
put("attempts", pending.attempts)
|
||||
put("nextAt", pending.nextAt)
|
||||
put("stamp", pending.stamp)
|
||||
}
|
||||
val tmp = File(target.parentFile, "${target.name}.tmp")
|
||||
runCatching {
|
||||
tmp.writeText(json.toString())
|
||||
Files.move(tmp.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING)
|
||||
}.onFailure { Log.w(TAG, "could not write ${target.path}", it) }
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,13 @@ import com.droiddeck.launcher.stores.CatalogItem
|
||||
import com.droiddeck.launcher.stores.InstalledStoreGame
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import com.droiddeck.launcher.stores.StoreInstallRoot
|
||||
import com.droiddeck.launcher.stores.StoreInstalls
|
||||
import com.droiddeck.launcher.stores.StoreLanguage
|
||||
import com.droiddeck.launcher.stores.StoresState
|
||||
import com.droiddeck.launcher.stores.download.DownloadEntry
|
||||
import com.droiddeck.launcher.stores.download.DownloadQueue
|
||||
import com.droiddeck.launcher.stores.download.DownloadStage
|
||||
import com.droiddeck.launcher.stores.download.SavedQueue
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
import java.net.HttpURLConnection
|
||||
@@ -35,7 +37,10 @@ object BattleNetInstall {
|
||||
private const val CN = "cn"
|
||||
private const val BUILD_INFO = ".build.info"
|
||||
private const val CHECK_AGAIN_MS = 30 * 60_000L
|
||||
private const val CHECK_RETRY_MS = 30_000L
|
||||
private const val CHECK_RETRY_MAX = 2
|
||||
private const val START_WAIT_MS = 60_000L
|
||||
private val reconciling = AtomicBoolean(false)
|
||||
|
||||
/** Blizzard serves China from battlenet.com.cn; its global version hostnames do not answer for that region. */
|
||||
internal fun versionsUrl(region: String, product: String): String =
|
||||
@@ -49,11 +54,32 @@ object BattleNetInstall {
|
||||
|
||||
internal val checks = Executors.newSingleThreadExecutor { r -> Thread(r, "battlenet-updates") }
|
||||
internal val checkedAt = HashMap<String, Long>()
|
||||
private val checkAttempts = java.util.concurrent.ConcurrentHashMap<String, Int>()
|
||||
private val checkRetry = Executors.newSingleThreadScheduledExecutor { r ->
|
||||
Thread(r, "battlenet-update-retry").apply { isDaemon = true }
|
||||
}
|
||||
|
||||
/** Test seams: the version service and the delayed re-check. */
|
||||
internal var fetchVersions: (String) -> String = ::fetch
|
||||
internal var scheduleRecheck: (() -> Unit, Long) -> Unit = { body, delay ->
|
||||
checkRetry.schedule(Runnable { body() }, delay, TimeUnit.MILLISECONDS)
|
||||
}
|
||||
|
||||
val updates = mutableStateMapOf<String, Boolean>()
|
||||
|
||||
fun updateKey(id: String, folder: File?): String = "$id@${folder?.absolutePath ?: ""}"
|
||||
|
||||
fun product(id: String): String? = BattleNet.title(id)?.product
|
||||
|
||||
/** The China client serves StarCraft II, Diablo II and Diablo III from products of their own; anbs_cn shares anbs. */
|
||||
private val CN_PRODUCTS = mapOf(
|
||||
"osi" to "osic",
|
||||
"s2" to "s2c",
|
||||
"diablo3" to "d3cn",
|
||||
)
|
||||
|
||||
internal fun chinaProduct(id: String): String? = CN_PRODUCTS[id]
|
||||
|
||||
fun headless(item: CatalogItem): Boolean = item.store == Store.BATTLENET && product(item.id) != null
|
||||
|
||||
internal fun locale(locale: Locale): String {
|
||||
@@ -87,19 +113,31 @@ object BattleNetInstall {
|
||||
|
||||
fun enqueue(context: Context, item: CatalogItem, folder: File, update: Boolean = false) {
|
||||
val app = context.applicationContext
|
||||
val recorded = item.extra[PREEXISTING]
|
||||
val tagged = if (recorded == "0" || recorded == "1") item
|
||||
else item.copy(extra = item.extra + (PREEXISTING to "pending"))
|
||||
val entry = DownloadEntry(
|
||||
Store.BATTLENET, item.id, item.title, cover = item.tallImageUrl ?: item.imageUrl,
|
||||
Store.BATTLENET, tagged.id, tagged.title, cover = tagged.tallImageUrl ?: tagged.imageUrl,
|
||||
location = StoreInstallRoot.labelFor(app, folder),
|
||||
cleanupKey = "${Store.BATTLENET.id}:${tagged.id}",
|
||||
)
|
||||
DownloadQueue.enqueue(app, entry) { BattleNetInstaller(app, item, folder, update) }
|
||||
val ownership = Ownership(tagged)
|
||||
DownloadQueue.enqueue(app, entry, onAccepted = {
|
||||
SavedQueue.remember(app, tagged, folder.parentFile?.parentFile)
|
||||
}) { BattleNetInstaller(app, tagged, folder, update, ownership) }
|
||||
}
|
||||
|
||||
fun update(context: Context, game: InstalledStoreGame) {
|
||||
val app = context.applicationContext
|
||||
Thread({
|
||||
val item = updateItem(game, installUid(app, game))
|
||||
game.folder.parentFile?.parentFile?.let { com.droiddeck.launcher.stores.download.SavedQueue.remember(app, item, it) }
|
||||
enqueue(app, item, game.folder, update = true)
|
||||
val uid = installUid(app, game)
|
||||
if (uid == null) {
|
||||
Log.w(TAG, "no Battle.net install matches ${game.folder}")
|
||||
StoresState.logLine("Battle.net: no registration matches ${game.folder.name}; update it from Battle.net")
|
||||
StoresState.post { updates.remove(updateKey(game.sidecar.id, game.folder)) }
|
||||
} else {
|
||||
enqueue(app, updateItem(game, uid), game.folder, update = true)
|
||||
}
|
||||
}, "battlenet-update").start()
|
||||
}
|
||||
|
||||
@@ -111,17 +149,120 @@ object BattleNetInstall {
|
||||
internal fun updateFolder(item: CatalogItem): File? = item.extra[UPDATE_FOLDER]?.let(::File)
|
||||
|
||||
internal const val INSTALL_UID = "installUid"
|
||||
internal const val PREEXISTING = "preexisting"
|
||||
internal const val UPDATE_FOLDER = "updateFolder"
|
||||
internal const val STALLED = "stalled"
|
||||
|
||||
internal fun installUid(context: Context, game: InstalledStoreGame): String =
|
||||
runCatching { BattleNet.games(context).firstOrNull { it.uid == game.sidecar.id }?.installUid }.getOrNull() ?: game.sidecar.id
|
||||
/** The registration of this folder: games() keeps one copy per launch code, so a second copy is not in it. */
|
||||
internal fun installUid(context: Context, game: InstalledStoreGame): String? =
|
||||
runCatching { BattleNet.installedRegistrationAt(context, game.sidecar.id, game.folder) }.getOrNull()?.first
|
||||
|
||||
fun uninstall(context: Context, game: InstalledStoreGame): Boolean {
|
||||
if (product(game.sidecar.id) == null || !BattleNet.installed(context)) return false
|
||||
val done = agentUninstall(context, installUid(context, game))
|
||||
if (done) StoresState.post { StoresState.notifyLibraryChanged(context.applicationContext) }
|
||||
return done
|
||||
val uid = installUid(context, game) ?: return false
|
||||
val done = agentUninstall(context, uid)
|
||||
val gone = registrationsGone(context, game.sidecar.id, game.folder, UNINSTALL_VERIFY_MS)
|
||||
if (gone == null || gone.isNotEmpty()) {
|
||||
Log.w(TAG, "uninstall $uid: the registration in ${game.folder.path} is still there")
|
||||
return false
|
||||
}
|
||||
if (!done) Log.i(TAG, "uninstall $uid: registration gone after the Agent stopped")
|
||||
BattleNetCleanup.clear(context, game.folder)
|
||||
StoresState.post { StoresState.notifyLibraryChanged(context.applicationContext) }
|
||||
return true
|
||||
}
|
||||
|
||||
internal fun registrationsGone(context: Context, id: String, folder: File, timeoutMs: Long): List<String>? {
|
||||
val deadline = System.currentTimeMillis() + timeoutMs
|
||||
while (true) {
|
||||
val found = runCatching { BattleNet.registrationsAt(context, id, folder) }.getOrNull() ?: return null
|
||||
if (found.isEmpty() || System.currentTimeMillis() >= deadline) return found
|
||||
Thread.sleep(250)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retries the markers a cancelled install leaves when the registration it wrote is still
|
||||
* present, or when it wrote one after the cancellation had already looked.
|
||||
*/
|
||||
fun reconcile(context: Context) {
|
||||
val app = context.applicationContext
|
||||
if (BattleNetCleanup.pending(app).isEmpty()) return
|
||||
if (!reconciling.compareAndSet(false, true)) return
|
||||
Thread({
|
||||
try {
|
||||
reconcileNow(app)
|
||||
} finally {
|
||||
reconciling.set(false)
|
||||
}
|
||||
}, "battlenet-cleanup-reconcile").start()
|
||||
}
|
||||
|
||||
internal fun reconcileNow(
|
||||
context: Context,
|
||||
uninstall: (String) -> Boolean = { agentUninstall(context, it) },
|
||||
verifyMs: Long = CLEANUP_VERIFY_MS,
|
||||
watchMs: Long = CLEANUP_WATCH_MS,
|
||||
) {
|
||||
val now = System.currentTimeMillis()
|
||||
for (pending in BattleNetCleanup.pending(context)) {
|
||||
if (pending.nextAt > now) continue
|
||||
if (pending.folder.absolutePath in cleanupRunning) continue
|
||||
if (StoreInstalls.isDiscarding(pending.folder)) continue
|
||||
val key = DownloadEntry(Store.BATTLENET, pending.id, pending.id).key
|
||||
if (!DownloadQueue.holdForRemoval(key)) continue
|
||||
try {
|
||||
val current = BattleNetCleanup.get(context, pending.folder)
|
||||
if (current == null || current.stamp != pending.stamp || current.id != pending.id ||
|
||||
current.createdFolder != pending.createdFolder || current.state != pending.state ||
|
||||
current.attempts != pending.attempts || current.nextAt != pending.nextAt
|
||||
) continue
|
||||
val found = runCatching { BattleNet.registrationsAt(context, pending.id, pending.folder) }.getOrNull()
|
||||
if (found == null) {
|
||||
retry(context, pending, "the registrations could not be read")
|
||||
continue
|
||||
}
|
||||
if (found.isEmpty()) {
|
||||
if (pending.createdFolder && pending.folder.exists() && (BattleNet.folderHasRegistrations(context, pending.folder) != false || !deleteFolder(pending.folder))) {
|
||||
retry(context, pending, "the folder could not be deleted")
|
||||
continue
|
||||
}
|
||||
if (pending.state == BattleNetCleanup.WATCHING && pending.attempts < CLEANUP_MAX_ATTEMPTS) {
|
||||
BattleNetCleanup.update(context, pending.folder, BattleNetCleanup.WATCHING, pending.attempts + 1, now + watchMs)
|
||||
continue
|
||||
}
|
||||
BattleNetCleanup.clear(context, pending.folder)
|
||||
Log.i(TAG, "cleanup of ${pending.folder.path}: no registration remains")
|
||||
continue
|
||||
}
|
||||
for (uid in found) uninstall(uid)
|
||||
val left = registrationsGone(context, pending.id, pending.folder, verifyMs)
|
||||
if (left == null || left.isNotEmpty()) {
|
||||
retry(context, pending, "the registration in ${pending.folder.path} is still there")
|
||||
continue
|
||||
}
|
||||
if (pending.createdFolder && pending.folder.exists() && (BattleNet.folderHasRegistrations(context, pending.folder) != false || !deleteFolder(pending.folder))) {
|
||||
retry(context, pending, "the folder could not be deleted")
|
||||
continue
|
||||
}
|
||||
BattleNetCleanup.clear(context, pending.folder)
|
||||
Log.i(TAG, "cleanup of ${pending.folder.path}: ${if (pending.createdFolder) "removed" else "registration removed; folder kept"}")
|
||||
} finally {
|
||||
DownloadQueue.releaseRemoval(key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun retry(context: Context, pending: BattleNetCleanup.Pending, reason: String) {
|
||||
val attempts = pending.attempts + 1
|
||||
val delay = if (attempts >= CLEANUP_MAX_ATTEMPTS) 10 * 60_000L else CLEANUP_RETRY_MS
|
||||
BattleNetCleanup.update(context, pending.folder, pending.state, attempts, System.currentTimeMillis() + delay)
|
||||
Log.w(TAG, "cleanup of ${pending.folder.path} is pending: $reason")
|
||||
}
|
||||
|
||||
internal fun deleteFolder(folder: File): Boolean {
|
||||
com.droiddeck.launcher.core.FileUtils.delete(folder)
|
||||
return !folder.exists()
|
||||
}
|
||||
|
||||
internal fun agentUninstall(context: Context, uid: String): Boolean {
|
||||
@@ -175,21 +316,40 @@ object BattleNetInstall {
|
||||
|
||||
internal fun check(id: String, folder: File, force: Boolean) {
|
||||
val product = product(id) ?: return
|
||||
val key = updateKey(id, folder)
|
||||
val now = System.currentTimeMillis()
|
||||
synchronized(checkedAt) {
|
||||
if (!force && now - (checkedAt[id] ?: 0L) < CHECK_AGAIN_MS) return
|
||||
checkedAt[id] = now
|
||||
if (!force && now - (checkedAt[key] ?: 0L) < CHECK_AGAIN_MS) return
|
||||
// A new regular check starts a new retry cycle; a forced re-check does not.
|
||||
if (!force) checkAttempts.remove(key)
|
||||
checkedAt[key] = now
|
||||
}
|
||||
fun retryLater(reschedule: Boolean = false) {
|
||||
synchronized(checkedAt) { if (checkedAt[key] == now) checkedAt.remove(key) }
|
||||
StoresState.post { updates.remove(key) }
|
||||
if (!reschedule) return
|
||||
// A build that changed while the request ran can be checked again, but only a few times.
|
||||
val attempt = checkAttempts.merge(key, 1) { old, _ -> old + 1 } ?: 1
|
||||
if (attempt > CHECK_RETRY_MAX) return
|
||||
scheduleRecheck({
|
||||
Log.i(TAG, "$id: the build changed while checking; asking the version service again")
|
||||
check(id, folder, force = true)
|
||||
}, CHECK_RETRY_MS * attempt)
|
||||
}
|
||||
fun retryLater() = synchronized(checkedAt) { if (checkedAt[id] == now) checkedAt.remove(id) }
|
||||
checks.execute {
|
||||
val local = runCatching { buildKey(File(folder, BUILD_INFO).readText()) }.getOrNull()
|
||||
?: return@execute retryLater()
|
||||
val latest = runCatching { latestBuild(fetch(versionsUrl(local.first, product)), local.first) }
|
||||
.onFailure { Log.w(TAG, "versions of $product: ${it.javaClass.simpleName}") }.getOrNull()
|
||||
val served = if (local.first == CN) chinaProduct(id) ?: product else product
|
||||
val latest = runCatching { latestBuild(fetchVersions(versionsUrl(local.first, served)), local.first) }
|
||||
.onFailure { Log.w(TAG, "versions of $served: ${it.javaClass.simpleName}") }.getOrNull()
|
||||
?: return@execute retryLater()
|
||||
val behind = latest != local.second
|
||||
val current = runCatching { buildKey(File(folder, BUILD_INFO).readText()) }.getOrNull()
|
||||
?: return@execute retryLater()
|
||||
if (current != local) return@execute retryLater(reschedule = true)
|
||||
val behind = latest != current.second
|
||||
Log.i(TAG, "$id: ${if (behind) "update available" else "up to date"}")
|
||||
StoresState.post { if (behind) updates[id] = true else updates.remove(id) }
|
||||
StoresState.post { if (behind) updates[key] = true else updates.remove(key) }
|
||||
checkAttempts.remove(key)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,22 +392,53 @@ object BattleNetInstall {
|
||||
private const val APPLY_PHASE = 2000
|
||||
}
|
||||
|
||||
internal class Ownership(item: CatalogItem) {
|
||||
@Volatile var known = item.extra[BattleNetInstall.PREEXISTING] in setOf("0", "1")
|
||||
@Volatile var preexisting = item.extra[BattleNetInstall.PREEXISTING] == "1"
|
||||
val createdFolder = AtomicBoolean(false)
|
||||
}
|
||||
|
||||
internal class BattleNetInstaller(
|
||||
private val app: Context,
|
||||
private val item: CatalogItem,
|
||||
private val folder: File,
|
||||
private val update: Boolean,
|
||||
private val ownership: Ownership = Ownership(item),
|
||||
private val registrationWaitMs: Long = REGISTRATION_WAIT_MS,
|
||||
private val cleanupVerifyMs: Long = CLEANUP_VERIFY_MS,
|
||||
private val uninstall: (String) -> Boolean = { BattleNetInstall.agentUninstall(app, it) },
|
||||
private val registration: () -> List<String>? = {
|
||||
BattleNet.registrationsAt(app, item.id, folder)
|
||||
},
|
||||
) : DownloadQueue.DownloadJob {
|
||||
private val cancelled = AtomicBoolean(false)
|
||||
private val cleanupStarted = AtomicBoolean(false)
|
||||
private val started = AtomicBoolean(false)
|
||||
private val queueKey = DownloadEntry(Store.BATTLENET, item.id, item.title).key
|
||||
private val ended = java.util.concurrent.CountDownLatch(1)
|
||||
|
||||
private var before = 0L
|
||||
private var kept = -1L
|
||||
|
||||
override fun run(handle: DownloadQueue.JobHandle): String? {
|
||||
if (!cancelled.get() && !ownership.known) {
|
||||
val found = runCatching { registration() }.getOrNull()
|
||||
ownership.preexisting = found == null || found.isNotEmpty()
|
||||
ownership.known = found != null
|
||||
if (found != null) {
|
||||
SavedQueue.remember(
|
||||
app,
|
||||
item.copy(extra = item.extra + (BattleNetInstall.PREEXISTING to if (ownership.preexisting) "1" else "0")),
|
||||
folder.parentFile?.parentFile,
|
||||
)
|
||||
}
|
||||
}
|
||||
started.set(true)
|
||||
try {
|
||||
return if (cancelled.get()) null else work(handle)
|
||||
} catch (t: Throwable) {
|
||||
if (!cancelled.get()) BattleNetCleanup.clear(app, folder)
|
||||
throw t
|
||||
} finally {
|
||||
ended.countDown()
|
||||
}
|
||||
@@ -260,7 +451,10 @@ internal class BattleNetInstaller(
|
||||
val title = BattleNet.title(item.id)
|
||||
val product = title?.product ?: throw IllegalStateException(app.getString(R.string.bnet_dl_failed, item.id))
|
||||
val uid = item.extra[BattleNetInstall.INSTALL_UID] ?: title.uid
|
||||
if (!update) folder.mkdirs()
|
||||
if (!update && folder.mkdirs()) {
|
||||
ownership.createdFolder.set(true)
|
||||
BattleNetCleanup.markActive(app, folder, item.id, createdFolder = true)
|
||||
}
|
||||
val guest = AddedGames.guestPath(app, folder) ?: throw IllegalStateException(app.getString(R.string.bnet_dl_failed, folder.path))
|
||||
val (country, region) = BattleNetInstall.country(Locale.getDefault())
|
||||
val args = if (update) listOf("agent-update", uid)
|
||||
@@ -282,10 +476,11 @@ internal class BattleNetInstaller(
|
||||
if (done == null) throw IllegalStateException(BattleNetInstall.failure(app, reason, code))
|
||||
handle.log("Battle.net: ${item.title} ${if (update) "updated" else "installed"} ${done?.optString("version").orEmpty()}".trimEnd())
|
||||
StoresState.post {
|
||||
BattleNetInstall.updates.remove(item.id)
|
||||
BattleNetInstall.updates.remove(BattleNetInstall.updateKey(item.id, folder))
|
||||
StoresState.notifyLibraryChanged(app)
|
||||
}
|
||||
BattleNetInstall.check(item.id, folder, force = true)
|
||||
BattleNetCleanup.clear(app, folder)
|
||||
return folder.absolutePath
|
||||
}
|
||||
|
||||
@@ -302,17 +497,109 @@ internal class BattleNetInstaller(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The client writes the install registration a little after the download starts; a cancel
|
||||
* right after the request would otherwise read an empty list and leave the registration behind.
|
||||
*/
|
||||
private fun registrationsWaiting(): List<String>? {
|
||||
val deadline = System.currentTimeMillis() + registrationWaitMs
|
||||
while (true) {
|
||||
val found = runCatching { registration() }.getOrNull() ?: return null
|
||||
if (found.isNotEmpty() || System.currentTimeMillis() >= deadline) return found
|
||||
Thread.sleep(250)
|
||||
}
|
||||
}
|
||||
|
||||
override fun cancel(deleteFiles: Boolean) {
|
||||
cancelled.set(true)
|
||||
if (!deleteFiles || update) return
|
||||
val uid = item.extra[BattleNetInstall.INSTALL_UID] ?: BattleNet.title(item.id)?.uid ?: return
|
||||
Thread({
|
||||
if (started.get() && !ended.await(END_WAIT_S, TimeUnit.SECONDS)) Log.w("BattleNetInstall", "the cancelled install of $uid is still stopping")
|
||||
val gone = BattleNetInstall.agentUninstall(app, uid)
|
||||
if (folder.isDirectory && (gone || folder.list().isNullOrEmpty())) com.droiddeck.launcher.core.FileUtils.delete(folder)
|
||||
Log.i("BattleNetInstall", "cancelled install of $uid: ${if (gone) "removed" else "left for Battle.net to remove"}")
|
||||
}, "battlenet-cancel").start()
|
||||
if (!deleteFiles || update) {
|
||||
if (update) DownloadQueue.cleanupFinished(queueKey)
|
||||
return
|
||||
}
|
||||
if (!cleanupStarted.compareAndSet(false, true)) return
|
||||
if (!started.get() && !ownership.known) ownership.preexisting = true
|
||||
val initialCreated = BattleNetCleanup.get(app, folder)?.createdFolder ?: ownership.createdFolder.get()
|
||||
val path = folder.absolutePath
|
||||
cleanupRunning.add(path)
|
||||
if (!ownership.preexisting) {
|
||||
BattleNetCleanup.mark(app, folder, item.id, initialCreated, BattleNetCleanup.PENDING)
|
||||
}
|
||||
val cleanup = Thread({
|
||||
var discarding = false
|
||||
try {
|
||||
val stopped = !started.get() || ended.await(END_WAIT_S, TimeUnit.SECONDS)
|
||||
val createdFolder = ownership.createdFolder.get() || (BattleNetCleanup.get(app, folder)?.createdFolder ?: false)
|
||||
if (!ownership.preexisting && createdFolder != initialCreated) {
|
||||
BattleNetCleanup.mark(app, folder, item.id, createdFolder, BattleNetCleanup.PENDING)
|
||||
}
|
||||
if (ownership.preexisting) {
|
||||
BattleNetCleanup.clear(app, folder)
|
||||
Log.i("BattleNetInstall", "cancelled install left the pre-existing registration in ${folder.path}")
|
||||
} else if (!stopped) {
|
||||
pending(createdFolder, "the cancelled install is still stopping")
|
||||
} else {
|
||||
StoreInstalls.beginDiscard(folder)
|
||||
discarding = true
|
||||
val created = registrationsWaiting()
|
||||
if (created == null) {
|
||||
pending(createdFolder, "the registrations could not be read")
|
||||
} else if (created.isEmpty()) {
|
||||
if (createdFolder && (BattleNet.folderHasRegistrations(app, folder) != false || !BattleNetInstall.deleteFolder(folder))) {
|
||||
pending(createdFolder, "the folder could not be deleted")
|
||||
} else {
|
||||
BattleNetCleanup.mark(app, folder, item.id, createdFolder, BattleNetCleanup.WATCHING)
|
||||
BattleNetCleanup.update(app, folder, BattleNetCleanup.WATCHING, 0, System.currentTimeMillis() + CLEANUP_WATCH_MS)
|
||||
Log.i("BattleNetInstall", "cancelled install of ${item.id}: no registration yet; watching ${folder.path}")
|
||||
}
|
||||
} else {
|
||||
for (uid in created.distinct()) uninstall(uid)
|
||||
val left = registrationsGoneHere(cleanupVerifyMs)
|
||||
if (left == null || left.isNotEmpty()) {
|
||||
pending(createdFolder, "the registration in ${folder.path} is still there")
|
||||
} else if (createdFolder && (BattleNet.folderHasRegistrations(app, folder) != false || !BattleNetInstall.deleteFolder(folder))) {
|
||||
pending(createdFolder, "the folder could not be deleted")
|
||||
} else {
|
||||
BattleNetCleanup.clear(app, folder)
|
||||
Log.i("BattleNetInstall", "cancelled install of ${created.first()}: ${if (createdFolder) "removed" else "registration removed; folder kept"}")
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
cleanupRunning.remove(path)
|
||||
if (discarding) StoreInstalls.endDiscard(folder)
|
||||
DownloadQueue.cleanupFinished(queueKey)
|
||||
}
|
||||
}, "battlenet-cancel")
|
||||
try {
|
||||
cleanup.start()
|
||||
} catch (t: Throwable) {
|
||||
cleanupRunning.remove(path)
|
||||
DownloadQueue.cleanupFinished(queueKey)
|
||||
throw t
|
||||
}
|
||||
}
|
||||
|
||||
private fun pending(createdFolder: Boolean, reason: String) {
|
||||
BattleNetCleanup.mark(app, folder, item.id, createdFolder, BattleNetCleanup.PENDING)
|
||||
BattleNetCleanup.update(app, folder, BattleNetCleanup.PENDING, 1, System.currentTimeMillis() + CLEANUP_RETRY_MS)
|
||||
Log.w("BattleNetInstall", "cleanup of ${folder.path} is pending: $reason")
|
||||
}
|
||||
|
||||
private fun registrationsGoneHere(timeoutMs: Long): List<String>? {
|
||||
val deadline = System.currentTimeMillis() + timeoutMs
|
||||
while (true) {
|
||||
val found = runCatching { registration() }.getOrNull() ?: return null
|
||||
if (found.isEmpty() || System.currentTimeMillis() >= deadline) return found
|
||||
Thread.sleep(250)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private const val END_WAIT_S = 120L
|
||||
private const val REGISTRATION_WAIT_MS = 5_000L
|
||||
private val cleanupRunning = java.util.concurrent.ConcurrentHashMap.newKeySet<String>()
|
||||
private const val CLEANUP_VERIFY_MS = 30_000L
|
||||
private const val CLEANUP_WATCH_MS = 15_000L
|
||||
private const val CLEANUP_RETRY_MS = 60_000L
|
||||
private const val CLEANUP_MAX_ATTEMPTS = 4
|
||||
private const val UNINSTALL_VERIFY_MS = 30_000L
|
||||
@@ -7,7 +7,6 @@ import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.frontend.AddedGames
|
||||
import com.droiddeck.launcher.runtime.BattleNet
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import com.droiddeck.launcher.session.GameStorage
|
||||
import com.droiddeck.launcher.stores.CatalogItem
|
||||
import com.droiddeck.launcher.stores.InstalledStoreGame
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
@@ -131,13 +130,13 @@ object BattleNetClient {
|
||||
StoresState.post { opener?.invoke(args) }
|
||||
}
|
||||
|
||||
fun library(context: Context, root: File? = preferred(context)): List<String> =
|
||||
root?.let { AddedGames.guestPath(context, StoreInstallRoot.storeDir(it, Store.BATTLENET)) }?.let { listOf("--library", it) }.orEmpty()
|
||||
fun library(context: Context, root: File = preferred(context)): List<String> =
|
||||
AddedGames.guestPath(context, StoreInstallRoot.storeDir(root, Store.BATTLENET))?.let { listOf("--library", it) }.orEmpty()
|
||||
|
||||
internal fun preferred(context: Context): File? {
|
||||
internal fun preferred(context: Context): File {
|
||||
val second = StoreInstallRoot.libraryRoot(context)?.absolutePath
|
||||
return StoreInstallRoot.targets(context).firstOrNull { it.root.absolutePath == second && (it.root.isDirectory || it.root.mkdirs()) }?.root
|
||||
?: StoreInstallRoot.internalRoot(context).takeIf { second == null && !GameStorage.disconnected(context) }
|
||||
?: StoreInstallRoot.internalRoot(context)
|
||||
}
|
||||
|
||||
fun installGame(context: Context, uid: String, root: File) {
|
||||
|
||||
@@ -24,7 +24,6 @@ internal object BlizzardArt {
|
||||
"WoWC" to "${KEY_ART_ASSETS}blt6a80c8e7260f84f2/690d2219b415dd246153245b/BCC.png",
|
||||
"WoWF" to "${KEY_ART_ASSETS}blt1d58537e928b17c5/6ae2c99668c747dd1b4f558b/WoW_Forever_AnimatedTrailerSupportAssets_BnetShop_1920x1080.png",
|
||||
"D3" to "${KEY_ART_CATALOG}/f96/8d92f4d8bd316d3787f02d8a86935d6a-Store_Product_960x540_D3.jpg",
|
||||
"D3CN" to "${KEY_ART_CATALOG}/f96/8d92f4d8bd316d3787f02d8a86935d6a-Store_Product_960x540_D3.jpg",
|
||||
"S2" to "${KEY_ART_ASSETS}blt4b6d6857f147a6de/61254804841f180993fedb61/6885-32192.png",
|
||||
"S1" to "${KEY_ART_ASSETS}blt03d69a4563a6ae63/6a34b50f799ece2cb2da248c/9458-28298.jpg",
|
||||
"WTCG" to "${KEY_ART_ASSETS}blt5a3d84e1d0b2bbcf/662aea9f842cecfd4fd95327/HS_Key_Art_SG2.png",
|
||||
|
||||
@@ -34,6 +34,7 @@ data class DownloadEntry(
|
||||
val interruptible: Boolean = true,
|
||||
val reusedBytes: Long = 0L,
|
||||
val appliedBytes: Long = 0L,
|
||||
val cleanupKey: String? = null,
|
||||
) {
|
||||
fun passed(s: DownloadStage): Boolean = state == DownloadState.INSTALLED || (stagesPassed and (1 shl s.ordinal)) != 0
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ object DownloadQueue {
|
||||
}
|
||||
|
||||
private val lock = Any()
|
||||
private val cancelling = HashSet<String>()
|
||||
private val items = LinkedHashMap<String, Item>()
|
||||
private val heldPaused = HashSet<String>()
|
||||
private val removing = HashSet<String>()
|
||||
@@ -114,7 +115,9 @@ object DownloadQueue {
|
||||
|
||||
fun holdForRemoval(key: String): Boolean = synchronized(lock) {
|
||||
val item = items[key]
|
||||
if (item?.entry?.isActive == true || item?.job != null || key in cleaningUp || key in removing) return@synchronized false
|
||||
if (item?.entry?.isActive == true || item?.job != null || key in cleaningUp || key in removing || key in cancelling) {
|
||||
return@synchronized false
|
||||
}
|
||||
removing.add(key)
|
||||
true
|
||||
}
|
||||
@@ -127,7 +130,7 @@ object DownloadQueue {
|
||||
return synchronized(lock) {
|
||||
while (true) {
|
||||
val busy = busyLocked(key)
|
||||
if (!busy && key !in cleaningUp && key !in removing) break
|
||||
if (!busy && key !in cleaningUp && key !in removing && key !in cancelling) break
|
||||
val left = deadline - android.os.SystemClock.uptimeMillis()
|
||||
if (busy && left <= 0) return@synchronized false
|
||||
(lock as Object).wait(if (busy) left else 0L)
|
||||
@@ -192,14 +195,31 @@ object DownloadQueue {
|
||||
|
||||
fun isActive(key: String): Boolean = entry(key)?.isActive == true
|
||||
|
||||
fun isCancelling(key: String): Boolean = synchronized(lock) { key in cancelling }
|
||||
|
||||
internal fun cleanupFinished(key: String?) {
|
||||
if (key == null) return
|
||||
synchronized(lock) {
|
||||
cancelling.remove(key)
|
||||
(lock as Object).notifyAll()
|
||||
}
|
||||
}
|
||||
|
||||
fun anyActive(): Boolean = synchronized(lock) { items.values.any { it.entry.isActive } }
|
||||
|
||||
fun enqueue(context: Context, entry: DownloadEntry, factory: () -> DownloadJob) {
|
||||
fun enqueue(context: Context, entry: DownloadEntry, onAccepted: (() -> Unit)? = null, factory: () -> DownloadJob): Boolean {
|
||||
val app = context.applicationContext
|
||||
synchronized(lock) {
|
||||
if (entry.key in removing) { Log.i(TAG, "${entry.key}: being uninstalled"); return }
|
||||
items[entry.key]?.let { if (it.entry.isActive) { Log.i(TAG, "${entry.key}: already queued"); return } }
|
||||
val cleanupKey = entry.cleanupKey
|
||||
if (cleanupKey != null && isCancelling(cleanupKey)) {
|
||||
Log.i(TAG, "${entry.key}: previous cancellation is still cleaning up")
|
||||
return false
|
||||
}
|
||||
if (entry.key in removing) { Log.i(TAG, "${entry.key}: being uninstalled"); return false }
|
||||
items[entry.key]?.let { if (it.entry.isActive) { Log.i(TAG, "${entry.key}: already queued"); return false } }
|
||||
items.remove(entry.key)
|
||||
// The callback records the task's ownership snapshot; run it before advance() can see the item.
|
||||
onAccepted?.invoke()
|
||||
val state = if (heldPaused.remove(entry.key)) DownloadState.PAUSED else DownloadState.QUEUED
|
||||
items[entry.key] = Item(entry.copy(state = state, stage = DownloadStage.MANIFEST, startedAt = System.currentTimeMillis()), factory)
|
||||
renumber()
|
||||
@@ -207,6 +227,7 @@ object DownloadQueue {
|
||||
StoresState.logLine("${entry.store.label}: queued \"${entry.name}\"" + if (entry.bytesTotal > 0) " (${com.droiddeck.launcher.stores.formatBytes(entry.bytesTotal)})" else "")
|
||||
publish(app)
|
||||
advance(app)
|
||||
return true
|
||||
}
|
||||
|
||||
fun recordFailed(context: Context, entry: DownloadEntry, error: String, retry: (() -> Unit)? = null) {
|
||||
@@ -274,26 +295,39 @@ object DownloadQueue {
|
||||
val app = context.applicationContext
|
||||
val item: Item
|
||||
val wasRunning: Boolean
|
||||
var cleanupKey: String? = null
|
||||
var cleanup = false
|
||||
var awaitDeletion: List<Thread> = emptyList()
|
||||
synchronized(lock) {
|
||||
item = items[key] ?: return
|
||||
if (!item.entry.interruptible) return
|
||||
val candidate = item.entry.cleanupKey?.takeIf { item.factory != null }
|
||||
if (candidate != null && !cancelling.add(candidate)) {
|
||||
Log.i(TAG, "$key: already cancelling")
|
||||
return
|
||||
}
|
||||
cleanupKey = candidate
|
||||
wasRunning = item.entry.state == DownloadState.RUNNING
|
||||
if (wasRunning) {
|
||||
item.pauseRequested = false
|
||||
item.cancelled.set(true)
|
||||
val deleting = StoreInstalls.collectingDiscards { runCatching { item.job?.cancel(deleteFiles = true) } }
|
||||
val deleting = StoreInstalls.collectingDiscards {
|
||||
if (runCatching { item.job?.cancel(deleteFiles = true) }.isFailure) cleanupFinished(cleanupKey)
|
||||
}
|
||||
if (deleting.isNotEmpty()) { holdCleanup(key); awaitDeletion = deleting }
|
||||
}
|
||||
if (!wasRunning) {
|
||||
cleanup = beginCleanup(key)
|
||||
if (!cleanup) cleanupFinished(cleanupKey)
|
||||
item.entry = item.entry.copy(state = DownloadState.CANCELLED, queuePosition = 0, finishedAt = System.currentTimeMillis())
|
||||
renumber()
|
||||
publishLocked()
|
||||
}
|
||||
}
|
||||
if (cleanup) {
|
||||
cleanUpLater(app, key, "store-dl-cancel") { runCatching { item.factory?.invoke()?.cancel(deleteFiles = true) } }
|
||||
if (!wasRunning && cleanup) {
|
||||
cleanUpLater(app, key, "store-dl-cancel") {
|
||||
if (runCatching { item.factory?.invoke()?.cancel(deleteFiles = true) }.isFailure) cleanupFinished(cleanupKey)
|
||||
}
|
||||
}
|
||||
if (awaitDeletion.isNotEmpty()) cleanUpLater(app, key, "store-dl-cancel-wait") { awaitDeletion.forEach { it.join() } }
|
||||
StoresState.logLine("cancelled \"${item.entry.name}\"")
|
||||
@@ -303,17 +337,27 @@ object DownloadQueue {
|
||||
}
|
||||
|
||||
fun clear(context: Context, key: String) {
|
||||
val app = context.applicationContext
|
||||
val item: Item
|
||||
val cleanup: Boolean
|
||||
var cleanupKey: String? = null
|
||||
var cleanup = false
|
||||
synchronized(lock) {
|
||||
item = items[key] ?: return
|
||||
if (item.entry.state == DownloadState.RUNNING || item.entry.state == DownloadState.QUEUED) return
|
||||
cleanup = (item.entry.state == DownloadState.FAILED || item.entry.state == DownloadState.PAUSED) && beginCleanup(key)
|
||||
if (item.entry.state == DownloadState.FAILED || item.entry.state == DownloadState.PAUSED) {
|
||||
val candidate = item.entry.cleanupKey?.takeIf { item.factory != null }
|
||||
if (candidate == null || cancelling.add(candidate)) {
|
||||
cleanup = beginCleanup(key)
|
||||
if (cleanup) cleanupKey = candidate else cleanupFinished(candidate)
|
||||
}
|
||||
}
|
||||
items.remove(key)
|
||||
publishLocked()
|
||||
}
|
||||
if (cleanup) cleanUpLater(context.applicationContext, key, "store-dl-clear") { runCatching { item.factory?.invoke()?.cancel(deleteFiles = true) } }
|
||||
StoreDownloadService.finish(context.applicationContext, key)
|
||||
if (cleanup) cleanUpLater(app, key, "store-dl-clear") {
|
||||
if (runCatching { item.factory?.invoke()?.cancel(deleteFiles = true) }.isFailure) cleanupFinished(cleanupKey)
|
||||
}
|
||||
StoreDownloadService.finish(app, key)
|
||||
}
|
||||
|
||||
fun dismissFinished() {
|
||||
@@ -393,11 +437,27 @@ object DownloadQueue {
|
||||
var error: String? = null
|
||||
try {
|
||||
val job = checkNotNull(item.factory).invoke()
|
||||
synchronized(lock) { item.job = job }
|
||||
var cancelled = false
|
||||
var paused = false
|
||||
synchronized(lock) {
|
||||
item.job = job
|
||||
cancelled = item.cancelled.get()
|
||||
paused = item.pauseRequested
|
||||
}
|
||||
StoresState.logLine("${item.entry.store.label}: fetching manifest for \"${item.entry.name}\"")
|
||||
val deleting = ArrayList<Thread>()
|
||||
try {
|
||||
StoreInstalls.collectingDiscards(deleting) { result = job.run(handle) }
|
||||
StoreInstalls.collectingDiscards(deleting) {
|
||||
if (cancelled) {
|
||||
try {
|
||||
job.cancel(deleteFiles = !paused)
|
||||
} catch (t: Throwable) {
|
||||
synchronized(lock) { cleanupFinished(item.entry.cleanupKey) }
|
||||
throw t
|
||||
}
|
||||
}
|
||||
result = job.run(handle)
|
||||
}
|
||||
} finally {
|
||||
if (deleting.isNotEmpty()) {
|
||||
holdCleanup(item.entry.key)
|
||||
@@ -408,6 +468,9 @@ object DownloadQueue {
|
||||
} catch (t: Throwable) {
|
||||
error = t.message ?: t.javaClass.simpleName
|
||||
Log.w(TAG, "${item.entry.key} failed", t)
|
||||
synchronized(lock) {
|
||||
if (item.job == null) cleanupFinished(item.entry.cleanupKey)
|
||||
}
|
||||
}
|
||||
synchronized(lock) {
|
||||
running--
|
||||
|
||||
@@ -29,6 +29,16 @@ object SavedQueue {
|
||||
wanted[key(item)] = Wanted(item, root)
|
||||
}
|
||||
|
||||
internal fun remembered(key: String): CatalogItem? = synchronized(this) { wanted[key]?.item }
|
||||
|
||||
internal fun resetForTest() {
|
||||
synchronized(this) {
|
||||
restored = false
|
||||
wanted.clear()
|
||||
app = null
|
||||
}
|
||||
}
|
||||
|
||||
fun save(entries: List<DownloadEntry>) {
|
||||
val context = app ?: return
|
||||
val rows = synchronized(this) {
|
||||
|
||||
@@ -46,7 +46,6 @@ import androidx.compose.ui.platform.testTag
|
||||
import com.droiddeck.launcher.agent.AgentSetup.Status
|
||||
import com.droiddeck.launcher.agent.AgentSetup.Step
|
||||
import com.droiddeck.launcher.core.WirelessAdbPairingService
|
||||
import com.droiddeck.launcher.session.QuestExperimental
|
||||
|
||||
@Composable
|
||||
internal fun AgentSetupView(modifier: Modifier, firstControl: Modifier = Modifier, onDone: () -> Unit = {}) {
|
||||
@@ -105,16 +104,11 @@ internal fun AgentSetupView(modifier: Modifier, firstControl: Modifier = Modifie
|
||||
var keyOpen by rememberSaveable(harness.id) { mutableStateOf(false) }
|
||||
val (title, hint) = labels(step, harness.name, keyed)
|
||||
val lab = AgentHost.lab?.takeIf { it.prepare && it.running }
|
||||
val questConnection = step == Step.CONNECTION && status != Status.DONE && QuestExperimental.isSupported()
|
||||
val detail = when {
|
||||
step == Step.PREPARE && lab != null ->
|
||||
stringResource(R.string.agent_prepare_progress, lab.permille / 10, clock(lab.etaSeconds.toLong().coerceAtLeast(0)))
|
||||
keyed && status == Status.DONE && AgentSetup.detail[step] == null ->
|
||||
harness.providers.filter { it.id in AgentSetup.keys }.joinToString(" · ") { it.name }.ifEmpty { stringResource(R.string.agent_step_free_models) }
|
||||
// The Quest hint holds the one-time commands, so it stays under the status until the step passes.
|
||||
questConnection -> AgentSetup.detail[step]?.let { "$it\n$hint" } ?: hint
|
||||
// The Quest hint is setup instructions; once connected, the row says what it is for.
|
||||
step == Step.CONNECTION && QuestExperimental.isSupported() -> AgentSetup.detail[step] ?: stringResource(R.string.agent_step_connection_hint)
|
||||
else -> AgentSetup.detail[step] ?: hint
|
||||
}
|
||||
// Shown while the sign-in is pending, so it is still there after a trip to the browser for the key.
|
||||
@@ -127,7 +121,6 @@ internal fun AgentSetupView(modifier: Modifier, firstControl: Modifier = Modifie
|
||||
Status.TODO, Status.FAILED -> CheckState.WARN
|
||||
},
|
||||
title, detail, divider = index < steps.lastIndex && !showKey,
|
||||
detailLines = if (questConnection) Int.MAX_VALUE else 2,
|
||||
) {
|
||||
val blocked = (step in setOf(Step.SIGN_IN, Step.GITHUB, Step.BUILD_TOOLS) && AgentSetup.status[Step.INSTALL] != Status.DONE) ||
|
||||
(step == Step.PREPARE && AgentSetup.status[Step.BUILD_TOOLS] != Status.DONE)
|
||||
@@ -265,9 +258,7 @@ internal fun agentStorageWarning(item: AgentStorage.Item) = when (item) {
|
||||
|
||||
@Composable
|
||||
private fun labels(step: Step, harness: String, keyed: Boolean = false): Pair<String, String> = when (step) {
|
||||
Step.CONNECTION -> stringResource(R.string.agent_step_connection) to
|
||||
if (QuestExperimental.isSupported()) stringResource(R.string.agent_step_connection_quest_hint, LocalContext.current.packageName)
|
||||
else stringResource(R.string.agent_step_connection_hint)
|
||||
Step.CONNECTION -> stringResource(R.string.agent_step_connection) to stringResource(R.string.agent_step_connection_hint)
|
||||
Step.INSTALL -> stringResource(R.string.agent_step_install, harness) to stringResource(R.string.agent_step_install_hint)
|
||||
Step.SIGN_IN -> stringResource(R.string.agent_step_sign_in, harness) to stringResource(if (keyed) R.string.agent_step_sign_in_key_hint else R.string.agent_step_sign_in_hint)
|
||||
Step.GITHUB -> stringResource(R.string.agent_step_github) to stringResource(R.string.agent_step_github_hint)
|
||||
@@ -276,7 +267,7 @@ private fun labels(step: Step, harness: String, keyed: Boolean = false): Pair<St
|
||||
}
|
||||
|
||||
private fun action(step: Step): Int = when (step) {
|
||||
Step.CONNECTION -> if (QuestExperimental.isSupported()) R.string.agent_action_allow else R.string.agent_action_pair
|
||||
Step.CONNECTION -> R.string.agent_action_pair
|
||||
Step.INSTALL -> R.string.agent_action_install
|
||||
Step.SIGN_IN, Step.GITHUB -> R.string.agent_action_sign_in
|
||||
Step.BUILD_TOOLS -> R.string.agent_action_install
|
||||
@@ -285,7 +276,6 @@ private fun action(step: Step): Int = when (step) {
|
||||
|
||||
/** The pairing DroidDeck already uses for the phantom process fix; the agent reuses its key. */
|
||||
private fun pair(context: android.content.Context) {
|
||||
if (QuestExperimental.isSupported()) return AgentSetup.trustOnDevice(context)
|
||||
if (!WirelessAdbPairingService.notificationsEnabled(context)) {
|
||||
context.startActivity(android.content.Intent(android.provider.Settings.ACTION_APP_NOTIFICATION_SETTINGS)
|
||||
.putExtra(android.provider.Settings.EXTRA_APP_PACKAGE, context.packageName)
|
||||
|
||||
@@ -8,14 +8,11 @@ import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.AlignHorizontalCenter
|
||||
import androidx.compose.material.icons.outlined.AlignHorizontalLeft
|
||||
import androidx.compose.material.icons.outlined.AlignHorizontalRight
|
||||
import androidx.compose.material.icons.outlined.VerticalSplit
|
||||
import androidx.compose.material.icons.outlined.WidthFull
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
@@ -75,8 +72,7 @@ internal enum class QamFit(val id: String, @StringRes val label: Int, val icon:
|
||||
FULL("full", R.string.bottom_qam_layout_full, Icons.Outlined.WidthFull, 0),
|
||||
LEFT("left", R.string.bottom_qam_layout_left, Icons.Outlined.AlignHorizontalLeft, -1),
|
||||
CENTER("center", R.string.bottom_qam_layout_center, Icons.Outlined.AlignHorizontalCenter, 0),
|
||||
RIGHT("right", R.string.bottom_qam_layout_right, Icons.Outlined.AlignHorizontalRight, 1),
|
||||
SPLIT("split", R.string.bottom_qam_layout_split, Icons.Outlined.VerticalSplit, 0);
|
||||
RIGHT("right", R.string.bottom_qam_layout_right, Icons.Outlined.AlignHorizontalRight, 1);
|
||||
|
||||
val next: QamFit get() = entries[(ordinal + 1) % entries.size]
|
||||
|
||||
@@ -96,7 +92,6 @@ internal enum class QamFit(val id: String, @StringRes val label: Int, val icon:
|
||||
|
||||
internal object QamLayout {
|
||||
private const val WIDE_CSS = "div.BasicUI { width: 100% !important; } div[class*=\\\"tab_\\\"] { max-width: none !important; }"
|
||||
private const val PARKED_CSS = " #Footer { display: none !important; }"
|
||||
|
||||
/** Scale and left edge of the menu in a box; [align] -1, 0 or 1 places a narrower menu left, centred or right. */
|
||||
fun fit(boxWidth: Float, boxHeight: Float, contentRight: Float, cssHeight: Float, align: Int = 0): Pair<Float, Float> {
|
||||
@@ -107,13 +102,10 @@ internal object QamLayout {
|
||||
fun toCss(x: Float, y: Float, scale: Float, left: Float): Pair<Float, Float> = (x - left) / scale to y / scale
|
||||
|
||||
/** Makes the menu follow the panel-shaped view (Steam sizes it once, on open) and lifts each tab's 300 px cap, then measures where the content ends. */
|
||||
/**
|
||||
* [wide] is false while the menu is shown on the top screen, where it keeps Steam's own layout. [parked] hides the
|
||||
* button-hint footer Steam draws in a game, which stays an empty black strip while the controller is not on the menu.
|
||||
*/
|
||||
fun contentScript(wide: Boolean, parked: Boolean = wide): String = "(() => { let s = document.getElementById('dd-qam-wide'); " +
|
||||
/** [wide] is false while the menu is shown on the top screen, where it keeps Steam's own layout. */
|
||||
fun contentScript(wide: Boolean): String = "(() => { let s = document.getElementById('dd-qam-wide'); " +
|
||||
"if (!s) { s = document.createElement('style'); s.id = 'dd-qam-wide'; document.head.appendChild(s); } " +
|
||||
"const css = '${(if (wide) WIDE_CSS else "") + (if (parked) PARKED_CSS else "")}'; " +
|
||||
"const css = '${if (wide) WIDE_CSS else ""}'; " +
|
||||
"if (s.textContent !== css) s.textContent = css; if (document.scrollingElement.scrollLeft) document.scrollingElement.scrollLeft = 0; " +
|
||||
"const w = innerWidth; let right = 0; for (const e of document.body.querySelectorAll('*')) { " +
|
||||
"const r = e.getBoundingClientRect(); const tab = /(^| )tab_/.test(String(e.className)); " +
|
||||
@@ -125,90 +117,17 @@ private const val TICK_MS = 1_000L
|
||||
private const val FAST_TICK_MS = 150L
|
||||
private const val MAX_RETRY_MS = 4_000L
|
||||
|
||||
/** One of Steam's menu pages streamed to the panel; the last frame is kept so returning to the panel shows it at once. */
|
||||
internal class MenuStream {
|
||||
@Volatile var page: CdpPage? = null
|
||||
val live = java.util.concurrent.atomic.AtomicBoolean(false)
|
||||
val image = mutableStateOf<ImageBitmap?>(null)
|
||||
val shape = mutableStateOf<FloatArray?>(null)
|
||||
|
||||
fun show(frame: ImageBitmap) {
|
||||
image.value = frame
|
||||
live.set(true)
|
||||
}
|
||||
|
||||
/** Connects to [path] and starts its screencast; false when the page cannot be reached. */
|
||||
fun connect(port: Int, path: String): Boolean {
|
||||
page?.close()
|
||||
page = null
|
||||
live.set(false)
|
||||
val p = runCatching {
|
||||
CdpPage(port, path) { method, params ->
|
||||
if (method == "Page.screencastFrame") {
|
||||
page?.send("Page.screencastFrameAck", JSONObject().put("sessionId", params.optInt("sessionId")))
|
||||
decodeFrame(params.optString("data"))?.let(::show)
|
||||
}
|
||||
}
|
||||
}.onFailure { android.util.Log.w("SteamQam", "devtools connect: $it") }.getOrNull() ?: return false
|
||||
page = p
|
||||
p.send("Page.enable")
|
||||
val started = p.call("Page.startScreencast", JSONObject().put("format", "jpeg").put("quality", 85)
|
||||
.put("maxWidth", 1920).put("maxHeight", 1440))
|
||||
if (started == null || started.has("error") || !started.has("result")) {
|
||||
p.close()
|
||||
page = null
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/** Runs [script], which returns the page's [width, height, pixel ratio, content right], and refreshes a still page. */
|
||||
fun refresh(script: String) {
|
||||
val p = page ?: return
|
||||
// The screencast sends frames only when the menu repaints, so a still menu needs one screenshot.
|
||||
if (!live.get()) {
|
||||
p.call("Page.captureScreenshot", JSONObject().put("format", "jpeg").put("quality", 85))
|
||||
?.optJSONObject("result")?.optString("data")?.let(::decodeFrame)?.let(::show)
|
||||
}
|
||||
(p.evaluate(script) as? String)?.let { text ->
|
||||
runCatching {
|
||||
val a = JSONArray(text)
|
||||
val layout = FloatArray(4) { a.getDouble(it).toFloat() }
|
||||
if (!layout.contentEquals(shape.value)) shape.value = layout
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Stops the stream and runs [restore] on the page, which outlives this connection. */
|
||||
fun stop(restore: String) {
|
||||
val p = page ?: return
|
||||
page = null
|
||||
runCatching { p.send("Page.stopScreencast") }
|
||||
runCatching { p.evaluate(restore) }
|
||||
p.close()
|
||||
}
|
||||
|
||||
fun frame(): QamFrame? {
|
||||
val img = image.value
|
||||
val l = shape.value
|
||||
return if (img != null && l != null && l[0] > 0f) QamFrame(img, l[0], l[1], l[3].coerceIn(l[0] * 0.25f, l[0])) else null
|
||||
}
|
||||
}
|
||||
|
||||
/** Steam's main menu beside the quick access menu; Steam's side of the hold keeps it in place and filling its view. */
|
||||
internal object MainMenuLayout {
|
||||
const val CONTENT_SCRIPT = "JSON.stringify([innerWidth, innerHeight, devicePixelRatio, innerWidth])"
|
||||
}
|
||||
|
||||
/** Panel streams kept across visits to the panel. */
|
||||
/** The last frame shown, so returning to the panel shows the menu at once while the live stream reconnects. */
|
||||
private object QamCache {
|
||||
val qam = MenuStream()
|
||||
val main = MenuStream()
|
||||
@Volatile var image: ImageBitmap? = null
|
||||
@Volatile var shape: FloatArray? = null
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun SteamQamPanel() {
|
||||
val context = LocalContext.current.applicationContext
|
||||
var image by remember { mutableStateOf(QamCache.image) }
|
||||
var shape by remember { mutableStateOf(QamCache.shape) }
|
||||
var failed by remember { mutableStateOf(false) }
|
||||
var slow by remember { mutableStateOf(false) }
|
||||
LaunchedEffect(Unit) {
|
||||
@@ -216,67 +135,78 @@ internal fun SteamQamPanel() {
|
||||
slow = true
|
||||
}
|
||||
val fit = QamFit.current(context)
|
||||
val qam = QamCache.qam
|
||||
val mainMenu = QamCache.main
|
||||
val holder = remember { arrayOfNulls<CdpPage>(1) }
|
||||
val owner = remember { SteamQam.newOwner() }
|
||||
val relay = remember { intArrayOf(0) }
|
||||
val mainPath = remember { arrayOfNulls<String>(1) }
|
||||
val live = remember { java.util.concurrent.atomic.AtomicBoolean(false) }
|
||||
val aspect = remember { floatArrayOf(0f) }
|
||||
val measure = Modifier.fillMaxSize().onSizeChanged { if (it.height > 0) aspect[0] = it.width.toFloat() / it.height }
|
||||
val show = { frame: ImageBitmap -> image = frame; QamCache.image = frame; live.set(true) }
|
||||
LaunchedEffect(Unit) {
|
||||
withContext(Dispatchers.IO) {
|
||||
var misses = 0
|
||||
// The main menu page backs off on its own, so Quick Access stays available while its neighbour cannot connect.
|
||||
var mainMisses = 0
|
||||
var mainRetryAt = 0L
|
||||
fun split() = QamFit.current(context) == QamFit.SPLIT
|
||||
// The lease is renewed on its own, so slow discovery or a retry backoff never lets the held menu lapse.
|
||||
val renew = launch {
|
||||
while (isActive) {
|
||||
if (SessionState.phase == SessionPhase.READY && aspect[0] > 0f) SteamQam.hold(context, aspect[0], owner, split())
|
||||
if (SessionState.phase == SessionPhase.READY && aspect[0] > 0f) SteamQam.hold(context, aspect[0], owner)
|
||||
delay(TICK_MS)
|
||||
}
|
||||
}
|
||||
try {
|
||||
while (isActive) {
|
||||
// Holding the menu before Steam's first frame keeps gamescope from presenting it.
|
||||
if (SessionState.phase != SessionPhase.READY || aspect[0] == 0f) {
|
||||
if (SessionState.phase != SessionPhase.READY) {
|
||||
delay(FAST_TICK_MS)
|
||||
continue
|
||||
}
|
||||
val split = split()
|
||||
val held = SteamQam.hold(context, aspect[0], owner, split)
|
||||
if (aspect[0] == 0f) {
|
||||
delay(FAST_TICK_MS)
|
||||
continue
|
||||
}
|
||||
val held = SteamQam.hold(context, aspect[0], owner)
|
||||
ensureActive()
|
||||
var reached = held != null
|
||||
if (held?.open == SteamQam.QUICK_ACCESS) {
|
||||
if (qam.page?.closed != false) {
|
||||
val t = SteamQam.target(context)
|
||||
if (t != null) {
|
||||
var page = holder[0]
|
||||
if (page == null || page.closed) {
|
||||
page?.close()
|
||||
live.set(false)
|
||||
page = SteamQam.target(context)?.let { t ->
|
||||
if (relay[0] != 0 && relay[0] != t.port) SteamQam.stopRelay(context, relay[0])
|
||||
relay[0] = t.port
|
||||
mainPath[0] = t.mainPath
|
||||
qam.connect(t.port, t.path)
|
||||
mainMenu.stop(MainMenuLayout.CONTENT_SCRIPT)
|
||||
runCatching {
|
||||
CdpPage(t.port, t.path) { method, params ->
|
||||
if (method == "Page.screencastFrame") {
|
||||
holder[0]?.send("Page.screencastFrameAck", JSONObject().put("sessionId", params.optInt("sessionId")))
|
||||
decodeFrame(params.optString("data"))?.let(show)
|
||||
}
|
||||
}
|
||||
}.onFailure { android.util.Log.w("SteamQam", "devtools connect: $it") }.getOrNull()
|
||||
}
|
||||
holder[0] = page
|
||||
ensureActive()
|
||||
page?.send("Page.enable")
|
||||
val started = page?.call("Page.startScreencast", JSONObject().put("format", "jpeg").put("quality", 85)
|
||||
.put("maxWidth", 1920).put("maxHeight", 1440))
|
||||
if (page != null && (started == null || started.has("error") || !started.has("result"))) {
|
||||
page.close()
|
||||
page = null
|
||||
holder[0] = null
|
||||
}
|
||||
}
|
||||
reached = qam.page?.closed == false
|
||||
val wide = !held.top && (QamFit.current(context) == QamFit.FULL || split)
|
||||
qam.refresh(QamLayout.contentScript(wide, parked = !held.top))
|
||||
val path = mainPath[0]
|
||||
if (split && path != null) {
|
||||
val now = android.os.SystemClock.elapsedRealtime()
|
||||
if (mainMenu.page?.closed != false && now >= mainRetryAt) {
|
||||
if (mainMenu.connect(relay[0], path)) {
|
||||
mainMisses = 0
|
||||
} else {
|
||||
mainMisses++
|
||||
mainRetryAt = now + minOf(TICK_MS shl minOf(mainMisses - 1, 2), MAX_RETRY_MS)
|
||||
}
|
||||
// The screencast sends frames only when the menu repaints, so a still menu needs one screenshot.
|
||||
if (!live.get()) {
|
||||
page?.call("Page.captureScreenshot", JSONObject().put("format", "jpeg").put("quality", 85))
|
||||
?.optJSONObject("result")?.optString("data")?.let(::decodeFrame)?.let(show)
|
||||
}
|
||||
reached = page != null
|
||||
val wide = !held.top && QamFit.current(context) == QamFit.FULL
|
||||
(page?.evaluate(QamLayout.contentScript(wide)) as? String)?.let { text ->
|
||||
runCatching {
|
||||
val a = JSONArray(text)
|
||||
val layout = floatArrayOf(a.getDouble(0).toFloat(), a.getDouble(1).toFloat(), a.getDouble(2).toFloat(), a.getDouble(3).toFloat())
|
||||
if (!layout.contentEquals(shape)) { shape = layout; QamCache.shape = layout }
|
||||
}
|
||||
mainMenu.refresh(MainMenuLayout.CONTENT_SCRIPT)
|
||||
} else if (!split) {
|
||||
mainMenu.stop(MainMenuLayout.CONTENT_SCRIPT)
|
||||
}
|
||||
}
|
||||
failed = !reached
|
||||
@@ -284,7 +214,7 @@ internal fun SteamQamPanel() {
|
||||
misses = if (reached) 0 else misses + 1
|
||||
val wait = when {
|
||||
!reached -> minOf(TICK_MS shl minOf(misses - 1, 2), MAX_RETRY_MS)
|
||||
qam.live.get() && (!split || mainMenu.live.get() || mainMenu.page?.closed != false) -> TICK_MS
|
||||
live.get() -> TICK_MS
|
||||
else -> FAST_TICK_MS
|
||||
}
|
||||
val used = QamFit.current(context)
|
||||
@@ -295,46 +225,35 @@ internal fun SteamQamPanel() {
|
||||
} finally {
|
||||
withContext(NonCancellable) {
|
||||
renew.cancelAndJoin()
|
||||
// The pages outlive these connections, so the widened layouts would otherwise stay on the top screen.
|
||||
qam.stop(QamLayout.contentScript(wide = false))
|
||||
mainMenu.stop(MainMenuLayout.CONTENT_SCRIPT)
|
||||
val page = holder[0]
|
||||
holder[0] = null
|
||||
runCatching { page?.send("Page.stopScreencast") }
|
||||
// The page outlives this connection, so the widened layout would otherwise stay on the top screen.
|
||||
runCatching { page?.evaluate(QamLayout.contentScript(wide = false)) }
|
||||
page?.close()
|
||||
SteamQam.release(context, relay[0], owner)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val qamFrame = qam.frame()
|
||||
if (qamFrame == null) {
|
||||
val img = image
|
||||
val l = shape
|
||||
val f = remember(img, l) {
|
||||
if (img != null && l != null && l[0] > 0f) QamFrame(img, l[0], l[1], l[3].coerceIn(l[0] * 0.25f, l[0])) else null
|
||||
}
|
||||
if (f == null) {
|
||||
Box(measure) {
|
||||
if (slow) PanelNote(stringResource(if (failed) R.string.bottom_qam_unavailable else R.string.achievements_reading))
|
||||
}
|
||||
return
|
||||
}
|
||||
if (fit != QamFit.SPLIT) {
|
||||
MenuCanvas(qamFrame, fit.align, measure) { qam.page }
|
||||
return
|
||||
}
|
||||
// Each side is as wide as its menu at the shared scale, so neither is shrunk nor padded with empty space.
|
||||
val mainFrame = mainMenu.frame()
|
||||
val mainWidth = mainFrame?.cssWidth ?: SteamQam.MAIN_CSS_WIDTH.toFloat()
|
||||
Row(measure) {
|
||||
val left = Modifier.weight(mainWidth).fillMaxHeight()
|
||||
if (mainFrame != null) MenuCanvas(mainFrame, -1, left) { mainMenu.page }
|
||||
else Box(left.background(qamFrame.fill))
|
||||
MenuCanvas(qamFrame, -1, Modifier.weight(qamFrame.cssWidth).fillMaxHeight()) { qam.page }
|
||||
}
|
||||
}
|
||||
|
||||
/** Draws [f] scaled into the box, placed by [align], and forwards touches on it to [page]. */
|
||||
@Composable
|
||||
private fun MenuCanvas(f: QamFrame, align: Int, modifier: Modifier, page: () -> CdpPage?) {
|
||||
BoxWithConstraints(modifier.background(f.fill)) {
|
||||
BoxWithConstraints(measure.background(f.fill)) {
|
||||
val density = LocalDensity.current
|
||||
val boxW = with(density) { maxWidth.toPx() }
|
||||
val boxH = with(density) { maxHeight.toPx() }
|
||||
val (scale, left) = QamLayout.fit(boxW, boxH, f.contentRight, f.cssHeight, align)
|
||||
val (scale, left) = QamLayout.fit(boxW, boxH, f.contentRight, f.cssHeight, fit.align)
|
||||
Canvas(
|
||||
Modifier.fillMaxSize().pointerInput(f.cssWidth, f.contentRight, boxW, boxH, align) {
|
||||
Modifier.fillMaxSize().pointerInput(f.cssWidth, f.contentRight, boxW, boxH, fit) {
|
||||
var touching = false
|
||||
var target: CdpPage? = null
|
||||
try {
|
||||
@@ -349,7 +268,7 @@ private fun MenuCanvas(f: QamFrame, align: Int, modifier: Modifier, page: () ->
|
||||
PointerEventType.Release -> "touchEnd"
|
||||
else -> null
|
||||
}?.takeIf { it == "touchStart" || touching } ?: continue
|
||||
if (type == "touchStart") target = page()
|
||||
if (type == "touchStart") target = holder[0]
|
||||
touching = type != "touchEnd"
|
||||
val points = if (type == "touchEnd") JSONArray()
|
||||
else JSONArray().put(JSONObject().put("x", x.toDouble()).put("y", y.toDouble()))
|
||||
|
||||
@@ -103,7 +103,7 @@ internal object SetupTabs {
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun CheckRow(state: CheckState, title: String, detail: String?, divider: Boolean = true, detailLines: Int = 2, action: (@Composable () -> Unit)? = null) {
|
||||
internal fun CheckRow(state: CheckState, title: String, detail: String?, divider: Boolean = true, action: (@Composable () -> Unit)? = null) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val tint = when (state) {
|
||||
@@ -135,7 +135,7 @@ internal fun CheckRow(state: CheckState, title: String, detail: String?, divider
|
||||
}
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(title, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground)
|
||||
if (detail != null) Text(detail, fontSize = 13.sp, color = colors.onSurfaceVariant, maxLines = detailLines, overflow = TextOverflow.Ellipsis)
|
||||
if (detail != null) Text(detail, fontSize = 13.sp, color = colors.onSurfaceVariant, maxLines = 2, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
if (action != null) action()
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ internal fun GameDetail(
|
||||
SideEffect { if (store != null && id != null) known[0] = store to id }
|
||||
val game = found ?: if (store != null && id != null) s.steamGames.firstOrNull { it.source == store.id && it.storeId == id } else null
|
||||
val item = if (store != null && id != null) StoresState.detailItem(store, id) else null
|
||||
val installed = if (store != null && id != null) StoresState.installedGame(store, id) else null
|
||||
val installed = if (store != null && id != null) StoresState.installedGame(store, id, game?.gameFiles) else null
|
||||
val rawDownload = if (store != null && id != null) StoresState.download("${store.id}:$id") else null
|
||||
val download = rawDownload?.takeIf { it.isActive }
|
||||
val failed = rawDownload?.takeIf { it.state == DownloadState.FAILED }
|
||||
@@ -584,12 +584,25 @@ internal fun GameActions(
|
||||
}
|
||||
if (store == Store.BATTLENET) {
|
||||
if (installed != null && id != null) {
|
||||
LaunchedEffect(id) { BattleNetInstall.checkUpdate(ctx, installed) }
|
||||
val updateKey = BattleNetInstall.updateKey(id, installed.folder)
|
||||
var wasRunning by remember(updateKey) { mutableStateOf(false) }
|
||||
// SessionState.running is not snapshot state, so poll it while this detail is shown.
|
||||
val sessionRunning by produceState(SessionState.running) {
|
||||
while (true) {
|
||||
value = SessionState.running
|
||||
kotlinx.coroutines.delay(1000)
|
||||
}
|
||||
}
|
||||
LaunchedEffect(updateKey, sessionRunning) {
|
||||
val ended = wasRunning && !sessionRunning
|
||||
wasRunning = sessionRunning
|
||||
if (!sessionRunning) BattleNetInstall.checkUpdate(ctx, installed, force = ended)
|
||||
}
|
||||
if (download != null) {
|
||||
SteadyDownloadChip(download)
|
||||
if (download.state != DownloadState.PAUSED) SecondaryButton(stringResource(R.string.stores_dl_pause)) { DownloadQueue.pause(download.key) }
|
||||
else SecondaryButton(stringResource(R.string.stores_dl_resume)) { DownloadQueue.resume(ctx, download.key) }
|
||||
} else if (BattleNetInstall.updates[id] == true) {
|
||||
} else if (BattleNetInstall.updates[updateKey] == true) {
|
||||
SecondaryButton(stringResource(R.string.bnet_update)) { BattleNetInstall.update(ctx, installed) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,15 +174,14 @@ private fun InputSettingsContent(onBack: () -> Unit, onChanged: () -> Unit, embe
|
||||
detail = if (library.usersOfBindings(b.id).size > 1) stringResource(R.string.input_shared_detail, b.name, library.usersOfBindings(b.id).size)
|
||||
else "${profile.name} · ${roleLabel(role)}", onSave = { action ->
|
||||
if (update { l ->
|
||||
val currentPreset = l.preset(editing.preset)
|
||||
val geometry = if (!editing.click && elementProperties != null && layout != null) l.withLayout(layout.copy(elements = layout.elements.map {
|
||||
if (it.id == elementProperties!!.id) elementProperties!!.copy(name = elementProperties!!.name.trim().ifBlank { it.name }) else it
|
||||
})) else l
|
||||
geometry.withPreset(when {
|
||||
editing.element != null && editing.click -> currentPreset.copy(clicks = currentPreset.clicks + (editing.element.id to action))
|
||||
editing.element != null -> currentPreset.copy(elements = currentPreset.elements + (editing.element.id to action))
|
||||
editing.key != null -> currentPreset.copy(keys = currentPreset.keys.filterNot { it.key == editing.key } + PhysicalInputBinding(editing.key, action))
|
||||
else -> currentPreset.copy(controls = currentPreset.controls + (editing.control to action))
|
||||
editing.element != null && editing.click -> b.copy(clicks = b.clicks + (editing.element.id to action))
|
||||
editing.element != null -> b.copy(elements = b.elements + (editing.element.id to action))
|
||||
editing.key != null -> b.copy(keys = b.keys.filterNot { it.key == editing.key } + PhysicalInputBinding(editing.key, action))
|
||||
else -> b.copy(controls = b.controls + (editing.control to action))
|
||||
}) }) edit = null
|
||||
})
|
||||
} else if (!surface) key(page, profileId, role) {
|
||||
|
||||
@@ -1198,8 +1198,22 @@ internal fun LibraryMarker(e: LibraryEntry, download: DownloadEntry?, showDownlo
|
||||
}
|
||||
}
|
||||
|
||||
private fun libraryUpdateAvailable(e: LibraryEntry): Boolean = e.storeKey?.let { it in ItchUpdates.available || it in GameJoltUpdates.available || it in com.droiddeck.launcher.stores.ea.EaUpdates.available } == true ||
|
||||
e.source == Store.GOG.id && (e.item?.id ?: e.game?.storeId)?.let { GogMaintenance.checks[it]?.state } == GogMaintenance.State.AVAILABLE
|
||||
private fun libraryUpdateAvailable(e: LibraryEntry): Boolean {
|
||||
val installed = e.storeKey?.let { key ->
|
||||
val store = Store.byId(e.source)
|
||||
val id = e.item?.id ?: e.game?.storeId
|
||||
if (store != null && id != null) StoresState.installedGame(store, id, e.game?.gameFiles)
|
||||
else StoresState.installed.firstOrNull { it.key == key }
|
||||
}
|
||||
val battleNet = installed?.let {
|
||||
com.droiddeck.launcher.stores.battlenet.BattleNetInstall.updates[
|
||||
com.droiddeck.launcher.stores.battlenet.BattleNetInstall.updateKey(it.sidecar.id, it.folder)
|
||||
] == true
|
||||
} == true
|
||||
return battleNet ||
|
||||
e.storeKey?.let { it in ItchUpdates.available || it in GameJoltUpdates.available || it in com.droiddeck.launcher.stores.ea.EaUpdates.available } == true ||
|
||||
e.source == Store.GOG.id && (e.item?.id ?: e.game?.storeId)?.let { GogMaintenance.checks[it]?.state } == GogMaintenance.State.AVAILABLE
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun LibraryRow(e: LibraryEntry, first: Boolean, navigation: Modifier, choose: (() -> Unit)?, onOpen: (String) -> Unit) {
|
||||
|
||||
@@ -1265,11 +1265,6 @@
|
||||
<string name="agent_action_prepare">تحضير</string>
|
||||
<string name="agent_connection_off">تعذّر الوصول إلى تصحيح الأخطاء اللاسلكي؛ زر الاقتران يشغّله</string>
|
||||
<string name="agent_action_pair">اقتران</string>
|
||||
<string name="agent_step_connection_quest_hint">لا يحتوي Quest على شاشة اقتران. من حاسوب، شغّل مرة واحدة: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS و adb tcpip 5555. ثم اضغط «السماح» واقبل الطلب في النظارة</string>
|
||||
<string name="agent_action_allow">السماح</string>
|
||||
<string name="agent_connection_quest_waiting">اقبل «السماح بتصحيح الأخطاء؟» في النظارة مع تحديد «السماح دائمًا»</string>
|
||||
<string name="agent_connection_quest_failed">تعذّر الاتصال. اقبل طلب تصحيح الأخطاء في النظارة، وإن لم يظهر، شغّل adb tcpip 5555 من حاسوب ثم حاول مجددًا</string>
|
||||
<string name="agent_connection_quest_off">تعذّر الوصول إلى تصحيح الأخطاء اللاسلكي. اضغط «السماح» لإعداده من جديد</string>
|
||||
<string name="agent_action_install">تثبيت</string>
|
||||
<string name="agent_action_sign_in">تسجيل الدخول</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2236,7 +2231,6 @@
|
||||
<string name="bottom_qam_layout_left">يسار</string>
|
||||
<string name="bottom_qam_layout_center">وسط</string>
|
||||
<string name="bottom_qam_layout_right">يمين</string>
|
||||
<string name="bottom_qam_layout_split">مقسّم</string>
|
||||
<string name="bottom_qam_unavailable">قائمة الوصول السريع في Steam غير متاحة بعد.</string>
|
||||
<string name="bottom_page_telemetry">إحصاءات داخل اللعبة</string>
|
||||
<string name="bottom_hud_group">مؤشرات الشاشة السفلية</string>
|
||||
|
||||
@@ -1280,11 +1280,6 @@
|
||||
<string name="agent_action_prepare">Preparar</string>
|
||||
<string name="agent_connection_off">No se puede acceder a la depuración inalámbrica; Vincular la activa</string>
|
||||
<string name="agent_action_pair">Vincular</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest no tiene pantalla de vinculación. Desde una computadora, ejecuta una vez: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS y adb tcpip 5555. Luego toca Permitir y acepta el aviso en el visor</string>
|
||||
<string name="agent_action_allow">Permitir</string>
|
||||
<string name="agent_connection_quest_waiting">Acepta «¿Permitir depuración?» en el visor, con Permitir siempre marcado</string>
|
||||
<string name="agent_connection_quest_failed">No se pudo conectar. Acepta el aviso de depuración en el visor o, si no apareció, ejecuta adb tcpip 5555 desde una computadora y vuelve a intentarlo</string>
|
||||
<string name="agent_connection_quest_off">No se puede acceder a la depuración inalámbrica. Toca Permitir para configurarla de nuevo</string>
|
||||
<string name="agent_action_install">Instalar</string>
|
||||
<string name="agent_action_sign_in">Iniciar sesión</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2231,7 +2226,6 @@
|
||||
<string name="bottom_qam_layout_left">Izquierda</string>
|
||||
<string name="bottom_qam_layout_center">Centro</string>
|
||||
<string name="bottom_qam_layout_right">Derecha</string>
|
||||
<string name="bottom_qam_layout_split">Dividido</string>
|
||||
<string name="bottom_qam_unavailable">El menú de acceso rápido de Steam aún no está disponible.</string>
|
||||
<string name="bottom_page_telemetry">Estadísticas del juego</string>
|
||||
<string name="bottom_hud_group">HUD de la pantalla inferior</string>
|
||||
|
||||
@@ -1249,11 +1249,6 @@
|
||||
<string name="agent_action_prepare">Подготви</string>
|
||||
<string name="agent_connection_off">Безжичното отстраняване на грешки не е достъпно; сдвояването го включва</string>
|
||||
<string name="agent_action_pair">Сдвой</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest няма екран за сдвояване. От компютър изпълнете веднъж: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS и adb tcpip 5555. След това докоснете „Разреши“ и приемете запитването в шлема</string>
|
||||
<string name="agent_action_allow">Разреши</string>
|
||||
<string name="agent_connection_quest_waiting">Приемете „Разрешаване на отстраняването на грешки?“ в шлема с отметка „Винаги разрешавай“</string>
|
||||
<string name="agent_connection_quest_failed">Неуспешно свързване. Приемете запитването за отстраняване на грешки в шлема, а ако не се е появило, изпълнете adb tcpip 5555 от компютър и опитайте отново</string>
|
||||
<string name="agent_connection_quest_off">Безжичното отстраняване на грешки не е достъпно. Докоснете „Разреши“, за да го настроите отново</string>
|
||||
<string name="agent_action_install">Инсталирай</string>
|
||||
<string name="agent_action_sign_in">Влез</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2136,7 +2131,6 @@
|
||||
<string name="bottom_qam_layout_left">Вляво</string>
|
||||
<string name="bottom_qam_layout_center">В центъра</string>
|
||||
<string name="bottom_qam_layout_right">Вдясно</string>
|
||||
<string name="bottom_qam_layout_split">Разделено</string>
|
||||
<string name="bottom_qam_unavailable">Менюто за бърз достъп на Steam още не е налично.</string>
|
||||
<string name="bottom_page_telemetry">Статистика в играта</string>
|
||||
<string name="bottom_hud_group">HUD на долния екран</string>
|
||||
|
||||
@@ -1257,11 +1257,6 @@
|
||||
<string name="agent_action_prepare">Připravit</string>
|
||||
<string name="agent_connection_off">Bezdrátové ladění není dostupné; Spárovat ho zapne</string>
|
||||
<string name="agent_action_pair">Spárovat</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest nemá obrazovku párování. Z počítače jednou spusťte: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS a adb tcpip 5555. Pak klepněte na Povolit a potvrďte výzvu v headsetu</string>
|
||||
<string name="agent_action_allow">Povolit</string>
|
||||
<string name="agent_connection_quest_waiting">V headsetu potvrďte „Povolit ladění?“ se zaškrtnutým Vždy povolit</string>
|
||||
<string name="agent_connection_quest_failed">Nepodařilo se připojit. Potvrďte výzvu k ladění v headsetu, a pokud se neobjevila, spusťte z počítače adb tcpip 5555 a zkuste to znovu</string>
|
||||
<string name="agent_connection_quest_off">Bezdrátové ladění není dostupné. Klepnutím na Povolit ho nastavíte znovu</string>
|
||||
<string name="agent_action_install">Instalovat</string>
|
||||
<string name="agent_action_sign_in">Přihlásit se</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2186,7 +2181,6 @@
|
||||
<string name="bottom_qam_layout_left">Vlevo</string>
|
||||
<string name="bottom_qam_layout_center">Na střed</string>
|
||||
<string name="bottom_qam_layout_right">Vpravo</string>
|
||||
<string name="bottom_qam_layout_split">Rozděleno</string>
|
||||
<string name="bottom_qam_unavailable">Nabídka rychlého přístupu Steamu zatím není k dispozici.</string>
|
||||
<string name="bottom_page_telemetry">Statistiky ve hře</string>
|
||||
<string name="bottom_hud_group">HUD na spodní obrazovce</string>
|
||||
|
||||
@@ -1249,11 +1249,6 @@
|
||||
<string name="agent_action_prepare">Forbered</string>
|
||||
<string name="agent_connection_off">Trådløs fejlfinding kan ikke nås; Par slår den til</string>
|
||||
<string name="agent_action_pair">Par</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest har ingen parringsskærm. Kør én gang fra en computer: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS og adb tcpip 5555. Tryk derefter på Tillad, og godkend prompten i headsettet</string>
|
||||
<string name="agent_action_allow">Tillad</string>
|
||||
<string name="agent_connection_quest_waiting">Godkend “Tillad fejlretning?” i headsettet med Tillad altid markeret</string>
|
||||
<string name="agent_connection_quest_failed">Kunne ikke oprette forbindelse. Godkend fejlretningsprompten i headsettet, eller kør adb tcpip 5555 fra en computer og prøv igen, hvis den ikke dukkede op</string>
|
||||
<string name="agent_connection_quest_off">Trådløs fejlretning kan ikke nås. Tryk på Tillad for at konfigurere den igen</string>
|
||||
<string name="agent_action_install">Installer</string>
|
||||
<string name="agent_action_sign_in">Log ind</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2136,7 +2131,6 @@
|
||||
<string name="bottom_qam_layout_left">Venstre</string>
|
||||
<string name="bottom_qam_layout_center">Midte</string>
|
||||
<string name="bottom_qam_layout_right">Højre</string>
|
||||
<string name="bottom_qam_layout_split">Delt</string>
|
||||
<string name="bottom_qam_unavailable">Steams menu til hurtig adgang er ikke tilgængelig endnu.</string>
|
||||
<string name="bottom_page_telemetry">Statistik i spillet</string>
|
||||
<string name="bottom_hud_group">HUD på nederste skærm</string>
|
||||
|
||||
@@ -1241,11 +1241,6 @@
|
||||
<string name="agent_action_prepare">Vorbereiten</string>
|
||||
<string name="agent_connection_off">Wireless-Debugging ist nicht erreichbar; Koppeln schaltet es ein</string>
|
||||
<string name="agent_action_pair">Koppeln</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest hat keinen Kopplungsbildschirm. Führe einmal an einem Computer aus: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS und adb tcpip 5555. Tippe dann auf Zulassen und bestätige die Abfrage im Headset</string>
|
||||
<string name="agent_action_allow">Zulassen</string>
|
||||
<string name="agent_connection_quest_waiting">Bestätige „Debugging zulassen?“ im Headset mit aktiviertem „Immer zulassen“</string>
|
||||
<string name="agent_connection_quest_failed">Verbindung fehlgeschlagen. Bestätige die Debugging-Abfrage im Headset. Falls keine erschienen ist, führe adb tcpip 5555 an einem Computer aus und versuche es erneut</string>
|
||||
<string name="agent_connection_quest_off">Kabelloses Debugging ist nicht erreichbar. Tippe auf Zulassen, um es neu einzurichten</string>
|
||||
<string name="agent_action_install">Installieren</string>
|
||||
<string name="agent_action_sign_in">Anmelden</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2128,7 +2123,6 @@
|
||||
<string name="bottom_qam_layout_left">Links</string>
|
||||
<string name="bottom_qam_layout_center">Mitte</string>
|
||||
<string name="bottom_qam_layout_right">Rechts</string>
|
||||
<string name="bottom_qam_layout_split">Geteilt</string>
|
||||
<string name="bottom_qam_unavailable">Das Schnellzugriffsmenü von Steam ist noch nicht verfügbar.</string>
|
||||
<string name="bottom_page_telemetry">Spielstatistiken</string>
|
||||
<string name="bottom_hud_group">HUD für den unteren Bildschirm</string>
|
||||
|
||||
@@ -1249,11 +1249,6 @@
|
||||
<string name="agent_action_prepare">Προετοιμασία</string>
|
||||
<string name="agent_connection_off">Η ασύρματη αποσφαλμάτωση δεν είναι προσβάσιμη · η Σύζευξη την ενεργοποιεί</string>
|
||||
<string name="agent_action_pair">Σύζευξη</string>
|
||||
<string name="agent_step_connection_quest_hint">Το Quest δεν έχει οθόνη σύζευξης. Από έναν υπολογιστή, εκτελέστε μία φορά: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS και adb tcpip 5555. Μετά πατήστε «Να επιτραπεί» και αποδεχτείτε το μήνυμα στο headset</string>
|
||||
<string name="agent_action_allow">Να επιτραπεί</string>
|
||||
<string name="agent_connection_quest_waiting">Αποδεχτείτε το «Να επιτραπεί ο εντοπισμός σφαλμάτων;» στο headset, με επιλεγμένο το «Να επιτρέπεται πάντα»</string>
|
||||
<string name="agent_connection_quest_failed">Δεν ήταν δυνατή η σύνδεση. Αποδεχτείτε το μήνυμα εντοπισμού σφαλμάτων στο headset ή, αν δεν εμφανίστηκε, εκτελέστε adb tcpip 5555 από υπολογιστή και δοκιμάστε ξανά</string>
|
||||
<string name="agent_connection_quest_off">Ο ασύρματος εντοπισμός σφαλμάτων δεν είναι προσβάσιμος. Πατήστε «Να επιτραπεί» για να τον ρυθμίσετε ξανά</string>
|
||||
<string name="agent_action_install">Εγκατάσταση</string>
|
||||
<string name="agent_action_sign_in">Σύνδεση</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2136,7 +2131,6 @@
|
||||
<string name="bottom_qam_layout_left">Αριστερά</string>
|
||||
<string name="bottom_qam_layout_center">Κέντρο</string>
|
||||
<string name="bottom_qam_layout_right">Δεξιά</string>
|
||||
<string name="bottom_qam_layout_split">Διαιρεμένο</string>
|
||||
<string name="bottom_qam_unavailable">Το μενού γρήγορης πρόσβασης του Steam δεν είναι ακόμη διαθέσιμο.</string>
|
||||
<string name="bottom_page_telemetry">Στατιστικά παιχνιδιού</string>
|
||||
<string name="bottom_hud_group">HUD κάτω οθόνης</string>
|
||||
|
||||
@@ -1253,11 +1253,6 @@
|
||||
<string name="agent_action_prepare">Preparar</string>
|
||||
<string name="agent_connection_off">No se puede acceder a la depuración inalámbrica; Emparejar la activa</string>
|
||||
<string name="agent_action_pair">Emparejar</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest no tiene pantalla de vinculación. Desde un ordenador, ejecuta una vez: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS y adb tcpip 5555. Después toca Permitir y acepta el aviso en el visor</string>
|
||||
<string name="agent_action_allow">Permitir</string>
|
||||
<string name="agent_connection_quest_waiting">Acepta «¿Permitir depuración?» en el visor, con Permitir siempre marcado</string>
|
||||
<string name="agent_connection_quest_failed">No se pudo conectar. Acepta el aviso de depuración en el visor o, si no apareció, ejecuta adb tcpip 5555 desde un ordenador y vuelve a intentarlo</string>
|
||||
<string name="agent_connection_quest_off">No se puede acceder a la depuración inalámbrica. Toca Permitir para configurarla de nuevo</string>
|
||||
<string name="agent_action_install">Instalar</string>
|
||||
<string name="agent_action_sign_in">Iniciar sesión</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2161,7 +2156,6 @@
|
||||
<string name="bottom_qam_layout_left">Izquierda</string>
|
||||
<string name="bottom_qam_layout_center">Centro</string>
|
||||
<string name="bottom_qam_layout_right">Derecha</string>
|
||||
<string name="bottom_qam_layout_split">Dividido</string>
|
||||
<string name="bottom_qam_unavailable">El menú de acceso rápido de Steam aún no está disponible.</string>
|
||||
<string name="bottom_page_telemetry">Estadísticas del juego</string>
|
||||
<string name="bottom_hud_group">HUD de la pantalla inferior</string>
|
||||
|
||||
@@ -1249,11 +1249,6 @@
|
||||
<string name="agent_action_prepare">Valmistele</string>
|
||||
<string name="agent_connection_off">Langaton virheenkorjaus ei ole tavoitettavissa; Parita ottaa sen käyttöön</string>
|
||||
<string name="agent_action_pair">Parita</string>
|
||||
<string name="agent_step_connection_quest_hint">Questissa ei ole laiteparinäkymää. Suorita kerran tietokoneelta: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS ja adb tcpip 5555. Napauta sitten Salli ja hyväksy kehote laseissa</string>
|
||||
<string name="agent_action_allow">Salli</string>
|
||||
<string name="agent_connection_quest_waiting">Hyväksy ”Sallitaanko virheenkorjaus?” laseissa, kun Salli aina on valittuna</string>
|
||||
<string name="agent_connection_quest_failed">Yhteyttä ei saatu. Hyväksy virheenkorjauskehote laseissa, tai jos sitä ei näkynyt, suorita adb tcpip 5555 tietokoneelta ja yritä uudelleen</string>
|
||||
<string name="agent_connection_quest_off">Langatonta virheenkorjausta ei tavoiteta. Määritä se uudelleen napauttamalla Salli</string>
|
||||
<string name="agent_action_install">Asenna</string>
|
||||
<string name="agent_action_sign_in">Kirjaudu sisään</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2136,7 +2131,6 @@
|
||||
<string name="bottom_qam_layout_left">Vasen</string>
|
||||
<string name="bottom_qam_layout_center">Keskellä</string>
|
||||
<string name="bottom_qam_layout_right">Oikea</string>
|
||||
<string name="bottom_qam_layout_split">Jaettu</string>
|
||||
<string name="bottom_qam_unavailable">Steamin pikavalikko ei ole vielä käytettävissä.</string>
|
||||
<string name="bottom_page_telemetry">Pelinsisäiset tilastot</string>
|
||||
<string name="bottom_hud_group">Alanäytön HUD</string>
|
||||
|
||||
@@ -1252,11 +1252,6 @@
|
||||
<string name="agent_action_prepare">Préparer</string>
|
||||
<string name="agent_connection_off">Le débogage sans fil n\'est pas accessible ; « Associer » l\'active</string>
|
||||
<string name="agent_action_pair">Associer</string>
|
||||
<string name="agent_step_connection_quest_hint">Le Quest n\'a pas d\'écran d\'association. Depuis un ordinateur, exécutez une fois : adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS et adb tcpip 5555. Touchez ensuite Autoriser et acceptez la demande dans le casque</string>
|
||||
<string name="agent_action_allow">Autoriser</string>
|
||||
<string name="agent_connection_quest_waiting">Acceptez « Autoriser le débogage ? » dans le casque, avec Toujours autoriser coché</string>
|
||||
<string name="agent_connection_quest_failed">Connexion impossible. Acceptez la demande de débogage dans le casque ou, si elle n\'est pas apparue, exécutez adb tcpip 5555 depuis un ordinateur et réessayez</string>
|
||||
<string name="agent_connection_quest_off">Le débogage sans fil est injoignable. Touchez Autoriser pour le configurer à nouveau</string>
|
||||
<string name="agent_action_install">Installer</string>
|
||||
<string name="agent_action_sign_in">Se connecter</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2160,7 +2155,6 @@
|
||||
<string name="bottom_qam_layout_left">Gauche</string>
|
||||
<string name="bottom_qam_layout_center">Centre</string>
|
||||
<string name="bottom_qam_layout_right">Droite</string>
|
||||
<string name="bottom_qam_layout_split">Partagé</string>
|
||||
<string name="bottom_qam_unavailable">Le menu d’accès rapide de Steam n’est pas encore disponible.</string>
|
||||
<string name="bottom_page_telemetry">Statistiques en jeu</string>
|
||||
<string name="bottom_hud_group">HUD de l\'écran du bas</string>
|
||||
|
||||
@@ -1249,11 +1249,6 @@
|
||||
<string name="agent_action_prepare">तैयार करें</string>
|
||||
<string name="agent_connection_off">वायरलेस डिबगिंग से कनेक्ट नहीं हो पा रहा; पेयर करने से यह चालू हो जाता है</string>
|
||||
<string name="agent_action_pair">पेयर करें</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest में पेयरिंग स्क्रीन नहीं है। किसी कंप्यूटर से एक बार चलाएँ: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS और adb tcpip 5555। फिर अनुमति दें पर टैप करें और हेडसेट में संकेत स्वीकार करें</string>
|
||||
<string name="agent_action_allow">अनुमति दें</string>
|
||||
<string name="agent_connection_quest_waiting">हेडसेट में “डीबगिंग की अनुमति दें?” स्वीकार करें, हमेशा अनुमति दें चुना हुआ रखें</string>
|
||||
<string name="agent_connection_quest_failed">कनेक्ट नहीं हो सका। हेडसेट में डीबगिंग संकेत स्वीकार करें, या अगर वह नहीं दिखा, तो कंप्यूटर से adb tcpip 5555 चलाएँ और दोबारा कोशिश करें</string>
|
||||
<string name="agent_connection_quest_off">वायरलेस डीबगिंग तक नहीं पहुँचा जा सकता। इसे फिर से सेट करने के लिए अनुमति दें पर टैप करें</string>
|
||||
<string name="agent_action_install">इंस्टॉल करें</string>
|
||||
<string name="agent_action_sign_in">साइन इन करें</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2136,7 +2131,6 @@
|
||||
<string name="bottom_qam_layout_left">बाएँ</string>
|
||||
<string name="bottom_qam_layout_center">बीच में</string>
|
||||
<string name="bottom_qam_layout_right">दाएँ</string>
|
||||
<string name="bottom_qam_layout_split">विभाजित</string>
|
||||
<string name="bottom_qam_unavailable">Steam का क्विक एक्सेस मेनू अभी उपलब्ध नहीं है।</string>
|
||||
<string name="bottom_page_telemetry">इन-गेम आंकड़े</string>
|
||||
<string name="bottom_hud_group">निचली स्क्रीन HUD</string>
|
||||
|
||||
@@ -1249,11 +1249,6 @@
|
||||
<string name="agent_action_prepare">Előkészítés</string>
|
||||
<string name="agent_connection_off">A vezeték nélküli hibakeresés nem érhető el; a Párosítás bekapcsolja</string>
|
||||
<string name="agent_action_pair">Párosítás</string>
|
||||
<string name="agent_step_connection_quest_hint">A Quest nem rendelkezik párosítási képernyővel. Egy számítógépről futtasd egyszer: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS és adb tcpip 5555. Ezután koppints az Engedélyezés gombra, és fogadd el a kérdést a headsetben</string>
|
||||
<string name="agent_action_allow">Engedélyezés</string>
|
||||
<string name="agent_connection_quest_waiting">Fogadd el az „Engedélyezed a hibakeresést?” kérdést a headsetben, a Mindig engedélyez bejelölésével</string>
|
||||
<string name="agent_connection_quest_failed">Nem sikerült csatlakozni. Fogadd el a hibakeresési kérdést a headsetben, vagy ha nem jelent meg, futtasd az adb tcpip 5555 parancsot egy számítógépről, és próbáld újra</string>
|
||||
<string name="agent_connection_quest_off">A vezeték nélküli hibakeresés nem érhető el. Koppints az Engedélyezés gombra az újbóli beállításhoz</string>
|
||||
<string name="agent_action_install">Telepítés</string>
|
||||
<string name="agent_action_sign_in">Bejelentkezés</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2136,7 +2131,6 @@
|
||||
<string name="bottom_qam_layout_left">Balra</string>
|
||||
<string name="bottom_qam_layout_center">Középen</string>
|
||||
<string name="bottom_qam_layout_right">Jobbra</string>
|
||||
<string name="bottom_qam_layout_split">Osztott</string>
|
||||
<string name="bottom_qam_unavailable">A Steam gyorselérési menüje még nem érhető el.</string>
|
||||
<string name="bottom_page_telemetry">Játékon belüli statisztikák</string>
|
||||
<string name="bottom_hud_group">HUD az alsó képernyőn</string>
|
||||
|
||||
@@ -1246,11 +1246,6 @@
|
||||
<string name="agent_action_prepare">Siapkan</string>
|
||||
<string name="agent_connection_off">Debug nirkabel tidak dapat dijangkau; Pasangkan menyalakannya</string>
|
||||
<string name="agent_action_pair">Pasangkan</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest tidak memiliki layar penyambungan. Dari komputer, jalankan sekali: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS dan adb tcpip 5555. Lalu ketuk Izinkan dan terima permintaan di headset</string>
|
||||
<string name="agent_action_allow">Izinkan</string>
|
||||
<string name="agent_connection_quest_waiting">Terima “Izinkan debugging?” di headset, dengan Selalu izinkan dicentang</string>
|
||||
<string name="agent_connection_quest_failed">Tidak dapat terhubung. Terima permintaan debugging di headset, atau jika tidak muncul, jalankan adb tcpip 5555 dari komputer lalu coba lagi</string>
|
||||
<string name="agent_connection_quest_off">Debugging nirkabel tidak dapat dijangkau. Ketuk Izinkan untuk menyiapkannya lagi</string>
|
||||
<string name="agent_action_install">Pasang</string>
|
||||
<string name="agent_action_sign_in">Masuk</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2112,7 +2107,6 @@
|
||||
<string name="bottom_qam_layout_left">Kiri</string>
|
||||
<string name="bottom_qam_layout_center">Tengah</string>
|
||||
<string name="bottom_qam_layout_right">Kanan</string>
|
||||
<string name="bottom_qam_layout_split">Terbagi</string>
|
||||
<string name="bottom_qam_unavailable">Menu Akses Cepat Steam belum tersedia.</string>
|
||||
<string name="bottom_page_telemetry">Statistik dalam gim</string>
|
||||
<string name="bottom_hud_group">HUD layar bawah</string>
|
||||
|
||||
@@ -1244,11 +1244,6 @@
|
||||
<string name="agent_action_prepare">Prepara</string>
|
||||
<string name="agent_connection_off">Il debug wireless non è raggiungibile; Associa lo attiva</string>
|
||||
<string name="agent_action_pair">Associa</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest non ha una schermata di accoppiamento. Da un computer, esegui una volta: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS e adb tcpip 5555. Poi tocca Consenti e accetta la richiesta nel visore</string>
|
||||
<string name="agent_action_allow">Consenti</string>
|
||||
<string name="agent_connection_quest_waiting">Accetta «Consentire il debug?» nel visore, con Consenti sempre selezionato</string>
|
||||
<string name="agent_connection_quest_failed">Impossibile connettersi. Accetta la richiesta di debug nel visore oppure, se non è comparsa, esegui adb tcpip 5555 da un computer e riprova</string>
|
||||
<string name="agent_connection_quest_off">Il debug wireless non è raggiungibile. Tocca Consenti per configurarlo di nuovo</string>
|
||||
<string name="agent_action_install">Installa</string>
|
||||
<string name="agent_action_sign_in">Accedi</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2152,7 +2147,6 @@
|
||||
<string name="bottom_qam_layout_left">Sinistra</string>
|
||||
<string name="bottom_qam_layout_center">Centro</string>
|
||||
<string name="bottom_qam_layout_right">Destra</string>
|
||||
<string name="bottom_qam_layout_split">Diviso</string>
|
||||
<string name="bottom_qam_unavailable">Il menu di accesso rapido di Steam non è ancora disponibile.</string>
|
||||
<string name="bottom_page_telemetry">Statistiche di gioco</string>
|
||||
<string name="bottom_hud_group">HUD dello schermo inferiore</string>
|
||||
|
||||
@@ -1246,11 +1246,6 @@
|
||||
<string name="agent_action_prepare">準備</string>
|
||||
<string name="agent_connection_off">ワイヤレスデバッグに接続できません。ペアリングで有効になります</string>
|
||||
<string name="agent_action_pair">ペアリング</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest にはペア設定画面がありません。パソコンから一度だけ adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS と adb tcpip 5555 を実行し、[許可] をタップしてヘッドセットの確認を承認してください</string>
|
||||
<string name="agent_action_allow">許可</string>
|
||||
<string name="agent_connection_quest_waiting">ヘッドセットで「デバッグを許可しますか?」を、[常に許可] にチェックを入れて承認してください</string>
|
||||
<string name="agent_connection_quest_failed">接続できませんでした。ヘッドセットでデバッグの確認を承認してください。表示されなかった場合は、パソコンから adb tcpip 5555 を実行してもう一度お試しください</string>
|
||||
<string name="agent_connection_quest_off">ワイヤレス デバッグに接続できません。[許可] をタップして設定し直してください</string>
|
||||
<string name="agent_action_install">インストール</string>
|
||||
<string name="agent_action_sign_in">サインイン</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2112,7 +2107,6 @@
|
||||
<string name="bottom_qam_layout_left">左</string>
|
||||
<string name="bottom_qam_layout_center">中央</string>
|
||||
<string name="bottom_qam_layout_right">右</string>
|
||||
<string name="bottom_qam_layout_split">分割</string>
|
||||
<string name="bottom_qam_unavailable">Steam のクイックアクセスメニューはまだ使えません。</string>
|
||||
<string name="bottom_page_telemetry">ゲーム内統計</string>
|
||||
<string name="bottom_hud_group">下部画面の HUD</string>
|
||||
|
||||
@@ -1246,11 +1246,6 @@
|
||||
<string name="agent_action_prepare">준비</string>
|
||||
<string name="agent_connection_off">무선 디버깅에 연결할 수 없습니다. 페어링하면 켜집니다</string>
|
||||
<string name="agent_action_pair">페어링</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest에는 페어링 화면이 없습니다. 컴퓨터에서 한 번 실행하세요: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS 및 adb tcpip 5555. 그런 다음 허용을 탭하고 헤드셋에서 요청을 수락하세요</string>
|
||||
<string name="agent_action_allow">허용</string>
|
||||
<string name="agent_connection_quest_waiting">헤드셋에서 \'디버깅을 허용하시겠습니까?\'를 항상 허용을 선택한 채로 수락하세요</string>
|
||||
<string name="agent_connection_quest_failed">연결하지 못했습니다. 헤드셋에서 디버깅 요청을 수락하거나, 요청이 나타나지 않았다면 컴퓨터에서 adb tcpip 5555를 실행한 뒤 다시 시도하세요</string>
|
||||
<string name="agent_connection_quest_off">무선 디버깅에 연결할 수 없습니다. 허용을 탭해 다시 설정하세요</string>
|
||||
<string name="agent_action_install">설치</string>
|
||||
<string name="agent_action_sign_in">로그인</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2112,7 +2107,6 @@
|
||||
<string name="bottom_qam_layout_left">왼쪽</string>
|
||||
<string name="bottom_qam_layout_center">가운데</string>
|
||||
<string name="bottom_qam_layout_right">오른쪽</string>
|
||||
<string name="bottom_qam_layout_split">분할</string>
|
||||
<string name="bottom_qam_unavailable">Steam 빠른 메뉴를 아직 사용할 수 없습니다.</string>
|
||||
<string name="bottom_page_telemetry">게임 내 통계</string>
|
||||
<string name="bottom_hud_group">하단 화면 HUD</string>
|
||||
|
||||
@@ -1246,11 +1246,6 @@
|
||||
<string name="agent_action_prepare">Sediakan</string>
|
||||
<string name="agent_connection_off">Penyahpepijatan wayarles tidak dapat dicapai; Pasangkan menghidupkannya</string>
|
||||
<string name="agent_action_pair">Pasangkan</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest tiada skrin pasangan. Dari komputer, jalankan sekali: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS dan adb tcpip 5555. Kemudian ketik Benarkan dan terima gesaan dalam set kepala</string>
|
||||
<string name="agent_action_allow">Benarkan</string>
|
||||
<string name="agent_connection_quest_waiting">Terima “Benarkan penyahpepijatan?” dalam set kepala, dengan Sentiasa benarkan ditanda</string>
|
||||
<string name="agent_connection_quest_failed">Tidak dapat bersambung. Terima gesaan penyahpepijatan dalam set kepala, atau jika tiada, jalankan adb tcpip 5555 dari komputer dan cuba lagi</string>
|
||||
<string name="agent_connection_quest_off">Penyahpepijatan wayarles tidak dapat dicapai. Ketik Benarkan untuk menyediakannya semula</string>
|
||||
<string name="agent_action_install">Pasang</string>
|
||||
<string name="agent_action_sign_in">Log masuk</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2112,7 +2107,6 @@
|
||||
<string name="bottom_qam_layout_left">Kiri</string>
|
||||
<string name="bottom_qam_layout_center">Tengah</string>
|
||||
<string name="bottom_qam_layout_right">Kanan</string>
|
||||
<string name="bottom_qam_layout_split">Terbahagi</string>
|
||||
<string name="bottom_qam_unavailable">Menu Akses Pantas Steam belum tersedia.</string>
|
||||
<string name="bottom_page_telemetry">Statistik dalam permainan</string>
|
||||
<string name="bottom_hud_group">HUD skrin bawah</string>
|
||||
|
||||
@@ -1249,11 +1249,6 @@
|
||||
<string name="agent_action_prepare">Forbered</string>
|
||||
<string name="agent_connection_off">Trådløs feilsøking er ikke tilgjengelig; Par slår den på</string>
|
||||
<string name="agent_action_pair">Par</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest har ingen sammenkoblingsskjerm. Kjør én gang fra en datamaskin: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS og adb tcpip 5555. Trykk deretter på Tillat og godta spørsmålet i hodesettet</string>
|
||||
<string name="agent_action_allow">Tillat</string>
|
||||
<string name="agent_connection_quest_waiting">Godta «Vil du tillate feilsøking?» i hodesettet med Tillat alltid avkrysset</string>
|
||||
<string name="agent_connection_quest_failed">Kunne ikke koble til. Godta feilsøkingsspørsmålet i hodesettet, eller kjør adb tcpip 5555 fra en datamaskin og prøv igjen hvis det ikke dukket opp</string>
|
||||
<string name="agent_connection_quest_off">Trådløs feilsøking kan ikke nås. Trykk på Tillat for å sette den opp på nytt</string>
|
||||
<string name="agent_action_install">Installer</string>
|
||||
<string name="agent_action_sign_in">Logg inn</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2136,7 +2131,6 @@
|
||||
<string name="bottom_qam_layout_left">Venstre</string>
|
||||
<string name="bottom_qam_layout_center">Midten</string>
|
||||
<string name="bottom_qam_layout_right">Høyre</string>
|
||||
<string name="bottom_qam_layout_split">Delt</string>
|
||||
<string name="bottom_qam_unavailable">Steams hurtigtilgangsmeny er ikke tilgjengelig ennå.</string>
|
||||
<string name="bottom_page_telemetry">Statistikk i spillet</string>
|
||||
<string name="bottom_hud_group">HUD på bunnskjermen</string>
|
||||
|
||||
@@ -1249,11 +1249,6 @@
|
||||
<string name="agent_action_prepare">Voorbereiden</string>
|
||||
<string name="agent_connection_off">Draadloze foutopsporing is niet bereikbaar; Koppelen schakelt dit in</string>
|
||||
<string name="agent_action_pair">Koppelen</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest heeft geen koppelscherm. Voer vanaf een computer één keer uit: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS en adb tcpip 5555. Tik daarna op Toestaan en accepteer de melding in de headset</string>
|
||||
<string name="agent_action_allow">Toestaan</string>
|
||||
<string name="agent_connection_quest_waiting">Accepteer ‘Foutopsporing toestaan?’ in de headset, met Altijd toestaan aangevinkt</string>
|
||||
<string name="agent_connection_quest_failed">Verbinden mislukt. Accepteer de foutopsporingsmelding in de headset, of voer adb tcpip 5555 uit vanaf een computer en probeer het opnieuw als er geen verscheen</string>
|
||||
<string name="agent_connection_quest_off">Draadloze foutopsporing is niet bereikbaar. Tik op Toestaan om het opnieuw in te stellen</string>
|
||||
<string name="agent_action_install">Installeren</string>
|
||||
<string name="agent_action_sign_in">Inloggen</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2136,7 +2131,6 @@
|
||||
<string name="bottom_qam_layout_left">Links</string>
|
||||
<string name="bottom_qam_layout_center">Midden</string>
|
||||
<string name="bottom_qam_layout_right">Rechts</string>
|
||||
<string name="bottom_qam_layout_split">Gesplitst</string>
|
||||
<string name="bottom_qam_unavailable">Het menu Snelle toegang van Steam is nog niet beschikbaar.</string>
|
||||
<string name="bottom_page_telemetry">In-game statistieken</string>
|
||||
<string name="bottom_hud_group">HUD op het onderste scherm</string>
|
||||
|
||||
@@ -1257,11 +1257,6 @@
|
||||
<string name="agent_action_prepare">Przygotuj</string>
|
||||
<string name="agent_connection_off">Debugowanie bezprzewodowe jest niedostępne; Paruj, aby je włączyć</string>
|
||||
<string name="agent_action_pair">Paruj</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest nie ma ekranu parowania. Na komputerze uruchom raz: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS oraz adb tcpip 5555. Następnie dotknij Zezwól i zaakceptuj monit w goglach</string>
|
||||
<string name="agent_action_allow">Zezwól</string>
|
||||
<string name="agent_connection_quest_waiting">Zaakceptuj „Zezwolić na debugowanie?” w goglach z zaznaczonym Zawsze zezwalaj</string>
|
||||
<string name="agent_connection_quest_failed">Nie udało się połączyć. Zaakceptuj monit debugowania w goglach, a jeśli się nie pojawił, uruchom adb tcpip 5555 na komputerze i spróbuj ponownie</string>
|
||||
<string name="agent_connection_quest_off">Debugowanie bezprzewodowe jest nieosiągalne. Dotknij Zezwól, aby skonfigurować je ponownie</string>
|
||||
<string name="agent_action_install">Zainstaluj</string>
|
||||
<string name="agent_action_sign_in">Zaloguj się</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2186,7 +2181,6 @@
|
||||
<string name="bottom_qam_layout_left">Do lewej</string>
|
||||
<string name="bottom_qam_layout_center">Na środku</string>
|
||||
<string name="bottom_qam_layout_right">Do prawej</string>
|
||||
<string name="bottom_qam_layout_split">Podzielony</string>
|
||||
<string name="bottom_qam_unavailable">Menu szybkiego dostępu Steam nie jest jeszcze dostępne.</string>
|
||||
<string name="bottom_page_telemetry">Statystyki w grze</string>
|
||||
<string name="bottom_hud_group">HUD dolnego ekranu</string>
|
||||
|
||||
@@ -1244,11 +1244,6 @@
|
||||
<string name="agent_action_prepare">Preparar</string>
|
||||
<string name="agent_connection_off">A depuração sem fios não está acessível; Emparelhar ativa-a</string>
|
||||
<string name="agent_action_pair">Emparelhar</string>
|
||||
<string name="agent_step_connection_quest_hint">O Quest não tem ecrã de emparelhamento. Num computador, execute uma vez: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS e adb tcpip 5555. Depois toque em Permitir e aceite o pedido no headset</string>
|
||||
<string name="agent_action_allow">Permitir</string>
|
||||
<string name="agent_connection_quest_waiting">Aceite “Permitir depuração?” no headset, com Permitir sempre assinalado</string>
|
||||
<string name="agent_connection_quest_failed">Não foi possível ligar. Aceite o pedido de depuração no headset ou, se não apareceu, execute adb tcpip 5555 num computador e tente novamente</string>
|
||||
<string name="agent_connection_quest_off">A depuração sem fios não está acessível. Toque em Permitir para a configurar de novo</string>
|
||||
<string name="agent_action_install">Instalar</string>
|
||||
<string name="agent_action_sign_in">Iniciar sessão</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2167,7 +2162,6 @@
|
||||
<string name="bottom_qam_layout_left">Esquerda</string>
|
||||
<string name="bottom_qam_layout_center">Centro</string>
|
||||
<string name="bottom_qam_layout_right">Direita</string>
|
||||
<string name="bottom_qam_layout_split">Dividido</string>
|
||||
<string name="bottom_qam_unavailable">O menu de acesso rápido do Steam ainda não está disponível.</string>
|
||||
<string name="bottom_page_telemetry">Estatísticas no jogo</string>
|
||||
<string name="bottom_hud_group">HUD do ecrã inferior</string>
|
||||
|
||||
@@ -1252,11 +1252,6 @@
|
||||
<string name="agent_action_prepare">Preparar</string>
|
||||
<string name="agent_connection_off">A depuração sem fio não está acessível; Parear a ativa</string>
|
||||
<string name="agent_action_pair">Parear</string>
|
||||
<string name="agent_step_connection_quest_hint">O Quest não tem tela de pareamento. Em um computador, execute uma vez: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS e adb tcpip 5555. Depois toque em Permitir e aceite o aviso no headset</string>
|
||||
<string name="agent_action_allow">Permitir</string>
|
||||
<string name="agent_connection_quest_waiting">Aceite “Permitir depuração?” no headset, com Sempre permitir marcado</string>
|
||||
<string name="agent_connection_quest_failed">Não foi possível conectar. Aceite o aviso de depuração no headset ou, se ele não apareceu, execute adb tcpip 5555 em um computador e tente novamente</string>
|
||||
<string name="agent_connection_quest_off">A depuração sem fio não está acessível. Toque em Permitir para configurá-la de novo</string>
|
||||
<string name="agent_action_install">Instalar</string>
|
||||
<string name="agent_action_sign_in">Entrar</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2175,7 +2170,6 @@
|
||||
<string name="bottom_qam_layout_left">Esquerda</string>
|
||||
<string name="bottom_qam_layout_center">Centro</string>
|
||||
<string name="bottom_qam_layout_right">Direita</string>
|
||||
<string name="bottom_qam_layout_split">Dividido</string>
|
||||
<string name="bottom_qam_unavailable">O menu de acesso rápido do Steam ainda não está disponível.</string>
|
||||
<string name="bottom_page_telemetry">Estatísticas no jogo</string>
|
||||
<string name="bottom_hud_group">HUD da tela inferior</string>
|
||||
|
||||
@@ -1253,11 +1253,6 @@
|
||||
<string name="agent_action_prepare">Pregătește</string>
|
||||
<string name="agent_connection_off">Depanarea fără fir nu este accesibilă; „Asociază” o activează</string>
|
||||
<string name="agent_action_pair">Asociază</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest nu are ecran de asociere. De pe un computer, rulează o dată: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS și adb tcpip 5555. Apoi atinge Permite și acceptă solicitarea în cască</string>
|
||||
<string name="agent_action_allow">Permite</string>
|
||||
<string name="agent_connection_quest_waiting">Acceptă „Permiți remedierea erorilor?” în cască, cu Permite întotdeauna bifat</string>
|
||||
<string name="agent_connection_quest_failed">Conectarea a eșuat. Acceptă solicitarea de remediere a erorilor în cască sau, dacă nu a apărut, rulează adb tcpip 5555 de pe un computer și încearcă din nou</string>
|
||||
<string name="agent_connection_quest_off">Remedierea wireless a erorilor nu este accesibilă. Atinge Permite pentru a o configura din nou</string>
|
||||
<string name="agent_action_install">Instalează</string>
|
||||
<string name="agent_action_sign_in">Conectați-vă</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2161,7 +2156,6 @@
|
||||
<string name="bottom_qam_layout_left">Stânga</string>
|
||||
<string name="bottom_qam_layout_center">Centru</string>
|
||||
<string name="bottom_qam_layout_right">Dreapta</string>
|
||||
<string name="bottom_qam_layout_split">Împărțit</string>
|
||||
<string name="bottom_qam_unavailable">Meniul de acces rapid Steam nu este încă disponibil.</string>
|
||||
<string name="bottom_page_telemetry">Statistici în joc</string>
|
||||
<string name="bottom_hud_group">HUD pe ecranul de jos</string>
|
||||
|
||||
@@ -1257,11 +1257,6 @@
|
||||
<string name="agent_action_prepare">Подготовить</string>
|
||||
<string name="agent_connection_off">Беспроводная отладка недоступна; «Сопряжение» включит её</string>
|
||||
<string name="agent_action_pair">Сопряжение</string>
|
||||
<string name="agent_step_connection_quest_hint">В Quest нет экрана сопряжения. Один раз выполните на компьютере: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS и adb tcpip 5555. Затем нажмите «Разрешить» и подтвердите запрос в шлеме</string>
|
||||
<string name="agent_action_allow">Разрешить</string>
|
||||
<string name="agent_connection_quest_waiting">Подтвердите «Разрешить отладку?» в шлеме, отметив «Всегда разрешать»</string>
|
||||
<string name="agent_connection_quest_failed">Не удалось подключиться. Подтвердите запрос на отладку в шлеме, а если он не появился, выполните adb tcpip 5555 на компьютере и повторите попытку</string>
|
||||
<string name="agent_connection_quest_off">Беспроводная отладка недоступна. Нажмите «Разрешить», чтобы настроить её заново</string>
|
||||
<string name="agent_action_install">Установить</string>
|
||||
<string name="agent_action_sign_in">Войти</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2187,7 +2182,6 @@
|
||||
<string name="bottom_qam_layout_left">Слева</string>
|
||||
<string name="bottom_qam_layout_center">По центру</string>
|
||||
<string name="bottom_qam_layout_right">Справа</string>
|
||||
<string name="bottom_qam_layout_split">Разделённый</string>
|
||||
<string name="bottom_qam_unavailable">Меню быстрого доступа Steam пока недоступно.</string>
|
||||
<string name="bottom_page_telemetry">Игровая статистика</string>
|
||||
<string name="bottom_hud_group">HUD нижнего экрана</string>
|
||||
|
||||
@@ -1249,11 +1249,6 @@
|
||||
<string name="agent_action_prepare">Förbered</string>
|
||||
<string name="agent_connection_off">Trådlös felsökning kan inte nås; Para slår på den</string>
|
||||
<string name="agent_action_pair">Para</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest har ingen parkopplingsskärm. Kör en gång från en dator: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS och adb tcpip 5555. Tryck sedan på Tillåt och godkänn frågan i headsetet</string>
|
||||
<string name="agent_action_allow">Tillåt</string>
|
||||
<string name="agent_connection_quest_waiting">Godkänn ”Tillåt felsökning?” i headsetet med Tillåt alltid markerat</string>
|
||||
<string name="agent_connection_quest_failed">Det gick inte att ansluta. Godkänn felsökningsfrågan i headsetet, eller kör adb tcpip 5555 från en dator och försök igen om ingen visades</string>
|
||||
<string name="agent_connection_quest_off">Trådlös felsökning går inte att nå. Tryck på Tillåt för att konfigurera den igen</string>
|
||||
<string name="agent_action_install">Installera</string>
|
||||
<string name="agent_action_sign_in">Logga in</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2136,7 +2131,6 @@
|
||||
<string name="bottom_qam_layout_left">Vänster</string>
|
||||
<string name="bottom_qam_layout_center">Mitten</string>
|
||||
<string name="bottom_qam_layout_right">Höger</string>
|
||||
<string name="bottom_qam_layout_split">Delad</string>
|
||||
<string name="bottom_qam_unavailable">Steams snabbåtkomstmeny är inte tillgänglig än.</string>
|
||||
<string name="bottom_page_telemetry">Statistik i spelet</string>
|
||||
<string name="bottom_hud_group">HUD på nedre skärmen</string>
|
||||
|
||||
@@ -1246,11 +1246,6 @@
|
||||
<string name="agent_action_prepare">เตรียม</string>
|
||||
<string name="agent_connection_off">เชื่อมต่อการดีบักแบบไร้สายไม่ได้; จับคู่จะเปิดใช้งาน</string>
|
||||
<string name="agent_action_pair">จับคู่</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest ไม่มีหน้าจอจับคู่ จากคอมพิวเตอร์ ให้รันหนึ่งครั้ง: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS และ adb tcpip 5555 จากนั้นแตะอนุญาตและยอมรับข้อความในเฮดเซ็ต</string>
|
||||
<string name="agent_action_allow">อนุญาต</string>
|
||||
<string name="agent_connection_quest_waiting">ยอมรับ “อนุญาตการแก้ไขข้อบกพร่องไหม” ในเฮดเซ็ต โดยเลือกอนุญาตเสมอ</string>
|
||||
<string name="agent_connection_quest_failed">เชื่อมต่อไม่ได้ ยอมรับข้อความแก้ไขข้อบกพร่องในเฮดเซ็ต หรือหากไม่มีข้อความขึ้น ให้รัน adb tcpip 5555 จากคอมพิวเตอร์แล้วลองอีกครั้ง</string>
|
||||
<string name="agent_connection_quest_off">เข้าถึงการแก้ไขข้อบกพร่องแบบไร้สายไม่ได้ แตะอนุญาตเพื่อตั้งค่าใหม่</string>
|
||||
<string name="agent_action_install">ติดตั้ง</string>
|
||||
<string name="agent_action_sign_in">ลงชื่อเข้าใช้</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2112,7 +2107,6 @@
|
||||
<string name="bottom_qam_layout_left">ซ้าย</string>
|
||||
<string name="bottom_qam_layout_center">กึ่งกลาง</string>
|
||||
<string name="bottom_qam_layout_right">ขวา</string>
|
||||
<string name="bottom_qam_layout_split">แบ่งหน้าจอ</string>
|
||||
<string name="bottom_qam_unavailable">เมนูเข้าถึงด่วนของ Steam ยังไม่พร้อมใช้งาน</string>
|
||||
<string name="bottom_page_telemetry">สถิติในเกม</string>
|
||||
<string name="bottom_hud_group">HUD หน้าจอล่าง</string>
|
||||
|
||||
@@ -1241,11 +1241,6 @@
|
||||
<string name="agent_action_prepare">Hazırla</string>
|
||||
<string name="agent_connection_off">Kablosuz hata ayıklamaya ulaşılamıyor; Eşleştir ile açılır</string>
|
||||
<string name="agent_action_pair">Eşleştir</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest\'te eşleme ekranı yok. Bir bilgisayardan bir kez çalıştırın: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS ve adb tcpip 5555. Ardından İzin ver\'e dokunun ve kulaklıktaki istemi kabul edin</string>
|
||||
<string name="agent_action_allow">İzin ver</string>
|
||||
<string name="agent_connection_quest_waiting">Kulaklıkta “Hata ayıklamaya izin verilsin mi?” istemini Her zaman izin ver işaretliyken kabul edin</string>
|
||||
<string name="agent_connection_quest_failed">Bağlanılamadı. Kulaklıktaki hata ayıklama istemini kabul edin veya istem görünmediyse bir bilgisayardan adb tcpip 5555 çalıştırıp tekrar deneyin</string>
|
||||
<string name="agent_connection_quest_off">Kablosuz hata ayıklamaya ulaşılamıyor. Yeniden ayarlamak için İzin ver\'e dokunun</string>
|
||||
<string name="agent_action_install">Yükle</string>
|
||||
<string name="agent_action_sign_in">Giriş yap</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2128,7 +2123,6 @@
|
||||
<string name="bottom_qam_layout_left">Sol</string>
|
||||
<string name="bottom_qam_layout_center">Orta</string>
|
||||
<string name="bottom_qam_layout_right">Sağ</string>
|
||||
<string name="bottom_qam_layout_split">Bölünmüş</string>
|
||||
<string name="bottom_qam_unavailable">Steam Hızlı Erişim menüsü henüz kullanılamıyor.</string>
|
||||
<string name="bottom_page_telemetry">Oyun içi istatistikler</string>
|
||||
<string name="bottom_hud_group">Alt ekrandaki HUD</string>
|
||||
|
||||
@@ -1257,11 +1257,6 @@
|
||||
<string name="agent_action_prepare">Підготувати</string>
|
||||
<string name="agent_connection_off">Бездротове налагодження недоступне; «Сполучити» увімкне його</string>
|
||||
<string name="agent_action_pair">Сполучити</string>
|
||||
<string name="agent_step_connection_quest_hint">У Quest немає екрана підключення. Один раз виконайте на комп’ютері: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS і adb tcpip 5555. Потім торкніться «Дозволити» й підтвердьте запит у шоломі</string>
|
||||
<string name="agent_action_allow">Дозволити</string>
|
||||
<string name="agent_connection_quest_waiting">Підтвердьте «Дозволити налагодження?» у шоломі, позначивши «Завжди дозволяти»</string>
|
||||
<string name="agent_connection_quest_failed">Не вдалося підключитися. Підтвердьте запит на налагодження в шоломі, а якщо його не було, виконайте adb tcpip 5555 на комп’ютері й спробуйте ще раз</string>
|
||||
<string name="agent_connection_quest_off">Бездротове налагодження недоступне. Торкніться «Дозволити», щоб налаштувати його знову</string>
|
||||
<string name="agent_action_install">Установити</string>
|
||||
<string name="agent_action_sign_in">Увійти</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2186,7 +2181,6 @@
|
||||
<string name="bottom_qam_layout_left">Ліворуч</string>
|
||||
<string name="bottom_qam_layout_center">По центру</string>
|
||||
<string name="bottom_qam_layout_right">Праворуч</string>
|
||||
<string name="bottom_qam_layout_split">Розділений</string>
|
||||
<string name="bottom_qam_unavailable">Меню швидкого доступу Steam ще недоступне.</string>
|
||||
<string name="bottom_page_telemetry">Ігрова статистика</string>
|
||||
<string name="bottom_hud_group">HUD на нижньому екрані</string>
|
||||
|
||||
@@ -1246,11 +1246,6 @@
|
||||
<string name="agent_action_prepare">Chuẩn bị</string>
|
||||
<string name="agent_connection_off">Không truy cập được gỡ lỗi không dây; Ghép đôi sẽ bật tính năng này</string>
|
||||
<string name="agent_action_pair">Ghép đôi</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest không có màn hình ghép nối. Từ máy tính, chạy một lần: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS và adb tcpip 5555. Sau đó nhấn Cho phép và chấp nhận lời nhắc trong kính</string>
|
||||
<string name="agent_action_allow">Cho phép</string>
|
||||
<string name="agent_connection_quest_waiting">Chấp nhận “Cho phép gỡ lỗi?” trong kính, với Luôn cho phép được chọn</string>
|
||||
<string name="agent_connection_quest_failed">Không thể kết nối. Chấp nhận lời nhắc gỡ lỗi trong kính, hoặc nếu không thấy lời nhắc, hãy chạy adb tcpip 5555 từ máy tính rồi thử lại</string>
|
||||
<string name="agent_connection_quest_off">Không thể kết nối gỡ lỗi không dây. Nhấn Cho phép để thiết lập lại</string>
|
||||
<string name="agent_action_install">Cài đặt</string>
|
||||
<string name="agent_action_sign_in">Đăng nhập</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2112,7 +2107,6 @@
|
||||
<string name="bottom_qam_layout_left">Trái</string>
|
||||
<string name="bottom_qam_layout_center">Giữa</string>
|
||||
<string name="bottom_qam_layout_right">Phải</string>
|
||||
<string name="bottom_qam_layout_split">Chia màn hình</string>
|
||||
<string name="bottom_qam_unavailable">Menu Truy cập nhanh của Steam chưa sẵn sàng.</string>
|
||||
<string name="bottom_page_telemetry">Thông số trong game</string>
|
||||
<string name="bottom_hud_group">HUD màn hình dưới</string>
|
||||
|
||||
@@ -1329,11 +1329,6 @@
|
||||
<string name="agent_action_prepare">准备</string>
|
||||
<string name="agent_connection_off">无线调试无法连接;配对即可开启</string>
|
||||
<string name="agent_action_pair">配对</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest 没有配对界面。请在电脑上运行一次:adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS 和 adb tcpip 5555。然后点按“允许”,并在头显中接受提示</string>
|
||||
<string name="agent_action_allow">允许</string>
|
||||
<string name="agent_connection_quest_waiting">在头显中接受“允许调试吗?”,并勾选“始终允许”</string>
|
||||
<string name="agent_connection_quest_failed">无法连接。请在头显中接受调试提示;如果没有出现提示,请在电脑上运行 adb tcpip 5555 后重试</string>
|
||||
<string name="agent_connection_quest_off">无法连接无线调试。点按“允许”重新设置</string>
|
||||
<string name="agent_action_install">安装</string>
|
||||
<string name="agent_action_sign_in">登录</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2189,7 +2184,6 @@
|
||||
<string name="bottom_qam_layout_left">左侧</string>
|
||||
<string name="bottom_qam_layout_center">居中</string>
|
||||
<string name="bottom_qam_layout_right">右侧</string>
|
||||
<string name="bottom_qam_layout_split">分屏</string>
|
||||
<string name="bottom_qam_unavailable">Steam 快速访问菜单暂不可用。</string>
|
||||
<string name="bottom_page_telemetry">游戏内数据</string>
|
||||
<string name="bottom_hud_group">下屏 HUD</string>
|
||||
|
||||
@@ -1245,11 +1245,6 @@
|
||||
<string name="agent_action_prepare">準備</string>
|
||||
<string name="agent_connection_off">無線偵錯無法連線;按「配對」即可開啟</string>
|
||||
<string name="agent_action_pair">配對</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest 沒有配對畫面。請在電腦上執行一次:adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS 及 adb tcpip 5555。然後輕按「允許」,並在頭戴裝置中接受提示</string>
|
||||
<string name="agent_action_allow">允許</string>
|
||||
<string name="agent_connection_quest_waiting">在頭戴裝置中接受「要允許偵錯嗎?」,並剔選「一律允許」</string>
|
||||
<string name="agent_connection_quest_failed">無法連接。請在頭戴裝置中接受偵錯提示;如果沒有出現提示,請在電腦上執行 adb tcpip 5555 後再試一次</string>
|
||||
<string name="agent_connection_quest_off">無法連接無線偵錯。輕按「允許」重新設定</string>
|
||||
<string name="agent_action_install">安裝</string>
|
||||
<string name="agent_action_sign_in">登入</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2111,7 +2106,6 @@
|
||||
<string name="bottom_qam_layout_left">左側</string>
|
||||
<string name="bottom_qam_layout_center">置中</string>
|
||||
<string name="bottom_qam_layout_right">右側</string>
|
||||
<string name="bottom_qam_layout_split">分割</string>
|
||||
<string name="bottom_qam_unavailable">Steam 快速存取選單暫時無法使用。</string>
|
||||
<string name="bottom_page_telemetry">遊戲內數據</string>
|
||||
<string name="bottom_hud_group">下方螢幕 HUD</string>
|
||||
|
||||
@@ -1245,11 +1245,6 @@
|
||||
<string name="agent_action_prepare">準備</string>
|
||||
<string name="agent_connection_off">無線偵錯無法連線;配對即可開啟</string>
|
||||
<string name="agent_action_pair">配對</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest 沒有配對畫面。請在電腦上執行一次:adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS 和 adb tcpip 5555。接著輕觸「允許」,並在頭戴式裝置中接受提示</string>
|
||||
<string name="agent_action_allow">允許</string>
|
||||
<string name="agent_connection_quest_waiting">在頭戴式裝置中接受「要允許偵錯嗎?」,並勾選「一律允許」</string>
|
||||
<string name="agent_connection_quest_failed">無法連線。請在頭戴式裝置中接受偵錯提示;如果沒有出現提示,請在電腦上執行 adb tcpip 5555 後再試一次</string>
|
||||
<string name="agent_connection_quest_off">無法連上無線偵錯。輕觸「允許」重新設定</string>
|
||||
<string name="agent_action_install">安裝</string>
|
||||
<string name="agent_action_sign_in">登入</string>
|
||||
<string name="upd_pr">PR #%1$d</string>
|
||||
@@ -2111,7 +2106,6 @@
|
||||
<string name="bottom_qam_layout_left">左側</string>
|
||||
<string name="bottom_qam_layout_center">置中</string>
|
||||
<string name="bottom_qam_layout_right">右側</string>
|
||||
<string name="bottom_qam_layout_split">分割</string>
|
||||
<string name="bottom_qam_unavailable">Steam 快速存取選單暫時無法使用。</string>
|
||||
<string name="bottom_page_telemetry">遊戲內數據</string>
|
||||
<string name="bottom_hud_group">下螢幕 HUD</string>
|
||||
|
||||
@@ -1392,11 +1392,6 @@
|
||||
<string name="agent_action_prepare">Prepare</string>
|
||||
<string name="agent_connection_off">Wireless debugging isn\'t reachable; Pair turns it on</string>
|
||||
<string name="agent_action_pair">Pair</string>
|
||||
<string name="agent_step_connection_quest_hint">Quest has no pairing screen. From a computer, run once: adb shell pm grant %1$s android.permission.WRITE_SECURE_SETTINGS and adb tcpip 5555. Then tap Allow and accept the prompt in the headset</string>
|
||||
<string name="agent_action_allow">Allow</string>
|
||||
<string name="agent_connection_quest_waiting">Accept “Allow debugging?” in the headset, with Always allow ticked</string>
|
||||
<string name="agent_connection_quest_failed">Couldn\'t connect. Accept the debugging prompt in the headset, or if none appeared, run adb tcpip 5555 from a computer and try again</string>
|
||||
<string name="agent_connection_quest_off">Wireless debugging isn\'t reachable. Tap Allow to set it up again</string>
|
||||
<string name="agent_action_install">Install</string>
|
||||
<string name="agent_action_sign_in">Sign in</string>
|
||||
<string name="agent_action_free">Free models</string>
|
||||
@@ -1759,6 +1754,7 @@
|
||||
<string name="game_link_program_unknown">Add this game to DroidDeck first, then start it from your frontend.</string>
|
||||
<string name="game_link_session_busy">Stop the current session before launching a Steam game.</string>
|
||||
<string name="game_link_failed">Could not send the game to Steam. Try launching it again.</string>
|
||||
<string name="game_link_battlenet_missing">Could not verify this Battle.net installation. Retry or open Battle.net to check the installed copy.</string>
|
||||
<string name="game_needs_app_model">%1$s is a UWP app. This runtime has no Windows app-model host to start it.</string>
|
||||
<string name="setup_retry_removal">Retry removal</string>
|
||||
<string name="runtime_removing">Removing</string>
|
||||
@@ -2419,7 +2415,6 @@
|
||||
<string name="bottom_qam_layout_left">Left</string>
|
||||
<string name="bottom_qam_layout_center">Center</string>
|
||||
<string name="bottom_qam_layout_right">Right</string>
|
||||
<string name="bottom_qam_layout_split">Split</string>
|
||||
<string name="bottom_qam_unavailable">Steam\'s Quick Access menu is not available yet.</string>
|
||||
<string name="bottom_page_telemetry">In-game stats</string>
|
||||
<string name="bottom_hud_group">Bottom screen HUD</string>
|
||||
|
||||
@@ -3,6 +3,17 @@ package com.droiddeck.launcher.runtime
|
||||
import android.content.Context
|
||||
import com.droiddeck.launcher.session.ComponentsManager
|
||||
import com.droiddeck.launcher.session.GameEnvironmentStore
|
||||
import com.droiddeck.launcher.stores.CatalogItem
|
||||
import com.droiddeck.launcher.stores.InstalledStoreGame
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import com.droiddeck.launcher.stores.StoreGameSidecar
|
||||
import com.droiddeck.launcher.stores.StoreInstalls
|
||||
import com.droiddeck.launcher.stores.StoresState
|
||||
import com.droiddeck.launcher.stores.battlenet.BattleNetCleanup
|
||||
import com.droiddeck.launcher.stores.battlenet.BattleNetInstall
|
||||
import com.droiddeck.launcher.stores.battlenet.BattleNetInstaller
|
||||
import com.droiddeck.launcher.stores.battlenet.Ownership
|
||||
import com.droiddeck.launcher.stores.download.DownloadQueue
|
||||
import com.github.luben.zstd.ZstdOutputStream
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveEntry
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream
|
||||
@@ -21,6 +32,10 @@ import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
import java.util.zip.CRC32
|
||||
|
||||
private val REGISTRY = """
|
||||
@@ -65,6 +80,7 @@ class BattleNetTest {
|
||||
@Before fun setUp() {
|
||||
context = RuntimeEnvironment.getApplication()
|
||||
File(context.filesDir, "components").deleteRecursively()
|
||||
File(context.filesDir, "battlenet-cleanup").deleteRecursively()
|
||||
LinuxRuntime.rootDir(context).deleteRecursively()
|
||||
}
|
||||
|
||||
@@ -345,17 +361,511 @@ class BattleNetTest {
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db").writeBytes(message(
|
||||
field(1, message(field(1, "osic"), field(3, message(field(1, "Z:/root/Games/Stores/Battle.net/Diablo II Resurrected"))))),
|
||||
field(1, message(field(1, "s2_cn"), field(3, message(field(1, "Z:/root/Games/Stores/Battle.net/StarCraft II"))))),
|
||||
field(1, message(field(1, "d3cn"), field(3, message(field(1, "Z:/root/Games/Stores/Battle.net/Diablo III"))))),
|
||||
))
|
||||
for (folder in listOf("Diablo II Resurrected", "StarCraft II")) {
|
||||
for (folder in listOf("Diablo II Resurrected", "StarCraft II", "Diablo III")) {
|
||||
File(LinuxRuntime.rootDir(context), "root/Games/Stores/Battle.net/$folder").mkdirs()
|
||||
}
|
||||
val games = BattleNet.games(context)
|
||||
assertEquals(listOf("osic", "s2_cn"), games.map { it.installUid })
|
||||
assertEquals(listOf("osi", "s2"), games.map { it.uid })
|
||||
assertEquals(listOf("Diablo II: Resurrected" to "OSI", "StarCraft II" to "S2"), games.map { it.name to it.code })
|
||||
assertFalse(BattleNet.notInstalled(BattleNet.title("osi")!!, listOf("osic")))
|
||||
assertFalse(BattleNet.notInstalled(BattleNet.title("s2")!!, games.map { it.installUid }))
|
||||
assertEquals(listOf("osic", "s2_cn", "d3cn"), games.map { it.installUid })
|
||||
assertEquals(listOf("osi", "s2", "diablo3"), games.map { it.uid })
|
||||
assertEquals(listOf("Diablo II: Resurrected" to "OSI", "StarCraft II" to "S2", "Diablo III" to "D3CN"), games.map { it.name to it.code })
|
||||
assertEquals("osic", BattleNet.title("osic")?.product)
|
||||
assertEquals("s2c", BattleNet.title("s2_cn")?.product)
|
||||
assertEquals("anbs", BattleNet.title("anbs_cn")?.product)
|
||||
assertEquals("d3cn", BattleNet.title("d3cn")?.product)
|
||||
assertEquals("s2c", BattleNet.title("s2_cn_zhcn")?.product)
|
||||
assertEquals("osic", BattleNet.title("osic_zhcn")?.product)
|
||||
assertEquals("anbs", BattleNet.title("anbs_cn_zhcn")?.product)
|
||||
}
|
||||
|
||||
@Test fun theFolderPicksBetweenTwoDiabloThreeInstalls() {
|
||||
val pfx = File(BattleNet.prefix(context), "pfx").apply { mkdirs() }
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent").mkdirs()
|
||||
val legacy = File(LinuxRuntime.rootDir(context), "root/Games/Stores/Battle.net/Diablo III")
|
||||
val china = File(LinuxRuntime.rootDir(context), "root/Games/Stores/Battle.net/Diablo III China")
|
||||
legacy.mkdirs()
|
||||
china.mkdirs()
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db").writeBytes(message(
|
||||
field(1, message(field(1, "diablo3"), field(3, message(field(1, "Z:/root/Games/Stores/Battle.net/Diablo III"))))),
|
||||
field(1, message(field(1, "d3cn"), field(3, message(field(1, "Z:/root/Games/Stores/Battle.net/Diablo III China"))))),
|
||||
))
|
||||
assertEquals(setOf("diablo3", "d3cn"), BattleNet.games(context).map { it.installUid }.toSet())
|
||||
|
||||
val sidecar = StoreGameSidecar(Store.BATTLENET, "diablo3", "Diablo III", "")
|
||||
val oldGame = InstalledStoreGame(sidecar, legacy)
|
||||
val chinaGame = InstalledStoreGame(sidecar, china)
|
||||
val records = listOf(oldGame, chinaGame)
|
||||
assertEquals(chinaGame, StoresState.pickInstalled(Store.BATTLENET, "diablo3", china, records))
|
||||
assertEquals(oldGame, StoresState.pickInstalled(Store.BATTLENET, "diablo3", legacy, records))
|
||||
assertEquals("d3cn", BattleNetInstall.installUid(context, chinaGame))
|
||||
assertEquals("diablo3", BattleNetInstall.installUid(context, oldGame))
|
||||
val missing = File(china, "missing")
|
||||
assertNull(StoresState.pickInstalled(Store.BATTLENET, "diablo3", missing, records))
|
||||
assertNull(BattleNetInstall.installUid(context, InstalledStoreGame(sidecar, missing)))
|
||||
}
|
||||
|
||||
@Test fun anUnfinishedInstallIsARegistrationButNotAGame() {
|
||||
val pfx = File(BattleNet.prefix(context), "pfx").apply { mkdirs() }
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent").mkdirs()
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Stores/Battle.net/StarCraft II").apply { mkdirs() }
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db").writeBytes(message(
|
||||
field(1, message(
|
||||
field(1, "s2_cn"), field(2, "s2c"),
|
||||
field(3, message(field(1, "Z:/root/Games/Stores/Battle.net/StarCraft II"))),
|
||||
field(4, message(field(1, message(varintField(1, 0), varintField(2, 0))))),
|
||||
)),
|
||||
))
|
||||
assertTrue("an unfinished install is not a library game", BattleNet.games(context).none { it.installUid == "s2_cn" })
|
||||
assertEquals(listOf("s2_cn"), BattleNet.registrationsAt(context, "s2", folder))
|
||||
}
|
||||
|
||||
@Test fun aChinaCopyLaunchesWithItsRecordedCode() {
|
||||
val pfx = File(BattleNet.prefix(context), "pfx").apply { mkdirs() }
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent").mkdirs()
|
||||
val legacy = File(LinuxRuntime.rootDir(context), "root/Games/Stores/Battle.net/Diablo III").apply { mkdirs() }
|
||||
val china = File(LinuxRuntime.rootDir(context), "root/Games/Stores/Battle.net/Diablo III China").apply { mkdirs() }
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db").writeBytes(message(
|
||||
field(1, message(field(1, "diablo3"), field(3, message(field(1, "Z:/root/Games/Stores/Battle.net/Diablo III"))))),
|
||||
field(1, message(field(1, "d3cn"), field(3, message(field(1, "Z:/root/Games/Stores/Battle.net/Diablo III China"))))),
|
||||
))
|
||||
assertEquals("D3CN", BattleNet.launchCode(context, "diablo3", china))
|
||||
assertEquals("D3CN", BattleNet.launchCode(context, "d3cn", china))
|
||||
assertEquals(listOf("d3cn"), BattleNet.registrationsAt(context, "d3cn", china))
|
||||
assertEquals("D3", BattleNet.launchCode(context, "diablo3", legacy))
|
||||
assertEquals("D3", BattleNet.launchCode(context, "diablo3", null))
|
||||
assertNull(BattleNet.launchCode(context, "diablo3", File(china, "missing")))
|
||||
val game = com.droiddeck.launcher.frontend.Library.SteamGame(
|
||||
1234, "Diablo III", null, com.droiddeck.launcher.frontend.Library.ADDED,
|
||||
source = Store.BATTLENET.id, storeId = "diablo3", gameFiles = china,
|
||||
)
|
||||
val command = com.droiddeck.launcher.session.NoSteamLaunch.command(context, game, null)!!
|
||||
assertEquals(com.droiddeck.launcher.session.NoSteamLaunch.BATTLENET, command.program)
|
||||
assertEquals(listOf("launch", "D3CN"), command.args)
|
||||
}
|
||||
|
||||
@Test fun aCopyInAnotherFolderResolvesItsOwnLaunchCode() {
|
||||
val pfx = File(BattleNet.prefix(context), "pfx").apply { mkdirs() }
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent").mkdirs()
|
||||
val first = File(LinuxRuntime.rootDir(context), "root/Games/Stores/Battle.net/StarCraft II").apply { mkdirs() }
|
||||
val second = File(LinuxRuntime.rootDir(context), "root/Games/Stores/Battle.net/StarCraft II Copy").apply { mkdirs() }
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db").writeBytes(message(
|
||||
field(1, message(field(1, "s2_cn"), field(3, message(field(1, "Z:/root/Games/Stores/Battle.net/StarCraft II"))))),
|
||||
field(1, message(field(1, "s2_cn"), field(3, message(field(1, "Z:/root/Games/Stores/Battle.net/StarCraft II Copy"))))),
|
||||
))
|
||||
// games() keeps one copy per launch code, so the second folder is only reachable per folder.
|
||||
assertEquals(1, BattleNet.games(context).size)
|
||||
assertEquals("S2", BattleNet.launchCode(context, "s2", first))
|
||||
assertEquals("S2", BattleNet.launchCode(context, "s2", second))
|
||||
}
|
||||
|
||||
@Test fun aCopyRegisteredUnderAnotherUidOfTheSameProductStillLaunches() {
|
||||
val pfx = File(BattleNet.prefix(context), "pfx").apply { mkdirs() }
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent").mkdirs()
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Stores/Battle.net/Diablo IV").apply { mkdirs() }
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db").writeBytes(message(
|
||||
field(1, message(field(1, "fen"), field(3, message(field(1, "Z:/root/Games/Stores/Battle.net/Diablo IV"))))),
|
||||
))
|
||||
assertTrue(BattleNet.sameTitle("fen", "fenris"))
|
||||
assertFalse(BattleNet.sameTitle("fen", "wow"))
|
||||
assertEquals("Fen", BattleNet.launchCode(context, "fenris", folder))
|
||||
assertEquals("Fen", BattleNet.launchCode(context, "fen", folder))
|
||||
}
|
||||
|
||||
@Test fun aMissingInstallFolderCannotLaunchEvenWhenRegistered() {
|
||||
val pfx = File(BattleNet.prefix(context), "pfx")
|
||||
val db = File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db").apply { parentFile!!.mkdirs() }
|
||||
val folder = File(pfx, "drive_c/Games/D3")
|
||||
db.writeBytes(message(field(1, message(field(1, "d3cn"), field(3, message(field(1, "C:/Games/D3")))))))
|
||||
assertNull(BattleNet.launchCode(context, "diablo3", folder))
|
||||
assertEquals(true, BattleNet.folderHasRegistrations(context, folder))
|
||||
}
|
||||
|
||||
@Test fun anUnreadableAgentDatabaseDoesNotAuthorizeFolderDeletion() {
|
||||
val pfx = File(BattleNet.prefix(context), "pfx")
|
||||
val db = File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db").apply { parentFile!!.mkdirs() }
|
||||
val folder = File(pfx, "drive_c/Games/D3").apply { mkdirs() }
|
||||
db.writeBytes(byteArrayOf(0x0a, 0x7f))
|
||||
assertFalse(BattleNet.registrationsReadable(context))
|
||||
assertNull(BattleNet.folderHasRegistrations(context, folder))
|
||||
}
|
||||
|
||||
@Test fun productFallbackResolvesBothLaunchCodeAndManagementUid() {
|
||||
val pfx = File(BattleNet.prefix(context), "pfx")
|
||||
val db = File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db").apply { parentFile!!.mkdirs() }
|
||||
val folder = File(pfx, "drive_c/Games/WoW").apply { mkdirs() }
|
||||
db.writeBytes(message(field(1, message(field(1, "wowf_live"), field(2, "wowf"), field(3, message(field(1, "C:/Games/WoW")))))))
|
||||
assertEquals("WoWF", BattleNet.launchCode(context, "wow_forever", folder))
|
||||
val sidecar = StoreGameSidecar(Store.BATTLENET, "wow_forever", "World of Warcraft", "")
|
||||
assertEquals("wowf_live", BattleNetInstall.installUid(context, InstalledStoreGame(sidecar, folder)))
|
||||
}
|
||||
|
||||
@Test fun aRegistrationForAMissingFolderStillCountsAsPreexisting() {
|
||||
val pfx = File(BattleNet.prefix(context), "pfx").apply { mkdirs() }
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent").mkdirs()
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Stores/Battle.net/Diablo III")
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db").writeBytes(message(
|
||||
field(1, message(field(1, "d3cn"), field(3, message(field(1, "Z:/root/Games/Stores/Battle.net/Diablo III"))))),
|
||||
))
|
||||
assertTrue(BattleNet.games(context).none { it.folder.absolutePath == folder.absolutePath })
|
||||
assertEquals(listOf("d3cn"), BattleNet.registrationsAt(context, "diablo3", folder))
|
||||
folder.mkdirs()
|
||||
val uninstalled = AtomicBoolean(false)
|
||||
val item = CatalogItem(Store.BATTLENET, "diablo3", "Diablo III", null)
|
||||
BattleNetInstaller(context, item, folder, false, uninstall = {
|
||||
uninstalled.set(true)
|
||||
true
|
||||
}).cancel(true)
|
||||
Thread.sleep(100)
|
||||
assertFalse("a registration whose folder was missing is still pre-existing", uninstalled.get())
|
||||
}
|
||||
|
||||
@Test fun aStaleRegistryRowDoesNotHideAnAgentRegistrationInAnotherFolder() {
|
||||
val pfx = File(BattleNet.prefix(context), "pfx").apply { mkdirs() }
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent").mkdirs()
|
||||
val a = File(LinuxRuntime.rootDir(context), "root/Games/Stores/Battle.net/Diablo III A")
|
||||
val b = File(LinuxRuntime.rootDir(context), "root/Games/Stores/Battle.net/Diablo III B")
|
||||
File(pfx, "system.reg").writeText("""
|
||||
WINE REGISTRY Version 2
|
||||
[Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Diablo III] 1
|
||||
"InstallLocation"="Z:/root/Games/Stores/Battle.net/Diablo III A"
|
||||
"UninstallString"="\"C:\\ProgramData\\Battle.net\\Agent\\Blizzard Uninstaller.exe\" --uid=d3cn"
|
||||
""".trimIndent())
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db").writeBytes(message(
|
||||
field(1, message(field(1, "d3cn"), field(3, message(field(1, "Z:/root/Games/Stores/Battle.net/Diablo III B"))))),
|
||||
))
|
||||
assertEquals(emptyList<String>(), BattleNet.registrationsAt(context, "diablo3", a))
|
||||
assertEquals(listOf("d3cn"), BattleNet.registrationsAt(context, "diablo3", b))
|
||||
}
|
||||
|
||||
@Test fun aPathOnlyAgentRegistrationMakesTheFolderUnknown() {
|
||||
val pfx = File(BattleNet.prefix(context), "pfx").apply { mkdirs() }
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent").mkdirs()
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Stores/Battle.net/Diablo III")
|
||||
val db = message(field(1, message(field(3, message(field(1, "Z:/root/Games/Stores/Battle.net/Diablo III"))))))
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db").writeBytes(db)
|
||||
assertEquals("", BattleNet.productDbRegistrations(db)!!.single().uid)
|
||||
assertNull(BattleNet.registrationsAt(context, "diablo3", folder))
|
||||
}
|
||||
|
||||
@Test fun aPreexistingRegistrationIsNotUninstalled() {
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Diablo II Resurrected").apply { mkdirs() }
|
||||
val item = CatalogItem(
|
||||
Store.BATTLENET, "osi", "Diablo II: Resurrected", null,
|
||||
extra = mapOf(BattleNetInstall.PREEXISTING to "1"),
|
||||
)
|
||||
val uninstalled = AtomicBoolean(false)
|
||||
val installer = BattleNetInstaller(context, item, folder, false, uninstall = {
|
||||
uninstalled.set(true)
|
||||
true
|
||||
}) { listOf("osic") }
|
||||
installer.cancel(true)
|
||||
Thread.sleep(100)
|
||||
assertFalse("a registration that existed before the task must survive", uninstalled.get())
|
||||
}
|
||||
|
||||
@Test fun aCancelledInstallUninstallsOnlyTheRegistrationItCreated() {
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Diablo II Resurrected").apply { mkdirs() }
|
||||
val item = CatalogItem(
|
||||
Store.BATTLENET, "osi", "Diablo II: Resurrected", null,
|
||||
extra = mapOf(BattleNetInstall.PREEXISTING to "0"),
|
||||
)
|
||||
val seen = AtomicReference<String?>(null)
|
||||
val done = CountDownLatch(1)
|
||||
val installer = BattleNetInstaller(context, item, folder, false, cleanupVerifyMs = 0, uninstall = { uid ->
|
||||
seen.set(uid)
|
||||
done.countDown()
|
||||
true
|
||||
}) { listOf("osic") }
|
||||
installer.cancel(true)
|
||||
assertTrue(done.await(5, TimeUnit.SECONDS))
|
||||
assertEquals("osic", seen.get())
|
||||
}
|
||||
|
||||
@Test fun aCancelledInstallsCleanupHoldsTheFolderForUninstall() {
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Diablo II Resurrected").apply { mkdirs() }
|
||||
val item = CatalogItem(
|
||||
Store.BATTLENET, "osi", "Diablo II: Resurrected", null,
|
||||
extra = mapOf(BattleNetInstall.PREEXISTING to "0"),
|
||||
)
|
||||
val holding = AtomicBoolean(false)
|
||||
val done = CountDownLatch(1)
|
||||
val ownership = Ownership(item)
|
||||
ownership.createdFolder.set(true)
|
||||
var registered = true
|
||||
val installer = BattleNetInstaller(context, item, folder, false, ownership = ownership, cleanupVerifyMs = 0, uninstall = { uid ->
|
||||
holding.set(StoreInstalls.isDiscarding(folder))
|
||||
registered = false
|
||||
done.countDown()
|
||||
true
|
||||
}) { if (registered) listOf("osic") else emptyList() }
|
||||
installer.cancel(true)
|
||||
assertTrue(done.await(5, TimeUnit.SECONDS))
|
||||
assertTrue("the cleanup must hold the folder against uninstall", holding.get())
|
||||
val until = System.nanoTime() + TimeUnit.SECONDS.toNanos(5)
|
||||
while (StoreInstalls.isDiscarding(folder) && System.nanoTime() < until) Thread.sleep(10)
|
||||
assertFalse(StoreInstalls.isDiscarding(folder))
|
||||
assertFalse(folder.exists())
|
||||
}
|
||||
|
||||
@Test fun aLateRegistrationReportedWhileTheWorkerStopsIsUsedForCancellation() {
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Diablo II Resurrected").apply { mkdirs() }
|
||||
val item = CatalogItem(Store.BATTLENET, "osi", "Diablo II: Resurrected", null)
|
||||
var visible = false
|
||||
val seen = AtomicReference<String?>(null)
|
||||
val done = CountDownLatch(1)
|
||||
val installer = BattleNetInstaller(context, item, folder, false, registrationWaitMs = 1000, cleanupVerifyMs = 0, uninstall = { uid ->
|
||||
seen.set(uid)
|
||||
done.countDown()
|
||||
true
|
||||
}) {
|
||||
if (visible) listOf("osic") else emptyList()
|
||||
}
|
||||
val started = BattleNetInstaller::class.java.getDeclaredField("started").apply { isAccessible = true }
|
||||
(started.get(installer) as AtomicBoolean).set(true)
|
||||
val ended = BattleNetInstaller::class.java.getDeclaredField("ended").apply { isAccessible = true }
|
||||
.get(installer) as CountDownLatch
|
||||
installer.cancel(true)
|
||||
visible = true
|
||||
ended.countDown()
|
||||
assertTrue(done.await(5, TimeUnit.SECONDS))
|
||||
assertEquals("osic", seen.get())
|
||||
}
|
||||
|
||||
@Test fun aCancelledInstallRemovesAFolderItCreatedWithoutARegistration() {
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Diablo II Resurrected")
|
||||
assertFalse(folder.exists())
|
||||
folder.mkdirs()
|
||||
File(folder, "partial.bin").writeBytes(byteArrayOf(1, 2, 3))
|
||||
val item = CatalogItem(
|
||||
Store.BATTLENET, "osi", "Diablo II: Resurrected", null,
|
||||
extra = mapOf(BattleNetInstall.PREEXISTING to "0"),
|
||||
)
|
||||
val ownership = Ownership(item)
|
||||
val uninstalled = AtomicBoolean(false)
|
||||
val installer = BattleNetInstaller(context, item, folder, false, ownership = ownership, registrationWaitMs = 0, uninstall = {
|
||||
uninstalled.set(true)
|
||||
false
|
||||
}) { emptyList() }
|
||||
ownership.createdFolder.set(true)
|
||||
BattleNetInstaller::class.java.getDeclaredField("started").apply { isAccessible = true }
|
||||
.set(installer, AtomicBoolean(true))
|
||||
val ended = BattleNetInstaller::class.java.getDeclaredField("ended").apply { isAccessible = true }
|
||||
.get(installer) as CountDownLatch
|
||||
installer.cancel(true)
|
||||
ended.countDown()
|
||||
val until = System.nanoTime() + TimeUnit.SECONDS.toNanos(5)
|
||||
while (folder.exists() && System.nanoTime() < until) Thread.sleep(10)
|
||||
assertFalse("a folder this task created must not survive a cancel", folder.exists())
|
||||
assertFalse(uninstalled.get())
|
||||
}
|
||||
|
||||
@Test fun aCancelledInstallKeepsTheFolderWhileItsRegistrationRemains() {
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Diablo II Resurrected").apply { mkdirs() }
|
||||
File(folder, "partial.bin").writeBytes(byteArrayOf(1, 2, 3))
|
||||
val item = CatalogItem(
|
||||
Store.BATTLENET, "osi", "Diablo II: Resurrected", null,
|
||||
extra = mapOf(BattleNetInstall.PREEXISTING to "0"),
|
||||
)
|
||||
val installer = BattleNetInstaller(context, item, folder, false, cleanupVerifyMs = 0, uninstall = { true }) {
|
||||
listOf("osic")
|
||||
}
|
||||
BattleNetInstaller::class.java.getDeclaredField("started").apply { isAccessible = true }
|
||||
.set(installer, AtomicBoolean(true))
|
||||
val ended = BattleNetInstaller::class.java.getDeclaredField("ended").apply { isAccessible = true }
|
||||
.get(installer) as CountDownLatch
|
||||
installer.cancel(true)
|
||||
ended.countDown()
|
||||
val until = System.nanoTime() + TimeUnit.SECONDS.toNanos(3)
|
||||
while (BattleNetCleanup.get(context, folder) == null && System.nanoTime() < until) Thread.sleep(10)
|
||||
assertTrue("the folder must stay while the registration exists", folder.exists())
|
||||
assertEquals(BattleNetCleanup.PENDING, BattleNetCleanup.get(context, folder)?.state)
|
||||
}
|
||||
|
||||
@Test fun aCancelledInstallDeletesTheFolderOnceItsRegistrationGoes() {
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Diablo II Resurrected").apply { mkdirs() }
|
||||
File(folder, "partial.bin").writeBytes(byteArrayOf(1, 2, 3))
|
||||
val item = CatalogItem(
|
||||
Store.BATTLENET, "osi", "Diablo II: Resurrected", null,
|
||||
extra = mapOf(BattleNetInstall.PREEXISTING to "0"),
|
||||
)
|
||||
val ownership = Ownership(item)
|
||||
ownership.createdFolder.set(true)
|
||||
var registered = true
|
||||
val installer = BattleNetInstaller(context, item, folder, false, ownership = ownership, cleanupVerifyMs = 0, uninstall = {
|
||||
registered = false
|
||||
true
|
||||
}) { if (registered) listOf("osic") else emptyList() }
|
||||
BattleNetInstaller::class.java.getDeclaredField("started").apply { isAccessible = true }
|
||||
.set(installer, AtomicBoolean(true))
|
||||
val ended = BattleNetInstaller::class.java.getDeclaredField("ended").apply { isAccessible = true }
|
||||
.get(installer) as CountDownLatch
|
||||
installer.cancel(true)
|
||||
ended.countDown()
|
||||
val until = System.nanoTime() + TimeUnit.SECONDS.toNanos(5)
|
||||
while (folder.exists() && System.nanoTime() < until) Thread.sleep(10)
|
||||
assertFalse(folder.exists())
|
||||
assertNull(BattleNetCleanup.get(context, folder))
|
||||
}
|
||||
|
||||
@Test fun reconcileCleansAMarkerAfterItsRegistrationGoes() {
|
||||
val pfx = File(BattleNet.prefix(context), "pfx").apply { mkdirs() }
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent").mkdirs()
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Stores/Battle.net/Diablo III").apply { mkdirs() }
|
||||
File(folder, "partial.bin").writeBytes(byteArrayOf(1, 2, 3))
|
||||
val db = File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db")
|
||||
db.writeBytes(message(
|
||||
field(1, message(field(1, "d3cn"), field(3, message(field(1, "Z:/root/Games/Stores/Battle.net/Diablo III"))))),
|
||||
))
|
||||
BattleNetCleanup.mark(context, folder, "diablo3", createdFolder = true, state = BattleNetCleanup.PENDING)
|
||||
BattleNetInstall.reconcileNow(context, uninstall = { uid ->
|
||||
assertEquals("d3cn", uid)
|
||||
db.writeBytes(ByteArray(0))
|
||||
true
|
||||
}, verifyMs = 0, watchMs = 0)
|
||||
assertFalse(folder.exists())
|
||||
assertNull(BattleNetCleanup.get(context, folder))
|
||||
}
|
||||
|
||||
@Test fun aCancellationRecordsItsMarkerBeforeItWaitsForTheWorker() {
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Diablo II Resurrected").apply { mkdirs() }
|
||||
val item = CatalogItem(
|
||||
Store.BATTLENET, "osi", "Diablo II: Resurrected", null,
|
||||
extra = mapOf(BattleNetInstall.PREEXISTING to "0"),
|
||||
)
|
||||
val installer = BattleNetInstaller(context, item, folder, false, registrationWaitMs = 0, cleanupVerifyMs = 0) {
|
||||
emptyList()
|
||||
}
|
||||
BattleNetInstaller::class.java.getDeclaredField("started").apply { isAccessible = true }
|
||||
.set(installer, AtomicBoolean(true))
|
||||
val ended = BattleNetInstaller::class.java.getDeclaredField("ended").apply { isAccessible = true }
|
||||
.get(installer) as CountDownLatch
|
||||
installer.cancel(true)
|
||||
assertEquals(BattleNetCleanup.PENDING, BattleNetCleanup.get(context, folder)?.state)
|
||||
ended.countDown()
|
||||
val until = System.nanoTime() + TimeUnit.SECONDS.toNanos(2)
|
||||
while (BattleNetCleanup.get(context, folder)?.state == BattleNetCleanup.PENDING && System.nanoTime() < until) Thread.sleep(10)
|
||||
}
|
||||
|
||||
@Test fun anActiveMarkerCannotOverwriteACancellation() {
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Diablo II Resurrected").apply { mkdirs() }
|
||||
BattleNetCleanup.mark(context, folder, "osi", createdFolder = false, state = BattleNetCleanup.PENDING)
|
||||
BattleNetCleanup.markActive(context, folder, "osi", createdFolder = true)
|
||||
val pending = BattleNetCleanup.get(context, folder)!!
|
||||
assertEquals(BattleNetCleanup.PENDING, pending.state)
|
||||
assertTrue(pending.createdFolder)
|
||||
}
|
||||
|
||||
@Test fun aCleanupMarkerRewrittenForAReplacementHasANewStamp() {
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Diablo II Resurrected").apply { mkdirs() }
|
||||
BattleNetCleanup.mark(context, folder, "osi", createdFolder = false, state = BattleNetCleanup.PENDING)
|
||||
val first = BattleNetCleanup.get(context, folder)!!
|
||||
BattleNetCleanup.mark(context, folder, "osi", createdFolder = true, state = BattleNetCleanup.PENDING)
|
||||
val second = BattleNetCleanup.get(context, folder)!!
|
||||
assertTrue(second.stamp > first.stamp)
|
||||
}
|
||||
|
||||
@Test fun aCleanupMarkerIsRestoredWithoutTheTask() {
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Diablo II Resurrected").apply { mkdirs() }
|
||||
BattleNetCleanup.mark(context, folder, "osi", createdFolder = true, state = BattleNetCleanup.PENDING)
|
||||
val pending = BattleNetCleanup.pending(context).single()
|
||||
assertEquals(folder.absolutePath, pending.folder.absolutePath)
|
||||
assertEquals("osi", pending.id)
|
||||
assertTrue(pending.createdFolder)
|
||||
assertEquals(BattleNetCleanup.PENDING, pending.state)
|
||||
BattleNetCleanup.clear(context, folder)
|
||||
assertTrue(BattleNetCleanup.pending(context).isEmpty())
|
||||
}
|
||||
|
||||
@Test fun aRegistrationSourceFailureMakesOwnershipUnknown() {
|
||||
val pfx = File(BattleNet.prefix(context), "pfx").apply { mkdirs() }
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent").mkdirs()
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db")
|
||||
.writeBytes(byteArrayOf(0x0a, 0x03, 0x0a, 0x7f, 0x01))
|
||||
assertNull(BattleNet.registrationsAt(context, "osi", File(LinuxRuntime.rootDir(context), "root/Games/D2R")))
|
||||
}
|
||||
|
||||
@Test fun aWorkerOwnershipSnapshotFailureDoesNotUninstall() {
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Diablo II Resurrected").apply { mkdirs() }
|
||||
val item = CatalogItem(Store.BATTLENET, "osi", "Diablo II: Resurrected", null)
|
||||
val ownership = Ownership(item)
|
||||
val uninstalled = AtomicBoolean(false)
|
||||
val installer = BattleNetInstaller(context, item, folder, false, ownership = ownership, uninstall = {
|
||||
uninstalled.set(true)
|
||||
true
|
||||
}) { null }
|
||||
runCatching { installer.run(DownloadQueue.JobHandle("battlenet:snapshot-failure", AtomicBoolean(false))) }
|
||||
assertFalse("a failed read must not become a final ownership decision", ownership.known)
|
||||
assertTrue(ownership.preexisting)
|
||||
installer.cancel(true)
|
||||
Thread.sleep(100)
|
||||
assertFalse("a failed worker snapshot must disable destructive cleanup", uninstalled.get())
|
||||
}
|
||||
|
||||
@Test fun aFailedRegistrationReadDoesNotUninstall() {
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Diablo II Resurrected").apply { mkdirs() }
|
||||
val item = CatalogItem(
|
||||
Store.BATTLENET, "osi", "Diablo II: Resurrected", null,
|
||||
extra = mapOf(BattleNetInstall.PREEXISTING to "0"),
|
||||
)
|
||||
val uninstalled = AtomicBoolean(false)
|
||||
BattleNetInstaller(context, item, folder, false, uninstall = {
|
||||
uninstalled.set(true)
|
||||
true
|
||||
}) { null }.cancel(true)
|
||||
Thread.sleep(100)
|
||||
assertFalse("an unreadable registration source must disable destructive cleanup", uninstalled.get())
|
||||
}
|
||||
|
||||
@Test fun aResumedInstallerKeepsTheOwnershipDecision() {
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Diablo II Resurrected").apply { mkdirs() }
|
||||
val item = CatalogItem(Store.BATTLENET, "osi", "Diablo II: Resurrected", null)
|
||||
val ownership = Ownership(item)
|
||||
ownership.known = true
|
||||
ownership.preexisting = false
|
||||
val seen = AtomicReference<String?>(null)
|
||||
val done = CountDownLatch(1)
|
||||
BattleNetInstaller(context, item, folder, false, ownership = ownership, cleanupVerifyMs = 0, uninstall = { uid ->
|
||||
seen.set(uid)
|
||||
done.countDown()
|
||||
true
|
||||
}) { listOf("osic") }.cancel(true)
|
||||
assertTrue(done.await(5, TimeUnit.SECONDS))
|
||||
assertEquals("osic", seen.get())
|
||||
}
|
||||
|
||||
@Test fun aRestoredPausedInstallUninstallsTheRegistrationItCreated() {
|
||||
val folder = File(LinuxRuntime.rootDir(context), "root/Games/Diablo II Resurrected").apply { mkdirs() }
|
||||
val item = CatalogItem(
|
||||
Store.BATTLENET, "osi", "Diablo II: Resurrected", null,
|
||||
extra = mapOf(BattleNetInstall.PREEXISTING to "0"),
|
||||
)
|
||||
val seen = AtomicReference<String?>(null)
|
||||
val done = CountDownLatch(1)
|
||||
BattleNetInstaller(context, item, folder, false, cleanupVerifyMs = 0, uninstall = { uid ->
|
||||
seen.set(uid)
|
||||
done.countDown()
|
||||
true
|
||||
}) { listOf("osic") }.cancel(true)
|
||||
assertTrue(done.await(5, TimeUnit.SECONDS))
|
||||
assertEquals("osic", seen.get())
|
||||
}
|
||||
|
||||
@Test fun theTitlePicksBetweenWarcraftFlavorsInOneFolder() {
|
||||
val pfx = File(BattleNet.prefix(context), "pfx").apply { mkdirs() }
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent").mkdirs()
|
||||
val wow = File(LinuxRuntime.rootDir(context), "root/Games/Stores/Battle.net/World of Warcraft")
|
||||
wow.mkdirs()
|
||||
File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db").writeBytes(message(
|
||||
field(1, message(field(1, "wow"), field(3, message(field(1, "Z:/root/Games/Stores/Battle.net/World of Warcraft"))))),
|
||||
field(1, message(field(1, "wow_classic"), field(3, message(field(1, "Z:/root/Games/Stores/Battle.net/World of Warcraft"))))),
|
||||
))
|
||||
val sidecar = StoreGameSidecar(Store.BATTLENET, "wow_classic", "World of Warcraft Classic", "")
|
||||
assertEquals("wow_classic", BattleNetInstall.installUid(context, InstalledStoreGame(sidecar, wow)))
|
||||
assertEquals(listOf("wow"), BattleNet.registrationsAt(context, "wow", File(wow, "_retail_")))
|
||||
assertEquals(listOf("wow_classic"), BattleNet.registrationsAt(context, "wow_classic", File(wow, "_classic_")))
|
||||
val single = StoreGameSidecar(Store.BATTLENET, "wow", "World of Warcraft", "")
|
||||
assertNull(BattleNetInstall.installUid(context, InstalledStoreGame(single, File(wow, "missing"))))
|
||||
}
|
||||
|
||||
@Test fun aScannedGamesShortcutReusesTheKeptRankingInsteadOfWalkingItsFolder() {
|
||||
@@ -408,8 +918,9 @@ class BattleNetTest {
|
||||
assertEquals("wow_forever", BattleNet.STORE.first { it.code == "WoWF" }.uid)
|
||||
assertEquals("fenris", BattleNet.STORE.first { it.code == "Fen" }.uid)
|
||||
assertTrue(BattleNet.STORE.all { it.uid.matches(Regex("[a-z0-9_]{1,32}")) })
|
||||
val installed = listOf("fenris", "diablo3_enus", null)
|
||||
val offered = BattleNet.STORE.filter { BattleNet.notInstalled(it, installed) }.map { it.code }
|
||||
val installedUids = listOf("fenris", "diablo3_enus", null)
|
||||
.mapNotNull { uid -> uid?.let { BattleNet.title(it)?.uid } }.toSet()
|
||||
val offered = BattleNet.STORE.filterNot { it.uid in installedUids }.map { it.code }
|
||||
assertFalse("Fen" in offered || "D3" in offered)
|
||||
assertTrue("OSI" in offered && "WoWF" in offered)
|
||||
assertFalse("WoWF" in BattleNet.STORE.filter { BattleNet.notInstalled(it, listOf("wow_forever")) }.map { it.code })
|
||||
@@ -428,7 +939,7 @@ class BattleNetTest {
|
||||
assertFalse(noSteam.enabled(context, game))
|
||||
assertTrue(BattleNet.ensureNoSteam(context))
|
||||
assertTrue(noSteam.enabled(context, game))
|
||||
val command = noSteam.command(game, shortcut)!!
|
||||
val command = noSteam.command(context, game, shortcut)!!
|
||||
assertEquals(noSteam.BATTLENET, command.program)
|
||||
assertEquals(listOf("launch", "Fen"), command.args)
|
||||
GameEnvironmentStore.setGameNoSteam(context, BattleNet.APP_ID.toString(), false)
|
||||
|
||||
@@ -114,19 +114,6 @@ class GameStorageTest {
|
||||
assertFalse(GameStorage.disconnected(app))
|
||||
}
|
||||
|
||||
@Test fun aRawCardPathTheProcessCannotUseFallsBackToItsStoragePath() {
|
||||
val usable = setOf("/storage/A042-9B16/Games")
|
||||
assertEquals("/storage/A042-9B16/Games", GameStorage.reachable("/mnt/media_rw/A042-9B16/Games") { it.path in usable })
|
||||
}
|
||||
|
||||
@Test fun aUsableRawPathAndOtherPathsAreKept() {
|
||||
assertEquals("/mnt/media_rw/A042-9B16/Games", GameStorage.reachable("/mnt/media_rw/A042-9B16/Games") { true })
|
||||
assertEquals("/mnt/media_rw/0000-0000/Games", GameStorage.reachable("/mnt/media_rw/0000-0000/Games") { false })
|
||||
assertEquals("/storage/A042-9B16/Games", GameStorage.reachable("/storage/A042-9B16/Games") { false })
|
||||
val folder = tmp.newFolder("library").path
|
||||
assertEquals(folder, GameStorage.reachable(folder) { false })
|
||||
}
|
||||
|
||||
@Test fun onlyAVfatMountCountsAsFat32() {
|
||||
val mounts = """
|
||||
/dev/fuse /storage/emulated fuse rw 0 0
|
||||
|
||||
@@ -55,7 +55,7 @@ class NoSteamLaunchTest {
|
||||
"/mnt/droiddeck-sd/Games/Epic/Hogwarts Legacy/.droiddeck-launch.bat", "/mnt/droiddeck-sd/Games/Epic/Hogwarts Legacy",
|
||||
2733369024L, 0L, emptyList(), source = "epic", launchOptions = "-windowed",
|
||||
)
|
||||
val added = NoSteamLaunch.command(shortcut, game)!!
|
||||
val added = NoSteamLaunch.command(context, shortcut, game)!!
|
||||
assertEquals(NoSteamLaunch.PROTON_RUN, added.program)
|
||||
assertEquals(
|
||||
listOf("--app", "2733369024", "--dir", game.guestDir, "--options", "-windowed", "--", game.guestExe),
|
||||
@@ -63,10 +63,10 @@ class NoSteamLaunchTest {
|
||||
)
|
||||
val plain = NoSteamLaunch.addedCommand(AddedGames.Game(game.folder, game.name, game.exe, game.guestExe, game.guestDir, 2733369024L, 0L, emptyList(), source = "gog"))
|
||||
assertEquals(listOf("--app", "2733369024", "--dir", game.guestDir, "--", game.guestExe), plain.args)
|
||||
assertNull(NoSteamLaunch.command(shortcut, null))
|
||||
val steam = NoSteamLaunch.command(steamGame, null)!!
|
||||
assertNull(NoSteamLaunch.command(context, shortcut, null))
|
||||
val steam = NoSteamLaunch.command(context, steamGame, null)!!
|
||||
assertEquals(listOf("--app", "413150"), steam.args)
|
||||
val epic = NoSteamLaunch.command(launcher, null)!!
|
||||
val epic = NoSteamLaunch.command(context, launcher, null)!!
|
||||
assertEquals(NoSteamLaunch.EPIC to listOf("run"), epic.program to epic.args)
|
||||
}
|
||||
|
||||
@@ -86,14 +86,14 @@ class NoSteamLaunchTest {
|
||||
assertEquals(413150L, NoSteamLaunch.settingsId(routed))
|
||||
val entry = Library.SteamGame(413150, "Stardew Valley", null, Library.ADDED)
|
||||
assertEquals(NoSteamLaunch.settingsId(routed).toString(), NoSteamLaunch.scope(entry))
|
||||
val command = NoSteamLaunch.command(entry, routed)!!
|
||||
val command = NoSteamLaunch.command(context, entry, routed)!!
|
||||
assertEquals(NoSteamLaunch.PROTON_RUN to listOf("--app", "413150"), command.program to command.args)
|
||||
val plain = AddedGames.Game(File("/x/a"), "a", File("/x/a/a.exe"), "/g/a.exe", "/g", 2733369024L, 0L, emptyList())
|
||||
assertEquals(2733369024L, NoSteamLaunch.settingsId(plain))
|
||||
}
|
||||
|
||||
@Test fun theRunningSessionIsNamedAfterItsGame() {
|
||||
val command = NoSteamLaunch.command(steamGame, null)!!
|
||||
val command = NoSteamLaunch.command(context, steamGame, null)!!
|
||||
assertNull(NoSteamLaunch.nameFor(command.program, command.args))
|
||||
NoSteamLaunch.remember(command)
|
||||
assertEquals("Stardew Valley", NoSteamLaunch.nameFor(command.program, command.args))
|
||||
|
||||
@@ -21,24 +21,6 @@ class SecondaryLibraryTest {
|
||||
assertFalse(SecondaryLibrary.privateRoot(files, content).exists())
|
||||
}
|
||||
|
||||
@Test fun aCardReachedThroughItsOtherPathKeepsItsPrivateDirectories() {
|
||||
val files = tmp.newFolder("files")
|
||||
val raw = SecondaryLibrary.privateRoot(files, File("/mnt/media_rw/A042-9B16/Games")).apply { mkdirs() }
|
||||
assertEquals(raw, SecondaryLibrary.privateRoot(files, File("/storage/A042-9B16/Games")))
|
||||
val storage = SecondaryLibrary.privateRoot(files, File("/storage/B2BD-BCFC/Games")).apply { mkdirs() }
|
||||
assertEquals(storage, SecondaryLibrary.privateRoot(files, File("/mnt/media_rw/B2BD-BCFC/Games")))
|
||||
}
|
||||
|
||||
@Test fun aLibraryWithItsOwnPrivateDirectoriesKeepsThem() {
|
||||
val files = tmp.newFolder("files")
|
||||
val own = SecondaryLibrary.privateRoot(files, File("/storage/A042-9B16/Games")).apply { mkdirs() }
|
||||
val raw = File(own.parentFile, SecondaryLibrary.privateRoot(tmp.newFolder("other"), File("/mnt/media_rw/A042-9B16/Games")).name)
|
||||
raw.mkdirs()
|
||||
assertEquals(own, SecondaryLibrary.privateRoot(files, File("/storage/A042-9B16/Games")))
|
||||
assertEquals(raw, SecondaryLibrary.privateRoot(files, File("/mnt/media_rw/A042-9B16/Games")))
|
||||
assertFalse(SecondaryLibrary.privateRoot(files, File("/storage/emulated/0/Games")).exists())
|
||||
}
|
||||
|
||||
@Test fun aWritableAliasIsSelectedAndItsProbeIsRemoved() {
|
||||
val library = tmp.newFolder("shared")
|
||||
val candidate = File(tmp.root, "direct")
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import com.droiddeck.launcher.ui.MainMenuLayout
|
||||
import com.droiddeck.launcher.ui.QamFit
|
||||
import com.droiddeck.launcher.ui.QamLayout
|
||||
import org.junit.Assert.assertEquals
|
||||
@@ -52,7 +51,6 @@ class SteamQamTest {
|
||||
val program = "const g = {};\n" + steps.joinToString("\n") { step ->
|
||||
when (step) {
|
||||
is Triple<*, *, *> -> SteamQam.leaseScript(step.first as Boolean, step.second as Long, step.third as Float)
|
||||
is SplitStep -> SteamQam.leaseScript(true, step.owner, 0.5f, step.split)
|
||||
is Pair<*, *> -> if (step.second == EXPIRE) "g.__ddQamUntil = Date.now() - 1;" else SteamQam.leaseScript(step.first as Boolean, step.second as Long)
|
||||
else -> error("unknown step $step")
|
||||
}
|
||||
@@ -87,17 +85,14 @@ class SteamQamTest {
|
||||
|
||||
@Test fun theQuickAccessButtonTogglesTheTopScreenAndTheWideLayoutFollows() {
|
||||
val script = SteamQam.script(true)
|
||||
assertTrue(script.contains("const ours = () => held() && !g.__ddQamTop && (m.m_eOpenSideMenu === QAM || (probing() && m.m_eOpenSideMenu === MAIN));"))
|
||||
assertTrue(script.contains("const ours = () => held() && m.m_eOpenSideMenu === QAM && !g.__ddQamTop;"))
|
||||
assertTrue(script.contains("if (press !== g.__ddQamPress) {"))
|
||||
assertTrue(QamLayout.contentScript(true).contains("max-width: none !important"))
|
||||
assertFalse(QamLayout.contentScript(false).contains("max-width: none"))
|
||||
// The empty in-game button-hint footer is hidden only while the menu is parked, in every layout.
|
||||
assertTrue(QamLayout.contentScript(false, parked = true).contains("#Footer { display: none !important; }"))
|
||||
assertFalse(QamLayout.contentScript(false).contains("#Footer"))
|
||||
}
|
||||
|
||||
@Test fun theMenuIsLaidOutAtThePanelsShapeOnlyWhileHeld() {
|
||||
assertTrue(SteamQam.script(true, 1.5f, owner = 3).contains("g.__ddQamOwner = 3; g.__ddQamUntil = Date.now() + ${SteamQam.LEASE_MS}; g.__ddQamAspect = 1.5; g.__ddQamSplit = false; }"))
|
||||
assertTrue(SteamQam.script(true, 1.5f, owner = 3).contains("g.__ddQamOwner = 3; g.__ddQamUntil = Date.now() + ${SteamQam.LEASE_MS}; g.__ddQamAspect = 1.5; }"))
|
||||
assertFalse(SteamQam.script(true).contains("g.__ddQamAspect ="))
|
||||
assertFalse(SteamQam.script(false, 1.5f).contains("g.__ddQamAspect ="))
|
||||
}
|
||||
@@ -119,8 +114,8 @@ class SteamQamTest {
|
||||
@Test fun whileHeldTheMenuStaysOffTheTopScreenAndOutOfTheGamesWay() {
|
||||
val script = SteamQam.script(true)
|
||||
assertTrue(script.contains("return without >= 2 ? v : 1;"))
|
||||
assertTrue(script.contains("if (w > 0 && ours() && isQam(v)) { x = parkX(); [w, h] = size(w, h); }"))
|
||||
assertTrue(script.contains("/^(QuickAccess|MainMenu)/.test(nav.m_LastActiveNavTree?.m_ID ?? \"\")"))
|
||||
assertTrue(script.contains("if (w > 0 && ours()) { x = popup.m_popup.innerWidth + 64; w = width(h) || w; }"))
|
||||
assertTrue(script.contains("nav.m_LastActiveNavTree?.m_ID?.startsWith(\"QuickAccess\")"))
|
||||
assertTrue(script.contains("if (m.m_eOpenSideMenu === QAM) m.CloseSideMenus();"))
|
||||
}
|
||||
|
||||
@@ -139,9 +134,8 @@ class SteamQamTest {
|
||||
assertEquals(0f, QamLayout.fit(1280f, 832f, 1280f, 640f, 1).second, 0.001f)
|
||||
}
|
||||
|
||||
@Test fun theLayoutButtonCyclesFullLeftCenterRightSplit() {
|
||||
assertEquals(listOf(QamFit.LEFT, QamFit.CENTER, QamFit.RIGHT, QamFit.SPLIT, QamFit.FULL), QamFit.entries.map { it.next })
|
||||
assertEquals(QamFit.SPLIT, QamFit.from("split"))
|
||||
@Test fun theLayoutButtonCyclesFullLeftCenterRight() {
|
||||
assertEquals(listOf(QamFit.LEFT, QamFit.CENTER, QamFit.RIGHT, QamFit.FULL), QamFit.entries.map { it.next })
|
||||
assertEquals(QamFit.FULL, QamFit.from(null))
|
||||
assertEquals(QamFit.RIGHT, QamFit.from("right"))
|
||||
assertEquals(QamFit.FULL, QamFit.from("sideways"))
|
||||
@@ -153,61 +147,6 @@ class SteamQamTest {
|
||||
assertEquals(0f, left, 0.001f)
|
||||
}
|
||||
|
||||
@Test fun findsTheMainMenuPageBesideQuickAccess() {
|
||||
val json = """[
|
||||
{"title":"MainMenu_uid2","webSocketDebuggerUrl":"ws://127.0.0.1:8080/devtools/page/M41N"},
|
||||
{"title":"QuickAccess_uid2","webSocketDebuggerUrl":"ws://127.0.0.1:8080/devtools/page/0F3A-b9"}
|
||||
]"""
|
||||
assertEquals(SteamQam.Target(4321, "/devtools/page/0F3A-b9", "/devtools/page/M41N"), SteamQam.parseTarget(4321, json))
|
||||
assertNull(SteamQam.parseTarget(1, """[{"title":"MainMenu_uid2","webSocketDebuggerUrl":"ws://127.0.0.1:1/devtools/page/A"}]"""))
|
||||
}
|
||||
|
||||
@Test fun theSplitLayoutIsPartOfTheLease() {
|
||||
assertEquals("true", runLease(listOf(SplitStep(1L, true)), "g.__ddQamSplit"))
|
||||
// A rejected hold from an older panel leaves the newer panel's split choice alone.
|
||||
assertEquals("true", runLease(listOf(SplitStep(2L, true), SplitStep(1L, false)), "g.__ddQamSplit"))
|
||||
assertTrue(SteamQam.script(true, 0.5f, owner = 3, split = true).contains("g.__ddQamSplit = true; }"))
|
||||
}
|
||||
|
||||
@Test fun onlyTheQuickAccessViewIsParked() {
|
||||
val script = SteamQam.script(true, 1.3f, owner = 3)
|
||||
// Store and other web pages live in the header's view, which keeps the bounds Steam gives it.
|
||||
assertTrue(script.contains("const isQam = (v) => !v.__ddMain && v !== headerView() &&"))
|
||||
assertTrue(script.contains("if (on && m.m_eOpenSideMenu === QAM && !v.__ddMain && v !== headerView()) {"))
|
||||
assertTrue(script.contains("if (!isQam(v)) {"))
|
||||
// A parked menu leaves the Store page unfrosted.
|
||||
assertTrue(script.contains("inst.__ddQamGlass.call(this, ours() ? 0 : e)"))
|
||||
}
|
||||
|
||||
@Test fun mainMenuDiscoveryRecoversAfterFailedProbes() {
|
||||
val script = SteamQam.script(true, 1.3f, owner = 3, split = true)
|
||||
assertTrue(script.contains("if (split() !== !!g.__ddQamSplitOn) { g.__ddQamSplitOn = split(); if (split()) g.__ddMainProbes = 0; }"))
|
||||
assertTrue(script.contains("if ((g.__ddMainProbes || 0) >= 3 && Date.now() - (g.__ddMainProbeLast || 0) > 30000) g.__ddMainProbes = 0;"))
|
||||
}
|
||||
|
||||
@Test fun theMainMenuStaysInPlaceOnlyWhileParked() {
|
||||
val script = SteamQam.script(true, 0.5f, owner = 3, split = true)
|
||||
assertTrue(script.contains("transform: none !important"))
|
||||
assertTrue(script.contains("mainStyle(!!mv && mainParked() && !probing());"))
|
||||
// Steam sizing the main menu for the top screen drops the parked style at once.
|
||||
assertTrue(script.contains("if (v.__ddMain && w > 0) mainStyle(false);"))
|
||||
}
|
||||
|
||||
@Test fun theScriptsParse() {
|
||||
val node = runCatching { ProcessBuilder("node", "--version").start().waitFor() == 0 }.getOrDefault(false)
|
||||
org.junit.Assume.assumeTrue("node is not installed", node)
|
||||
val scripts = listOf(SteamQam.script(true, 0.5f, 3, split = true), SteamQam.script(false, owner = 3),
|
||||
QamLayout.contentScript(true), MainMenuLayout.CONTENT_SCRIPT)
|
||||
val program = scripts.joinToString(";") { "new Function(" + org.json.JSONObject.quote(it) + ")" }
|
||||
// Passed on stdin: Windows argument quoting would mangle the quotes in the scripts.
|
||||
val p = ProcessBuilder("node").redirectErrorStream(true).start()
|
||||
p.outputStream.use { it.write(program.toByteArray()) }
|
||||
val out = p.inputStream.bufferedReader().readText()
|
||||
assertEquals(out, 0, p.waitFor())
|
||||
}
|
||||
|
||||
private data class SplitStep(val owner: Long, val split: Boolean)
|
||||
|
||||
private companion object {
|
||||
/** A lease step that lets the current lease run out. */
|
||||
const val EXPIRE = -1L
|
||||
|
||||
@@ -28,6 +28,41 @@ class BattleNetInstallTest {
|
||||
eu|e474008a3535d8ea978949a90d9873e6|db0583272ed15286569b5f24ce516876||119725|16.1.2.119725|f6a454799d25791e5a37a7547d75ce49
|
||||
""".trimIndent()
|
||||
|
||||
private val osiVersions = """
|
||||
Region!STRING:0|BuildConfig!HEX:16|CDNConfig!HEX:16|KeyRing!HEX:16|BuildId!DEC:4|VersionsName!String:0|ProductConfig!HEX:16
|
||||
## seqn = 3964805
|
||||
us|11111111111111111111111111111111|aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa||93847|3.3.93847|bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
eu|11111111111111111111111111111111|aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa||93847|3.3.93847|bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
kr|11111111111111111111111111111111|aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa||93847|3.3.93847|bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
""".trimIndent()
|
||||
|
||||
private val osicVersions = """
|
||||
Region!STRING:0|BuildConfig!HEX:16|CDNConfig!HEX:16|KeyRing!HEX:16|BuildId!DEC:4|VersionsName!String:0|ProductConfig!HEX:16
|
||||
## seqn = 3964866
|
||||
cn|44444444444444444444444444444444|cccccccccccccccccccccccccccccccc||93854|3.3.93854|dddddddddddddddddddddddddddddddd
|
||||
""".trimIndent()
|
||||
|
||||
private val s2Versions = """
|
||||
Region!STRING:0|BuildConfig!HEX:16|CDNConfig!HEX:16|KeyRing!HEX:16|BuildId!DEC:4|VersionsName!String:0|ProductConfig!HEX:16
|
||||
## seqn = 4064835
|
||||
us|55555555555555555555555555555555|eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee||98310|5.0.17.98310|ffffffffffffffffffffffffffffffff
|
||||
cn|66666666666666666666666666666666|eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee||93333|5.0.14.93333|ffffffffffffffffffffffffffffffff
|
||||
""".trimIndent()
|
||||
|
||||
private val s2cVersions = """
|
||||
Region!STRING:0|BuildConfig!HEX:16|CDNConfig!HEX:16|KeyRing!HEX:16|BuildId!DEC:4|VersionsName!String:0|ProductConfig!HEX:16
|
||||
## seqn = 4064962
|
||||
cn|77777777777777777777777777777777|eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee||98370|5.0.17.98370|ffffffffffffffffffffffffffffffff
|
||||
""".trimIndent()
|
||||
|
||||
private val anbsVersions = """
|
||||
Region!STRING:0|BuildConfig!HEX:16|CDNConfig!HEX:16|KeyRing!HEX:16|BuildId!DEC:4|VersionsName!String:0|ProductConfig!HEX:16
|
||||
## seqn = 4105154
|
||||
us|88888888888888888888888888888888|99999999999999999999999999999999||3935504|5.1.3.3935504|aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab
|
||||
eu|88888888888888888888888888888888|99999999999999999999999999999999||3935504|5.1.3.3935504|aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab
|
||||
kr|88888888888888888888888888888888|99999999999999999999999999999999||3935504|5.1.3.3935504|aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab
|
||||
""".trimIndent()
|
||||
|
||||
@Test fun theActiveRowGivesTheRegionAndBuildOnDisk() {
|
||||
assertEquals("us" to "e474008a3535d8ea978949a90d9873e6", BattleNetInstall.buildKey(buildInfo))
|
||||
assertNull(BattleNetInstall.buildKey("Branch!STRING:0|Active!DEC:1\n"))
|
||||
@@ -41,9 +76,18 @@ class BattleNetInstallTest {
|
||||
assertNull(BattleNetInstall.latestBuild("", "us"))
|
||||
}
|
||||
|
||||
@Test fun theChinaProductsAreNotOnTheGlobalVersionLine() {
|
||||
assertNull(BattleNetInstall.latestBuild(osiVersions, "cn"))
|
||||
assertEquals("44444444444444444444444444444444", BattleNetInstall.latestBuild(osicVersions, "cn"))
|
||||
assertEquals("66666666666666666666666666666666", BattleNetInstall.latestBuild(s2Versions, "cn"))
|
||||
assertEquals("77777777777777777777777777777777", BattleNetInstall.latestBuild(s2cVersions, "cn"))
|
||||
assertNull(BattleNetInstall.latestBuild(anbsVersions, "cn"))
|
||||
}
|
||||
|
||||
@Test fun theVersionServiceIsBlizzardsChineseOneForChina() {
|
||||
assertEquals("https://us.version.battle.net/v2/products/wow/versions", BattleNetInstall.versionsUrl("us", "wow"))
|
||||
assertEquals("https://cn.version.battlenet.com.cn/v2/products/d3cn/versions", BattleNetInstall.versionsUrl("cn", "d3cn"))
|
||||
assertEquals("https://cn.version.battlenet.com.cn/v2/products/s2c/versions", BattleNetInstall.versionsUrl("cn", "s2c"))
|
||||
}
|
||||
|
||||
@Test fun theDeviceLanguagePicksABlizzardLocale() {
|
||||
@@ -69,7 +113,16 @@ class BattleNetInstallTest {
|
||||
assertTrue(BattleNetInstall.headless(CatalogItem(Store.BATTLENET, "gryphon", "Warcraft Rumble", null)))
|
||||
assertEquals("hsb", BattleNetInstall.product("hs_beta"))
|
||||
assertEquals("d3", BattleNetInstall.product("diablo3_enus"))
|
||||
assertFalse(BattleNetInstall.headless(CatalogItem(Store.BATTLENET, "d3cn", "Diablo III", null)))
|
||||
assertEquals("d3cn", BattleNetInstall.product("d3cn"))
|
||||
assertEquals("osic", BattleNetInstall.product("osic"))
|
||||
assertEquals("s2c", BattleNetInstall.product("s2_cn"))
|
||||
assertEquals("anbs", BattleNetInstall.product("anbs_cn"))
|
||||
assertEquals("osic", BattleNetInstall.chinaProduct("osi"))
|
||||
assertEquals("s2c", BattleNetInstall.chinaProduct("s2"))
|
||||
assertEquals("d3cn", BattleNetInstall.chinaProduct("diablo3"))
|
||||
assertNull(BattleNetInstall.chinaProduct("anbs"))
|
||||
assertNull(BattleNetInstall.chinaProduct("wow"))
|
||||
assertTrue(BattleNetInstall.headless(CatalogItem(Store.BATTLENET, "d3cn", "Diablo III", null)))
|
||||
assertFalse(BattleNetInstall.headless(CatalogItem(Store.EPIC, "gryphon", "Warcraft Rumble", null)))
|
||||
}
|
||||
|
||||
@@ -78,12 +131,76 @@ class BattleNetInstallTest {
|
||||
try {
|
||||
BattleNetInstall.check("gryphon", folder, false)
|
||||
BattleNetInstall.checks.submit {}.get()
|
||||
assertFalse(synchronized(BattleNetInstall.checkedAt) { "gryphon" in BattleNetInstall.checkedAt })
|
||||
assertFalse(synchronized(BattleNetInstall.checkedAt) {
|
||||
BattleNetInstall.updateKey("gryphon", folder) in BattleNetInstall.checkedAt
|
||||
})
|
||||
} finally {
|
||||
folder.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun aBuildThatChangesDuringTheCheckIsAskedAgainOnlyTwice() {
|
||||
val folder = Files.createTempDirectory("bnet-retry").toFile()
|
||||
val scheduled = mutableListOf<Pair<() -> Unit, Long>>()
|
||||
val originalFetch = BattleNetInstall.fetchVersions
|
||||
val originalSchedule = BattleNetInstall.scheduleRecheck
|
||||
try {
|
||||
File(folder, ".build.info").writeText(buildInfo)
|
||||
var asked = 0
|
||||
BattleNetInstall.fetchVersions = {
|
||||
// Every request runs against a different build, so the post-read never matches.
|
||||
asked += 1
|
||||
File(folder, ".build.info").writeText(buildInfo.replace("e474008a3535d8ea978949a90d9873e6", "%032x".format(asked)))
|
||||
versions
|
||||
}
|
||||
BattleNetInstall.scheduleRecheck = { body, delay -> scheduled += body to delay }
|
||||
synchronized(BattleNetInstall.checkedAt) { BattleNetInstall.checkedAt.clear() }
|
||||
|
||||
BattleNetInstall.check("gryphon", folder, false)
|
||||
BattleNetInstall.checks.submit {}.get()
|
||||
assertEquals(1, scheduled.size)
|
||||
assertEquals(30_000L, scheduled[0].second)
|
||||
|
||||
scheduled[0].first()
|
||||
BattleNetInstall.checks.submit {}.get()
|
||||
assertEquals(2, scheduled.size)
|
||||
assertEquals(60_000L, scheduled[1].second)
|
||||
|
||||
var next = 1
|
||||
repeat(4) {
|
||||
if (next < scheduled.size) {
|
||||
scheduled[next].first()
|
||||
BattleNetInstall.checks.submit {}.get()
|
||||
next += 1
|
||||
}
|
||||
}
|
||||
assertEquals("re-checks are bounded", 2, scheduled.size)
|
||||
assertEquals(30_000L, scheduled[0].second)
|
||||
assertNull(BattleNetInstall.updates[BattleNetInstall.updateKey("gryphon", folder)])
|
||||
} finally {
|
||||
BattleNetInstall.fetchVersions = originalFetch
|
||||
BattleNetInstall.scheduleRecheck = originalSchedule
|
||||
synchronized(BattleNetInstall.checkedAt) { BattleNetInstall.checkedAt.remove(BattleNetInstall.updateKey("gryphon", folder)) }
|
||||
folder.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun updateStateIsSeparateForEachInstallFolder() {
|
||||
val one = Files.createTempDirectory("bnet-one").toFile()
|
||||
val two = Files.createTempDirectory("bnet-two").toFile()
|
||||
try {
|
||||
val first = BattleNetInstall.updateKey("diablo3", one)
|
||||
val second = BattleNetInstall.updateKey("diablo3", two)
|
||||
assertFalse(first == second)
|
||||
BattleNetInstall.updates[first] = true
|
||||
assertNull(BattleNetInstall.updates[second])
|
||||
BattleNetInstall.updates.remove(first)
|
||||
} finally {
|
||||
one.deleteRecursively()
|
||||
two.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun theAgentStatusPicksTheDownloadStep() {
|
||||
assertEquals(BattleNetInstall.Step.PREPARING, BattleNetInstall.step(1008, 0, 0, 0))
|
||||
assertEquals(BattleNetInstall.Step.PREPARING, BattleNetInstall.step(1003, 500, 0, 0))
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.droiddeck.launcher.stores.battlenet
|
||||
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [33])
|
||||
class BattleNetLibraryTest {
|
||||
private val app get() = RuntimeEnvironment.getApplication()
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
|
||||
@Test fun aMissingLibraryLeavesBattleNetsInstallFolderAlone() {
|
||||
SessionPrefs.setGameStorage(app, "/storage/0000-0000/Games", "SD card")
|
||||
assertTrue(BattleNetClient.library(app).isEmpty())
|
||||
}
|
||||
|
||||
@Test fun anAttachedLibraryIsHandedToBattleNet() {
|
||||
SessionPrefs.setGameStorage(app, tmp.newFolder("card").path, "SD card")
|
||||
assertEquals("--library", BattleNetClient.library(app).firstOrNull())
|
||||
}
|
||||
|
||||
@Test fun internalStorageIsHandedToBattleNetWhenItIsTheChoice() {
|
||||
SessionPrefs.setGameStorage(app, SessionPrefs.GAME_STORAGE_OFF, "")
|
||||
assertEquals("--library", BattleNetClient.library(app).firstOrNull())
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.droiddeck.launcher.stores.download
|
||||
|
||||
import android.content.Context
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import com.droiddeck.launcher.stores.*
|
||||
import com.droiddeck.launcher.stores.battlenet.BattleNetInstall
|
||||
import com.droiddeck.launcher.stores.battlenet.BattleNetInstaller
|
||||
import java.io.File
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
@@ -12,9 +15,11 @@ import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.shadows.ShadowLooper
|
||||
import org.robolectric.shadows.ShadowStatFs
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@@ -117,6 +122,351 @@ class DownloadQueueRetryTest {
|
||||
assertNull(DownloadQueue.entry(entry.key))
|
||||
}
|
||||
|
||||
@Test fun cancellingBeforeTheJobIsPublishedCancelsIt() {
|
||||
val entry = DownloadEntry(Store.GOG, "cancel-before-publish", "Cancel before publish")
|
||||
val factoryEntered = CountDownLatch(1)
|
||||
val release = CountDownLatch(1)
|
||||
val cancelled = CountDownLatch(1)
|
||||
val job = object : DownloadQueue.DownloadJob {
|
||||
override fun run(handle: DownloadQueue.JobHandle): String? = null
|
||||
override fun cancel(deleteFiles: Boolean) {
|
||||
if (deleteFiles) cancelled.countDown()
|
||||
}
|
||||
}
|
||||
DownloadQueue.enqueue(app, entry) {
|
||||
factoryEntered.countDown()
|
||||
release.await(5, TimeUnit.SECONDS)
|
||||
job
|
||||
}
|
||||
assertTrue(factoryEntered.await(5, TimeUnit.SECONDS))
|
||||
DownloadQueue.pause(entry.key)
|
||||
DownloadQueue.cancel(app, entry.key)
|
||||
release.countDown()
|
||||
assertTrue("cancel must reach the job published after the request", cancelled.await(5, TimeUnit.SECONDS))
|
||||
val until = System.nanoTime() + TimeUnit.SECONDS.toNanos(5)
|
||||
while (DownloadQueue.entry(entry.key)?.state != DownloadState.CANCELLED && System.nanoTime() < until) {
|
||||
Thread.sleep(10)
|
||||
}
|
||||
assertEquals(DownloadState.CANCELLED, DownloadQueue.entry(entry.key)?.state)
|
||||
DownloadQueue.clear(app, entry.key)
|
||||
}
|
||||
|
||||
@Test fun aRejectedEnqueueDoesNotRunItsAcceptedCallback() {
|
||||
val entry = DownloadEntry(
|
||||
Store.BATTLENET, "rejected-enqueue", "Rejected enqueue",
|
||||
cleanupKey = "${Store.BATTLENET.id}:rejected-enqueue",
|
||||
)
|
||||
val started = CountDownLatch(1)
|
||||
val release = CountDownLatch(1)
|
||||
DownloadQueue.enqueue(app, entry) {
|
||||
object : DownloadQueue.DownloadJob {
|
||||
override fun run(handle: DownloadQueue.JobHandle): String? {
|
||||
started.countDown()
|
||||
release.await()
|
||||
return null
|
||||
}
|
||||
override fun cancel(deleteFiles: Boolean) {}
|
||||
}
|
||||
}
|
||||
assertTrue(started.await(5, TimeUnit.SECONDS))
|
||||
var accepted = false
|
||||
assertFalse(DownloadQueue.enqueue(app, entry, onAccepted = { accepted = true }) {
|
||||
object : DownloadQueue.DownloadJob {
|
||||
override fun run(handle: DownloadQueue.JobHandle): String? = null
|
||||
override fun cancel(deleteFiles: Boolean) {}
|
||||
}
|
||||
})
|
||||
assertFalse(accepted)
|
||||
release.countDown()
|
||||
DownloadQueue.clear(app, entry.key)
|
||||
}
|
||||
|
||||
@Test fun aSavedQueueRestoreCarriesOwnershipIntoEnqueue() {
|
||||
val root = File(app.filesDir, "restore-root").apply { mkdirs() }
|
||||
val key = "battlenet:restore-chain"
|
||||
SavedQueue.resetForTest()
|
||||
SavedQueue.remember(
|
||||
app,
|
||||
CatalogItem(
|
||||
Store.BATTLENET, "restore-chain", "Restore chain", null,
|
||||
extra = mapOf("preexisting" to "0"),
|
||||
),
|
||||
root,
|
||||
)
|
||||
val row = JSONObject().apply {
|
||||
put("paused", true)
|
||||
put("root", root.absolutePath)
|
||||
put("item", JSONObject().apply {
|
||||
put("store", Store.BATTLENET.id); put("id", "restore-chain"); put("title", "Restore chain")
|
||||
put("extra", JSONObject().put("preexisting", "0"))
|
||||
put("owned", true)
|
||||
})
|
||||
}
|
||||
File(app.filesDir, "store-queue.json").writeText(JSONArray().put(row).toString())
|
||||
DownloadQueue.holdPaused(key)
|
||||
val previous = StoresState.backend(Store.BATTLENET)
|
||||
val installed = CountDownLatch(1)
|
||||
StoresState.register(object : StoreBackend {
|
||||
override val store = Store.BATTLENET
|
||||
override fun signIn(context: Context) {}
|
||||
override fun signOut(context: Context) {}
|
||||
override fun syncLibrary(context: Context, force: Boolean) {}
|
||||
override fun loadShelves(context: Context, force: Boolean) {}
|
||||
override fun uninstall(context: Context, game: InstalledStoreGame) {}
|
||||
override fun install(context: Context, item: CatalogItem, root: File) {
|
||||
BattleNetInstall.enqueue(context, item, StoreInstallRoot.folderFor(context, store, item.id, item.title, root))
|
||||
installed.countDown()
|
||||
}
|
||||
})
|
||||
try {
|
||||
SavedQueue.restore(app)
|
||||
val until = System.nanoTime() + TimeUnit.SECONDS.toNanos(5)
|
||||
while (installed.count > 0 && System.nanoTime() < until) {
|
||||
ShadowLooper.idleMainLooper()
|
||||
Thread.sleep(10)
|
||||
}
|
||||
assertTrue(installed.await(1, TimeUnit.SECONDS))
|
||||
assertEquals("0", SavedQueue.remembered(key)?.extra?.get("preexisting"))
|
||||
DownloadQueue.clear(app, key)
|
||||
} finally {
|
||||
if (previous != null) StoresState.register(previous)
|
||||
SavedQueue.resetForTest()
|
||||
File(app.filesDir, "store-queue.json").delete()
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun aRejectedUpdateKeepsTheSavedOwnershipSnapshot() {
|
||||
val original = CatalogItem(
|
||||
Store.BATTLENET, "rejected-update", "Rejected update", null,
|
||||
extra = mapOf("preexisting" to "0"),
|
||||
)
|
||||
SavedQueue.remember(app, original, null)
|
||||
val entry = DownloadEntry(Store.BATTLENET, "rejected-update", "Rejected update")
|
||||
val started = CountDownLatch(1)
|
||||
val release = CountDownLatch(1)
|
||||
DownloadQueue.enqueue(app, entry) {
|
||||
object : DownloadQueue.DownloadJob {
|
||||
override fun run(handle: DownloadQueue.JobHandle): String? {
|
||||
started.countDown()
|
||||
release.await()
|
||||
return null
|
||||
}
|
||||
override fun cancel(deleteFiles: Boolean) {}
|
||||
}
|
||||
}
|
||||
assertTrue(started.await(5, TimeUnit.SECONDS))
|
||||
var accepted = false
|
||||
assertFalse(DownloadQueue.enqueue(app, entry, onAccepted = {
|
||||
accepted = true
|
||||
SavedQueue.remember(app, original.copy(extra = mapOf("preexisting" to "1")), null)
|
||||
}) {
|
||||
object : DownloadQueue.DownloadJob {
|
||||
override fun run(handle: DownloadQueue.JobHandle): String? = null
|
||||
override fun cancel(deleteFiles: Boolean) {}
|
||||
}
|
||||
})
|
||||
assertFalse(accepted)
|
||||
assertEquals("0", SavedQueue.remembered(entry.key)?.extra?.get("preexisting"))
|
||||
release.countDown()
|
||||
DownloadQueue.clear(app, entry.key)
|
||||
}
|
||||
|
||||
@Test fun aFactorylessFailedBattleNetEntryDoesNotBlockAReplacement() {
|
||||
val entry = DownloadEntry(
|
||||
Store.BATTLENET, "factoryless-failure", "Factoryless failure",
|
||||
cleanupKey = "${Store.BATTLENET.id}:factoryless-failure",
|
||||
)
|
||||
DownloadQueue.recordFailed(app, entry, "failed before a job existed")
|
||||
DownloadQueue.clear(app, entry.key)
|
||||
DownloadQueue.enqueue(app, entry) {
|
||||
object : DownloadQueue.DownloadJob {
|
||||
override fun run(handle: DownloadQueue.JobHandle): String? = null
|
||||
override fun cancel(deleteFiles: Boolean) {}
|
||||
}
|
||||
}
|
||||
assertNotNull("a cleared factoryless failure must not hold a cleanup key", DownloadQueue.entry(entry.key))
|
||||
val until = System.nanoTime() + TimeUnit.SECONDS.toNanos(5)
|
||||
while (DownloadQueue.entry(entry.key)?.isActive == true && System.nanoTime() < until) Thread.sleep(10)
|
||||
DownloadQueue.clear(app, entry.key)
|
||||
}
|
||||
|
||||
@Test fun aBattleNetClientDownloadIsNotInTheGameCleanupGuard() {
|
||||
val entry = DownloadEntry(Store.BATTLENET, "battlenet-client", "Battle.net")
|
||||
DownloadQueue.enqueue(app, entry) {
|
||||
object : DownloadQueue.DownloadJob {
|
||||
override fun run(handle: DownloadQueue.JobHandle): String? = null
|
||||
override fun cancel(deleteFiles: Boolean) {}
|
||||
}
|
||||
}
|
||||
DownloadQueue.cancel(app, entry.key)
|
||||
assertFalse(DownloadQueue.isCancelling(entry.key))
|
||||
DownloadQueue.clear(app, entry.key)
|
||||
}
|
||||
|
||||
@Test fun aPauseCallbackDoesNotReleaseAnotherCleanup() {
|
||||
val title = "Pause during cleanup"
|
||||
val entry = DownloadEntry(
|
||||
Store.BATTLENET, "pause-during-cleanup", title,
|
||||
cleanupKey = "${Store.BATTLENET.id}:pause-during-cleanup",
|
||||
)
|
||||
val cancelled = CountDownLatch(1)
|
||||
val release = CountDownLatch(1)
|
||||
val job = object : DownloadQueue.DownloadJob {
|
||||
override fun run(handle: DownloadQueue.JobHandle): String? = null
|
||||
override fun cancel(deleteFiles: Boolean) {
|
||||
if (!deleteFiles) return
|
||||
cancelled.countDown()
|
||||
Thread({
|
||||
release.await()
|
||||
DownloadQueue.cleanupFinished(entry.key)
|
||||
}, "test-pause-cleanup").start()
|
||||
}
|
||||
}
|
||||
DownloadQueue.enqueue(app, entry) { job }
|
||||
DownloadQueue.cancel(app, entry.key)
|
||||
assertTrue(cancelled.await(5, TimeUnit.SECONDS))
|
||||
assertTrue(DownloadQueue.isCancelling(entry.key))
|
||||
|
||||
val folder = File(LinuxRuntime.rootDir(app), "root/Games/Diablo II Resurrected").apply { mkdirs() }
|
||||
val item = CatalogItem(Store.BATTLENET, entry.id, title, null)
|
||||
BattleNetInstaller(app, item, folder, false).cancel(false)
|
||||
assertTrue("a pause must not release the destructive cleanup guard", DownloadQueue.isCancelling(entry.key))
|
||||
|
||||
release.countDown()
|
||||
val until = System.nanoTime() + TimeUnit.SECONDS.toNanos(5)
|
||||
while (DownloadQueue.isCancelling(entry.key) && System.nanoTime() < until) Thread.sleep(10)
|
||||
assertFalse(DownloadQueue.isCancelling(entry.key))
|
||||
val entryUntil = System.nanoTime() + TimeUnit.SECONDS.toNanos(5)
|
||||
while (DownloadQueue.entry(entry.key)?.state != DownloadState.CANCELLED && System.nanoTime() < entryUntil) {
|
||||
Thread.sleep(10)
|
||||
}
|
||||
DownloadQueue.clear(app, entry.key)
|
||||
}
|
||||
|
||||
@Test fun aDoubleClearStartsOneCleanup() {
|
||||
val entry = DownloadEntry(
|
||||
Store.BATTLENET, "double-clear", "Double clear",
|
||||
cleanupKey = "${Store.BATTLENET.id}:double-clear",
|
||||
)
|
||||
val cancelled = CountDownLatch(1)
|
||||
val release = CountDownLatch(1)
|
||||
val cancels = AtomicInteger()
|
||||
val job = object : DownloadQueue.DownloadJob {
|
||||
override fun run(handle: DownloadQueue.JobHandle): String? = null
|
||||
override fun cancel(deleteFiles: Boolean) {
|
||||
if (!deleteFiles) return
|
||||
cancels.incrementAndGet()
|
||||
cancelled.countDown()
|
||||
Thread({
|
||||
release.await()
|
||||
DownloadQueue.cleanupFinished(entry.key)
|
||||
}, "test-double-clear").start()
|
||||
}
|
||||
}
|
||||
DownloadQueue.enqueue(app, entry) { job }
|
||||
val failedUntil = System.nanoTime() + TimeUnit.SECONDS.toNanos(5)
|
||||
while (DownloadQueue.entry(entry.key)?.state != DownloadState.FAILED && System.nanoTime() < failedUntil) {
|
||||
Thread.sleep(10)
|
||||
}
|
||||
DownloadQueue.clear(app, entry.key)
|
||||
DownloadQueue.clear(app, entry.key)
|
||||
assertTrue(cancelled.await(5, TimeUnit.SECONDS))
|
||||
assertEquals(1, cancels.get())
|
||||
assertTrue(DownloadQueue.isCancelling(entry.key))
|
||||
release.countDown()
|
||||
val until = System.nanoTime() + TimeUnit.SECONDS.toNanos(5)
|
||||
while (DownloadQueue.isCancelling(entry.key) && System.nanoTime() < until) Thread.sleep(10)
|
||||
assertFalse(DownloadQueue.isCancelling(entry.key))
|
||||
}
|
||||
|
||||
@Test fun aCancelledBattleNetJobBlocksAReplacementWhileCleanupRuns() {
|
||||
val entry = DownloadEntry(
|
||||
Store.BATTLENET, "same-folder-race", "Same folder race",
|
||||
cleanupKey = "${Store.BATTLENET.id}:same-folder-race",
|
||||
)
|
||||
val started = CountDownLatch(1)
|
||||
val cancelled = CountDownLatch(1)
|
||||
val release = CountDownLatch(1)
|
||||
val cancels = AtomicInteger()
|
||||
val job = object : DownloadQueue.DownloadJob {
|
||||
override fun run(handle: DownloadQueue.JobHandle): String? {
|
||||
started.countDown()
|
||||
return null
|
||||
}
|
||||
|
||||
override fun cancel(deleteFiles: Boolean) {
|
||||
if (!deleteFiles) return
|
||||
cancels.incrementAndGet()
|
||||
cancelled.countDown()
|
||||
Thread({
|
||||
release.await()
|
||||
DownloadQueue.cleanupFinished(entry.key)
|
||||
}, "test-cleanup").start()
|
||||
}
|
||||
}
|
||||
DownloadQueue.enqueue(app, entry) { job }
|
||||
assertTrue(started.await(5, TimeUnit.SECONDS))
|
||||
try {
|
||||
DownloadQueue.cancel(app, entry.key)
|
||||
DownloadQueue.cancel(app, entry.key)
|
||||
assertTrue(cancelled.await(5, TimeUnit.SECONDS))
|
||||
assertEquals(1, cancels.get())
|
||||
assertTrue(DownloadQueue.isCancelling(entry.key))
|
||||
val until = System.nanoTime() + TimeUnit.SECONDS.toNanos(5)
|
||||
while (DownloadQueue.entry(entry.key)?.state != DownloadState.CANCELLED && System.nanoTime() < until) {
|
||||
Thread.sleep(10)
|
||||
}
|
||||
assertEquals(DownloadState.CANCELLED, DownloadQueue.entry(entry.key)?.state)
|
||||
DownloadQueue.clear(app, entry.key)
|
||||
DownloadQueue.enqueue(app, entry) {
|
||||
object : DownloadQueue.DownloadJob {
|
||||
override fun run(handle: DownloadQueue.JobHandle): String? = "replacement"
|
||||
override fun cancel(deleteFiles: Boolean) {}
|
||||
}
|
||||
}
|
||||
assertNull("replacement must not be published during cleanup", DownloadQueue.entry(entry.key))
|
||||
} finally {
|
||||
release.countDown()
|
||||
}
|
||||
val until = System.nanoTime() + TimeUnit.SECONDS.toNanos(5)
|
||||
while (DownloadQueue.isCancelling(entry.key) && System.nanoTime() < until) Thread.sleep(10)
|
||||
assertFalse(DownloadQueue.isCancelling(entry.key))
|
||||
}
|
||||
|
||||
@Test fun aCancelledBattleNetJobHoldsRemovalUntilItsCleanupFinishes() {
|
||||
val entry = DownloadEntry(
|
||||
Store.BATTLENET, "hold-during-cleanup", "Hold during cleanup",
|
||||
cleanupKey = "${Store.BATTLENET.id}:hold-during-cleanup",
|
||||
)
|
||||
val cancelled = CountDownLatch(1)
|
||||
val release = CountDownLatch(1)
|
||||
val job = object : DownloadQueue.DownloadJob {
|
||||
override fun run(handle: DownloadQueue.JobHandle): String? = null
|
||||
override fun cancel(deleteFiles: Boolean) {
|
||||
if (!deleteFiles) return
|
||||
cancelled.countDown()
|
||||
Thread({
|
||||
release.await(5, TimeUnit.SECONDS)
|
||||
DownloadQueue.cleanupFinished(entry.key)
|
||||
}, "test-hold-cleanup").start()
|
||||
}
|
||||
}
|
||||
DownloadQueue.enqueue(app, entry) { job }
|
||||
val failed = System.nanoTime() + TimeUnit.SECONDS.toNanos(5)
|
||||
while (DownloadQueue.entry(entry.key)?.state != DownloadState.FAILED && System.nanoTime() < failed) Thread.sleep(10)
|
||||
DownloadQueue.cancel(app, entry.key)
|
||||
assertTrue(cancelled.await(5, TimeUnit.SECONDS))
|
||||
assertFalse(DownloadQueue.holdForRemoval(entry.key))
|
||||
val held = CountDownLatch(1)
|
||||
Thread({
|
||||
if (DownloadQueue.stopForRemoval(app, entry.key)) held.countDown()
|
||||
}, "test-hold-removal").start()
|
||||
assertFalse("removal must wait for the cancellation cleanup", held.await(300, TimeUnit.MILLISECONDS))
|
||||
release.countDown()
|
||||
assertTrue(held.await(5, TimeUnit.SECONDS))
|
||||
DownloadQueue.releaseRemoval(entry.key)
|
||||
}
|
||||
|
||||
@Test fun heldPausedBackendRestoresAndResumesWithoutAPlaceholder() {
|
||||
val entry = DownloadEntry(Store.GOG, "restored-paused", "Paused")
|
||||
val ran = CountDownLatch(1)
|
||||
|
||||
@@ -258,10 +258,8 @@ and `--rate` (120 samples a second); `--pressure` and tilt take `FROM:TO` ranges
|
||||
`--tilt-x=-30:30` when they start negative. A gesture lasts at most 30 s. `UINPUT_UNAVAILABLE`
|
||||
means the shell has no `uinput` or cannot write `/dev/uinput`, `NO_VIEWPORT` that there is no
|
||||
internal display or it is off, and `UINPUT_FAILED` that `uinput` stopped early; all three exit 3.
|
||||
The `uinput` of Android 12 to 14 QPR1 takes only numeric codes, the USB or Bluetooth bus and no
|
||||
`sync` command. Below SDK 34 the pen and the gamepad send that form, with the pen on the USB bus,
|
||||
and success is a clean exit. On SDK 34, which spans both sides of QPR2, the named form goes first
|
||||
and is resent in that form when `uinput` rejects it before registering the device.
|
||||
It needs Android 14 QPR2 or later: the `uinput` of Android 12 to 14 QPR1 takes only numeric codes
|
||||
and the USB or Bluetooth bus, so there the pen ends with `UINPUT_FAILED`.
|
||||
|
||||
## State (schema 2)
|
||||
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
# Battle.net China install, update and cleanup mapping
|
||||
|
||||
Last reviewed: 2026-11-16, against `main` `a20528c` with this change applied. The China
|
||||
version rows were observed on 2026-11-06 at
|
||||
`cn.version.battlenet.com.cn/v2/products/<product>/versions`; installs use
|
||||
`cn.patch.battlenet.com.cn`. #1660 added the China uid aliases to the catalogue and #1661
|
||||
made the Agent driver report Battle.net's own refusal reason instead of `exit 0`; #1705 was
|
||||
closed in favour of this change. This document describes the merged state and supersedes the
|
||||
earlier plan that treated #1705 as pending.
|
||||
|
||||
## Product mapping
|
||||
|
||||
| Game | Store uid | China uid | China product | China version | Handling |
|
||||
|---|---|---|---|---|---|
|
||||
| World of Warcraft | `wow` | same uid | `wow` | 12.1.5.70783 | none |
|
||||
| World of Warcraft Classic | `wow_classic` | same uid | `wow_classic` | 5.5.4.70631 | none |
|
||||
| World of Warcraft Classic Era | `wow_classic_era` | same uid | `wow_classic_era` | 1.15.9.70576 | none |
|
||||
| World of Warcraft Classic Anniversary | `wow_classic_anniversary` | same uid | `wow_anniversary` | 2.5.6.70577 | none |
|
||||
| World of Warcraft: Forever | `wow_forever` | same uid, or unknown uid with product `wowf` | `wowf` | 1.60.1.70790 | in `TITLES`, excluded from `STORE` |
|
||||
| Diablo III | `diablo3` | `d3cn` | `d3cn` | 2.8.1.101167 | alias; install and update use `d3cn` |
|
||||
| Diablo II: Resurrected | `osi` | `osic` | `osic` | 3.3.93854 | alias; install and update use `osic` |
|
||||
| StarCraft II | `s2` | `s2_cn` | `s2c` | 5.0.17.98370 | alias; install maps uid to `s2_cn` and product to `s2c` |
|
||||
| Diablo Immortal | `anbs` | `anbs_cn` | `anbs` | no `cn` row | uid alias only; unverified |
|
||||
| Hearthstone | `hs_beta` | same uid | `hsb` | 37.0.2.256589.255790 | none |
|
||||
| Heroes of the Storm | `heroes` | same uid | `hero` | 2.55.3.89566 | none |
|
||||
| Overwatch 2 | `prometheus` | same uid | `pro` | 2.25.1.0.155284N | none |
|
||||
| StarCraft: Remastered | `s1` | same uid | `s1` | 1.23.10.11269 | none |
|
||||
| Warcraft III: Reforged | `w3` | same uid | `w3` | no `cn` row | none |
|
||||
| `wow_classic_titan` | not in the catalogue | unconfirmed | `wow_classic_titan` | not checked | out of scope |
|
||||
|
||||
No separate China uid has been observed for `wow`, the Classic flavors, `hs_beta`,
|
||||
`heroes`, `prometheus`, `s1` or `w3`; the client reports the store uid for those.
|
||||
|
||||
## What the change does
|
||||
|
||||
### Catalogue
|
||||
|
||||
`BattleNet.CN_UIDS` maps the China uids to the existing cards instead of adding titles of
|
||||
their own:
|
||||
|
||||
- `d3cn` resolves to the `diablo3` card with launch code `D3CN` and product `d3cn`. The
|
||||
standalone `d3cn` title and the `STORE`/`fetchCovers` filters for it are gone.
|
||||
- `osic` resolves to `osi` with product `osic`; `s2_cn` resolves to `s2` with product
|
||||
`s2c`; `anbs_cn` resolves to `anbs` with product `anbs`.
|
||||
- Locale suffixes resolve through the base alias, so `osic_zhcn` and `s2_cn_zhcn` name the
|
||||
same cards.
|
||||
|
||||
A `BattleNet.Game` keeps the store uid in `uid` and the Agent's uid in `installUid`. The
|
||||
Library, the desktop shortcut, the store "installed" state, covers and the launch code
|
||||
therefore agree; a China Diablo III install still lands on the `diablo3` card and launches
|
||||
with `D3CN`.
|
||||
|
||||
### Install driver
|
||||
|
||||
On a China agent (`region == "cn"`) every install sends `account_country = CHN` and
|
||||
`geo_ip_country = CN`, not only the remapped products. Products `osi`, `s2` and `diablo3`
|
||||
become `osic`, `s2c` and `d3cn`; uids become `osic`, `s2_cn` and `d3cn` (`anbs` becomes
|
||||
`anbs_cn`). Updates and uninstalls use the uid the Agent recorded, so they are not
|
||||
remapped.
|
||||
|
||||
### Update checks
|
||||
|
||||
`BattleNetInstall.check()` reads `.build.info`. When its active branch is `cn`, the version
|
||||
query uses the China product (`osic`, `s2c`, `d3cn`); other branches keep the store
|
||||
product. `checkedAt` and `updates` are keyed by `id@folder` (`updateKey`), so an
|
||||
international and a China copy of Diablo III neither suppress nor offer each other's
|
||||
update. `anbs` has no China product mapping, so its China check still asks `anbs`, which
|
||||
has no `cn` row.
|
||||
|
||||
### Install identity
|
||||
|
||||
Update and uninstall select the installed record by its exact folder and use the Agent uid
|
||||
recorded for that folder. A folder with no matching registration is not retargeted to
|
||||
another copy; a game detail opened from a shortcut passes its folder through, so two
|
||||
Diablo III installs, or WoW flavors sharing one folder, do not act on each other.
|
||||
|
||||
### Cancellation ownership
|
||||
|
||||
Before an install starts, a raw `product.db` and `system.reg` query records whether the
|
||||
target folder already has a registration. The query does not require the folder to exist
|
||||
and does not deduplicate by launch code. The result is `PREEXISTING = pending | 0 | 1`; the
|
||||
installer worker resolves it once, persists it through `SavedQueue`, and a shared
|
||||
`Ownership` holder keeps the decision across pause and resume. `SavedQueue` only receives
|
||||
the item after `DownloadQueue.enqueue()` accepts it (`onAccepted`), so a rejected enqueue
|
||||
cannot leave ownership for a task that will not run.
|
||||
|
||||
Cancel uninstalls only a registration that appeared after the task recorded "no
|
||||
registration"; a pre-existing registration is never removed. If either registration source
|
||||
cannot be read, the decision stays conservative (no destructive cleanup) and is not
|
||||
persisted as final. Cleanup is skipped when the worker has not stopped after the wait.
|
||||
`clear()` and `cancel()` share one cleanup claim, and a new enqueue for the same game is
|
||||
rejected while that cleanup runs.
|
||||
|
||||
## Why the version lines differ
|
||||
|
||||
| Product | Observed rows | Build | Note |
|
||||
|---|---|---|---|
|
||||
| `osi` | `us`, `eu`, `kr` | 3.3.93847 | no `cn` row |
|
||||
| `osic` | `cn` | 3.3.93854 | China only |
|
||||
| `s2` | `cn` | 5.0.14.93333 | older China line |
|
||||
| `s2c` | `cn` | 5.0.17.98370 | current China line |
|
||||
| `d3` | `us`, `eu`, `kr`, `tw` | 2.8.0.99920 | no `cn` row |
|
||||
| `d3cn` | `cn` | 2.8.1.101167 | China only |
|
||||
| `anbs` | no `cn` row | - | no separate `anbs_cn` product |
|
||||
| `w3` | no `cn` row | - | keeps the global build |
|
||||
|
||||
### Products without a `cn` row
|
||||
|
||||
`osi`, `d3`, `anbs` and `w3` have no `cn` row, and `anbs_cn` has no product or repository
|
||||
of its own. For `osi` and `d3`, an install made with the store product in a clean folder
|
||||
misses the China line and the Agent falls back to the international build: for Diablo II:
|
||||
Resurrected that is 3.3.93847 instead of the China 3.3.93854. The install succeeds, but
|
||||
`.build.info` and `product.db` now follow the international line, and the BuildConfig
|
||||
differs, so renaming the folder cannot migrate it. `w3` has no China line at all and keeps
|
||||
the global build; `anbs` is unverified (see below).
|
||||
|
||||
### The two sides then disagree
|
||||
|
||||
When the wrong product is installed, `product.db` records `osi` while the China client
|
||||
enumerates `osic`. DroidDeck shows the game as installed, the client shows it as missing,
|
||||
and update, repair and uninstall each follow a different product. No error is reported,
|
||||
which makes this state harder to notice than a visible failure. `s2` is the milder variant:
|
||||
it does have a `cn` row, but that row is the older 5.0.14.93333 line, while `s2c` is the
|
||||
current 5.0.17.98370.
|
||||
|
||||
### Error 800
|
||||
|
||||
Error 800 is not only a China-copy conflict. A folder registered in `product.db`, an empty
|
||||
directory, a directory with residual files from an earlier attempt, or a path earlier
|
||||
registered by a different product can trigger it. This change does not alter those triggers
|
||||
and does not clean them automatically; #1661 now surfaces Battle.net's own refusal reason,
|
||||
so the failure is reported instead of looking like `exit 0`.
|
||||
|
||||
## Automated coverage
|
||||
|
||||
- `BattleNetTest`: China uid aliases including locale suffixes, the `d3cn` alias on the
|
||||
`diablo3` card, folder selection between two Diablo III installs, WoW flavors in one folder,
|
||||
registrations for a missing folder, pre-existing registration protection,
|
||||
created-registration cleanup, registration read failure, restored ownership, per-folder
|
||||
update state, and the cancelled install's folder hold against uninstall.
|
||||
- `BattleNetInstallTest`: `chinaProduct()`, the `s2c` version URL, the `osic`, `s2c` and
|
||||
`anbs` version rows, and per-folder update keys.
|
||||
- `DownloadQueueRetryTest`: double `clear()` single-flight, a rejected enqueue not running
|
||||
its accepted callback, a rejected update preserving the saved ownership snapshot,
|
||||
factoryless cleanup, client-download exclusion, a removal hold waiting for a cancelled
|
||||
Battle.net cleanup, and the restore, install, enqueue chain.
|
||||
- `tools/tests/test_battlenet.py`: the driver's China uid and product maps, the
|
||||
install-only condition, and the `CHN`/`CN` request fields.
|
||||
|
||||
## Not covered
|
||||
|
||||
- Migration of existing wrong-product installs (`osi`, `d3`, `s2`): uninstall through
|
||||
DroidDeck (it calls the Agent with the uid recorded for the folder) and install again;
|
||||
renaming or deleting the folder alone leaves the `product.db` registration behind and can
|
||||
hit 800 on the next attempt.
|
||||
- Automatic cleanup of the wider 800 triggers; #1661 surfaces the reason, it does not
|
||||
remove the registration or the folder.
|
||||
- Diablo Immortal: `anbs` has no `cn` row and `anbs_cn` has no separate product, so whether
|
||||
the Agent falls back to the international build and whether the client accepts `anbs_cn`
|
||||
is unverified. This change does not claim to fix it.
|
||||
- Store region filtering: the store is a static global catalogue and there is no separate
|
||||
China "owned" feed.
|
||||
- WoW Classic family cards and deduplication: `STORE` keeps one `WoWC` card and the game
|
||||
list keeps one folder per launch code. This is an existing design, not a China uid issue.
|
||||
- `wow_forever` (in `TITLES`, excluded from `STORE`) and `wow_classic_titan` (not in
|
||||
`TITLES`) catalogue entries.
|
||||
- Covers for titles without a Steam app id still depend on `us.shop.battle.net`.
|
||||
- The Battle.net client installer's region; it is pinned to `downloader.battle.net`.
|
||||
|
||||
Refs: #1660, #1661, #1705 (closed).
|
||||
@@ -181,10 +181,8 @@ Plugin loaders expose Steam's CEF DevTools so the menu can be viewed in a deskto
|
||||
- The menu's browser view is placed just outside the Big Picture window through its own `SetBounds`, so it keeps rendering but never shows on top, including while Steam slides it wider for Friends and chat. The view is also given the panel's shape (about 712 × 463 instead of Steam's 856 × 463), so every tab shows at one scale. In Full width, a style on the menu page also lifts Steam's 300 px cap on each tab, so every tab fills the panel and Friends shows its list and chat side by side.
|
||||
- A timer inside Steam keeps this state every 250 ms, so the menu comes back, on the tab it was showing, as soon as Steam's main menu or a full-screen page such as Decky's store closes. It runs on a 5 s lease that the panel renews each second: if the app stops, Steam returns to normal by itself.
|
||||
- The hold starts only once the session is ready: holding the menu before Steam's first frame kept gamescope from presenting anything.
|
||||
- `droiddeck-qam-relay` relays the app to the DevTools port, which only answers clients inside the guest. The panel streams the menu with `Page.startScreencast`, scales its content to the panel and fills the rest with the menu's own background, and forwards touches on the menu with `Input.dispatchTouchEvent`. A layout button in the panel's bar cycles Full width (every tab stretched to the panel), Left, Center and Right (Steam's own narrow tabs, placed on that side) and Split (below); the choice is kept. Returning to the panel shows the last frame at once while the stream reconnects, and the first frame after a cold start takes about 1.4 s.
|
||||
- `droiddeck-qam-relay` relays the app to the DevTools port, which only answers clients inside the guest. The panel streams the menu with `Page.startScreencast`, scales its content to the panel and fills the rest with the menu's own background, and forwards touches on the menu with `Input.dispatchTouchEvent`. A layout button in the panel's bar cycles Full width (every tab stretched to the panel), Left, Center and Right (Steam's own narrow tabs, placed on that side); the choice is kept. Returning to the panel shows the last frame at once while the stream reconnects, and the first frame after a cold start takes about 1.4 s.
|
||||
- The Quick Access button still shows the menu on the top screen, in Steam's own layout and with the controller; closing it there (B or the button again) returns it to the bottom screen on the same tab.
|
||||
- The Split layout puts Steam's main menu (the Steam button's menu) on the left and Quick Access on the right. Both are laid out 480 CSS pixels tall so they show at one scale: the main menu at Steam's own 240 px width with its rows spread over the full height, Quick Access across the rest. Steam keeps one side menu open at a time and slides the other out, so the main menu's view is kept visible, parked beside Quick Access's, and a style on its page holds it in place. Steam's views carry no names: the main menu's is the one Steam focuses while the main menu is open, so after Steam starts the panel opens it once, parked before it is drawn. Taps on either half go to that menu; in a game, the running game's card at the top of the main menu returns to it. The Steam button still shows the main menu on the top screen in Steam's own layout, and closing it returns both menus to the bottom. Checked on the AYN Thor in Big Picture and in Bomb Rush Cyberfunk, with the game keeping focus.
|
||||
- Only Quick Access's own view is parked: the one Steam focuses while Quick Access is open. Store and other web pages live in another view, which keeps the bounds Steam gives it, and Steam's frosted glass over the Store page is left off while the menu is parked rather than over it.
|
||||
- Leaving the panel closes the menu and turns the patches off; the Steam button and the normal Quick Access button then work as before. Opening Steam's main menu replaces the Quick Access menu for as long as it is open, as on a Deck.
|
||||
|
||||
Checked with Decky Loader 3.3.1 enabled: its tab renders and takes touch, and its store opens full screen on top with the controller, then returns to the Decky tab below. Decky hooks the menu after Steam starts, so the panel reopens it once when that happens.
|
||||
@@ -203,10 +201,6 @@ Limits: it relies on Steam's minified UI stores and method names, so a client up
|
||||
| --- | --- |
|
||||
|  |  |
|
||||
|
||||
| Layout: Split | Split, in a game |
|
||||
| --- | --- |
|
||||
|  |  |
|
||||
|
||||
The top screen during that game, with the menu open on the bottom: 
|
||||
|
||||
## Related fixes
|
||||
|
||||
@@ -27,28 +27,6 @@ bytes for dimensions at least four pixels:
|
||||
|
||||
These are pixel payloads, not driver allocation sizes or measured FPS gains.
|
||||
|
||||
## Scratch ownership and rebuilds
|
||||
|
||||
Each `FrameGen` instance owns its scratch buffers, mappings and descriptor sets.
|
||||
A size or live-preset rebuild first confirms GPU completion and resets that
|
||||
instance's descriptor pool, then releases the old scratch and image resources.
|
||||
Motion/history validity is reset with the rebuilt images. Repeated preparation
|
||||
at the same size and ordinary frame recording do not add device-idle waits.
|
||||
|
||||
Healthy destruction releases the descriptor pool, mapped scratch buffers and
|
||||
images. The native engine releases its input ring only after the chain confirms
|
||||
completion, so an input image is not destroyed before the wait.
|
||||
|
||||
If `vkDeviceWaitIdle` fails with an error other than
|
||||
`VK_ERROR_DEVICE_LOST`, the affected instance becomes unusable: further
|
||||
recording and rebuilding stop, and its Vulkan resources and input ring are
|
||||
intentionally retained because GPU completion is unknown. Device loss follows
|
||||
a separate teardown path: `FrameGen::destroy()` releases its owned resources
|
||||
without another wait and returns true, allowing the Engine to release the
|
||||
input ring. This is local DD-FG containment, not compositor-wide GPU recovery.
|
||||
A descriptor-pool reset failure also stops that resize without releasing the
|
||||
resources, but healthy teardown can still release them.
|
||||
|
||||
## Validation
|
||||
|
||||
Run `python3 -m unittest discover -s tools/tests -p 'test_ddfg_flow_levels.py'`.
|
||||
@@ -57,10 +35,4 @@ selected through the usual SDK/NDK environment variables. It compiles the actual
|
||||
DD-FG chain against a mock Vulkan dispatch table and checks resource counts,
|
||||
dispatch order and sizes, valid descriptor bindings, both models, every preset,
|
||||
2x/3x/4x generation, small/odd extents, resize and live preset changes.
|
||||
The same harness enforces descriptor-pool capacity, accounts for all live
|
||||
resources, and models pending GPU work to reject early cleanup. Lifecycle cases
|
||||
cover repeated rebuilds, same-size restarts, two simultaneous instances,
|
||||
automatic/idempotent destruction, partial resize allocation, failed GPU waits,
|
||||
and failed descriptor-pool resets. The actual native `Engine` is included to
|
||||
check the input-ring destruction order.
|
||||
It does not execute shaders on a GPU or replace on-device validation.
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 288 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 397 KiB |
@@ -1,68 +0,0 @@
|
||||
# Experimental spatial upscaling after frame generation
|
||||
|
||||
The compositor limits effects output to the logical scene size while frame
|
||||
generation is active. This avoids running interpolation over the full phone
|
||||
panel, but can make FSR/GSR/NIS see equal input and output sizes and skip their
|
||||
spatial pass. Version 0.5.0 instead upscaled before interpolation, which made
|
||||
the interpolation workload scale with panel resolution.
|
||||
|
||||
This experiment keeps the existing source-resolution selection and runs frame
|
||||
generation at the effects input size. Each generated frame and the final real
|
||||
frame then uses the selected spatial filter at the mapped display size.
|
||||
It introduces no extra frame queue or CPU fence wait. Performance and latency
|
||||
improvements are hypotheses, not measured results.
|
||||
|
||||
## Scope and activation
|
||||
|
||||
Use an SDR game with a real input buffer smaller than the mapped output.
|
||||
Enable frame generation and select AMD FSR 1, FSR Fit, Snapdragon GSR/GSR HQ,
|
||||
or NIS in the scaling filter setting. Keep additional effects (CAS, color,
|
||||
FXAA, CRT, etc.) off for this experiment. Sharpen-only, linear, nearest,
|
||||
frame-generation-off, HDR and cardboard paths retain their existing behavior.
|
||||
Combining a spatial filter with additional effects also retains the old path;
|
||||
this experiment does not claim to fix that combination.
|
||||
|
||||
Source selection remains conservative. A game already rendering a native-size
|
||||
backbuffer cannot recover its lower internal rendering resolution here.
|
||||
Overlays included in the low-resolution input are interpolated/upscaled with
|
||||
that input; this is not a separate native-resolution HUD reconstruction.
|
||||
|
||||
GPU targets and source descriptors are separate for each presentation slot so
|
||||
recording one generated frame cannot replace another frame's bindings.
|
||||
Source views are released after the existing frame-completion fence; targets
|
||||
are cached and destroyed with the effects device. This increases GPU memory
|
||||
use with interpolation multiplier and panel resolution. Allocation failures
|
||||
retain the input-sized image and the existing screen blit fallback.
|
||||
|
||||
## Applying and reverting
|
||||
|
||||
Install the test APK produced for this PR. Check its signing/package identity
|
||||
before replacing an installed release: an Actions test-key APK is not a
|
||||
release-signed update. An official signed test build requires the repository's
|
||||
normal publication authorization. Back up session logs and record the exact
|
||||
APK commit, GPU driver, engine and game settings for comparisons.
|
||||
|
||||
No setting migration is required. Disable frame generation or select Linear
|
||||
to return to the previous presentation path. Do not mix this test with Vulkan
|
||||
feature-level or game compatibility changes.
|
||||
|
||||
## Device validation required before merge
|
||||
|
||||
- Compare the same scene on baseline main and this branch: FG off/on, Linear,
|
||||
FSR, GSR, GSR HQ, NIS, FSR Fit, sharpen-only and nearest.
|
||||
- Test each supported interpolation multiplier, both engines, warm-up/no
|
||||
generated frames, 720p-to-1080p and 1080p-to-panel scaling, and no upscale.
|
||||
- Check real and generated frames for consistent sharpness, halos, ghosting,
|
||||
text/cursor artifacts, black bars, stretching and frame-order errors.
|
||||
- Change resolution/filter/engine/multiplier live; open Steam/QAM, rotate,
|
||||
suspend/resume and stop/restart. Verify no stale image, GPU loss or crash.
|
||||
- Confirm HDR, cardboard, FG-off and additional-effects fallback behavior.
|
||||
- Compare sustained frame pacing, generated vs real FPS, GPU load, memory,
|
||||
temperature and battery use after warm-up; do not treat output FPS alone as
|
||||
lower input latency. Measure input-to-display latency if equipment permits.
|
||||
- Test memory pressure and allocation failure fallback; inspect Vulkan
|
||||
validation for descriptor lifetime, image layouts and synchronization.
|
||||
|
||||
Host harnesses exercise resolution routing, generated/real frame counts,
|
||||
filter gates, fallback and source descriptor lifetime. They do not validate
|
||||
shader output, mobile-driver behavior, performance or physical input latency.
|
||||
@@ -1,28 +0,0 @@
|
||||
# Screen-effect pipeline creation
|
||||
|
||||
The screen-effect chain creates its shared render passes, sampler, descriptor
|
||||
layout/pool and pipeline layout when first used. Graphics pipelines are created
|
||||
only when the frame's settings require them, then reused until output-format
|
||||
reset or explicit chain teardown. Source-image and size changes keep the cache.
|
||||
|
||||
Pipeline preparation happens before any effect draw is recorded. If a required
|
||||
pipeline fails to initialize, the chain follows its existing whole-chain
|
||||
fallback and returns the unprocessed scene; it does not record a partial stack.
|
||||
Settings are snapshotted at frame entry, so changes during recording apply to
|
||||
the next invocation.
|
||||
|
||||
Spatial upscalers are prepared only when their dispatch path is active. FSR
|
||||
creates EASU and creates RCAS only when sharpening is enabled; sharpen-only
|
||||
mode creates RCAS. SMAA prepares its three passes only when selected, while
|
||||
keeping FXAA available for the existing SMAA scratch-allocation fallback.
|
||||
Half-precision shaders remain selected by the existing debug property. The
|
||||
optional fast NIS path and its coefficient resources are deferred until NIS is
|
||||
actually used; the existing fragment-shader fallback is retained.
|
||||
|
||||
This reduces unused pipeline creation and first-use setup work. It does not
|
||||
reduce the shader work performed each frame, and first use of a newly selected
|
||||
effect may still compile its pipelines. No background precompilation is added.
|
||||
Pipeline-count reductions are not measurements of startup latency or FPS.
|
||||
|
||||
Validation still requires the native effect-chain tests and on-device visual
|
||||
testing. Static source checks alone do not establish Vulkan runtime correctness.
|
||||
@@ -71,7 +71,7 @@ both build jobs verify the Arch Linux ARM signature and pinned SHA-256 as for ev
|
||||
The desktop workflow replaces the same-version `kwin_wayland` executable and `libkwin.so`; the rest
|
||||
comes from the signature-checked Arch packages. `desktop-kde.kwin.txt` records the source, patch,
|
||||
executable, library and build package hashes. Corresponding source is
|
||||
https://download.kde.org/stable/plasma/6.8.3/kwin-6.8.3.tar.xz plus the patch in this repository.
|
||||
https://download.kde.org/stable/plasma/6.8.2/kwin-6.8.2.tar.xz plus the patch in this repository.
|
||||
|
||||
The inventories use `.gzip` rather than `.gz`: Android's asset packer expands `.gz` and strips
|
||||
its suffix. The shared local/CI runtime payload check verifies the exact APK names and bytes.
|
||||
|
||||
@@ -6,7 +6,7 @@ here=$(cd "$(dirname "$0")" && pwd)
|
||||
source "$here/kwin.env"
|
||||
source "$here/mesa.env"
|
||||
version=$DESKTOP_KWIN_VERSION
|
||||
source_sha=fd5cb783f220ea4526a9afee2f72b582c3e87ef7f91b19bc5c7a6662ffe7fbdc
|
||||
source_sha=ea5e68d957c7d70abed97222a592d4445fda29129e20942658badd224ee138b4
|
||||
mirror=https://fl.us.mirror.archlinuxarm.org/aarch64
|
||||
builder=68B3537F39A313B3E574D06777193F152BDBE6A6
|
||||
work=$(mktemp -d)
|
||||
|
||||
@@ -1 +1 @@
|
||||
DESKTOP_KWIN_VERSION=6.8.3
|
||||
DESKTOP_KWIN_VERSION=6.8.2
|
||||
@@ -8,8 +8,8 @@ Third-party files in DroidDeck's KDE desktop package (tools/desktop-kde/overlay)
|
||||
- steam.svg: Papirus icon theme (https://github.com/PapirusDevelopmentTeam/papirus-icon-theme),
|
||||
GPL-3.0.
|
||||
|
||||
- kwin_wayland: KWin 6.8.3, GPL-2.0-or-later. Built with DroidDeck's nested desktop scale patch.
|
||||
Corresponding source: https://download.kde.org/stable/plasma/6.8.3/kwin-6.8.3.tar.xz and
|
||||
- kwin_wayland: KWin 6.8.2, GPL-2.0-or-later. Built with DroidDeck's nested desktop scale patch.
|
||||
Corresponding source: https://download.kde.org/stable/plasma/6.8.2/kwin-6.8.2.tar.xz and
|
||||
https://github.com/Droid-Deck/DroidDeck/tree/fix/kde-desktop-followups/tools/desktop-kde/patches
|
||||
(the source and patch hashes are recorded in desktop-kde.kwin.txt beside the package).
|
||||
|
||||
|
||||
+17
-83
@@ -750,16 +750,13 @@ def uinput_commands(samples: list[dict], tool: str, viewport: dict) -> list[dict
|
||||
return {"code": code, "info": {"value": 0, "minimum": low, "maximum": high, "fuzz": 0, "flat": 0, "resolution": 0}}
|
||||
|
||||
commands = [
|
||||
# The bus comes after the codes: a `uinput` without the virtual bus fails on it with no "Error reading in
|
||||
# object", while symbolic codes read first produce that message and send the script round again as numbers.
|
||||
{"id": 1, "command": "register", "name": "DroidDeck agent pen", "configuration": [
|
||||
{"id": 1, "command": "register", "name": "DroidDeck agent pen", "bus": "virtual", "configuration": [
|
||||
{"type": "UI_SET_EVBIT", "data": ["EV_KEY", "EV_ABS"]},
|
||||
{"type": "UI_SET_KEYBIT", "data": ["BTN_TOOL_PEN", "BTN_TOOL_RUBBER", "BTN_TOUCH", "BTN_STYLUS", "BTN_STYLUS2"]},
|
||||
{"type": "UI_SET_ABSBIT", "data": ["ABS_X", "ABS_Y", "ABS_PRESSURE", "ABS_DISTANCE", "ABS_TILT_X", "ABS_TILT_Y"]},
|
||||
{"type": "UI_SET_PROPBIT", "data": ["INPUT_PROP_DIRECT"]},
|
||||
], "abs_info": [axis("ABS_X", 0, width - 1), axis("ABS_Y", 0, height - 1), axis("ABS_PRESSURE", 0, UINPUT_PRESSURE),
|
||||
axis("ABS_DISTANCE", 0, UINPUT_DISTANCE), axis("ABS_TILT_X", -90, 90), axis("ABS_TILT_Y", -90, 90)],
|
||||
"bus": "virtual"},
|
||||
axis("ABS_DISTANCE", 0, UINPUT_DISTANCE), axis("ABS_TILT_X", -90, 90), axis("ABS_TILT_Y", -90, 90)]},
|
||||
{"id": 1, "command": "delay", "duration": UINPUT_REGISTER_MS},
|
||||
]
|
||||
sent = {tool_key: 0, "BTN_TOUCH": 0, "BTN_STYLUS": 0, "BTN_STYLUS2": 0}
|
||||
@@ -795,91 +792,27 @@ def uinput_commands(samples: list[dict], tool: str, viewport: dict) -> list[dict
|
||||
{"id": 1, "command": "sync", "syncToken": UINPUT_SYNC}]
|
||||
|
||||
|
||||
def uinput_check(adb: str, serial: str) -> int:
|
||||
"""Checks the device can inject through `uinput` and returns its SDK level."""
|
||||
def uinput_check(adb: str, serial: str) -> None:
|
||||
probe = run_adb(adb, serial, "shell",
|
||||
"command -v uinput >/dev/null 2>&1 || echo no-uinput; [ -w /dev/uinput ] || echo no-dev-uinput; "
|
||||
"echo sdk=$(getprop ro.build.version.sdk)")
|
||||
"command -v uinput >/dev/null 2>&1 || echo no-uinput; [ -w /dev/uinput ] || echo no-dev-uinput")
|
||||
if probe.returncode != 0:
|
||||
raise ControlError((probe.stdout + probe.stderr).decode(errors="replace").strip() or "adb shell failed", "ADB_FAILED")
|
||||
words = probe.stdout.decode(errors="replace").split()
|
||||
if "no-uinput" in words:
|
||||
missing = probe.stdout.decode(errors="replace").split()
|
||||
if "no-uinput" in missing:
|
||||
raise ControlError("This device's shell has no `uinput` command", "UINPUT_UNAVAILABLE")
|
||||
if "no-dev-uinput" in words:
|
||||
if "no-dev-uinput" in missing:
|
||||
raise ControlError("The ADB shell cannot write /dev/uinput on this device", "UINPUT_UNAVAILABLE")
|
||||
sdk = next((w[4:] for w in words if w.startswith("sdk=")), "")
|
||||
return int(sdk) if sdk.isdigit() else UINPUT_NAMED_SDK
|
||||
|
||||
|
||||
# Android 14 QPR2 taught `uinput` symbolic event names, the `sync` command and the virtual bus. Earlier versions stop at
|
||||
# the register line with "Error reading in object" before any device exists, so their scripts carry Linux's numeric
|
||||
# codes, register on the USB bus and end without `sync`. SDK 34 covers both sides of QPR2, so it is tried named first.
|
||||
UINPUT_NAMED_SDK = 34
|
||||
UINPUT_REJECTED = "Error reading in object"
|
||||
UINPUT_CODES = {
|
||||
"EV_SYN": 0, "EV_KEY": 1, "EV_ABS": 3, "SYN_REPORT": 0, "INPUT_PROP_DIRECT": 1,
|
||||
"BTN_SOUTH": 304, "BTN_EAST": 305, "BTN_NORTH": 307, "BTN_WEST": 308, "BTN_TL": 310, "BTN_TR": 311,
|
||||
"BTN_SELECT": 314, "BTN_START": 315, "BTN_MODE": 316, "BTN_THUMBL": 317, "BTN_THUMBR": 318,
|
||||
"BTN_TOOL_PEN": 320, "BTN_TOOL_RUBBER": 321, "BTN_TOUCH": 330, "BTN_STYLUS": 331, "BTN_STYLUS2": 332,
|
||||
"ABS_X": 0, "ABS_Y": 1, "ABS_RX": 3, "ABS_RY": 4, "ABS_HAT0X": 16, "ABS_HAT0Y": 17,
|
||||
"ABS_PRESSURE": 24, "ABS_DISTANCE": 25, "ABS_TILT_X": 26, "ABS_TILT_Y": 27,
|
||||
}
|
||||
UINPUT_CONFIG_CODES = {"UI_SET_EVBIT": 100, "UI_SET_KEYBIT": 101, "UI_SET_ABSBIT": 103, "UI_SET_PROPBIT": 110}
|
||||
|
||||
|
||||
def uinput_script(commands: list[dict], legacy: bool) -> str:
|
||||
"""The `uinput -` input: as written, or for [legacy] `uinput` numeric, on the USB bus and without `sync`."""
|
||||
if legacy:
|
||||
def code(value):
|
||||
return UINPUT_CODES[value] if isinstance(value, str) else value
|
||||
|
||||
numeric = []
|
||||
for command in commands:
|
||||
if command["command"] == "sync":
|
||||
continue
|
||||
command = dict(command)
|
||||
if command["command"] == "register":
|
||||
if command.get("bus") == "virtual":
|
||||
command["bus"] = "usb"
|
||||
command["configuration"] = [{"type": UINPUT_CONFIG_CODES[c["type"]], "data": [code(d) for d in c["data"]]}
|
||||
for c in command["configuration"]]
|
||||
command["abs_info"] = [dict(a, code=code(a["code"])) for a in command.get("abs_info", [])]
|
||||
elif command["command"] == "inject":
|
||||
command["events"] = [code(e) for e in command["events"]]
|
||||
numeric.append(command)
|
||||
commands = numeric
|
||||
return "".join(json.dumps(command) + "\n" for command in commands)
|
||||
|
||||
|
||||
def uinput_finished(result: subprocess.CompletedProcess, token: str, legacy: bool) -> bool:
|
||||
"""Whether `uinput` ran the whole script: by its sync token, or for [legacy] `uinput` by a clean exit."""
|
||||
out = result.stdout.decode(errors="replace")
|
||||
if not legacy:
|
||||
return token in out
|
||||
text = out + (result.stderr or b"").decode(errors="replace")
|
||||
return result.returncode == 0 and "Error" not in text and "Exception" not in text
|
||||
|
||||
|
||||
def uinput_run(adb: str, serial: str, sdk: int, commands: list[dict], token: str,
|
||||
timeout: float) -> tuple[subprocess.CompletedProcess, bool]:
|
||||
"""Runs [commands] through `uinput -` in the form the device reads; returns the result and whether it finished."""
|
||||
legacy = sdk < UINPUT_NAMED_SDK
|
||||
result = run_adb(adb, serial, "shell", "uinput", "-", stdin=uinput_script(commands, legacy).encode(), timeout=timeout)
|
||||
out = result.stdout.decode(errors="replace")
|
||||
if not legacy and UINPUT_REJECTED in out and token not in out:
|
||||
legacy = True
|
||||
result = run_adb(adb, serial, "shell", "uinput", "-", stdin=uinput_script(commands, legacy).encode(), timeout=timeout)
|
||||
return result, uinput_finished(result, token, legacy)
|
||||
|
||||
|
||||
def pen_uinput(adb: str, serial: str, samples: list[dict], tool: str) -> dict:
|
||||
sdk = uinput_check(adb, serial)
|
||||
uinput_check(adb, serial)
|
||||
viewport = input_viewport(run_adb(adb, serial, "shell", "dumpsys", "input").stdout.decode(errors="replace"))
|
||||
script = "".join(json.dumps(command) + "\n" for command in uinput_commands(samples, tool, viewport))
|
||||
started = time.monotonic()
|
||||
result, finished = uinput_run(adb, serial, sdk, uinput_commands(samples, tool, viewport), UINPUT_SYNC,
|
||||
(UINPUT_REGISTER_MS + samples[-1]["t"] + UINPUT_TAIL_MS) / 1000 + 30)
|
||||
result = run_adb(adb, serial, "shell", "uinput", "-", stdin=script.encode(),
|
||||
timeout=(UINPUT_REGISTER_MS + samples[-1]["t"] + UINPUT_TAIL_MS) / 1000 + 30)
|
||||
elapsed = round((time.monotonic() - started) * 1000)
|
||||
if not finished:
|
||||
if UINPUT_SYNC not in result.stdout.decode(errors="replace"):
|
||||
detail = (result.stderr or result.stdout).decode(errors="replace").strip()[-400:]
|
||||
raise ControlError(f"uinput stopped before the end of the gesture (exit {result.returncode})"
|
||||
+ (f": {detail}" if detail else "") + "; `adb logcat -s UINPUT UinputDevice` tells why",
|
||||
@@ -936,12 +869,13 @@ def gamepad_commands(buttons: list[str], hold: int, gap: int) -> list[dict]:
|
||||
|
||||
def gamepad_uinput(adb: str, serial: str, buttons: list[str], hold: int, gap: int) -> dict:
|
||||
commands = gamepad_commands(buttons, hold, gap)
|
||||
sdk = uinput_check(adb, serial)
|
||||
uinput_check(adb, serial)
|
||||
script = "".join(json.dumps(command) + "\n" for command in commands)
|
||||
started = time.monotonic()
|
||||
result, finished = uinput_run(adb, serial, sdk, commands, GAMEPAD_SYNC,
|
||||
(UINPUT_REGISTER_MS + len(buttons) * (hold + gap) + UINPUT_TAIL_MS) / 1000 + 30)
|
||||
result = run_adb(adb, serial, "shell", "uinput", "-", stdin=script.encode(),
|
||||
timeout=(UINPUT_REGISTER_MS + len(buttons) * (hold + gap) + UINPUT_TAIL_MS) / 1000 + 30)
|
||||
elapsed = round((time.monotonic() - started) * 1000)
|
||||
if not finished:
|
||||
if GAMEPAD_SYNC not in result.stdout.decode(errors="replace"):
|
||||
detail = (result.stderr or result.stdout).decode(errors="replace").strip()[-400:]
|
||||
raise ControlError(f"uinput stopped before the last button (exit {result.returncode})"
|
||||
+ (f": {detail}" if detail else "") + "; `adb logcat -s UINPUT UinputDevice` tells why",
|
||||
|
||||
@@ -21,10 +21,9 @@ library list, before anything is published.
|
||||
trip to Xwayland on the paint thread; with no image, wlserver's position is used as upstream does.
|
||||
- `0101-nested-wayland-cursor-routing.patch` - this app: `gamescope_cursor_composite=2` lets the
|
||||
nested Wayland session paint its cursor in the output using the real X pointer position; client
|
||||
cursor surfaces are cleared to prevent a duplicate at the host pointer, and so is Gamescope's
|
||||
default host-cursor fallback, which would otherwise show a second arrow until Gamescope gets
|
||||
keyboard focus. Empty client cursor images and Gamescope's hidden flag still suppress the
|
||||
painted cursor.
|
||||
cursor surfaces are cleared to prevent a duplicate at the host pointer, while Gamescope's original
|
||||
default host-cursor fallback is preserved when its no-keyboard-focus policy selects it. Empty
|
||||
client cursor images and Gamescope's hidden flag still suppress the painted cursor.
|
||||
- `0110-wayland-backend-touch.patch` - this app: the nested Wayland backend bound only the host's
|
||||
pointer and keyboard, so a finger on the phone's screen never reached Steam. It now binds
|
||||
`wl_touch` too and hands each finger to wlserver's touch path (`wlserver_touchdown` / `motion` /
|
||||
@@ -485,14 +484,3 @@ not wait on fences attached to a dma-buf, so the composite now checks each outpu
|
||||
It picks the next image that is neither held by the host nor still being scanned out. Only when every free image is
|
||||
still on the display does it wait for one, up to 100 ms. On kernels that cannot attach the fence, the host keeps
|
||||
waiting itself and nothing changes. `tools/gamescope/tests/nested-swapchain.cpp` covers the choice and the busy check.
|
||||
|
||||
## 0147 Wayland backend: a forwarded client buffer goes back to its client only after scanout
|
||||
|
||||
When no composite is needed, gamescope hands a client's own buffer to the host compositor as a plane. The host now
|
||||
releases a buffer as soon as the display latches the next one and leaves its release fence on the buffer's dma-buf.
|
||||
gamescope returned the buffer to the client on that release, and a client whose Vulkan driver does not wait on
|
||||
fences attached to a dma-buf then drew into it while the display was still scanning it out, which showed as black
|
||||
tiles in compressed buffers. A forwarded client buffer now stays held until `poll(POLLOUT)` on its dma-buf reports
|
||||
that the display has finished with it, on a waiter thread so nothing else blocks. A release that arrives after the
|
||||
buffer was shown again is dropped, so the later release decides. Composite output images keep the 0146 path, and a
|
||||
host that waits for the fence itself releases buffers that are already idle, so nothing changes there.
|
||||
@@ -74,7 +74,7 @@ index 0000000..d7c21da
|
||||
+
|
||||
+ constexpr bool CursorShouldBeForwardedToHost( int cursorCompositeMode, bool useHostCursorFallback )
|
||||
+ {
|
||||
+ return cursorCompositeMode != 2;
|
||||
+ return cursorCompositeMode != 2 || useHostCursorFallback;
|
||||
+ }
|
||||
+
|
||||
+ constexpr bool CursorImageShouldBePainted( bool imageEmpty, bool cursorHidden )
|
||||
@@ -176,10 +176,10 @@ index 0000000..9c622db
|
||||
+ REQUIRE( CursorShouldBeComposited( 2, false, false, true, false ) );
|
||||
+}
|
||||
+
|
||||
+TEST_CASE("manual composition never forwards a cursor to the host", "[cursor_routing]")
|
||||
+TEST_CASE("manual composition retains only the no-focus default cursor fallback", "[cursor_routing]")
|
||||
+{
|
||||
+ REQUIRE_FALSE( CursorShouldBeForwardedToHost( 2, false ) );
|
||||
+ REQUIRE_FALSE( CursorShouldBeForwardedToHost( 2, true ) );
|
||||
+ REQUIRE( CursorShouldBeForwardedToHost( 2, true ) );
|
||||
+ REQUIRE( CursorShouldBeForwardedToHost( 1, false ) );
|
||||
+ REQUIRE( CursorShouldBeForwardedToHost( 0, false ) );
|
||||
+}
|
||||
|
||||
@@ -1,351 +0,0 @@
|
||||
diff --git a/src/Backends/WaylandBackend.cpp b/src/Backends/WaylandBackend.cpp
|
||||
index 12f0f50..a0fedd4 100644
|
||||
--- a/src/Backends/WaylandBackend.cpp
|
||||
+++ b/src/Backends/WaylandBackend.cpp
|
||||
@@ -3,24 +3,28 @@
|
||||
#include "wlserver.hpp"
|
||||
#include "vblankmanager.hpp"
|
||||
#include "steamcompmgr.hpp"
|
||||
#include "edid.h"
|
||||
#include "Utils/Defer.h"
|
||||
#include "Utils/Algorithm.h"
|
||||
#include "convar.h"
|
||||
#include "refresh_rate.h"
|
||||
#include "waitable.h"
|
||||
#include "Utils/TempFiles.h"
|
||||
#include "Utils/CursorRouting.h"
|
||||
#include "Utils/WaylandScaling.h"
|
||||
+#include "output_image_pick.hpp"
|
||||
+
|
||||
+#include <fcntl.h>
|
||||
+#include <mutex>
|
||||
|
||||
#include <cstring>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <csignal>
|
||||
#include <sys/mman.h>
|
||||
#include <poll.h>
|
||||
#include <linux/input-event-codes.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
#include <libdecor.h>
|
||||
|
||||
#include "wlr_begin.hpp"
|
||||
@@ -485,44 +489,82 @@ namespace gamescope
|
||||
|
||||
// One backing plane plus every layer steamcompmgr can hand us.
|
||||
CWaylandPlane m_Planes[k_nMaxLayers + 1];
|
||||
bool m_bVisible = true;
|
||||
std::atomic<bool> m_bDesiredFullscreenState = { false };
|
||||
|
||||
bool m_bHostCompositorIsCurrentlyVRR = false;
|
||||
};
|
||||
|
||||
class CWaylandFb final : public CBaseBackendFb
|
||||
{
|
||||
public:
|
||||
- CWaylandFb( CWaylandBackend *pBackend, wl_buffer *pHostBuffer );
|
||||
+ CWaylandFb( CWaylandBackend *pBackend, wl_buffer *pHostBuffer, int nDmabufFd = -1 );
|
||||
~CWaylandFb();
|
||||
|
||||
void OnCompositorAcquire();
|
||||
void OnCompositorRelease();
|
||||
+ void OnScanoutDone( uint64_t ulAcquireSerial );
|
||||
|
||||
wl_buffer *GetHostBuffer() const { return m_pHostBuffer; }
|
||||
wlr_buffer *GetClientBuffer() const { return m_pClientBuffer; }
|
||||
|
||||
bool HeldByHost() const override { return m_bCompositorAcquired; }
|
||||
|
||||
void Wayland_Buffer_Release( wl_buffer *pBuffer );
|
||||
static const wl_buffer_listener s_BufferListener;
|
||||
|
||||
private:
|
||||
CWaylandBackend *m_pBackend = nullptr;
|
||||
wl_buffer *m_pHostBuffer = nullptr;
|
||||
wlr_buffer *m_pClientBuffer = nullptr;
|
||||
+ int m_nDmabufFd = -1;
|
||||
+ std::mutex m_AcquireMutex;
|
||||
+ uint64_t m_ulAcquireSerial = 0;
|
||||
bool m_bCompositorAcquired = false;
|
||||
};
|
||||
+
|
||||
+ class CWaylandScanoutRelease final : public IWaitable
|
||||
+ {
|
||||
+ public:
|
||||
+ CWaylandScanoutRelease( CWaylandFb *pFb, int nFd, uint64_t ulAcquireSerial )
|
||||
+ : m_pFb{ pFb }
|
||||
+ , m_nFd{ nFd }
|
||||
+ , m_ulAcquireSerial{ ulAcquireSerial }
|
||||
+ {
|
||||
+ }
|
||||
+
|
||||
+ int GetFD() override { return m_nFd; }
|
||||
+ void OnPollOut() override { Finish(); }
|
||||
+ void OnPollHangUp() override { Finish(); }
|
||||
+
|
||||
+ static CAsyncWaiter<> &Waiter()
|
||||
+ {
|
||||
+ static CAsyncWaiter<> s_Waiter{ "gamescope-scanout" };
|
||||
+ return s_Waiter;
|
||||
+ }
|
||||
+
|
||||
+ private:
|
||||
+ void Finish()
|
||||
+ {
|
||||
+ Waiter().RemoveWaitable( this );
|
||||
+ m_pFb->OnScanoutDone( m_ulAcquireSerial );
|
||||
+ close( m_nFd );
|
||||
+ delete this;
|
||||
+ }
|
||||
+
|
||||
+ CWaylandFb *m_pFb;
|
||||
+ int m_nFd;
|
||||
+ uint64_t m_ulAcquireSerial;
|
||||
+ };
|
||||
const wl_buffer_listener CWaylandFb::s_BufferListener =
|
||||
{
|
||||
.release = WAYLAND_USERDATA_TO_THIS( CWaylandFb, Wayland_Buffer_Release ),
|
||||
};
|
||||
|
||||
class CWaylandInputThread
|
||||
{
|
||||
public:
|
||||
CWaylandInputThread();
|
||||
~CWaylandInputThread();
|
||||
|
||||
bool Init( CWaylandBackend *pBackend );
|
||||
@@ -969,73 +1011,108 @@ namespace gamescope
|
||||
.action = WAYLAND_NULL(),
|
||||
};
|
||||
const zwp_primary_selection_source_v1_listener CWaylandBackend::s_PrimarySelectionSourceListener =
|
||||
{
|
||||
.send = WAYLAND_USERDATA_TO_THIS( CWaylandBackend, Wayland_PrimarySelectionSource_Send ),
|
||||
.cancelled = WAYLAND_USERDATA_TO_THIS( CWaylandBackend, Wayland_PrimarySelectionSource_Cancelled ),
|
||||
};
|
||||
|
||||
//////////////////
|
||||
// CWaylandFb
|
||||
//////////////////
|
||||
|
||||
- CWaylandFb::CWaylandFb( CWaylandBackend *pBackend, wl_buffer *pHostBuffer )
|
||||
+ CWaylandFb::CWaylandFb( CWaylandBackend *pBackend, wl_buffer *pHostBuffer, int nDmabufFd )
|
||||
: CBaseBackendFb()
|
||||
, m_pBackend { pBackend }
|
||||
, m_pHostBuffer { pHostBuffer }
|
||||
+ , m_nDmabufFd { nDmabufFd }
|
||||
{
|
||||
wl_buffer_add_listener( pHostBuffer, &s_BufferListener, this );
|
||||
}
|
||||
|
||||
CWaylandFb::~CWaylandFb()
|
||||
{
|
||||
// I own the pHostBuffer.
|
||||
wl_buffer_destroy( m_pHostBuffer );
|
||||
m_pHostBuffer = nullptr;
|
||||
+ if ( m_nDmabufFd >= 0 )
|
||||
+ close( m_nDmabufFd );
|
||||
}
|
||||
|
||||
void CWaylandFb::OnCompositorAcquire()
|
||||
{
|
||||
- // If the compositor has acquired us, track that
|
||||
- // and increment the ref count.
|
||||
- if ( !m_bCompositorAcquired )
|
||||
+ bool bTakeRef = false;
|
||||
{
|
||||
+ std::scoped_lock lock( m_AcquireMutex );
|
||||
+ m_ulAcquireSerial++;
|
||||
+ bTakeRef = !m_bCompositorAcquired;
|
||||
m_bCompositorAcquired = true;
|
||||
- IncRef();
|
||||
}
|
||||
+
|
||||
+ if ( bTakeRef )
|
||||
+ IncRef();
|
||||
}
|
||||
|
||||
void CWaylandFb::OnCompositorRelease()
|
||||
{
|
||||
- // Compositor has released us, decrement rc.
|
||||
- //assert( m_bCompositorAcquired );
|
||||
+ uint64_t ulSerial;
|
||||
+ {
|
||||
+ std::scoped_lock lock( m_AcquireMutex );
|
||||
+ ulSerial = m_ulAcquireSerial;
|
||||
+ }
|
||||
+ OnScanoutDone( ulSerial );
|
||||
+ }
|
||||
|
||||
- if ( m_bCompositorAcquired )
|
||||
+ void CWaylandFb::OnScanoutDone( uint64_t ulAcquireSerial )
|
||||
+ {
|
||||
+ bool bDropRef = false;
|
||||
{
|
||||
+ std::scoped_lock lock( m_AcquireMutex );
|
||||
+ if ( ulAcquireSerial != m_ulAcquireSerial )
|
||||
+ return;
|
||||
+ bDropRef = m_bCompositorAcquired;
|
||||
m_bCompositorAcquired = false;
|
||||
- DecRef();
|
||||
}
|
||||
+
|
||||
+ if ( bDropRef )
|
||||
+ DecRef();
|
||||
else
|
||||
- {
|
||||
xdg_log.errorf( "Compositor released us but we were not acquired. Oh no." );
|
||||
- }
|
||||
}
|
||||
|
||||
void CWaylandFb::Wayland_Buffer_Release( wl_buffer *pBuffer )
|
||||
{
|
||||
assert( m_pHostBuffer );
|
||||
assert( m_pHostBuffer == pBuffer );
|
||||
|
||||
xdg_log.debugf( "buffer_release: %p", pBuffer );
|
||||
|
||||
+ if ( ShowsClientBuffer() && gamescope::DmabufScanoutPending( m_nDmabufFd ) )
|
||||
+ {
|
||||
+ int nFd = fcntl( m_nDmabufFd, F_DUPFD_CLOEXEC, 0 );
|
||||
+ if ( nFd >= 0 )
|
||||
+ {
|
||||
+ uint64_t ulSerial;
|
||||
+ {
|
||||
+ std::scoped_lock lock( m_AcquireMutex );
|
||||
+ ulSerial = m_ulAcquireSerial;
|
||||
+ }
|
||||
+ auto *pWait = new CWaylandScanoutRelease( this, nFd, ulSerial );
|
||||
+ if ( CWaylandScanoutRelease::Waiter().AddWaitable( pWait, EPOLLOUT | EPOLLHUP | EPOLLONESHOT ) )
|
||||
+ return;
|
||||
+ delete pWait;
|
||||
+ close( nFd );
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
OnCompositorRelease();
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// CWaylandConnector
|
||||
//////////////////
|
||||
|
||||
CWaylandConnector::CWaylandConnector( CWaylandBackend *pBackend, uint64_t ulVirtualConnectorKey )
|
||||
: CBaseBackendConnector{ ulVirtualConnectorKey }
|
||||
, m_pBackend( pBackend )
|
||||
, m_Planes{ this, this, this, this, this, this, this, this, this }
|
||||
{
|
||||
@@ -2349,25 +2426,26 @@ namespace gamescope
|
||||
pDmaBuf->format,
|
||||
0u );
|
||||
|
||||
if ( !pImportedBuffer )
|
||||
{
|
||||
xdg_log.errorf( "Failed to import dmabuf" );
|
||||
zwp_linux_buffer_params_v1_destroy( pBufferParams );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
zwp_linux_buffer_params_v1_destroy( pBufferParams );
|
||||
|
||||
- return new CWaylandFb{ this, pImportedBuffer };
|
||||
+ int nDmabufFd = pDmaBuf->n_planes > 0 ? fcntl( pDmaBuf->fd[0], F_DUPFD_CLOEXEC, 0 ) : -1;
|
||||
+ return new CWaylandFb{ this, pImportedBuffer, nDmabufFd };
|
||||
}
|
||||
|
||||
bool CWaylandBackend::UsesModifiers() const
|
||||
{
|
||||
if ( !cv_wayland_use_modifiers )
|
||||
return false;
|
||||
|
||||
return m_bCanUseModifiers;
|
||||
}
|
||||
std::span<const uint64_t> CWaylandBackend::GetSupportedModifiers( uint32_t uDrmFormat ) const
|
||||
{
|
||||
auto iter = m_FormatModifiers.find( uDrmFormat );
|
||||
diff --git a/src/backend.cpp b/src/backend.cpp
|
||||
index cc91853..ec59c8b 100644
|
||||
--- a/src/backend.cpp
|
||||
+++ b/src/backend.cpp
|
||||
@@ -109,41 +109,47 @@ namespace gamescope
|
||||
wlserver_unlock();
|
||||
}
|
||||
|
||||
// Potentially release now!
|
||||
DecRefPrivate();
|
||||
}
|
||||
|
||||
return uRefCount;
|
||||
}
|
||||
|
||||
void CBaseBackendFb::SetBuffer( wlr_buffer *pClientBuffer )
|
||||
{
|
||||
+ if ( pClientBuffer )
|
||||
+ m_bShowsClientBuffer = true;
|
||||
+
|
||||
if ( m_pClientBuffer == pClientBuffer )
|
||||
return;
|
||||
|
||||
assert( m_pClientBuffer == nullptr );
|
||||
m_pClientBuffer = pClientBuffer;
|
||||
if ( GetRefCount() )
|
||||
{
|
||||
wlserver_lock();
|
||||
wlr_buffer_lock( m_pClientBuffer );
|
||||
wlserver_unlock( false );
|
||||
}
|
||||
|
||||
m_pReleasePoint = nullptr;
|
||||
}
|
||||
|
||||
void CBaseBackendFb::SetReleasePoint( std::shared_ptr<CReleaseTimelinePoint> pReleasePoint )
|
||||
{
|
||||
+ if ( pReleasePoint )
|
||||
+ m_bShowsClientBuffer = true;
|
||||
+
|
||||
if ( m_pReleasePoint == pReleasePoint )
|
||||
return;
|
||||
|
||||
m_pReleasePoint = pReleasePoint;
|
||||
|
||||
if ( m_pClientBuffer && GetRefCount() )
|
||||
{
|
||||
wlserver_lock();
|
||||
wlr_buffer_unlock( m_pClientBuffer );
|
||||
wlserver_unlock();
|
||||
m_pClientBuffer = nullptr;
|
||||
}
|
||||
diff --git a/src/backend.h b/src/backend.h
|
||||
index 30b42ca..9a27711 100644
|
||||
--- a/src/backend.h
|
||||
+++ b/src/backend.h
|
||||
@@ -303,26 +303,29 @@ namespace gamescope
|
||||
public:
|
||||
CBaseBackendFb();
|
||||
virtual ~CBaseBackendFb();
|
||||
|
||||
uint32_t IncRef() override;
|
||||
uint32_t DecRef() override;
|
||||
|
||||
void SetBuffer( wlr_buffer *pClientBuffer ) override;
|
||||
void SetReleasePoint( std::shared_ptr<CReleaseTimelinePoint> pReleasePoint ) override;
|
||||
|
||||
virtual IBackendFb *EnsureImported() override { return this; };
|
||||
|
||||
+ bool ShowsClientBuffer() const { return m_bShowsClientBuffer; }
|
||||
+
|
||||
private:
|
||||
wlr_buffer *m_pClientBuffer = nullptr;
|
||||
+ std::atomic<bool> m_bShowsClientBuffer = { false };
|
||||
std::shared_ptr<CReleaseTimelinePoint> m_pReleasePoint;
|
||||
};
|
||||
|
||||
class IBackend
|
||||
{
|
||||
public:
|
||||
virtual ~IBackend() {}
|
||||
|
||||
virtual bool Init() = 0;
|
||||
virtual bool PostInit() = 0;
|
||||
virtual std::span<const char *const> GetInstanceExtensions() const = 0;
|
||||
virtual std::span<const char *const> GetDeviceExtensions( VkPhysicalDevice pVkPhysicalDevice ) const = 0;
|
||||
@@ -1,3 +1,3 @@
|
||||
GAMESCOPE_REPO=Droid-Deck/DroidDeck-Components
|
||||
GAMESCOPE_TAG=gamescope-3.16.29-cb9c4861
|
||||
GAMESCOPE_SHA256=89a3d70124a13bb5de0b4c67ff75d748a5d7ba6f29590194621754e3550b1f31
|
||||
GAMESCOPE_TAG=gamescope-3.16.29-f3a45b31
|
||||
GAMESCOPE_SHA256=3908af87b2ee8a328e9780fc805c6a7bddd11d7405b9992d717b94e16c019313
|
||||
@@ -135,6 +135,9 @@ function job(text) {
|
||||
return /"state"\s*:\s*\d+/.test(bare) || /"download_current"\s*:/.test(bare);
|
||||
}
|
||||
|
||||
var CHINA = {osi: "osic", s2: "s2_cn", anbs: "anbs_cn", diablo3: "d3cn"};
|
||||
var CHINA_PRODUCT = {osi: "osic", s2: "s2c", diablo3: "d3cn"};
|
||||
|
||||
function install() {
|
||||
// Blizzard's China repository moved to cn.patch.battlenet.com.cn; cn.patch.battle.net only redirects away from it.
|
||||
var patch = zone == "cn" ? "cn.patch.battlenet.com.cn" : zone + ".patch.battle.net";
|
||||
@@ -193,6 +196,17 @@ try {
|
||||
token = field(agent, "authorization");
|
||||
zone = field(agent, "region") || "us";
|
||||
if (!token) throw new Error("no authorization from the agent");
|
||||
// The China client installs these under uids of its own. s2_cn is served from s2c; anbs_cn shares anbs.
|
||||
if (zone == "cn" && action == "install") {
|
||||
country = "CHN";
|
||||
region = "CN";
|
||||
if (CHINA[uid]) {
|
||||
product = CHINA_PRODUCT[uid] || product;
|
||||
uid = CHINA[uid];
|
||||
}
|
||||
}
|
||||
// The app cancels an install by the uid the Agent really used; report the remapped one.
|
||||
save(".uid", uid);
|
||||
if (action == "install") install(); else if (action == "update") update(); else uninstall();
|
||||
} catch (e) {
|
||||
save(".error", e.message || "the agent stopped answering");
|
||||
@@ -350,17 +364,6 @@ def keeps_open(root):
|
||||
return isinstance(client, dict) and LAUNCH_BEHAVIOR[0] in client and client[LAUNCH_BEHAVIOR[0]] != LAUNCH_BEHAVIOR[1]
|
||||
|
||||
|
||||
def chosen_folder(root, current, library):
|
||||
current = current.strip()
|
||||
folder = windows_path(root, current) if current else None
|
||||
if not folder or rootfs_drive(root, current) or not os.path.isdir(folder):
|
||||
return False
|
||||
try:
|
||||
return volume_root(os.path.realpath(folder)) == volume_root(os.path.realpath(library))
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
||||
def write_config(root, library=None):
|
||||
path = os.path.join(drive_c(root), *CONFIG)
|
||||
key, value = LAUNCH_BEHAVIOR
|
||||
@@ -385,7 +388,6 @@ def write_config(root, library=None):
|
||||
client["HardwareAcceleration"] = "false"
|
||||
changes.append("acceleration")
|
||||
if library and isinstance(client.setdefault("Install", {}), dict) \
|
||||
and not chosen_folder(root, str(client["Install"].get("DefaultInstallPath", "")), library) \
|
||||
and str(client["Install"].get("DefaultInstallPath", "")).rstrip("/\\") != install_path(root, library).rstrip("\\"):
|
||||
client["Install"]["DefaultInstallPath"] = install_path(root, library)
|
||||
changes.append("library")
|
||||
@@ -1513,6 +1515,17 @@ def read_status(path):
|
||||
return None
|
||||
|
||||
|
||||
def read_text(path):
|
||||
try:
|
||||
with open(path, "rb") as f:
|
||||
data = f.read()
|
||||
except OSError:
|
||||
return None
|
||||
if data[:2] in (b"\xff\xfe", b"\xfe\xff"):
|
||||
return data.decode("utf-16", "replace").strip()
|
||||
return data.decode("utf-8", "replace").strip()
|
||||
|
||||
|
||||
def summary(status):
|
||||
out = {key: status[key] for key in REPORTED if key in status}
|
||||
for key in ("download_current", "download_total"):
|
||||
@@ -1565,7 +1578,7 @@ def agent_job(root, action, uid, product="", folder="", locale="enUS", country="
|
||||
emit("STATE", "starting")
|
||||
base = os.path.join(CACHE, "agent-%s" % uid)
|
||||
os.makedirs(CACHE, exist_ok=True)
|
||||
for suffix in (".json", ".game", ".form", ".error"):
|
||||
for suffix in (".json", ".game", ".form", ".error", ".uid"):
|
||||
try:
|
||||
os.unlink(base + suffix)
|
||||
except OSError:
|
||||
@@ -1583,10 +1596,15 @@ def agent_job(root, action, uid, product="", folder="", locale="enUS", country="
|
||||
return 1
|
||||
seen = None
|
||||
mark = None
|
||||
effective = None
|
||||
moved = time.monotonic()
|
||||
stalled = False
|
||||
while True:
|
||||
done = child.poll() is not None
|
||||
if effective is None:
|
||||
effective = read_text(base + ".uid")
|
||||
if effective:
|
||||
emit("UID", effective)
|
||||
status = read_status(base + ".json")
|
||||
if status is not None and action != "uninstall":
|
||||
brief = summary(status)
|
||||
@@ -1632,8 +1650,13 @@ def agent_job(root, action, uid, product="", folder="", locale="enUS", country="
|
||||
if reason is None and action != "uninstall" and game.get("installed") is True \
|
||||
and (game.get("playable") is True or status.get("state") == DONE_STATE):
|
||||
binary = ((game.get("binaries") or {}).get("game") or {}).get("relative_path", "")
|
||||
emit("DONE", json.dumps({"install_dir": game.get("install_dir", windows), "exe": binary,
|
||||
"version": game.get("local_version", "")}, sort_keys=True))
|
||||
if effective is None:
|
||||
effective = read_text(base + ".uid")
|
||||
result = {"install_dir": game.get("install_dir", windows), "exe": binary,
|
||||
"version": game.get("local_version", "")}
|
||||
if effective:
|
||||
result["uid"] = effective
|
||||
emit("DONE", json.dumps(result, sort_keys=True))
|
||||
say("%s %s in %s" % (uid, "updated" if action == "update" else "installed", game.get("install_dir", windows)))
|
||||
return 0
|
||||
if reason is None and action == "uninstall" and (game.get("installed") is False or answer == {}):
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#define _GNU_SOURCE
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "named_semaphores.h"
|
||||
#endif
|
||||
@@ -1,127 +0,0 @@
|
||||
static int posix_shm_path(const char *name, const char *prefix, char *path, size_t size) {
|
||||
if (!name) { errno = EINVAL; return -1; }
|
||||
while (*name == '/') name++;
|
||||
size_t len = strlen(name) + strlen(prefix);
|
||||
if (len == strlen(prefix) || len > NAME_MAX || strchr(name, '/') || strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
|
||||
errno = len > NAME_MAX ? ENAMETOOLONG : EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (snprintf(path, size, "/dev/shm/%s%s", prefix, name) >= (int)size) { errno = ENAMETOOLONG; return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct posix_sem {
|
||||
dev_t dev;
|
||||
ino_t ino;
|
||||
sem_t *addr;
|
||||
unsigned int refs;
|
||||
struct posix_sem *next;
|
||||
};
|
||||
static struct posix_sem *g_posix_sems;
|
||||
static pthread_mutex_t g_posix_sems_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static void posix_sems_unlock(void) { pthread_mutex_unlock(&g_posix_sems_lock); }
|
||||
|
||||
static void posix_sems_hold(void) { pthread_mutex_lock(&g_posix_sems_lock); }
|
||||
|
||||
__attribute__((constructor)) static void posix_sems_across_fork(void) {
|
||||
pthread_atfork(posix_sems_hold, posix_sems_unlock, posix_sems_unlock);
|
||||
}
|
||||
|
||||
static void close_keeping_errno(int fd) {
|
||||
int saved = errno;
|
||||
close(fd);
|
||||
errno = saved;
|
||||
}
|
||||
|
||||
static sem_t *posix_sem_map(int fd) {
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) < 0) return SEM_FAILED;
|
||||
sem_t *sem = SEM_FAILED;
|
||||
posix_sems_hold();
|
||||
struct posix_sem *e = g_posix_sems;
|
||||
while (e && (e->dev != st.st_dev || e->ino != st.st_ino)) e = e->next;
|
||||
if (e) {
|
||||
e->refs++;
|
||||
sem = e->addr;
|
||||
} else {
|
||||
void *addr = mmap(NULL, sizeof(sem_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
e = addr == MAP_FAILED ? NULL : malloc(sizeof(*e));
|
||||
if (e) {
|
||||
*e = (struct posix_sem){st.st_dev, st.st_ino, addr, 1, g_posix_sems};
|
||||
g_posix_sems = e;
|
||||
sem = addr;
|
||||
} else if (addr != MAP_FAILED) {
|
||||
munmap(addr, sizeof(sem_t));
|
||||
errno = ENOMEM;
|
||||
}
|
||||
}
|
||||
posix_sems_unlock();
|
||||
return sem;
|
||||
}
|
||||
|
||||
static sem_t *posix_sem_open_fd(int fd) {
|
||||
if (fd < 0) return SEM_FAILED;
|
||||
sem_t *sem = posix_sem_map(fd);
|
||||
close_keeping_errno(fd);
|
||||
return sem;
|
||||
}
|
||||
|
||||
sem_t *sem_open(const char *name, int oflag, ...) {
|
||||
char path[PATH_MAX];
|
||||
if (posix_shm_path(name, "sem.", path, sizeof(path)) < 0) return SEM_FAILED;
|
||||
if (!(oflag & O_CREAT)) return posix_sem_open_fd(open(path, O_RDWR | O_NOFOLLOW | O_CLOEXEC));
|
||||
va_list args;
|
||||
va_start(args, oflag);
|
||||
mode_t mode = va_arg(args, mode_t);
|
||||
unsigned int value = va_arg(args, unsigned int);
|
||||
va_end(args);
|
||||
static unsigned int serial;
|
||||
for (;;) {
|
||||
if (!(oflag & O_EXCL)) {
|
||||
int fd = open(path, O_RDWR | O_NOFOLLOW | O_CLOEXEC);
|
||||
if (fd >= 0 || errno != ENOENT) return posix_sem_open_fd(fd);
|
||||
}
|
||||
if (value > SEM_VALUE_MAX) { errno = EINVAL; return SEM_FAILED; }
|
||||
sem_t initial;
|
||||
memset(&initial, 0, sizeof(initial));
|
||||
sem_init(&initial, 1, value);
|
||||
char temp[PATH_MAX];
|
||||
int fd;
|
||||
do {
|
||||
snprintf(temp, sizeof(temp), "/dev/shm/.sem-%d-%u", (int)getpid(), __atomic_fetch_add(&serial, 1, __ATOMIC_RELAXED));
|
||||
fd = open(temp, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW | O_CLOEXEC, mode);
|
||||
} while (fd < 0 && errno == EEXIST);
|
||||
if (fd < 0) return SEM_FAILED;
|
||||
errno = EIO;
|
||||
sem_t *sem = write(fd, &initial, sizeof(initial)) == (ssize_t)sizeof(initial) ? posix_sem_map(fd) : SEM_FAILED;
|
||||
close_keeping_errno(fd);
|
||||
if (sem != SEM_FAILED && renameat2(AT_FDCWD, temp, AT_FDCWD, path, RENAME_NOREPLACE) == 0) return sem;
|
||||
int saved = errno;
|
||||
if (sem != SEM_FAILED) sem_close(sem);
|
||||
unlink(temp);
|
||||
errno = saved;
|
||||
if (errno != EEXIST || (oflag & O_EXCL)) return SEM_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
int sem_close(sem_t *sem) {
|
||||
posix_sems_hold();
|
||||
struct posix_sem **link = &g_posix_sems;
|
||||
while (*link && (*link)->addr != sem) link = &(*link)->next;
|
||||
struct posix_sem *e = *link;
|
||||
if (e && --e->refs == 0) {
|
||||
*link = e->next;
|
||||
munmap(e->addr, sizeof(sem_t));
|
||||
free(e);
|
||||
}
|
||||
posix_sems_unlock();
|
||||
if (!e) { errno = EINVAL; return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sem_unlink(const char *name) {
|
||||
char path[PATH_MAX];
|
||||
if (posix_shm_path(name, "sem.", path, sizeof(path)) < 0) return -1;
|
||||
return unlink(path);
|
||||
}
|
||||
Loaded 100 of 120 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user