From 48a675b71e9948106062a5bd24288a6728f2b1cb Mon Sep 17 00:00:00 2001 From: Nathanael Anderson Date: Thu, 28 Mar 2024 18:58:00 -0600 Subject: [PATCH] Lots of fixes.... --- desktop-app/src/app/adb-client.service.ts | 53 ++++-- .../header-banner/header-banner.component.ts | 1 - .../src/app/header/header.component.html | 2 +- .../headset-settings.component.html | 5 +- .../setup-guide/setup-guide.component.html | 3 + .../app/setup-guide/setup-guide.component.ts | 3 +- .../src/environments/environment.test.ts | 2 +- electron/app.ts | 156 +++++++++++++----- electron/platform-tools.ts | 8 +- package.json | 6 +- 10 files changed, 170 insertions(+), 69 deletions(-) diff --git a/desktop-app/src/app/adb-client.service.ts b/desktop-app/src/app/adb-client.service.ts index d208012..b9066fc 100644 --- a/desktop-app/src/app/adb-client.service.ts +++ b/desktop-app/src/app/adb-client.service.ts @@ -57,7 +57,7 @@ export class AdbClientService { devices: ADBDevice[]; displayDevices: ADBDevice[]; deviceName: string; - connectionCss: any; + connectionCss: string = "connection-status-unauthorized"; obbRegex = /[a-z]{4,5}.[0-9]{1,}.([A-z0-9.]{1,}).obb/; freespace = { available: '', @@ -85,13 +85,25 @@ export class AdbClientService { this.setConnectionCssClass(); } setConnectionCssClass() { - this.connectionCss = { - 'connection-status-connected': this.deviceStatus === ConnectionStatus.CONNECTED, - 'connection-status-unauthorized': this.deviceStatus === ConnectionStatus.UNAUTHORIZED, - 'connection-status-disconnected': this.deviceStatus === ConnectionStatus.DISCONNECTED, - 'connection-status-too-many': this.deviceStatus === ConnectionStatus.LINUX_PERMS, - 'connection-status-dev-mode': this.deviceStatus === ConnectionStatus.DEV_MODE, - }; + switch ( this.deviceStatus ) { + case ConnectionStatus.CONNECTED: + this.connectionCss = 'connection-status-connected'; + break; + case ConnectionStatus.UNAUTHORIZED: + this.connectionCss = 'connection-status-unauthorized'; + break; + case ConnectionStatus.DISCONNECTED: + this.connectionCss = 'connection-status-disconnected'; + break; + case ConnectionStatus.LINUX_PERMS: + this.connectionCss = 'connection-status-too-many'; + break; + case ConnectionStatus.DEV_MODE: + this.connectionCss = 'connection-status-dev-mode'; + break; + default: + this.connectionCss = 'connection-status-unauthorized'; + } } diagBegin() { @@ -147,13 +159,19 @@ export class AdbClientService { command = command.substr(3); } return new Promise((resolve, reject) => { + const cmd = '"' + this.appService.path.join(this.adbPath, this.getAdbBinary()) + '" -s ' + this.deviceSerial + ' ' + command this.appService.exec( - '"' + this.appService.path.join(this.adbPath, this.getAdbBinary()) + '" -s ' + this.deviceSerial + ' ' + command, + cmd, function(err, stdout, stderr) { if (err) { return reject(err); } - if (stderr) return reject(stderr); + if (stderr) { + // Monkey always reports the Args/Commands on stderr, so ignore it if that is all that it is... + if (cmd.indexOf("shell monkey -p") === -1 || stderr.indexOf("data=\"android.intent.category.LAUNCHER\"") !== stderr.length - 40) { + return reject(stderr); + } + } return resolve(stdout); } ); @@ -246,13 +264,22 @@ export class AdbClientService { ((p.substr(0, 10) !== 'com.oculus' && p.substr(0, 11) !== 'com.android' && p.substr(0, 11) !== 'android.ext' && + p.substr(0, 8) !== 'com.meta' && p !== 'android' && p.substr(0, 12) !== 'com.qualcomm' && p !== 'com.facebook.system' && p !== 'oculus.platform' && p !== 'com.svox.pico' && - p !== 'org.codeaurora.bluetooth') || - p === 'com.oculus.DogCorp') + p !== 'org.codeaurora.bluetooth' && + p !== 'com.facebook.wearable.system.location.proxy' && + p !== 'com.facebook.arvr.quillplayer' && + p !== 'com.facebook.wearable.system.location.service' && + p !== 'com.facebook.spatial_persistence_service' && + p !== 'meta.skymap.service' + ) || + p === 'com.oculus.DogCorp' || + p === 'com.meta.samples.crypticcabinet' + ) ); }); // if (this.devicePackages.indexOf('com.apkinstaller.ApkInstaller') > -1 ) { @@ -338,7 +365,7 @@ export class AdbClientService { } this.displayDevices = this.devices; })(); - document.getElementById('connection-status').className = 'connection-status-' + status; + document.getElementById('connection-status').className = this.connectionCss; switch (this.deviceStatus) { case ConnectionStatus.LINUX_PERMS: this.deviceStatusMessage = 'Warning: no permissions. ADB udev rules missing.'; diff --git a/desktop-app/src/app/header-banner/header-banner.component.ts b/desktop-app/src/app/header-banner/header-banner.component.ts index 584f2b8..cc38896 100644 --- a/desktop-app/src/app/header-banner/header-banner.component.ts +++ b/desktop-app/src/app/header-banner/header-banner.component.ts @@ -115,7 +115,6 @@ export class HeaderBannerComponent implements OnInit { // this.telemetry.telemetry({ event: 'install-sidequest-apk', installType: telemEvent, oldVersion }); this.isLoading = true; try { - throw new Error('bypass_sdk_download'); await this.getLatestApk(); await this.downloadAPK(); } catch (e) { diff --git a/desktop-app/src/app/header/header.component.html b/desktop-app/src/app/header/header.component.html index 1303947..2f708e8 100644 --- a/desktop-app/src/app/header/header.component.html +++ b/desktop-app/src/app/header/header.component.html @@ -132,7 +132,7 @@ arrow_drop_down
-
diff --git a/desktop-app/src/app/headset-settings/headset-settings.component.html b/desktop-app/src/app/headset-settings/headset-settings.component.html index a965dfc..4908830 100644 --- a/desktop-app/src/app/headset-settings/headset-settings.component.html +++ b/desktop-app/src/app/headset-settings/headset-settings.component.html @@ -434,15 +434,16 @@
+ - +

SideQuest Stuff

SideQuest Folders

- This changes the resolution of captured videos on the Quest + This allows you to open a folder in your file explorer.

diff --git a/desktop-app/src/app/setup-guide/setup-guide.component.html b/desktop-app/src/app/setup-guide/setup-guide.component.html index 53c922b..f1b11d7 100644 --- a/desktop-app/src/app/setup-guide/setup-guide.component.html +++ b/desktop-app/src/app/setup-guide/setup-guide.component.html @@ -16,6 +16,8 @@

If you are still having trouble then please visit our support community on SideQuest.

Open Support Community

+ + TODO: This site is no longer active -- find another way....

If instructed to upload logs by a SideQuest support person, please click this button.

{{'Upload Logs'}}
@@ -23,6 +25,7 @@

{{link}}

Copy to Clipboard
+
Thank you!
diff --git a/desktop-app/src/app/setup-guide/setup-guide.component.ts b/desktop-app/src/app/setup-guide/setup-guide.component.ts index c85f366..eef4077 100644 --- a/desktop-app/src/app/setup-guide/setup-guide.component.ts +++ b/desktop-app/src/app/setup-guide/setup-guide.component.ts @@ -51,8 +51,7 @@ export class SetupGuideComponent implements OnInit { .map(key => encodeURIComponent(key) + '=' + encodeURIComponent(data[key])) .join('&'); try { - const ftch = (window as any).require('node-fetch'); - const resp = await ftch('https://api.teknik.io/v1/Paste', { + const resp = await fetch('https://api.teknik.io/v1/Paste', { body: formData, method: 'POST', headers: { diff --git a/desktop-app/src/environments/environment.test.ts b/desktop-app/src/environments/environment.test.ts index 42d4ddc..bc7899d 100644 --- a/desktop-app/src/environments/environment.test.ts +++ b/desktop-app/src/environments/environment.test.ts @@ -1,5 +1,5 @@ export const environment = { - production: false, + production: true, header: {color: "sidetestvr", text: "Side Test VR"}, configuration: { web_url: 'https://sidetestvr.com', diff --git a/electron/app.ts b/electron/app.ts index edfaac4..ef9f5d3 100644 --- a/electron/app.ts +++ b/electron/app.ts @@ -9,11 +9,11 @@ const download = require('./download'); const extract = require('extract-zip'); const Readable = require('stream').Readable; -const adb = require('@devicefarmer/adbkit').Adb; +const Adb = require('@devicefarmer/adbkit').Adb; const fs = require('fs'); const crypto = require('crypto'); const request = require('request'); -const progress = require('request-progress'); +//const progress = require('request-progress'); //without this, there's a bug in electron that makes facebook pages ruin everything, see https://github.com/electron/electron/issues/25469 app.commandLine.appendSwitch('disable-features', 'CrossOriginOpenerPolicy'); @@ -43,8 +43,27 @@ const makeDeferred = () => { return deferred; } +export class ReadableStreamClone extends Readable { + constructor(readableStream, options?) { + super(options); + readableStream.on('data', chunk => { + this.push(chunk); + }); + + readableStream.on('end', () => { + this.push(null); + }); + + readableStream.on('error', err => { + this.emit('error', err); + }); + } + public _read() {} +} + + class ADB { - client= null; + client = null; _logcat; adbPath; _clientSetup = makeDeferred(); @@ -52,7 +71,7 @@ class ADB { setupAdb(adbPath, cb, ecb) { if (this.client) return; this.adbPath = adbPath; - this.client = adb.createClient({ + this.client = Adb.createClient({ bin: adbPath, }); this._clientSetup.resolve(); @@ -74,7 +93,7 @@ class ADB { }, rejectUnauthorized: process.env.NODE_ENV !== 'dev', }; - request(options, (error, response, body) => { + request(url, options, (error, response, body) => { if (error) { reject(error); } else { @@ -141,7 +160,7 @@ class ADB { rejectUnauthorized: process.env.NODE_ENV !== 'dev', json: { token: token }, }; - request(options, (error, response, body) => { + request(options.url, options, (error, response, body) => { if (!error && body.data && body.data.apps && body.data.apps.length) { let tasks = []; for (let i = 0; i < body.data.apps.length; i++) { @@ -185,8 +204,9 @@ class ADB { this._clientSetup.promise.then(() => { if (!this.client) return ecb('Not connected.'); if (!this._logcat) this.endLogcat(); - this.client - .openLogcat(serial, { clear: true }) + const device = this.client.getDevice(serial); + device + .openLogcat({ clear: true }) .then(logcat => { this._logcat = logcat; logcat.include(tag, priority).on('entry', entry => scb(entry)); @@ -197,8 +217,8 @@ class ADB { installRemote(serial, path, cb, ecb) { this._clientSetup.promise.then(() => { if (!this.client) return ecb('Not connected.'); - this.client - .installRemote(serial, path) + const device = this.client.getDevice(serial); + device.installRemote(path) .then(cb) .catch(e => ecb(e)); }).catch(e => ecb(e)); @@ -206,7 +226,7 @@ class ADB { async install(serial, apkpath, isLocal, cb, scb, ecb) { await this._clientSetup.promise; - console.log('installapk'); + console.log('installapk', apkpath, isLocal); let stopUpdate; installErrorCallback = e => { @@ -214,6 +234,7 @@ class ADB { ecb(e); console.log(e, stopUpdate); }; + if (!this.client) return ecb('Not connected.'); if (isLocal) { let found; @@ -232,8 +253,41 @@ class ADB { if (isLocal) { stream = fs.createReadStream(apkpath); } else { + const response = await fetch(apkpath + '?t=' + Date.now()); + if (!response.ok || response.body == null) { + console.log(response.statusText, response.status, response.headers); + return ecb('Unable to fetch package'); + } + + let size = parseInt(response.headers.get('Content-Length') || '0', 10); + if (size <= 0) { + // Approximate app size in case we cannot get the size from the server + size = 30_000_000; + } + let bytesRead = 0; + let webStream = Readable.fromWeb(response.body); + stream = new ReadableStreamClone(webStream); + let progress = new ReadableStreamClone(webStream); + + progress.on('data', chunk => { + bytesRead += chunk.length; + const percentage = Math.round(Math.min(bytesRead / size, 1) * 100); + if (!stopUpdate) { + scb({percent: percentage}); + } + }); + progress.on('end', () => { + if (!stopUpdate) { + scb({ + percent: 1, + }); + } + }); + + + /* stream = new Readable().wrap( - progress(request(apkpath), { + progress(request(apkpath, undefined, undefined), { throttle: 60, }) .on('progress', state => { @@ -242,15 +296,17 @@ class ADB { } }) .on('end', () => { + console.log("Downloaded") if (!stopUpdate) { scb({ percent: 1, }); } }) - ); + ); */ } } catch (e) { + console.error(e) const isInvalidURI = e && typeof e.message === 'string' && e.message.startsWith('Invalid URI "'); if (isInvalidURI) { return ecb("Can't download file. Invalid URL:"); @@ -258,16 +314,19 @@ class ADB { return ecb(e); } } - this.client - .install(serial, stream) + + const device = this.client.getDevice(serial); + device + .install(stream) .then(cb) - .catch(e => ecb(e)); + .catch(e => { console.error("error installing", e); ecb(e) }); } uninstall(serial, packageName, cb, ecb) { this._clientSetup.promise.then(() => { if (!this.client) return ecb('Not connected.'); - this.client - .uninstall(serial, packageName) + const device = this.client.getDevice(serial); + device + .uninstall(packageName) .then(cb) .catch(e => ecb(e)); }).catch(e => ecb(e)); @@ -275,8 +334,10 @@ class ADB { clear(serial, packageName, cb, ecb) { this._clientSetup.promise.then(() => { if (!this.client) return ecb('Not connected.'); - this.client - .clear(serial, packageName) + + const device = this.client.getDevice(serial); + device + .clear(packageName) .then(cb) .catch(e => ecb(e)); }).catch(e => ecb(e)); @@ -303,8 +364,9 @@ class ADB { tcpip(serial, cb, ecb) { this._clientSetup.promise.then(() => { if (!this.client) return ecb('Not connected.'); - this.client - .tcpip(serial, 5555) + const device = this.client.getDevice(serial); + device + .tcpip(5555) .then(r => { console.log(r); cb(r); @@ -318,8 +380,9 @@ class ADB { usb(serial, cb, ecb) { this._clientSetup.promise.then(() => { if (!this.client) return ecb('Not connected.'); - this.client - .usb(serial) + const device = this.client.getDevice(serial); + device + .usb() .then(cb) .catch(e => ecb(e)); }).catch(e => ecb(e)); @@ -336,7 +399,9 @@ class ADB { setProperties(serial, command, cb, ecb) { this._clientSetup.promise.then(() => { if (!this.client) return ecb('Not connected.'); - this.client + + const device = this.client.getDevice(serial); + device .transport(serial) .then(function(transport) { return new SetPropertiesCommand(transport).execute(command); @@ -350,8 +415,9 @@ class ADB { getPackages(serial, cb, ecb) { this._clientSetup.promise.then(() => { if (!this.client) return ecb('Not connected.'); - this.client - .getPackages(serial) + const device = this.client.getDevice(serial); + device + .getPackages() .then(res => cb(res)) .catch(e => ecb(e)); }).catch(e => ecb(e)); @@ -359,9 +425,10 @@ class ADB { shell(serial, command, cb, ecb) { this._clientSetup.promise.then(() => { if (!this.client) return ecb('Not connected.'); - this.client - .shell(serial, command) - .then(adb.util.readAll) + const device = this.client.getDevice(serial); + device + .shell(command) + .then(Adb.util.readAll) .then(res => cb(res.toString())) .catch(e => ecb(e)); }).catch(e => ecb(e)); @@ -369,8 +436,9 @@ class ADB { readdir(serial, path, cb, ecb) { this._clientSetup.promise.then(() => { if (!this.client) return ecb('Not connected.'); - this.client - .readdir(serial, path) + const device = this.client.getDevice(serial); + device + .readdir(path) .then(res => res .map(r => { @@ -387,8 +455,9 @@ class ADB { this._clientSetup.promise.then(() => { if (!this.client) return ecb('Not connected.'); - this.client - .push(serial, fs.createReadStream(path), savePath) + const device = this.client.getDevice(serial); + device + .push(fs.createReadStream(path), savePath) .then(transfer => { let _stats, autoCancel; const interval = setInterval(() => { @@ -420,8 +489,9 @@ class ADB { this._clientSetup.promise.then(() => { if (!this.client) return ecb('Not connected.'); - this.client - .pull(serial, path) + const device = this.client.getDevice(serial); + device + .pull(path) .then(transfer => { transfer.on('progress', stats => { scb(stats); @@ -442,7 +512,8 @@ class ADB { stat(serial, path, cb, ecb) { this._clientSetup.promise.then(() => { if (!this.client) return ecb('Not connected.'); - this.client + const device = this.client.getDevice(serial); + device .stat(serial, path) .then(res => cb(res)) .catch(e => ecb(e)); @@ -807,10 +878,9 @@ function setupApp() { event.sender.send('extract-progress', { stats, token }); }, }, - err => { - event.sender.send('extract-file', { token }); - } - ); + ).catch(err => { + event.sender.send('extract-file', { token }); + }); }); ipcMain.on('automatic-update', (event, arg) => { @@ -822,13 +892,13 @@ function setupApp() { }); ipcMain.on('adb-command', (event, arg) => { const success = d => { - // console.log(" ", arg.command, "Success", d) + //console.log(" ", arg.command, "Success", d) if (!event.sender.isDestroyed()) { event.sender.send('adb-command', { command: arg.command, resp: d, uuid: arg.uuid }); } }; const reject = e => { - // console.log(" ", arg.command, "reject", e) + //console.log(" ", arg.command, "reject", e) if (!event.sender.isDestroyed()) { event.sender.send('adb-command', { command: arg.command, error: e, uuid: arg.uuid }); } diff --git a/electron/platform-tools.ts b/electron/platform-tools.ts index e64a83a..202d6d3 100644 --- a/electron/platform-tools.ts +++ b/electron/platform-tools.ts @@ -38,8 +38,8 @@ if (!__fs.existsSync(outputPath)) { var stats = entry.fileName; // console.log(stats); }, - }, - function(err) { + }).catch( + (err) => { if (err) { return console.log(err); } @@ -58,8 +58,8 @@ if (!__fs.existsSync(outputPath)) { } }); }); - } - ); + }); + }, 5000); }) .catch(function(e) { diff --git a/package.json b/package.json index 77ebad0..baad1b5 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "concurrently": "concurrently", "start": "concurrently \"yarn electron-build && yarn platform-tools && wait-on http-get://localhost:4205/ && cross-env NODE_ENV=dev electron .\" \"cd desktop-app && ng serve --port 4205\"", "start:test": "concurrently \"yarn electron-build && yarn platform-tools && wait-on http-get://localhost:4205/ && cross-env NODE_ENV=dev SQ_ENV_CFG=test electron .\" \"cd desktop-app && ng serve -c test --port 4205\"", + "start:sidetest": "concurrently \"yarn electron-build && yarn platform-tools && wait-on http-get://localhost:4205/ && cross-env NODE_ENV=dev SQ_ENV_CFG=test electron .\" \"cd desktop-app && ng serve -c test --port 4205\"", "start:test2": "concurrently \"yarn electron-build && yarn platform-tools && wait-on http-get://localhost:4205/ && cross-env NODE_ENV=dev SQ_ENV_CFG=test2 electron .\" \"cd desktop-app && ng serve -c test2 --port 4205\"", "start:local": "concurrently \"yarn electron-build && yarn platform-tools && wait-on http-get://localhost:4205/ && cross-env NODE_ENV=dev SQ_ENV_CFG=local electron .\" \"cd desktop-app && ng serve -c local --port 4205\"", "start:localhost": "concurrently \"yarn electron-build && yarn platform-tools && wait-on http-get://localhost:4205/ && cross-env NODE_ENV=dev SQ_ENV_CFG=localhost electron .\" \"cd desktop-app && ng serve -c localhost --port 4205\"", @@ -18,8 +19,9 @@ "dist": "yarn electron-build && yarn platform-tools && yarn app-build && env-cmd --silent electron-builder --publish onTagOrDraft", "build:win": "yarn electron-build && yarn platform-tools && yarn app-build && cross-env NODE_ENV=production electron-builder --win", "build:linux": "yarn electron-build && yarn platform-tools && yarn app-build && cross-env NODE_ENV=production electron-builder --linux", - "dist-test": "yarn electron-build && yarn platform-tools && yarn app-build-test && cross-env SQ_ENV_CFG=test electron-builder", - "dist-fried": "yarn electron-build && yarn platform-tools && yarn app-build-fried && cross-env SQ_ENV_CFG=fried electron-builder", + "dist-test": "yarn electron-build && yarn platform-tools && yarn app-build-test && cross-env NODE_ENV=production SQ_ENV_CFG=test electron-builder", + "dist-sidetest": "yarn electron-build && yarn platform-tools && yarn app-build-test && cross-env NODE_ENV=production SQ_ENV_CFG=test electron-builder", + "dist-fried": "yarn electron-build && yarn platform-tools && yarn app-build-fried && cross-env NODE_ENV=production SQ_ENV_CFG=fried electron-builder", "dist-localhost": "yarn electron-build && yarn platform-tools && yarn app-build-localhost && cross-env SQ_ENV_CFG=localhost electron-builder --linux", "angular": "cd desktop-app && ng serve --port 4205", "angular:test": "cd desktop-app && ng serve -c test --port 4205",