From c6d1f69fd4a934d697895ba766965738316eaf0b Mon Sep 17 00:00:00 2001 From: Shane Harris Date: Tue, 24 Aug 2021 12:10:20 +0200 Subject: [PATCH] added fixes for connecting issues including restoring the adb files if any are missing and better handling of errors. --- desktop-app/src/app/adb-client.service.ts | 35 ++++++++++-------- desktop-app/src/app/app.service.ts | 43 +++++++++++------------ electron/app.ts | 2 +- package.json | 2 +- 4 files changed, 42 insertions(+), 40 deletions(-) diff --git a/desktop-app/src/app/adb-client.service.ts b/desktop-app/src/app/adb-client.service.ts index d467588..8e4dbe2 100644 --- a/desktop-app/src/app/adb-client.service.ts +++ b/desktop-app/src/app/adb-client.service.ts @@ -275,7 +275,7 @@ export class AdbClientService { ' ' + this.batteryLevel + '% '; - this.beatonService.checkIsBeatOnRunning(this); + // this.beatonService.checkIsBeatOnRunning(this); } catch (e) { const isBadConnection = e && e.message === "Failure: 'closed'" && e.name === 'FailError'; if (isBadConnection) { @@ -336,7 +336,13 @@ export class AdbClientService { requestAnimationFrame(this.connectedStatus.bind(this)); }) .catch(err => { - requestAnimationFrame(this.connectedStatus.bind(this)); + alert( + this.appService.os.platform() === 'win32' + ? `It looks like there is something wrong with your install. +Uninstall SideQuest and select "yes" when asked to delete app data and then install again. You may need to move your backup apks.` + : `It looks like something went wrong, try uninstalling SideQuest and reinstalling. +This can sometimes be caused by changes to your hosts file. Don't make changes unless you know what you are doing.` + ); }); } adbCommand(command: string, settings?, callback?) { @@ -366,19 +372,18 @@ export class AdbClientService { }); } isAdbDownloaded() { - // let command = 'which adb'; - // if (process.platform == 'win32') { - // command = 'where adb'; - // } - // try{ - // - // let stdout = this.appService.execSync(command); - // if (this.doesFileExist(stdout)) { - // this.adbPath = this.appService.path.dirname(stdout); - // return true; - // } - // }catch(e){} - return this.doesFileExist(this.adbPath); + let downloaded = true; + if (!this.doesFileExist(this.adbPath)) { + return false; + } + let source_files = this.appService.fs.readdirSync(this.appService.path.join(process.cwd(), 'build', 'platform-tools')); + let dest_files = this.appService.fs.readdirSync(this.adbPath); + source_files.forEach(d => { + if (dest_files.indexOf(d) === -1) { + downloaded = false; + } + }); + return downloaded; // this.doesFileExist(this.appService.path.join(this.adbPath, this.getAdbBinary())); } setPermission(packageName: string, permission: string, isRevoke?: boolean) { return this.adbCommand('shell', { diff --git a/desktop-app/src/app/app.service.ts b/desktop-app/src/app/app.service.ts index b239a56..c7f2082 100644 --- a/desktop-app/src/app/app.service.ts +++ b/desktop-app/src/app/app.service.ts @@ -227,30 +227,27 @@ export class AppService { } seedPlatformTools() { return new Promise(async resolve => { - if (!this.fs.existsSync(this.path.join(this.appData, 'platform-tools'))) { - let sourcesPath = this.path.join(__dirname, '..', 'platform-tools'); - if (!this.fs.existsSync(sourcesPath)) { - sourcesPath = this.path.join(process.cwd(), 'build', 'platform-tools'); - } - // console.log(this.path.join(__dirname, '..', 'platform-tools'), process.cwd(), __dirname); - await this.mkdir(this.path.join(this.appData, 'platform-tools')); - try { - let files = this.fs.readdirSync(sourcesPath); - for (let i = 0; i < files.length; i++) { - this.fs.copyFileSync( - this.path.join(sourcesPath, files[i]), - this.path.join(this.appData, 'platform-tools', files[i]) - ); - } - if (this.os.platform() === 'darwin' || this.os.platform() === 'linux') { - this.setExecutable(this.path.join(this.appData, 'platform-tools', 'adb')).then(() => - setTimeout(() => resolve(), 5000) - ); - } else { - setTimeout(() => resolve(), 5000); - } - } catch (e) {} + let sourcesPath = this.path.join(__dirname, '..', 'platform-tools'); + if (!this.fs.existsSync(sourcesPath)) { + sourcesPath = this.path.join(process.cwd(), 'build', 'platform-tools'); } + await this.mkdir(this.path.join(this.appData, 'platform-tools')); + try { + let files = this.fs.readdirSync(sourcesPath); + for (let i = 0; i < files.length; i++) { + this.fs.copyFileSync( + this.path.join(sourcesPath, files[i]), + this.path.join(this.appData, 'platform-tools', files[i]) + ); + } + if (this.os.platform() === 'darwin' || this.os.platform() === 'linux') { + this.setExecutable(this.path.join(this.appData, 'platform-tools', 'adb')).then(() => + setTimeout(() => resolve(), 5000) + ); + } else { + setTimeout(() => resolve(), 5000); + } + } catch (e) {} }); } makeFolders() { diff --git a/electron/app.ts b/electron/app.ts index e48734f..808cf58 100644 --- a/electron/app.ts +++ b/electron/app.ts @@ -327,7 +327,7 @@ class ADB { if (!this.client) return ecb('Not connected.'); this.client .listDevices() - .then(cb) + .then(d => cb(d)) .catch(e => ecb(e)); } setProperties(serial, command, cb, ecb) { diff --git a/package.json b/package.json index f7847ea..5d8f218 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "SideQuest", "productName": "SideQuest", - "version": "0.10.24", + "version": "0.10.25", "description": "A open app store for mobile android based VR devices such as the Levovo Mirage, Oculus Go, Oculus Quest, Vive Focus.", "repository": "https://github.com/SideQuestVR/SideQuest.git", "license": "UNLICENCED",