added fixes for connecting issues including restoring the adb files if any are missing and better handling of errors.

This commit is contained in:
Shane Harris
2021-08-24 12:10:20 +02:00
parent ae4e2b1556
commit c6d1f69fd4
4 changed files with 42 additions and 40 deletions
+20 -15
View File
@@ -275,7 +275,7 @@ export class AdbClientService {
' </i>' +
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', {
+20 -23
View File
@@ -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() {
+1 -1
View File
@@ -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) {
+1 -1
View File
@@ -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",