droidsuite 1.0.0-beta.12 → 1.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/DroidSuite.apk +0 -0
- package/package.json +1 -1
- package/src/adbinstall.mjs +19 -0
- package/src/builds.mjs +5 -2
- package/src/server.mjs +9 -4
package/app/DroidSuite.apk
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "droidsuite",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.13",
|
|
4
4
|
"description": "Your Android phone on your computer, no cable: see and control its screen, type on it, copy files and text both ways, install builds and debug over Wi-Fi.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"android",
|
package/src/adbinstall.mjs
CHANGED
|
@@ -81,6 +81,25 @@ async function extractSplits(path) {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* sha256 of the APK [serial] has installed for [packageName], or null (not installed, split APKs, or no sha256sum).
|
|
86
|
+
* A build that matches is already on the phone (Gradle or Android Studio just installed it): reinstalling it would
|
|
87
|
+
* kill the app, and any test running in it.
|
|
88
|
+
*/
|
|
89
|
+
export async function installedSha(adb, serial, packageName) {
|
|
90
|
+
if (!/^[\w.]+$/.test(packageName ?? '')) return null;
|
|
91
|
+
try {
|
|
92
|
+
const paths = (await adb(['-s', serial, 'shell', `pm path ${packageName}`], { timeout: 10_000 }))
|
|
93
|
+
.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.startsWith('package:')).map((l) => l.slice(8));
|
|
94
|
+
// Android 11+ paths look like /data/app/~~Xy3_=/com.example.app-Ab9==/base.apk: allow ~ = + but nothing a shell reads.
|
|
95
|
+
if (paths.length !== 1 || !/^\/[\w./~=+-]+\.apk$/.test(paths[0])) return null;
|
|
96
|
+
const out = await adb(['-s', serial, 'shell', `sha256sum ${paths[0]}`], { timeout: 30_000 });
|
|
97
|
+
return /^([0-9a-f]{64})\s/i.exec(out.trim())?.[1].toLowerCase() ?? null;
|
|
98
|
+
} catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
84
103
|
/**
|
|
85
104
|
* Installs [build] ({ path, kind }) on [serial]: `install -r -d -t` (replace, allow downgrade of debug builds,
|
|
86
105
|
* allow test-only APKs), or `install-multiple` for split bundles. Resolves to { ok, code, message, routeProblem }.
|
package/src/builds.mjs
CHANGED
|
@@ -7,7 +7,10 @@ import { basename, extname, join, resolve, dirname } from 'node:path';
|
|
|
7
7
|
import { readApkInfo } from './apkinfo.mjs';
|
|
8
8
|
|
|
9
9
|
const EXTS = new Set(['.apk', '.apks', '.zip']);
|
|
10
|
-
|
|
10
|
+
// androidTest: Gradle's instrumentation-test APKs. They aren't apps to install, and pushing them (or the app again)
|
|
11
|
+
// while Gradle runs its tests on the phone kills the app under test, so the tests restart.
|
|
12
|
+
const SKIP_DIRS = new Set(['node_modules', '.git', '.gradle', 'intermediates', 'tmp', 'androidTest']);
|
|
13
|
+
const isTestApk = (name) => /-androidTest(-[\w-]+)?\.apk$/i.test(name);
|
|
11
14
|
|
|
12
15
|
export function buildId(path) {
|
|
13
16
|
return createHash('sha1').update(resolve(path)).digest('hex').slice(0, 12);
|
|
@@ -23,7 +26,7 @@ export function sha256File(path) {
|
|
|
23
26
|
async function listFiles(root, depth = 0) {
|
|
24
27
|
let st;
|
|
25
28
|
try { st = await stat(root); } catch { return []; }
|
|
26
|
-
if (st.isFile()) return EXTS.has(extname(root).toLowerCase()) ? [root] : [];
|
|
29
|
+
if (st.isFile()) return EXTS.has(extname(root).toLowerCase()) && !isTestApk(basename(root)) ? [root] : [];
|
|
27
30
|
if (!st.isDirectory() || depth > 8) return [];
|
|
28
31
|
const out = [];
|
|
29
32
|
for (const ent of await readdir(root, { withFileTypes: true })) {
|
package/src/server.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { pairLink, safeEqual } from './config.mjs';
|
|
|
11
11
|
import { PushStore } from './files.mjs';
|
|
12
12
|
import { sha256File } from './builds.mjs';
|
|
13
13
|
import { Nearby, NearbyError } from './nearby.mjs';
|
|
14
|
-
import { adbDevices, installApk, matchDevice } from './adbinstall.mjs';
|
|
14
|
+
import { adbDevices, installApk, installedSha, matchDevice } from './adbinstall.mjs';
|
|
15
15
|
import { InstallQueue } from './installer.mjs';
|
|
16
16
|
import { capabilities, tooNew } from './capabilities.mjs';
|
|
17
17
|
import {
|
|
@@ -217,9 +217,14 @@ export function createBridgeServer({
|
|
|
217
217
|
const current = index.get(build.id);
|
|
218
218
|
if (!current || current.sha256 !== build.sha256) return; // superseded by a newer build of the same file
|
|
219
219
|
const route = await resolveAdb(res, phone);
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
220
|
+
// Already on the phone byte for byte (Gradle or Android Studio installed it): don't restart the app for nothing.
|
|
221
|
+
const same = route && !manual && current.kind === 'apk' && current.packageName
|
|
222
|
+
&& (await installedSha(route.runner, route.serial, current.packageName)) === current.sha256;
|
|
223
|
+
const result = same
|
|
224
|
+
? { ok: true, code: null, message: 'Already installed' }
|
|
225
|
+
: route
|
|
226
|
+
? await installApk(route.runner, route.serial, current)
|
|
227
|
+
: { ok: false, code: null, message: 'Wireless debugging is no longer connected', routeProblem: true };
|
|
223
228
|
if (!phones.has(res)) {
|
|
224
229
|
// The phone went away (DroidSuite updating itself restarts the app): still say what happened here;
|
|
225
230
|
// the phone sees the build list when it's back.
|