mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
Fix agent pet overlay permission and GitHub setup (#2548)
This commit is contained in:
1 parent
827ab2d485
commit
1b732c1b65
5 files changed
+28
-35
No files matched your search
@@ -1,27 +1,17 @@
|
||||
#!/bin/bash
|
||||
# GitHub sign-in through Android's browser, with the one-time code typed in for the person.
|
||||
serial=${ADB_SERIAL:-127.0.0.1:5555}
|
||||
display=${DD_BROWSER_DISPLAY:-0}
|
||||
adb connect "$serial" >/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"
|
||||
@@ -77,6 +77,9 @@ class AgentHostService : Service() {
|
||||
private fun describe(context: Context): String {
|
||||
val lab = AgentHost.lab?.takeIf { it.running }
|
||||
if (lab != null) return context.getString(R.string.agent_lab_progress, lab.permille / 10, minutes(lab.etaSeconds.toLong().coerceAtLeast(0)))
|
||||
AgentSetup.detail[AgentSetup.Step.GITHUB]?.takeIf {
|
||||
AgentSetup.status[AgentSetup.Step.GITHUB] == AgentSetup.Status.WORKING && it.startsWith("GitHub device code:")
|
||||
}?.let { return it }
|
||||
if (AgentHost.state != AgentHost.State.WORKING) return context.getString(R.string.agent_setting_up)
|
||||
val tool = AgentHost.running()
|
||||
val elapsed = minutes((SystemClock.elapsedRealtime() - AgentHost.turnStarted) / 1000)
|
||||
|
||||
@@ -106,7 +106,10 @@ object AgentSetup {
|
||||
child.inputStream.bufferedReader().forEachLine { line ->
|
||||
log.appendLine(line)
|
||||
val text = line.trim()
|
||||
if (text.isNotEmpty() && !noise(text)) main.post { detail[step] = text.take(160) }
|
||||
if (text.isNotEmpty() && !noise(text)) main.post {
|
||||
detail[step] = text.take(160)
|
||||
if (step == Step.GITHUB && text.startsWith("GitHub device code:")) AgentHostService.update(app)
|
||||
}
|
||||
}
|
||||
child.waitFor().also { log.appendLine("exit $it") }
|
||||
}
|
||||
|
||||
@@ -116,6 +116,10 @@ internal object AgentPet {
|
||||
fun set(context: Context, on: Boolean) {
|
||||
enabled = on
|
||||
AgentHost.prefs(context).edit().putBoolean(KEY, on).apply()
|
||||
if (on) {
|
||||
allowed = PetWindows.allowed(context)
|
||||
if (!allowed) requestFloating(context)
|
||||
}
|
||||
}
|
||||
|
||||
/** Opens the system page where the user lets DroidDeck draw over other apps. */
|
||||
|
||||
Reference in new issue
Block a user