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
@@ -30,6 +30,7 @@ export class AdbClientService {
lastConnectionCheck: number; lastConnectionCheck: number;
deviceStatus: ConnectionStatus = ConnectionStatus.UNAUTHORIZED; deviceStatus: ConnectionStatus = ConnectionStatus.UNAUTHORIZED;
deviceStatusMessage: string = 'Connecting...'; deviceStatusMessage: string = 'Connecting...';
lastErrorMessage: string = '';
pollInterval: number = 1000 * 2; pollInterval: number = 1000 * 2;
savePath: string; savePath: string;
isTransferring: boolean; isTransferring: boolean;
@@ -353,6 +354,7 @@ This can sometimes be caused by changes to your hosts file. Don't make changes u
}); });
} }
async setupAdb() { async setupAdb() {
try {
if (!this.isAdbDownloaded()) { if (!this.isAdbDownloaded()) {
await this.appService.seedPlatformTools(); await this.appService.seedPlatformTools();
} }
@@ -370,6 +372,13 @@ This can sometimes be caused by changes to your hosts file. Don't make changes u
this.adbCommand('setupAdb', { this.adbCommand('setupAdb', {
adbPath: this.appService.path.join(this.adbPath, this.getAdbBinary()), 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() { isAdbDownloaded() {
try { try {
+16 -6
View File
@@ -249,32 +249,42 @@ export class AppService {
return sourcesPath; return sourcesPath;
} }
seedPlatformTools() { seedPlatformTools() {
return new Promise<void>(async resolve => { return new Promise<void>(async (resolve, reject) => {
let sourcesPath = this.getPlatformToolsSeedPath(); let sourcesPath = this.getPlatformToolsSeedPath();
if (sourcesPath == null) { if (sourcesPath == null) {
console.error('Unable to locate platform tools! Try reinstalling sidequest.'); console.error('Unable to locate platform tools! Try reinstalling sidequest.');
resolve(); reject('Unable to locate platform tools! Try reinstalling sidequest.');
return; return;
} }
await this.mkdir(this.path.join(this.appData, 'platform-tools')); await this.mkdir(this.path.join(this.appData, 'platform-tools'));
try { 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++) { for (let i = 0; i < files.length; i++) {
try {
this.fs.copyFileSync( this.fs.copyFileSync(
this.path.join(sourcesPath, files[i]), this.path.join(sourcesPath, files[i]),
this.path.join(this.appData, 'platform-tools', 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') { if (this.os.platform() === 'darwin' || this.os.platform() === 'linux') {
this.setExecutable(this.path.join(this.appData, 'platform-tools', 'adb')).then(() => this.setExecutable(this.path.join(this.appData, 'platform-tools', 'adb')).then(() =>
setTimeout(() => resolve(), 5000) setTimeout(() => resolve(), 8000)
); );
} else { } else {
setTimeout(() => resolve(), 5000); setTimeout(() => resolve(), 8000);
} }
} catch (e) { } catch (e) {
console.error('Error seeding platform tools! ', e); console.error('Error seeding platform tools! ', e);
resolve(); reject('Error seeding platform tools: ' + e.toString());
} }
}); });
} }
@@ -222,7 +222,7 @@
arrow_drop_down arrow_drop_down
</i> </i>
<div id="connection-status" class="connection-status-unauthorized" mz-tooltip <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 id="connection-status-message" [innerHTML]="appService.versionName+'&nbsp;&nbsp;'+adbService.deviceStatusMessage"></div>
</div> </div>
</div> </div>
+2
View File
@@ -15,6 +15,8 @@ const exec = require('child_process').exec;
const crypto = require('crypto'); const crypto = require('crypto');
const request = require('request'); 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');
const OPEN_IN_SYSTEM_BROWSER_DOMAINS = [ const OPEN_IN_SYSTEM_BROWSER_DOMAINS = [
'www.oculus.com', 'www.oculus.com',