diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 555d8b673c..15f68eb87c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -562,6 +562,12 @@ jobs:
command -v x86_64-w64-mingw32-gcc >/dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq gcc-mingw-w64-x86-64; }
bash tools/ubisoft-launcher/build.sh
+ - name: Rockstar launcher service (32-bit and 64-bit)
+ run: |
+ set -euo pipefail
+ command -v i686-w64-mingw32-gcc >/dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq gcc-mingw-w64-i686; }
+ bash tools/rockstar-launcher/build.sh
+
- uses: actions/download-artifact@v4
with:
name: xbox-arm64
@@ -617,12 +623,11 @@ jobs:
- name: Check out MaliBridge
run: git submodule update --init external/MaliBridge
- name: Fetch the Mali (Venus) component (tools/venus/release.env)
- env:
- GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
. tools/venus/release.env
- gh release download "${VENUS_TAG}" -R "${VENUS_REPO}" -p venus.tzst -O venus.tzst
+ curl -fsSL --retry 5 --retry-all-errors --retry-delay 10 -o venus.tzst \
+ "https://github.com/${VENUS_REPO}/releases/download/${VENUS_TAG}/venus.tzst"
echo "${VENUS_SHA256} venus.tzst" | sha256sum -c -
tar --use-compress-program=unzstd -xf venus.tzst -C app/src/main
test -f app/src/main/jniLibs/arm64-v8a/libvirgl_test_server.so
@@ -798,9 +803,11 @@ jobs:
set -o pipefail
cd app/src/main/rust/stores
cargo test --locked 2>&1 | tail -60
- - name: Ubisoft launcher service host unit tests
+ - name: Windows launcher service host unit tests
timeout-minutes: 10
- run: cargo test --locked --manifest-path tools/ubisoft-launcher/Cargo.toml
+ run: |
+ cargo test --locked --manifest-path tools/ubisoft-launcher/Cargo.toml
+ cargo test --locked --manifest-path tools/rockstar-launcher/Cargo.toml
python-tests:
name: Python and native regression tests
diff --git a/.gitignore b/.gitignore
index 0a404ef667..d0fe3ea9ea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,3 +36,4 @@ __pycache__/
app/src/main/assets/directaudio/
app/src/main/assets/hybris/
/tools/vr/out/
+app/src/main/resources/rockstar/helpers/
diff --git a/AGENTS.md b/AGENTS.md
index c22c5647c0..447807615b 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,3 +1,13 @@
# Rules
- Comments should be rare, factual, and explain only non-obvious external constraints or business invariants.
+
+# Working on the device
+
+- `dd-lab-build` builds only committed work. Check `git status` and `gh api user` for the identity before committing; if `git config user.name` is empty, use the `gh` login's name and noreply email for this repo, never a guess.
+- Do not commit or start a build in the same step: a build started next to a failed commit fails too. Commit first, check it, then build.
+- Uncommitted changes in the tree may not be yours. Read `git diff` before committing them and tell the user what they do.
+- If `dd-lab-build` says "could not read DroidDeck's state", loopback adb is down and `$ADB_SERIAL` is stale. Run `adb devices`; the port changes whenever wireless debugging is toggled. Ask the user to turn it on rather than retrying.
+- A build that "did not start" can be adb, not the app. Read `~/.cache/dd-lab-build.json` and `.log` for the real reason; they can be stale from an earlier build, so compare their times with `date`.
+- Run `dd-lab-build` with `run_in_background` and read its output file. A foreground `sleep` is blocked; wait with Monitor and an until-loop.
+- The build restarts DroidDeck and ends your process. A turn that ends this way is not a failure.
diff --git a/app/build.gradle b/app/build.gradle
index 28bf184e32..bb0b7132e5 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -277,6 +277,8 @@ def stageRuntimeAssets = tasks.register('stageRuntimeAssets', Sync) {
dependsOn(stageSessionScripts)
from(layout.projectDirectory.dir('src/main/assets')) { exclude 'pulseaudio.tzst' }
from(rootProject.file('tools/linuxfs/innoextract'))
+ from(rootProject.file('tools')) { include 'droiddeckctl', 'adb_device.py', 'proot_profile.py'; into('agent/ctl') }
+ from(rootProject.file('docs/agent-control.md')) { into('agent/ctl') }
from(layout.buildDirectory.dir('prepared-assets'))
into(runtimeAssetsDir)
}
@@ -380,6 +382,11 @@ dependencies {
implementation 'androidx.activity:activity-compose:1.8.2'
implementation 'androidx.compose.material:material-icons-extended'
implementation 'io.coil-kt:coil-compose:2.6.0'
+ implementation 'io.noties.markwon:core:4.6.2'
+ implementation 'io.noties.markwon:ext-strikethrough:4.6.2'
+ implementation 'io.noties.markwon:ext-tables:4.6.2'
+ implementation 'io.noties.markwon:ext-tasklist:4.6.2'
+ implementation 'com.atlassian.commonmark:commonmark-ext-autolink:0.13.0'
implementation 'com.caverock:androidsvg-aar:1.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
implementation 'com.flyfishxu:kadb-android:1.2.1'
@@ -387,11 +394,14 @@ dependencies {
implementation 'androidx.camera:camera-camera2:1.4.2'
implementation 'androidx.camera:camera-lifecycle:1.4.2'
implementation 'androidx.webkit:webkit:1.12.1'
+ implementation 'androidx.palette:palette:1.0.0'
implementation 'io.github.webrtc-sdk:android:125.6422.07'
implementation("com.google.mediapipe:tasks-vision:${trackingPack.MEDIAPIPE_VERSION}") {
exclude group: 'com.google.auto.value', module: 'auto-value'
}
implementation 'com.google.zxing:core:3.5.3'
+ implementation 'androidx.media3:media3-exoplayer:1.3.1'
+ implementation 'androidx.media3:media3-session:1.3.1'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.robolectric:robolectric:4.16.1'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 4ae8741a4d..5d3f283701 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -18,8 +18,15 @@
+
+
+
+
+
+
+
@@ -146,6 +153,7 @@
+
@@ -339,6 +347,14 @@
android:name=".sync.SyncthingService"
android:exported="false"
android:foregroundServiceType="dataSync" />
+
+
+
+
+
/dev/null 2>&1
+# Starts GitHub's device login and opens its approval page in Android.
coproc GH { BROWSER=true gh auth login --hostname github.com --git-protocol https --web 2>&1; }
-# bash drops GH and GH_PID once gh exits, which can be before the loop reads its last line.
-ghpid=$GH_PID
+gh_pid=$GH_PID
exec {ghout}<&"${GH[0]}" {ghin}>&"${GH[1]}"
-typed=
+shown=
while IFS= read -r line <&"$ghout"; do
printf '%s\n' "$line"
code=$(grep -oE '[A-Z0-9]{4}-[A-Z0-9]{4}' <<<"$line" | head -1)
- if [ -n "$code" ] && [ -z "$typed" ]; then
- typed=1
+ if [ -n "$code" ] && [ -z "$shown" ]; then
+ shown=1
echo >&"$ghin"
- adb -s "$serial" shell "am start --display $display -a android.intent.action.VIEW -d https://github.com/login/device" >/dev/null 2>&1
- # Chrome drops characters from `input text` and from fast key events on this page.
- keys=
- for ((i = 0; i < ${#code}; i++)); do
- c=${code:i:1}
- [ "$c" = - ] || keys+="input -d $display keyevent KEYCODE_$c; sleep 0.4; "
- done
- (sleep 7; adb -s "$serial" shell "$keys" >/dev/null 2>&1) &
+ printf 'GitHub device code: %s ยท github.com/login/device\n' "$code"
+ android-open https://github.com/login/device
fi
done
-wait "$ghpid"
+wait "$gh_pid"
diff --git a/app/src/main/assets/agent/droiddeckctl b/app/src/main/assets/agent/droiddeckctl
new file mode 100755
index 0000000000..a72cb2587c
--- /dev/null
+++ b/app/src/main/assets/agent/droiddeckctl
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec python3 /root/.local/share/droiddeck/ctl/droiddeckctl "$@"
diff --git a/app/src/main/cpp/waylandcomp/CMakeLists.txt b/app/src/main/cpp/waylandcomp/CMakeLists.txt
index 61baf0d379..c7aa1b0eb4 100644
--- a/app/src/main/cpp/waylandcomp/CMakeLists.txt
+++ b/app/src/main/cpp/waylandcomp/CMakeLists.txt
@@ -1,5 +1,6 @@
add_library(droiddeckwayland SHARED
src/compositor.c
+ src/clock_domain.c
src/vk_present.c
src/effects_chain.c
src/cardboard.c
diff --git a/app/src/main/cpp/waylandcomp/src/clock_domain.c b/app/src/main/cpp/waylandcomp/src/clock_domain.c
new file mode 100644
index 0000000000..30fd73a4eb
--- /dev/null
+++ b/app/src/main/cpp/waylandcomp/src/clock_domain.c
@@ -0,0 +1,72 @@
+#define _GNU_SOURCE
+#include "clock_domain.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+static const int64_t *g_shift;
+static pthread_mutex_t g_control_lock = PTHREAD_MUTEX_INITIALIZER;
+static dev_t g_device;
+static ino_t g_inode;
+
+void droiddeck_clock_domain_set_control(const char *path) {
+ int fd;
+ struct stat st;
+ pthread_mutex_lock(&g_control_lock);
+ if (!path || !*path) {
+ const int64_t *previous = g_shift;
+ g_shift = NULL;
+ if (previous) munmap((void *)previous, sizeof(*previous));
+ pthread_mutex_unlock(&g_control_lock);
+ return;
+ }
+ fd = open(path, O_RDONLY | O_CLOEXEC);
+ if (fd < 0 || fstat(fd, &st) != 0 || st.st_size < (off_t)sizeof(int64_t)) {
+ if (fd >= 0) close(fd);
+ pthread_mutex_unlock(&g_control_lock);
+ return;
+ }
+ if (g_shift && st.st_dev == g_device && st.st_ino == g_inode) {
+ close(fd);
+ pthread_mutex_unlock(&g_control_lock);
+ return;
+ }
+ const int64_t *shift = mmap(NULL, sizeof(*shift), PROT_READ, MAP_SHARED, fd, 0);
+ close(fd);
+ if (shift != MAP_FAILED) {
+ g_device = st.st_dev;
+ g_inode = st.st_ino;
+ const int64_t *previous = g_shift;
+ g_shift = shift;
+ if (previous) munmap((void *)previous, sizeof(*previous));
+ }
+ pthread_mutex_unlock(&g_control_lock);
+}
+
+static int64_t shift_ns(void) {
+ pthread_mutex_lock(&g_control_lock);
+ const int64_t *mapping = g_shift;
+ int64_t shift = mapping ? __atomic_load_n(mapping, __ATOMIC_RELAXED) : 0;
+ pthread_mutex_unlock(&g_control_lock);
+ return shift > 0 ? shift : 0;
+}
+
+int64_t droiddeck_clock_domain_adjust_ns(int64_t value) {
+ int64_t shift = shift_ns();
+ return value > shift ? value - shift : 0;
+}
+
+int64_t droiddeck_clock_domain_now_ns(void) {
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return droiddeck_clock_domain_adjust_ns((int64_t)ts.tv_sec * 1000000000LL + ts.tv_nsec);
+}
+
+uint32_t droiddeck_clock_domain_now_ms(void) {
+ return (uint32_t)(droiddeck_clock_domain_now_ns() / 1000000LL);
+}
diff --git a/app/src/main/cpp/waylandcomp/src/clock_domain.h b/app/src/main/cpp/waylandcomp/src/clock_domain.h
new file mode 100644
index 0000000000..acb7e0e174
--- /dev/null
+++ b/app/src/main/cpp/waylandcomp/src/clock_domain.h
@@ -0,0 +1,11 @@
+#ifndef DROIDDECK_CLOCK_DOMAIN_H
+#define DROIDDECK_CLOCK_DOMAIN_H
+
+#include
+
+void droiddeck_clock_domain_set_control(const char *path);
+int64_t droiddeck_clock_domain_now_ns(void);
+uint32_t droiddeck_clock_domain_now_ms(void);
+int64_t droiddeck_clock_domain_adjust_ns(int64_t value);
+
+#endif
diff --git a/app/src/main/cpp/waylandcomp/src/compositor.c b/app/src/main/cpp/waylandcomp/src/compositor.c
index 21ef1d23f9..3510ea29a3 100644
--- a/app/src/main/cpp/waylandcomp/src/compositor.c
+++ b/app/src/main/cpp/waylandcomp/src/compositor.c
@@ -36,6 +36,7 @@
#include "droiddeck_ext.h"
#include "droiddeck_color.h"
#include "compositor_internal.h"
+#include "clock_domain.h"
#define WLOGI(...) __android_log_print(ANDROID_LOG_INFO, "DroidDeckWayland", __VA_ARGS__)
#define WLOGE(...) __android_log_print(ANDROID_LOG_ERROR, "DroidDeckWayland", __VA_ARGS__)
@@ -727,9 +728,7 @@ static void on_pending_buffer_destroyed(struct wl_listener *l, void *data) {
static void fire_frames(struct wl_list *frames) {
struct wl_resource *cb, *tmp;
uint32_t t;
- struct timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- t = (uint32_t)(ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
+ t = droiddeck_clock_domain_now_ms();
wl_resource_for_each_safe(cb, tmp, frames) {
wl_callback_send_done(cb, t);
wl_resource_destroy(cb);
@@ -1061,6 +1060,7 @@ static int64_t presented_ns(int64_t render_ns) {
static void feedback_present_all(struct wl_list *list, int64_t t) {
struct wl_resource *fb, *tmp;
+ t = droiddeck_clock_domain_adjust_ns(t);
uint64_t sec = (uint64_t)(t / 1000000000LL);
uint32_t nsec = (uint32_t)(t % 1000000000LL);
wl_resource_for_each_safe(fb, tmp, list) {
@@ -2493,8 +2493,7 @@ static void on_vsync(int64_t frame_time_ns) {
static uint32_t now_ms(void) {
- struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);
- return (uint32_t)(ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
+ return droiddeck_clock_domain_now_ms();
}
static void pointer_set_cursor(struct wl_client *c, struct wl_resource *r, uint32_t serial,
@@ -3114,12 +3113,10 @@ static void relative_pointers_pointer_gone(struct wl_resource *pointer) {
static int send_relative_motion(struct wl_client *client, double dx, double dy) {
struct relative_pointer *rp;
- struct timespec ts;
uint64_t ut;
int sent = 0;
if (dx == 0 && dy == 0) return 0;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- ut = (uint64_t)ts.tv_sec * 1000000ULL + (uint64_t)ts.tv_nsec / 1000;
+ ut = (uint64_t)(droiddeck_clock_domain_now_ns() / 1000);
wl_list_for_each(rp, &g_relative_pointers, link) {
if (!rp->pointer || wl_resource_get_client(rp->pointer) != client) continue;
zwp_relative_pointer_v1_send_relative_motion(rp->resource, (uint32_t)(ut >> 32), (uint32_t)ut,
diff --git a/app/src/main/cpp/waylandcomp/src/framegen_bridge.c b/app/src/main/cpp/waylandcomp/src/framegen_bridge.c
index eceb796398..d29b328a05 100644
--- a/app/src/main/cpp/waylandcomp/src/framegen_bridge.c
+++ b/app/src/main/cpp/waylandcomp/src/framegen_bridge.c
@@ -33,7 +33,9 @@ static PFN_vkGetInstanceProcAddr g_gipa;
static VkPhysicalDevice g_pd;
static VkQueue g_queue;
static uint32_t g_qfam;
-static int g_dev_ready, g_dev_lost, g_features_enabled;
+static _Atomic int g_dev_ready, g_dev_lost;
+static int g_features_enabled;
+static _Atomic int g_caps_lsfg_ok, g_caps_ddfg_ok;
static VkPhysicalDeviceMemoryProperties g_memprops;
static struct {
PFN_vkCreateImage CreateImage;
@@ -141,9 +143,12 @@ static void mark_failed(int kind) {
}
int vkp_framegen_problem(void) {
- if (!g_dev_ready) return -1;
+ if (!atomic_load(&g_dev_ready)) return -1;
int kind = atomic_load(&g_kind);
- if (!fge_caps_ok(kind)) return 1;
+ int caps_ok = kind == VKP_FG_ENGINE_DDFG
+ ? atomic_load(&g_caps_ddfg_ok)
+ : atomic_load(&g_caps_lsfg_ok);
+ if (!caps_ok) return 1;
if (start_failed_for(kind)) return 2;
if (g_engine_ok && g_engine_kind == kind && fge_unavailable()) return 2;
return 0;
@@ -179,13 +184,17 @@ void vkp_framegen_device_ready(VkDevice dev, VkQueue queue, uint32_t qfam, int f
#undef R
g_vk.GetPhysicalDeviceMemoryProperties(g_pd, &g_memprops);
fge_device_ready(g_gipa, g_inst, g_pd, dev, queue, qfam, features_enabled);
- g_dev_ready = vk.CreateImage && vk.CreateImageView && vk.CmdPipelineBarrier;
+ atomic_store(&g_caps_lsfg_ok, fge_caps_ok(VKP_FG_ENGINE_LSFG));
+ atomic_store(&g_caps_ddfg_ok, fge_caps_ok(VKP_FG_ENGINE_DDFG));
+ atomic_store(&g_dev_lost, 0);
+ atomic_store(&g_dev_ready,
+ vk.CreateImage && vk.CreateImageView && vk.CmdPipelineBarrier);
FGLOG("engines ready on the compositor's device: LSFG Native %s (%s), DD-FG Native %s",
fge_caps_ok(VKP_FG_ENGINE_LSFG) ? "available" : "unavailable", fge_caps_reason(),
fge_caps_ok(VKP_FG_ENGINE_DDFG) ? "available" : "unavailable");
}
-void vkp_framegen_device_lost(void) { g_dev_lost = 1; }
+void vkp_framegen_device_lost(void) { atomic_store(&g_dev_lost, 1); }
static void destroy_ring(void) {
@@ -244,7 +253,12 @@ static int ensure_ring(uint32_t w, uint32_t h, VkFormat fmt, uint32_t n) {
static int engine_usable(void) {
int kind = atomic_load(&g_kind);
- return g_dev_ready && !g_dev_lost && fge_caps_ok(kind) && !start_failed_for(kind);
+ int ready = atomic_load(&g_dev_ready);
+ int lost = atomic_load(&g_dev_lost);
+ int caps_ok = kind == VKP_FG_ENGINE_DDFG
+ ? atomic_load(&g_caps_ddfg_ok)
+ : atomic_load(&g_caps_lsfg_ok);
+ return ready && !lost && caps_ok && !start_failed_for(kind);
}
int vkp_framegen_format_ok(VkFormat fmt) {
diff --git a/app/src/main/cpp/waylandcomp/src/framegen_jni.c b/app/src/main/cpp/waylandcomp/src/framegen_jni.c
index 35c5a3de46..e5a51456ed 100644
--- a/app/src/main/cpp/waylandcomp/src/framegen_jni.c
+++ b/app/src/main/cpp/waylandcomp/src/framegen_jni.c
@@ -50,6 +50,12 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeFrameGenCapsReason(J
return (*env)->NewStringUTF(env, r ? r : "");
}
+JNIEXPORT jboolean JNICALL
+Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeFrameGenActive(JNIEnv *env, jclass clazz) {
+ (void)env; (void)clazz;
+ return vkp_framegen_active() ? JNI_TRUE : JNI_FALSE;
+}
+
JNIEXPORT jfloatArray JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeFrameGenStats(JNIEnv *env, jclass clazz) {
(void)clazz;
diff --git a/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c b/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c
index ffbfdfd935..25b97ae0f8 100644
--- a/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c
+++ b/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c
@@ -18,6 +18,7 @@
#include "cardboard.h"
#include "droiddeck_color.h"
#include "gpu_clock_pin.h"
+#include "clock_domain.h"
extern int droiddeck_wayland_run(void);
extern void droiddeck_wayland_set_scale_mode(int mode, int alignment);
@@ -354,6 +355,13 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeVsync(JNIEnv *env, j
droiddeck_wayland_vsync((int64_t)frameTimeNanos);
}
+JNIEXPORT void JNICALL
+Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetClockControl(JNIEnv *env, jclass clazz, jstring path) {
+ const char *value = path ? (*env)->GetStringUTFChars(env, path, NULL) : NULL;
+ droiddeck_clock_domain_set_control(value);
+ if (value) (*env)->ReleaseStringUTFChars(env, path, value);
+}
+
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetHideShell(JNIEnv *env, jclass clazz, jboolean hide) {
g_hide_shell = hide ? 1 : 0;
diff --git a/app/src/main/java/com/droiddeck/launcher/App.kt b/app/src/main/java/com/droiddeck/launcher/App.kt
index 79f42d118a..6ecd72d5f5 100644
--- a/app/src/main/java/com/droiddeck/launcher/App.kt
+++ b/app/src/main/java/com/droiddeck/launcher/App.kt
@@ -43,7 +43,10 @@ class App : Application() {
process == "$packageName:shortcuts_sync" || process == "$packageName:bottom_desktop") return
CrashHandler.install(this)
com.droiddeck.launcher.agent.AgentHost.refresh(this)
- if (com.droiddeck.launcher.agent.AgentHost.available) com.droiddeck.launcher.lab.LabNotice.openOnInstall = "agent"
+ com.droiddeck.launcher.agent.AgentTab.load(this)
+ com.droiddeck.launcher.ui.NavTabs.load(this)
+ com.droiddeck.launcher.ui.AgentPet.install(this)
+ if (com.droiddeck.launcher.agent.AgentTab.visible) com.droiddeck.launcher.lab.LabNotice.openOnInstall = "agent"
com.droiddeck.launcher.lab.LabNotice.started(this)
com.droiddeck.launcher.core.SteamIntegration.syncShortcutsListing(this)
com.droiddeck.launcher.session.QuestExperimental.initialize(this)
@@ -70,6 +73,7 @@ class App : Application() {
com.droiddeck.launcher.stores.StoresState.register(com.droiddeck.launcher.stores.ubisoft.UbisoftBackend)
com.droiddeck.launcher.stores.ea.EaBackend.app = this
com.droiddeck.launcher.stores.StoresState.register(com.droiddeck.launcher.stores.ea.EaBackend)
+ com.droiddeck.launcher.stores.StoresState.register(com.droiddeck.launcher.stores.rockstar.RockstarBackend)
}
private fun prefetchAddonPacks() {
diff --git a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt
index 55fdf3f1f3..c8ce1e4ae8 100644
--- a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt
+++ b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt
@@ -84,7 +84,7 @@ import com.droiddeck.launcher.session.SteamLibraries
import com.droiddeck.launcher.input.SecondScreenDisplay
import com.droiddeck.launcher.input.SecondScreenDisplays
-class FrontEndActivity : ComponentActivity() {
+class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPetHost {
override fun attachBaseContext(newBase: android.content.Context) {
super.attachBaseContext(newBase)
com.droiddeck.launcher.core.AppLanguage.applyTo(this, newBase)
@@ -196,6 +196,7 @@ class FrontEndActivity : ComponentActivity() {
private var stretch16x9 by mutableStateOf(false)
private var orientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE)
private var launcherOrientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER)
+ private var homePage by mutableStateOf(com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_STEAM)
private var launcherFullscreen by mutableStateOf(true)
private var downloadSource by mutableStateOf(DownloadSource.MODE_AUTO)
private var downloadMirror by mutableStateOf("")
@@ -205,6 +206,10 @@ class FrontEndActivity : ComponentActivity() {
private var lowStorageWarning by mutableStateOf(true)
private var launcherIcon by mutableStateOf(LauncherIcon.DARK)
private var gameStoresEnabled by mutableStateOf(true)
+ private var soundtracksEnabled by mutableStateOf(true)
+ private var soundtracksIngame by mutableStateOf(false)
+ private var soundtracks by mutableStateOf>(emptyList())
+ private var soundtracksLoaded by mutableStateOf(false)
private var gameStoresSpeedTier by mutableStateOf("fast")
private var navRequest by mutableStateOf(null)
private val gameLaunchRequest = java.util.concurrent.atomic.AtomicLong()
@@ -226,6 +231,11 @@ class FrontEndActivity : ComponentActivity() {
refreshWifiDiscovery()
}
}
+ private val dateReceiver = object : android.content.BroadcastReceiver() {
+ override fun onReceive(context: android.content.Context?, intent: Intent?) {
+ refreshAndroidApps()
+ }
+ }
private val mediaRefresh = Runnable {
refresh()
refreshAddedGames()
@@ -593,6 +603,7 @@ class FrontEndActivity : ComponentActivity() {
private var vacDiagnostics by mutableStateOf(false)
private var agentCommands by mutableStateOf(false)
private var graphicsLogs by mutableStateOf(false)
+ private var buildWatermark by mutableStateOf(true)
private var steamGpuDrawing by mutableStateOf(false)
private var bridgeFellBack by mutableStateOf(false)
private var bridgeFellBackMemory by mutableStateOf(false)
@@ -778,6 +789,11 @@ class FrontEndActivity : ComponentActivity() {
private var shortcutPicker by mutableStateOf(false)
private var shortcutLibraryScanning by mutableStateOf(false)
@Volatile private var libraryScanGeneration = 0
+ private class SoundtrackRemoval(val op: Int, var scan: Int, var settled: Boolean)
+ private val soundtrackRemovals = HashMap()
+ private var soundtrackOp = 0
+ private var soundtrackAddScan = -1
+ private val soundtrackWork = java.util.concurrent.Executors.newSingleThreadExecutor { r -> Thread(r, "soundtrack-work").apply { isDaemon = true } }
@Volatile private var lastComponentRestore = 0L
@Volatile private var componentRestoreRetry = false
private val componentRestoreLock = Any()
@@ -828,6 +844,10 @@ class FrontEndActivity : ComponentActivity() {
private fun readGameIntent(request: Intent) {
request.getStringExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV)?.let { navRequest = it; request.removeExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV) }
+ if (navRequest == com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_APPS) {
+ homeAppSelected = HomeApp.isHomeScreenEnabled(this) && HomeApp.isDefault(this)
+ if (!homeAppSelected) navRequest = null
+ }
shortcutPicker = request.action == Intent.ACTION_CREATE_SHORTCUT
if (shortcutPicker) {
steamGames = emptyList()
@@ -836,6 +856,15 @@ class FrontEndActivity : ComponentActivity() {
pendingGameLink = null
gameLinkReading = false
gameLinkTried = false
+ soundtrackLaunch = false
+ val soundtrackId = com.droiddeck.launcher.frontend.SoundtrackShortcuts.read(request)
+ if (soundtrackId != null) {
+ soundtrackLaunch = true
+ navRequest = if (SessionPrefs.soundtracksEnabled(this)) "sound:$soundtrackId" else "app:$soundtrackId"
+ request.data = null
+ request.action = Intent.ACTION_MAIN
+ return
+ }
if (GameLaunchIntent.accepts(request.action)) {
gameLinkReading = true
com.droiddeck.launcher.ui.DualScreenPanel.hide(taskId)
@@ -860,6 +889,7 @@ class FrontEndActivity : ComponentActivity() {
}
private fun launchGame(game: Library.SteamGame, returnHome: Boolean = false): Boolean {
+ if (!SessionPrefs.soundtracksIngame(this)) com.droiddeck.launcher.playback.SoundtrackController.pause(this)
if (pkgStage != null) {
android.widget.Toast.makeText(this, R.string.main_wait_install_game, android.widget.Toast.LENGTH_SHORT).show()
return false
@@ -1106,7 +1136,7 @@ class FrontEndActivity : ComponentActivity() {
if (savedInstanceState == null) readIntegrationIntent(intent)
readGameIntent(intent)
// A Lab build is usually the agent's work, so the app comes back where the agent is.
- if (savedInstanceState == null && navRequest == null && com.droiddeck.launcher.lab.LabOverlay.promoted && com.droiddeck.launcher.agent.AgentHost.available) navRequest = "agent"
+ if (savedInstanceState == null && navRequest == null && com.droiddeck.launcher.lab.LabOverlay.promoted && com.droiddeck.launcher.agent.AgentTab.visible) navRequest = "agent"
gameSyncFolder = GameFileSync.folder(this)
displayManager = getSystemService(DISPLAY_SERVICE) as DisplayManager
refreshPhantomStatus()
@@ -1121,6 +1151,7 @@ class FrontEndActivity : ComponentActivity() {
orientation = SessionPrefs.orientation(this)
launcherOrientation = com.droiddeck.launcher.core.AppUiPrefs.orientation(this)
requestedOrientation = launcherOrientation
+ homePage = com.droiddeck.launcher.core.AppUiPrefs.homePage(this)
launcherFullscreen = SessionPrefs.launcherFullscreen(this)
downloadSource = DownloadSource.mode(this)
downloadMirror = DownloadSource.mirror(this)
@@ -1132,6 +1163,8 @@ class FrontEndActivity : ComponentActivity() {
LauncherIcon.repair(this, intent?.component)
launcherIcon = LauncherIcon.current(this)
gameStoresEnabled = SessionPrefs.gameStoresEnabled(this)
+ soundtracksEnabled = SessionPrefs.soundtracksEnabled(this)
+ soundtracksIngame = SessionPrefs.soundtracksIngame(this)
gameStoresSpeedTier = SessionPrefs.gameStoresSpeedTier(this)
storesShowMature = SessionPrefs.storesShowMature(this)
storesSort = SessionPrefs.storesSort(this)
@@ -1178,6 +1211,7 @@ class FrontEndActivity : ComponentActivity() {
gameDebugLogsEnabled = gameDebugLogsEnabled, gameDebugLogsNeedsRestart = gameDebugLogsNeedsRestart,
vacDiagnostics = vacDiagnostics, agentCommands = agentCommands,
graphicsLogs = graphicsLogs, steamGpuDrawing = steamGpuDrawing, bridgeFellBack = bridgeFellBack, bridgeFellBackMemory = bridgeFellBackMemory,
+ buildWatermark = buildWatermark,
clearCachedApps = clearCachedApps, adbPaired = adbPaired, memoryHud = memoryHud, backgroundAppLimit = backgroundAppLimit,
tpUbwcMode = drivers.tpUbwcModeForDevice(), tpUbwcRestartRequired = drivers.tpUbwcRestartRequired(), canRestartApp = !runtimeChangesBlocked(),
steamGames = steamGames, steamGamesX64 = steamGamesX64, emulators = emulatorList, running = runningLabel,
@@ -1216,6 +1250,7 @@ class FrontEndActivity : ComponentActivity() {
showPhantomGate = showPhantomGate,
orientation = orientation,
launcherOrientation = launcherOrientation,
+ homePage = homePage,
launcherFullscreen = launcherFullscreen,
downloadSource = downloadSource,
downloadMirror = downloadMirror,
@@ -1225,6 +1260,10 @@ class FrontEndActivity : ComponentActivity() {
lowStorageWarning = lowStorageWarning,
launcherIcon = launcherIcon,
gameStoresEnabled = gameStoresEnabled,
+ soundtracksEnabled = soundtracksEnabled,
+ soundtracksIngame = soundtracksIngame,
+ soundtracks = soundtracks,
+ soundtracksLoaded = soundtracksLoaded,
gameStoresSpeedTier = gameStoresSpeedTier,
navigate = navRequest,
addedGamesArt = addedGamesArt,
@@ -1273,7 +1312,10 @@ class FrontEndActivity : ComponentActivity() {
},
onEpicLauncher = { openEpicLauncher() },
onUninstallEpicLauncher = { uninstallEpicLauncher() },
- onGameShortcut = { g -> com.droiddeck.launcher.frontend.GameShortcuts.pin(this, g) },
+ onGameShortcut = { g ->
+ if (g.soundtrack) com.droiddeck.launcher.frontend.SoundtrackShortcuts.pin(this, g)
+ else com.droiddeck.launcher.frontend.GameShortcuts.pin(this, g)
+ },
onExportGameFile = { g -> pickGameExport(g) },
onSyncGameFiles = { pickGameExport(null) },
onAddGameExe = { path -> addGameExe(path) },
@@ -1298,8 +1340,9 @@ class FrontEndActivity : ComponentActivity() {
}, "game-file-stop-sync").start()
},
onCopyGameLink = { g ->
- (getSystemService(CLIPBOARD_SERVICE) as ClipboardManager).setPrimaryClip(
- ClipData.newPlainText(g.name, com.droiddeck.launcher.frontend.GameLaunchLink.uri(g.gameIdString)))
+ val link = if (g.soundtrack) com.droiddeck.launcher.frontend.SoundtrackShortcuts.uri(g.appId)
+ else com.droiddeck.launcher.frontend.GameLaunchLink.uri(g.gameIdString)
+ (getSystemService(CLIPBOARD_SERVICE) as ClipboardManager).setPrimaryClip(ClipData.newPlainText(g.name, link))
android.widget.Toast.makeText(this, R.string.game_link_copied, android.widget.Toast.LENGTH_SHORT).show()
},
onDesktop = {
@@ -1324,6 +1367,7 @@ class FrontEndActivity : ComponentActivity() {
},
onRom = { g ->
val e = emulatorList.first { it.id == g.emulatorId }
+ if (!SessionPrefs.soundtracksIngame(this)) com.droiddeck.launcher.playback.SoundtrackController.pause(this)
startActivity(Intent(this, SessionActivity::class.java)
.putExtra(SessionService.EXTRA_MODE, SessionService.MODE_RUN)
.putExtra(SessionService.EXTRA_PROGRAM, e.program)
@@ -1416,6 +1460,11 @@ class FrontEndActivity : ComponentActivity() {
SessionPrefs.setDetailedGraphicsLogs(this, !SessionPrefs.detailedGraphicsLogs(this))
graphicsLogs = SessionPrefs.detailedGraphicsLogs(this)
},
+ onBuildWatermark = {
+ SessionPrefs.setBuildWatermarkEnabled(this, !SessionPrefs.buildWatermarkEnabled(this))
+ buildWatermark = SessionPrefs.buildWatermarkEnabled(this)
+ com.droiddeck.launcher.ui.BuildWatermark.refresh(this)
+ },
onVacDiagnostics = {
SessionPrefs.setVacDiagnostics(this, !SessionPrefs.vacDiagnostics(this))
vacDiagnostics = SessionPrefs.vacDiagnostics(this)
@@ -1487,6 +1536,15 @@ class FrontEndActivity : ComponentActivity() {
},
onPageBack = { showPerformance = false; showComponents = false; showMapping = false },
onGameStoresEnabled = { on -> SessionPrefs.setGameStoresEnabled(this, on); gameStoresEnabled = on },
+ onSoundtracksEnabled = { on -> SessionPrefs.setSoundtracksEnabled(this, on); soundtracksEnabled = on },
+ onSoundtracksIngame = { on ->
+ SessionPrefs.setSoundtracksIngame(this, on)
+ soundtracksIngame = on
+ com.droiddeck.launcher.playback.SoundtrackController.setIngame(this, on)
+ },
+ onSoundtrackAdded = { folder -> addSoundtrack(folder) },
+ onSoundtracksChanged = { refreshAddedSoundtracks() },
+ onSoundtrackRemoved = { g -> removeSoundtrack(g) },
onTheme = { id -> SessionPrefs.setTheme(this, id); theme = id },
onLauncherIcon = { style -> switchLauncherIcon(style) },
onLanguage = { tag ->
@@ -1508,6 +1566,10 @@ class FrontEndActivity : ComponentActivity() {
launcherOrientation = value
requestedOrientation = value
},
+ onHomePage = { value ->
+ com.droiddeck.launcher.core.AppUiPrefs.setHomePage(this, value)
+ homePage = value
+ },
onLauncherFullscreen = { on ->
SessionPrefs.setLauncherFullscreen(this, on)
launcherFullscreen = on
@@ -1576,6 +1638,7 @@ class FrontEndActivity : ComponentActivity() {
refreshHomeAppState()
}
},
+ onAppIconsChanged = { refreshAndroidApps() },
onAndroidApp = { app, displayId -> launchAndroidApp(app, displayId) },
onBackActionsInverted = { inverted ->
SessionPrefs.setBackActionsInverted(this, inverted)
@@ -1758,6 +1821,8 @@ class FrontEndActivity : ComponentActivity() {
}, "finish-abandoned").start()
}
+ override val petBlocked: Boolean get() = false
+
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setIntent(intent)
@@ -1773,7 +1838,10 @@ class FrontEndActivity : ComponentActivity() {
startSteamAtStartupIfEnabled()
}
+ private var soundtrackLaunch = false
+
private fun startSteamAtStartupIfEnabled(cold: Boolean = false) {
+ if (soundtrackLaunch) return
if (intent.action != Intent.ACTION_MAIN && !(cold && intent.action == null)) return
if (isFinishing || isDestroyed) return
when (SessionPrefs.startupSession(this)) {
@@ -1851,6 +1919,7 @@ class FrontEndActivity : ComponentActivity() {
}
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
+ if (com.droiddeck.launcher.ui.AgentPet.handleBack(this, event)) return true
if (compatLaunch != null) {
if (event.keyCode == KeyEvent.KEYCODE_BACK || event.keyCode == KeyEvent.KEYCODE_BUTTON_B) {
if (event.action == KeyEvent.ACTION_UP) cancelCompatLaunch()
@@ -1900,6 +1969,7 @@ class FrontEndActivity : ComponentActivity() {
orientation = SessionPrefs.orientation(this)
launcherOrientation = com.droiddeck.launcher.core.AppUiPrefs.orientation(this)
requestedOrientation = launcherOrientation
+ homePage = com.droiddeck.launcher.core.AppUiPrefs.homePage(this)
SteamIntegration.syncShortcutsListing(this)
refreshWifiDiscovery()
com.droiddeck.launcher.stores.StoresState.refresh(this)
@@ -1953,6 +2023,7 @@ class FrontEndActivity : ComponentActivity() {
override fun onStart() {
super.onStart()
registerReceiver(wifiLocationReceiver, android.content.IntentFilter(android.location.LocationManager.MODE_CHANGED_ACTION))
+ registerReceiver(dateReceiver, android.content.IntentFilter(Intent.ACTION_DATE_CHANGED))
registerReceiver(mediaReceiver, android.content.IntentFilter().apply {
for (action in listOf(Intent.ACTION_MEDIA_MOUNTED, Intent.ACTION_MEDIA_UNMOUNTED, Intent.ACTION_MEDIA_REMOVED,
Intent.ACTION_MEDIA_EJECT, Intent.ACTION_MEDIA_BAD_REMOVAL)) addAction(action)
@@ -2019,6 +2090,7 @@ class FrontEndActivity : ComponentActivity() {
override fun onStop() {
if (!homeChoiceOpen) HomeApp.releaseUnusedHomeEntry(this)
unregisterReceiver(wifiLocationReceiver)
+ unregisterReceiver(dateReceiver)
unregisterReceiver(mediaReceiver)
getSystemService(android.content.pm.LauncherApps::class.java).unregisterCallback(packageCallback)
HomeWidgets.stopListening(this)
@@ -2614,15 +2686,89 @@ class FrontEndActivity : ComponentActivity() {
val version = (steamArtRefreshes[appId] ?: 0) + 1
steamArtRefreshes[appId] = version
Thread({
- val fresh = com.droiddeck.launcher.frontend.Library.steamGames(this).firstOrNull { it.appId == appId } ?: return@Thread
+ val fresh = com.droiddeck.launcher.frontend.Library.steamGames(this, soundtracks = true).firstOrNull { it.appId == appId } ?: return@Thread
ui.post {
if (steamArtRefreshes[appId] != version) return@post
- steamGames = steamGames.map { if (it.appId == appId && it.library != Library.ADDED) fresh else it }
+ if (fresh.soundtrack) soundtracks = soundtracks.map { if (it.appId == appId && it.library != Library.ADDED) fresh else it }
+ else steamGames = steamGames.map { if (it.appId == appId && it.library != Library.ADDED) fresh else it }
}
}, "steam-art-update").start()
}
+ private fun addSoundtrack(folder: java.io.File) {
+ val op = ++soundtrackOp
+ soundtrackAddScan = libraryScanGeneration
+ soundtrackWork.execute {
+ val added = com.droiddeck.launcher.frontend.AddedSoundtracks.add(this, folder)
+ val list = com.droiddeck.launcher.frontend.AddedSoundtracks.games(this)
+ ui.post {
+ if (added) {
+ soundtrackRemovals[folder.path]?.takeIf { it.op < op }?.let {
+ soundtrackRemovals.remove(folder.path)
+ com.droiddeck.launcher.playback.SoundtrackController.allow(listOf(folder.path))
+ }
+ val visible = list.filterNot { s -> s.gameFiles?.path?.let { soundtrackRemovals[it] }?.let { it.op > op } == true }
+ soundtracks = soundtracks.filter { it.library != Library.ADDED } + visible
+ } else android.widget.Toast.makeText(this, R.string.soundtracks_add_empty, android.widget.Toast.LENGTH_SHORT).show()
+ }
+ }
+ }
+
+ private fun refreshAddedSoundtracks() {
+ val op = soundtrackOp
+ soundtrackWork.execute {
+ val list = com.droiddeck.launcher.frontend.AddedSoundtracks.games(this)
+ ui.post {
+ if (op != soundtrackOp) return@post
+ val visible = list.filterNot { s -> s.gameFiles?.path?.let { soundtrackRemovals[it] } != null }
+ soundtracks = soundtracks.filter { it.library != Library.ADDED } + visible
+ }
+ }
+ }
+
+ private fun removeSoundtrack(g: Library.SteamGame) {
+ val path = g.gameFiles?.path
+ val added = g.library == Library.ADDED
+ val target = if (added) null else com.droiddeck.launcher.frontend.GameRemoval.steamFiles(g) ?: return
+ com.droiddeck.launcher.playback.SoundtrackController.stopIf(this, g.gameFiles)
+ val marker = SoundtrackRemoval(++soundtrackOp, libraryScanGeneration, added)
+ path?.let { soundtrackRemovals[it] = marker }
+ if (target == null) {
+ soundtracks = soundtracks.filterNot { it.appId == g.appId && it.library == Library.ADDED }
+ soundtrackWork.execute {
+ val removed = com.droiddeck.launcher.frontend.AddedSoundtracks.remove(this, path.orEmpty())
+ val list = if (removed) emptyList() else com.droiddeck.launcher.frontend.AddedSoundtracks.games(this)
+ if (!removed) ui.post {
+ if (path != null && soundtrackRemovals[path] === marker) {
+ soundtrackRemovals.remove(path)
+ com.droiddeck.launcher.playback.SoundtrackController.allow(listOf(path))
+ }
+ soundtracks = soundtracks.filter { it.library != Library.ADDED } + list.filterNot { s -> s.gameFiles?.path?.let { soundtrackRemovals[it] } != null }
+ android.widget.Toast.makeText(this, getString(R.string.gfiles_remove_failed, g.name), android.widget.Toast.LENGTH_SHORT).show()
+ }
+ }
+ return
+ }
+ soundtrackWork.execute {
+ val deleted = com.droiddeck.launcher.frontend.GameRemoval.delete(target)
+ ui.post {
+ if (deleted) {
+ marker.scan = libraryScanGeneration
+ marker.settled = true
+ } else {
+ if (path != null && soundtrackRemovals[path] === marker) {
+ soundtrackRemovals.remove(path)
+ com.droiddeck.launcher.playback.SoundtrackController.allow(listOf(path))
+ }
+ android.widget.Toast.makeText(this, getString(R.string.gfiles_remove_failed, g.name), android.widget.Toast.LENGTH_SHORT).show()
+ }
+ refresh()
+ }
+ }
+ }
+
private fun removeGame(g: Library.SteamGame) {
+ if (g.soundtrack) { removeSoundtrack(g); return }
val folder = g.gameFiles ?: return
when (com.droiddeck.launcher.frontend.GameRemoval.kind(g)) {
com.droiddeck.launcher.frontend.GameRemoval.Kind.LAUNCHER -> Unit
@@ -2867,6 +3013,7 @@ class FrontEndActivity : ComponentActivity() {
vacDiagnostics = SessionPrefs.vacDiagnostics(this)
agentCommands = com.droiddeck.launcher.agent.AgentAccess.commandsEnabled(this)
graphicsLogs = SessionPrefs.detailedGraphicsLogs(this)
+ buildWatermark = SessionPrefs.buildWatermarkEnabled(this)
steamGpuDrawing = SessionPrefs.steamGpuCompositing(this)
bridgeFellBack = SessionPrefs.bridgeFellBack(this)
bridgeFellBackMemory = SessionPrefs.bridgeFellBackForMemory(this)
@@ -2905,6 +3052,19 @@ class FrontEndActivity : ComponentActivity() {
}
val scannedArch = SessionPrefs.activeSteamClientArch(this)
val scannedX64 = scannedArch == "x86_64"
+ val scannedSoundtracks = runCatching {
+ (if (ready || com.droiddeck.launcher.runtime.LinuxRuntime.hasRootfs(this)) Library.soundtracks(this, scannedArch) else emptyList()) +
+ com.droiddeck.launcher.frontend.AddedSoundtracks.games(this)
+ }.getOrDefault(emptyList())
+ ui.post {
+ if (scanGeneration == libraryScanGeneration) {
+ val scanned = if (scanGeneration <= soundtrackAddScan) scannedSoundtracks + soundtracks.filter { cur -> cur.library == Library.ADDED && scannedSoundtracks.none { it.library == Library.ADDED && it.appId == cur.appId } } else scannedSoundtracks
+ val kept = scanned.filterNot { s -> s.gameFiles?.path?.let { p -> soundtrackRemovals[p]?.let { m -> !m.settled || s.library == Library.ADDED || scanGeneration <= m.scan } } == true }
+ com.droiddeck.launcher.playback.SoundtrackController.allow(kept.mapNotNull { it.gameFiles?.path })
+ soundtracks = kept
+ soundtracksLoaded = true
+ }
+ }
val games = if (ready || com.droiddeck.launcher.runtime.LinuxRuntime.hasRootfs(this)) Library.launchableGames(this, arch = scannedArch) else emptyList()
val all = games.distinctBy { it.gameId }
if (ready && scanGeneration == libraryScanGeneration) com.droiddeck.launcher.frontend.LibraryCache.save(this, all, scannedX64)
@@ -3046,6 +3206,8 @@ class FrontEndActivity : ComponentActivity() {
com.droiddeck.launcher.core.AppLanguage.setChosen(this, com.droiddeck.launcher.core.AppLanguage.SYSTEM)
if (!ok) android.widget.Toast.makeText(this, R.string.setup_reset_settings_partial, android.widget.Toast.LENGTH_LONG).show()
com.droiddeck.launcher.ui.Motion.refresh(this)
+ com.droiddeck.launcher.agent.AgentTab.load(this)
+ com.droiddeck.launcher.ui.NavTabs.load(this)
if (!switchLauncherIcon(LauncherIcon.DARK)) recreate()
}
}, "reset-settings").start()
diff --git a/app/src/main/java/com/droiddeck/launcher/HomeActivity.kt b/app/src/main/java/com/droiddeck/launcher/HomeActivity.kt
index 59e10c48e7..0f3a37e83e 100644
--- a/app/src/main/java/com/droiddeck/launcher/HomeActivity.kt
+++ b/app/src/main/java/com/droiddeck/launcher/HomeActivity.kt
@@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Intent
import android.os.Bundle
import com.droiddeck.launcher.session.SessionService
+import com.droiddeck.launcher.session.SessionState
class HomeActivity : Activity() {
override fun attachBaseContext(newBase: android.content.Context) {
@@ -18,15 +19,22 @@ class HomeActivity : Activity() {
}
private fun routeHome() {
- val destination = if (HomeApp.isActiveSteamSession()) {
+ val destination = if (HomeApp.isActiveSteamSession() && !SessionState.pipActive) {
Intent(this, SessionActivity::class.java)
.setAction(SessionService.ACTION_HOME_GUIDE)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
} else {
Intent(this, FrontEndActivity::class.java)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
+ .apply {
+ val page = com.droiddeck.launcher.core.AppUiPrefs.homePage(this@HomeActivity)
+ if (page != com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_STEAM) {
+ putExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV, page)
+ }
+ }
}
- startActivity(destination)
+ if (SessionState.pipActive && destination.component?.className == FrontEndActivity::class.java.name) HomeApp.showFrontEnd(this, destination)
+ else startActivity(destination)
finish()
}
}
diff --git a/app/src/main/java/com/droiddeck/launcher/HomeApp.kt b/app/src/main/java/com/droiddeck/launcher/HomeApp.kt
index 9a724d9044..789af4ec49 100644
--- a/app/src/main/java/com/droiddeck/launcher/HomeApp.kt
+++ b/app/src/main/java/com/droiddeck/launcher/HomeApp.kt
@@ -41,7 +41,7 @@ object HomeApp {
val userSerial: Long = 0L,
) {
val component get() = ComponentName(packageName, className)
- val key get() = "$packageName/$className" + if (userSerial != 0L) "#$userSerial" else ""
+ val key get() = appKey(packageName, className, userSerial)
val work get() = userSerial != 0L
}
@@ -101,6 +101,9 @@ object HomeApp {
?: resolved.loadLabel(pm)?.toString()?.trim()?.takeIf { it.isNotEmpty() }
}
+ private fun appKey(packageName: String, className: String, userSerial: Long) =
+ "$packageName/$className" + if (userSerial != 0L) "#$userSerial" else ""
+
fun roleRequestIntent(context: Context): Intent? {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) return null
val roles = context.getSystemService(RoleManager::class.java) ?: return null
@@ -116,13 +119,25 @@ object HomeApp {
val pm = context.packageManager
val own = Process.myUserHandle()
val iconPx = (ICON_DP * context.resources.displayMetrics.density).roundToInt()
+ val densityDpi = context.resources.displayMetrics.densityDpi
+ val pack = IconPack.active(context)
+ val appColors = IconPack.appColors(context)
+ HomeIcons.load(context)
+ val overrides = HomeIcons.overrides
val apps = users.userProfiles.flatMap { user ->
val serial = if (user == own) 0L else users.getSerialNumberForUser(user)
runCatching { launcher.getActivityList(null, user) }.getOrDefault(emptyList()).mapNotNull { info ->
val component = info.componentName
if (component.packageName == context.packageName && user == own) return@mapNotNull null
val label = info.label?.toString()?.trim().orEmpty().ifEmpty { component.packageName }
- val icon = runCatching { info.getBadgedIcon(0).toBitmap(iconPx, iconPx) }.getOrNull()
+ val icon = runCatching {
+ (overrides[appKey(component.packageName, component.className, serial)]
+ ?.let { IconPack.drawable(context, it.pack, it.drawable, densityDpi) }
+ ?: pack?.icon(component, densityDpi)
+ ?: pack?.plated(info.getIcon(0), iconPx, densityDpi, appColors))
+ ?.let { pm.getUserBadgedIcon(it, user) }
+ ?.toBitmap(iconPx, iconPx)
+ }.getOrNull() ?: runCatching { info.getBadgedIcon(0).toBitmap(iconPx, iconPx) }.getOrNull()
val app = info.applicationInfo
val updated = if (user == own) runCatching { pm.getPackageInfo(component.packageName, 0).lastUpdateTime }.getOrNull() else null
@Suppress("DEPRECATION")
@@ -243,6 +258,19 @@ object HomeApp {
fun isActiveSteamSession(): Boolean =
SessionState.running && SessionState.mode == SessionService.MODE_STEAM
+ fun showFrontEnd(context: Context, intent: Intent = Intent(context, FrontEndActivity::class.java)) {
+ val frontEnd = FrontEndActivity::class.java.name
+ val tasks = runCatching { context.getSystemService(android.app.ActivityManager::class.java)?.appTasks }.getOrNull().orEmpty()
+ val own = tasks.firstOrNull { task ->
+ runCatching { task.taskInfo.let { it.baseIntent.component?.className == frontEnd && it.topActivity?.className == frontEnd } }
+ .getOrDefault(false)
+ }
+ val launch = Intent(intent).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
+ if (own != null && runCatching { own.startActivity(context, launch, null) }.isSuccess) return
+ // The session task shares the front end's affinity, so without MULTIPLE_TASK the front end lands inside the session's PiP window.
+ context.startActivity(launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK))
+ }
+
fun openSystemHomeSettings(context: Context) {
try {
context.startActivity(settingsIntent())
diff --git a/app/src/main/java/com/droiddeck/launcher/HomeIcons.kt b/app/src/main/java/com/droiddeck/launcher/HomeIcons.kt
new file mode 100644
index 0000000000..d3a57be2b4
--- /dev/null
+++ b/app/src/main/java/com/droiddeck/launcher/HomeIcons.kt
@@ -0,0 +1,46 @@
+package com.droiddeck.launcher
+
+import android.content.Context
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.setValue
+
+object HomeIcons {
+ private const val PREFS = "home_launcher"
+ private const val KEY = "icon_overrides"
+ private const val SEPARATOR = '\t'
+
+ data class Choice(val pack: String, val drawable: String)
+
+ var overrides by mutableStateOf