fixed the popup when you unplug the cable
This commit is contained in:
@@ -169,7 +169,7 @@ export class AdbClientService {
|
||||
let extention = this.appService.path.extname(filepath);
|
||||
switch (extention) {
|
||||
case '.apk':
|
||||
return this.installAPK(filepath, true, false, 0, 0, false, this.appService.path.basename(filepath));
|
||||
return this.installAPK(filepath, true, false, 0, 0, false, this.appService.path.basename(filepath) + ': ');
|
||||
case '.obb':
|
||||
return this.processService.addItem('file_install', async task => {
|
||||
task.status = 'Transferring OBB file...';
|
||||
@@ -605,12 +605,12 @@ This can sometimes be caused by changes to your hosts file. Don't make changes u
|
||||
return this.processService.addItem(
|
||||
'apk_install',
|
||||
task => {
|
||||
name = name ? name + ': ' : '';
|
||||
if (this.deviceStatus !== ConnectionStatus.CONNECTED) {
|
||||
return Promise.reject(name + 'Apk install failed - No device connected!');
|
||||
}
|
||||
const showTotal = number && total ? '(' + number + '/' + total + ') ' : '';
|
||||
task.app_name = name;
|
||||
task.show_total = showTotal;
|
||||
task.app_name = name || '';
|
||||
task.status = name + showTotal + 'Installing Apk... ';
|
||||
return this.adbCommand('install', { serial: this.deviceSerial, path: filePath, isLocal: !!isLocal }, status => {
|
||||
if (status.percent && status.size && status.time) {
|
||||
@@ -619,10 +619,11 @@ This can sometimes be caused by changes to your hosts file. Don't make changes u
|
||||
? name + showTotal + 'Installing Apk...'
|
||||
: name + showTotal + 'Downloading APK... ' + Math.round(status.percent * 100) + '% ';
|
||||
} else {
|
||||
task.status =
|
||||
status === 'Checking APK against blacklist...'
|
||||
? name + showTotal + status
|
||||
: name + showTotal + 'Installing Apk...';
|
||||
if (status === 'Checking APK against blacklist...') {
|
||||
task.status = name + showTotal + status;
|
||||
} else {
|
||||
task.status = name + showTotal + 'Installing Apk...';
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(r => {
|
||||
@@ -638,7 +639,7 @@ This can sometimes be caused by changes to your hosts file. Don't make changes u
|
||||
if (deleteAfter) {
|
||||
this.appService.fs.unlink(filePath, err => {});
|
||||
}
|
||||
let er = e.message ? e.message : e.code ? e.code : e.reason ? e.reason : JSON.stringify(e);
|
||||
let er = e.message ? e.message : e.code ? e.code : e.reason ? e.reason : e.toString();
|
||||
if (
|
||||
er.indexOf('INSTALL_FAILED_UPDATE_INCOMPATIBLE') > -1 &&
|
||||
er.indexOf('com.oculus.environment.prod.') > -1
|
||||
@@ -648,9 +649,13 @@ This can sometimes be caused by changes to your hosts file. Don't make changes u
|
||||
this.installAPK(filePath, isLocal, shouldUninstall, number, total, deleteAfter, name);
|
||||
return Promise.reject('Install failed, uninstalling and trying again...');
|
||||
}
|
||||
if (er === 'SAFESIDE') {
|
||||
if (er.includes('SAFESIDE')) {
|
||||
this.appService.headerComponent.safeModal.openModal();
|
||||
}
|
||||
console.log('app failed', er);
|
||||
task.status =
|
||||
(task.app_name ? task.app_name + ': ' : '') +
|
||||
(e.message ? e.message : e.code ? e.code : e.reason ? e.reason : e.toString());
|
||||
return Promise.reject(er);
|
||||
});
|
||||
},
|
||||
@@ -1031,7 +1036,7 @@ This can sometimes be caused by changes to your hosts file. Don't make changes u
|
||||
async installLocalZip(filepath, dontCatchError, cb, task?, deleteAfter?) {
|
||||
const typeBasedActions = {
|
||||
'.apk': filepath => {
|
||||
this.installAPK(filepath, true, false, 0, 0, deleteAfter);
|
||||
this.installAPK(filepath, true, false, 0, 0, deleteAfter, this.appService.path.basename(filepath));
|
||||
},
|
||||
'.obb': filepath => {
|
||||
if (this.appService.path.basename(filepath).match(this.obbRegex)) {
|
||||
|
||||
@@ -99,29 +99,34 @@ export class AppService {
|
||||
}
|
||||
this.versionName = 'v' + this.remote.app.getVersion();
|
||||
this.electron.ipcRenderer.on('extract-file', (event, data) => {
|
||||
console.log('download-url-progress');
|
||||
if (!!this.extractResolves[data.token]) {
|
||||
this.extractResolves[data.token].resolve();
|
||||
delete this.extractResolves[data.token];
|
||||
}
|
||||
});
|
||||
this.electron.ipcRenderer.on('extract-progress', (event, data) => {
|
||||
console.log('download-url-progress');
|
||||
if (!!this.extractResolves[data.token]) {
|
||||
this.extractResolves[data.token].scb(data.stats);
|
||||
}
|
||||
});
|
||||
this.electron.ipcRenderer.on('download-url-fail', (event, data) => {
|
||||
console.log('download-url-progress');
|
||||
if (!!this.downloadResolves[data.token]) {
|
||||
this.downloadResolves[data.token].reject(data.e);
|
||||
delete this.downloadResolves[data.token];
|
||||
}
|
||||
});
|
||||
this.electron.ipcRenderer.on('download-url', (event, data) => {
|
||||
console.log('download-url-progress');
|
||||
if (!!this.downloadResolves[data.token]) {
|
||||
this.downloadResolves[data.token].resolve();
|
||||
delete this.downloadResolves[data.token];
|
||||
}
|
||||
});
|
||||
this.electron.ipcRenderer.on('download-progress', (event, data) => {
|
||||
console.log('download-url-progress');
|
||||
if (!!this.downloadResolves[data.token]) {
|
||||
this.downloadResolves[data.token].scb(data.stats);
|
||||
}
|
||||
|
||||
@@ -65,14 +65,13 @@ export class ElectronService {
|
||||
|
||||
async installFromToken(token) {
|
||||
let res = await this.adbService.adbCommand('installFromToken', { token });
|
||||
console.log(res);
|
||||
res.forEach((l, i) => {
|
||||
switch (l.type) {
|
||||
case 'Mod':
|
||||
this.beatonService.downloadSong(l.url, this.adbService);
|
||||
break;
|
||||
case 'APK':
|
||||
this.adbService.installAPK(l.url, false, false, i + 1, res.length, false, l.name);
|
||||
this.adbService.installAPK(l.url, false, false, i + 1, res.length, false, l.name + ': ');
|
||||
break;
|
||||
case 'OBB':
|
||||
this.adbService.installObb(l.url, i + 1, res.length, l.name);
|
||||
@@ -95,7 +94,7 @@ export class ElectronService {
|
||||
this.adbService.installObb(data.url, 0, 0, data.name);
|
||||
break;
|
||||
case '.apk':
|
||||
this.adbService.installAPK(data.url, false, false, 0, 0, true, data.name);
|
||||
this.adbService.installAPK(data.url, false, false, 0, 0, true, data.name + ': ');
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -290,23 +290,6 @@ export class HeaderComponent implements OnInit {
|
||||
}
|
||||
);
|
||||
}
|
||||
closeApp() {
|
||||
this.appService.remote.getCurrentWindow().close();
|
||||
}
|
||||
pingHeadset() {
|
||||
this.isAlive = true;
|
||||
}
|
||||
minimizeApp() {
|
||||
this.appService.remote.getCurrentWindow().minimize();
|
||||
}
|
||||
maximizeApp() {
|
||||
const win = this.appService.remote.getCurrentWindow();
|
||||
if (win.isMaximized()) {
|
||||
win.unmaximize();
|
||||
} else {
|
||||
win.maximize();
|
||||
}
|
||||
}
|
||||
async selectAppToInstall() {
|
||||
let files = await this.appService.remote.dialog.showOpenDialog({
|
||||
properties: ['openFile', 'multiSelections'],
|
||||
@@ -322,20 +305,4 @@ export class HeaderComponent implements OnInit {
|
||||
}
|
||||
});
|
||||
}
|
||||
confirmRestore() {
|
||||
this.spinnerService.showLoader();
|
||||
this.spinnerService.setMessage('Restoring BMBF<br>Please Wait...');
|
||||
this.beatonService.confirmRestore(this.adbService).then(r => {
|
||||
this.spinnerService.hideLoader();
|
||||
this.statusService.showStatus('BMBF Restored Successfully!!');
|
||||
this.beatOnModal.openModal();
|
||||
this.beatonService.checkHasRestore(this.adbService);
|
||||
});
|
||||
}
|
||||
installAPK(name: string) {
|
||||
return this.adbService.installAPK(this.appService.path.join(this.appService.appData, name), true, true);
|
||||
}
|
||||
removeText(text) {
|
||||
this.replaceText = this.replaceText.filter(d => d !== text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,14 @@ export class ProcessTask {
|
||||
key: string;
|
||||
name: string;
|
||||
app_name?: string;
|
||||
show_total?: string;
|
||||
icon: string;
|
||||
private _status?;
|
||||
get status(): string {
|
||||
return this._status;
|
||||
}
|
||||
set status(d) {
|
||||
this.statusService.showStatus(d, false, true);
|
||||
this.statusService.showStatus(d.replace(/:\s+/g, ': '), false, true);
|
||||
this._status = d;
|
||||
}
|
||||
running?: boolean;
|
||||
@@ -87,7 +88,7 @@ export class ProcessBucketService {
|
||||
|
||||
async processBucket() {
|
||||
const objects = this.tasks.filter(t => !t.failed && !t.running && !t.cancelled && !t.succeeded);
|
||||
const timeout = new Promise(resolve => setTimeout(() => resolve(), 1000));
|
||||
const timeout = () => new Promise(resolve => setTimeout(() => resolve(), 500));
|
||||
this.left_length = objects.length;
|
||||
if (objects.length) {
|
||||
this.is_running = true;
|
||||
@@ -101,18 +102,22 @@ export class ProcessBucketService {
|
||||
task.succeeded = true;
|
||||
this.currentTask = null;
|
||||
if (!task.cancelled) {
|
||||
return timeout.then(() => this.processBucket());
|
||||
return timeout().then(() => this.processBucket());
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
task.running = false;
|
||||
task.status =
|
||||
(task.app_name ? task.app_name + ': ' : '') + (e.message ? e.message : e.code ? e.code : e.toString());
|
||||
(task.app_name || '') + (e.message ? e.message : e.code ? e.code : e.reason ? e.reason : e.toString());
|
||||
task.failed = true;
|
||||
this.currentTask = null;
|
||||
this.statusService.showStatus(task.status, true);
|
||||
if (!task.cancelled) {
|
||||
return timeout.then(() => this.processBucket());
|
||||
console.log('h1');
|
||||
return timeout().then(async () => {
|
||||
console.log('h2');
|
||||
await this.processBucket();
|
||||
});
|
||||
}
|
||||
});
|
||||
this.tasks = this.tasks.filter(t => t !== task);
|
||||
@@ -132,7 +137,7 @@ export class ProcessBucketService {
|
||||
);
|
||||
}
|
||||
this.is_running = false;
|
||||
await timeout.then(() => this.processBucket());
|
||||
await timeout().then(() => this.processBucket());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ export class StatusBarService {
|
||||
this.status = status;
|
||||
}
|
||||
showStatus(message: string, isError?: boolean, isInfo?: boolean) {
|
||||
console.warn('here');
|
||||
this.status.showStatus(message, isError, isInfo);
|
||||
}
|
||||
hideStatus() {
|
||||
|
||||
+40
-75
@@ -22,8 +22,20 @@ app.allowRendererProcessReuse = false;
|
||||
// const Readable = require('stream').Readable;
|
||||
import { SetPropertiesCommand } from './setproperties';
|
||||
import { OPEN_IN_SYSTEM_BROWSER_DOMAINS } from './external-urls';
|
||||
|
||||
let has_port = process.argv.indexOf('--port');
|
||||
let valid_port = has_port > -1 && process.argv[has_port + 1] && Number.isInteger(Number(process.argv[has_port + 1]));
|
||||
|
||||
let installErrorCallback;
|
||||
|
||||
process.on('uncaughtException', function(error) {
|
||||
if (error.toString().includes('Error: This socket has been ended by the other party') && installErrorCallback) {
|
||||
installErrorCallback("Couldn't communicate with the headset, try another USB port or cable...");
|
||||
installErrorCallback = null;
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
|
||||
class ADB {
|
||||
client;
|
||||
_logcat;
|
||||
@@ -178,6 +190,13 @@ class ADB {
|
||||
.catch(e => ecb(e));
|
||||
}
|
||||
async install(serial, apkpath, isLocal, cb, scb, ecb) {
|
||||
console.log('installapk');
|
||||
let stopUpdate;
|
||||
installErrorCallback = e => {
|
||||
stopUpdate = true;
|
||||
ecb(e);
|
||||
console.log(e, stopUpdate);
|
||||
};
|
||||
if (!this.client) return ecb('Not connected.');
|
||||
if (isLocal) {
|
||||
let found;
|
||||
@@ -193,21 +212,27 @@ class ADB {
|
||||
scb('Transferring APK to device...');
|
||||
let stream;
|
||||
try {
|
||||
stream = isLocal
|
||||
? fs.createReadStream(apkpath)
|
||||
: new Readable().wrap(
|
||||
progress(request(apkpath), {
|
||||
throttle: 60,
|
||||
})
|
||||
.on('progress', state => {
|
||||
scb(state);
|
||||
})
|
||||
.on('end', () => {
|
||||
scb({
|
||||
percent: 1,
|
||||
});
|
||||
})
|
||||
);
|
||||
if (isLocal) {
|
||||
stream = fs.createReadStream(apkpath);
|
||||
} else {
|
||||
stream = new Readable().wrap(
|
||||
progress(request(apkpath), {
|
||||
throttle: 60,
|
||||
})
|
||||
.on('progress', state => {
|
||||
if (!stopUpdate) {
|
||||
scb(state);
|
||||
}
|
||||
})
|
||||
.on('end', () => {
|
||||
if (!stopUpdate) {
|
||||
scb({
|
||||
percent: 1,
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
const isInvalidURI = e && typeof e.message === 'string' && e.message.startsWith('Invalid URI "');
|
||||
if (isInvalidURI) {
|
||||
@@ -220,66 +245,6 @@ class ADB {
|
||||
.install(serial, stream)
|
||||
.then(cb)
|
||||
.catch(e => ecb(e));
|
||||
|
||||
// let outpath = isLocal ? apkpath : path.join(app.getPath('appData'), 'SideQuest', new Date().getTime() + '.apk');
|
||||
// let promise;
|
||||
// if (isLocal) {
|
||||
// let found;
|
||||
// try {
|
||||
// found = await this.checkAPK(scb, apkpath);
|
||||
// } catch (e) {
|
||||
// return ecb(e);
|
||||
// }
|
||||
// if (found) {
|
||||
// return ecb('SAFESIDE');
|
||||
// }
|
||||
// }
|
||||
// promise = isLocal
|
||||
// ? Promise.resolve()
|
||||
// : new Promise(resolve => {
|
||||
// progress(request(apkpath), {
|
||||
// throttle: 60,
|
||||
// })
|
||||
// .on('progress', state => {
|
||||
// scb(state);
|
||||
// })
|
||||
// .on('end', () => {
|
||||
// scb({
|
||||
// percent: 1,
|
||||
// size: 1,
|
||||
// time: 1,
|
||||
// });
|
||||
// resolve();
|
||||
// })
|
||||
// .on('error', () => {
|
||||
// ecb('Download error! Please try again!');
|
||||
// })
|
||||
// .pipe(fs.createWriteStream(outpath));
|
||||
// });
|
||||
// promise
|
||||
// .then(
|
||||
// () =>
|
||||
// new Promise((resolve, reject) => {
|
||||
// console.log('"' + this.adbPath + '" -s ' + serial + ' install -r -d "' + outpath + '"');
|
||||
// exec(
|
||||
// '"' + this.adbPath + '" -s ' + serial + ' install -r -d "' + outpath + '"',
|
||||
// {},
|
||||
// (error, stdout, stderr) => {
|
||||
// if (error) {
|
||||
// reject(error.message ? error.message : error.toString());
|
||||
// } else {
|
||||
// resolve();
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
// })
|
||||
// )
|
||||
// .then(() => (isLocal ? null : fs.unlinkSync(outpath)))
|
||||
// .then(cb)
|
||||
// .catch(e => {
|
||||
// if (!isLocal) fs.unlinkSync(outpath);
|
||||
// ecb(e);
|
||||
// });
|
||||
}
|
||||
uninstall(serial, packageName, cb, ecb) {
|
||||
if (!this.client) return ecb('Not connected.');
|
||||
|
||||
Reference in New Issue
Block a user