fix oculus page problem, add minor debugging around Connecting...

This commit is contained in:
Max Myers
2021-12-14 17:04:47 -05:00
parent 0956a3b512
commit f2d146d6fc
4 changed files with 48 additions and 27 deletions
+25 -16
View File
@@ -30,6 +30,7 @@ export class AdbClientService {
lastConnectionCheck: number;
deviceStatus: ConnectionStatus = ConnectionStatus.UNAUTHORIZED;
deviceStatusMessage: string = 'Connecting...';
lastErrorMessage: string = '';
pollInterval: number = 1000 * 2;
savePath: string;
isTransferring: boolean;
@@ -353,23 +354,31 @@ This can sometimes be caused by changes to your hosts file. Don't make changes u
});
}
async setupAdb() {
if (!this.isAdbDownloaded()) {
await this.appService.seedPlatformTools();
}
this.appService.electron.ipcRenderer.on('adb-command', (event, arg: any) => {
if (this.adbResolves[arg.uuid]) {
if (arg.status && this.adbResolves[arg.uuid].callback) {
this.adbResolves[arg.uuid].callback(arg.status);
} else if (arg.error) {
this.adbResolves[arg.uuid].reject(arg.error);
} else {
this.adbResolves[arg.uuid].resolve(arg.resp);
}
try {
if (!this.isAdbDownloaded()) {
await this.appService.seedPlatformTools();
}
});
this.adbCommand('setupAdb', {
adbPath: this.appService.path.join(this.adbPath, this.getAdbBinary()),
});
this.appService.electron.ipcRenderer.on('adb-command', (event, arg: any) => {
if (this.adbResolves[arg.uuid]) {
if (arg.status && this.adbResolves[arg.uuid].callback) {
this.adbResolves[arg.uuid].callback(arg.status);
} else if (arg.error) {
this.adbResolves[arg.uuid].reject(arg.error);
} else {
this.adbResolves[arg.uuid].resolve(arg.resp);
}
}
});
this.adbCommand('setupAdb', {
adbPath: this.appService.path.join(this.adbPath, this.getAdbBinary()),
});
this.lastErrorMessage = null;
} catch (e) {
console.error(e);
this.deviceStatus = ConnectionStatus.DISCONNECTED;
this.deviceStatusMessage = 'ADB Setup Error';
this.lastErrorMessage = e.toString();
}
}
isAdbDownloaded() {
try {
+20 -10
View File
@@ -249,32 +249,42 @@ export class AppService {
return sourcesPath;
}
seedPlatformTools() {
return new Promise<void>(async resolve => {
return new Promise<void>(async (resolve, reject) => {
let sourcesPath = this.getPlatformToolsSeedPath();
if (sourcesPath == null) {
console.error('Unable to locate platform tools! Try reinstalling sidequest.');
resolve();
reject('Unable to locate platform tools! Try reinstalling sidequest.');
return;
}
await this.mkdir(this.path.join(this.appData, 'platform-tools'));
try {
let files = this.fs.readdirSync(sourcesPath);
let files: [] = this.fs.readdirSync(sourcesPath);
//always copy the adb executable last so this will retry in the event some copying fails
files.sort((a: string, b) => (a.endsWith('adb') || a.endsWith('adb.exe') ? 1 : -1));
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])
);
try {
this.fs.copyFileSync(
this.path.join(sourcesPath, files[i]),
this.path.join(this.appData, 'platform-tools', files[i])
);
} catch (e) {
console.error('Error copying platform tools file ' + files[i] + e);
//if the file exists and isn't writeable, don't give up, have some hope it's just in use and is fine.
if (!this.fs.existsSync(this.path.join(this.appData, 'platform-tools', files[i]))) {
throw 'Error copying platform tools file: ' + e.toString();
}
}
}
if (this.os.platform() === 'darwin' || this.os.platform() === 'linux') {
this.setExecutable(this.path.join(this.appData, 'platform-tools', 'adb')).then(() =>
setTimeout(() => resolve(), 5000)
setTimeout(() => resolve(), 8000)
);
} else {
setTimeout(() => resolve(), 5000);
setTimeout(() => resolve(), 8000);
}
} catch (e) {
console.error('Error seeding platform tools! ', e);
resolve();
reject('Error seeding platform tools: ' + e.toString());
}
});
}
@@ -222,7 +222,7 @@
arrow_drop_down
</i>
<div id="connection-status" class="connection-status-unauthorized" mz-tooltip
position="bottom" [ngClass]="adbService.connectionCss" [tooltip]="'Device connection status.'">
position="bottom" [ngClass]="adbService.connectionCss" [tooltip]="adbService.lastErrorMessage||'Device connection status.'">
<div id="connection-status-message" [innerHTML]="appService.versionName+'&nbsp;&nbsp;'+adbService.deviceStatusMessage"></div>
</div>
</div>
+2
View File
@@ -15,6 +15,8 @@ const exec = require('child_process').exec;
const crypto = require('crypto');
const request = require('request');
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');
const OPEN_IN_SYSTEM_BROWSER_DOMAINS = [
'www.oculus.com',