Lots of fixes....

This commit is contained in:
Nathanael Anderson
2024-03-28 18:58:00 -06:00
parent 112546c13b
commit 48a675b71e
10 changed files with 170 additions and 69 deletions
+40 -13
View File
@@ -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.';
@@ -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) {
@@ -132,7 +132,7 @@
arrow_drop_down
</i>
<div class="connection-status-outer left">
<div id="connection-status" class="connection-status-unauthorized"
<div id="connection-status" [class]="adbService.connectionCss"
data-position="bottom" [ngClass]="adbService.connectionCss" mTooltip [attr.data-tooltip]="adbService.lastErrorMessage||'Device connection status.'">
@@ -434,15 +434,16 @@
</div>
</div>
</ng-container>
<ng-container>
<h4 class="section-title">SideQuest Stuff </h4>
<div class="section-container card z-depth-2">
<h5 class="section-title">SideQuest Folders</h5>
<!-- <div class="divider header-divider-margin margin-bottom"></div> -->
<h4 class="description-section">
This changes the resolution of captured videos on the Quest
This allows you to open a folder in your file explorer.
</h4>
<div class="button-section">
@@ -16,6 +16,8 @@
<p>If you are still having trouble then please visit our support community on SideQuest.</p>
<div class="pure-material-button-contained extra-margin-bottom" (click)="appService.opn('https://sdq.st/support')">Open Support Community</div>
<br>
<ng-container *nfIf="false">
TODO: This site is no longer active -- find another way....
<p *ngIf="adb.diagnostics?.usb && adb.diagnostics.usb.log">If instructed to upload logs by a SideQuest support person, please click this button.</p>
<div *ngIf="adb.diagnostics?.usb && adb.diagnostics.usb.log" class="pure-material-button-contained extra-margin-bottom" (click)="uploadLogs();">{{'Upload Logs'}}</div>
<div *ngIf="link">
@@ -23,6 +25,7 @@
<h3>{{link}}</h3>
<div class="pure-material-button-contained button-margin-bottom" (click)="copyToClipboard()">Copy to Clipboard</div>
</div>
</ng-container>
<div id="thankYou">
<ng-container *ngIf="link">Thank you!</ng-container>
</div>
@@ -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: {
@@ -1,5 +1,5 @@
export const environment = {
production: false,
production: true,
header: {color: "sidetestvr", text: "Side Test VR"},
configuration: {
web_url: 'https://sidetestvr.com',
+113 -43
View File
@@ -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 });
}
+4 -4
View File
@@ -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) {
+4 -2
View File
@@ -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",