moving to private repo

This commit is contained in:
Shane Harris
2020-08-17 13:31:48 +01:00
committed by Your Name
parent fe20b27432
commit afcc6e58f8
16 changed files with 211 additions and 117 deletions
+111 -95
View File
@@ -510,76 +510,87 @@ export class AdbClientService {
shouldUninstall?: boolean, shouldUninstall?: boolean,
number?: number, number?: number,
total?: number, total?: number,
deleteAfter?: boolean deleteAfter?: boolean,
name?: string
) { ) {
return this.processService.addItem('apk_install', task => { return this.processService.addItem(
if (this.deviceStatus !== ConnectionStatus.CONNECTED) { 'apk_install',
return Promise.reject('Apk install failed: No device connected! ' + filePath); task => {
} name = name ? name + ': ' : '';
const showTotal = number && total ? '(' + number + '/' + total + ') ' : ''; if (this.deviceStatus !== ConnectionStatus.CONNECTED) {
const updateStatus = (text: string): void => { return Promise.reject(name + 'Apk install failed - No device connected! ' + filePath);
const newStatus = `${showTotal}${text} `;
if (task.status !== newStatus) {
task.status = newStatus;
} }
}; const showTotal = number && total ? '(' + number + '/' + total + ') ' : '';
const checkReported: Promise<InstallDecision> = isLocal const updateStatus = (text: string): void => {
? this.checkIsAPKReported(updateStatus, filePath) const newStatus = `${showTotal}${text} `;
: Promise.resolve('DoInstall'); if (task.status !== newStatus) {
return checkReported.then(installDecision => { task.status = newStatus;
if (installDecision === 'DoInstall') {
task.status = showTotal + 'Installing Apk... ';
return this.adbCommand('install', { serial: this.deviceSerial, path: filePath, isLocal: !!isLocal }, status => {
task.status =
(status.percent === 1
? showTotal + 'Installing Apk... '
: showTotal + 'Downloading APK... ' + Math.round(status.percent * 100) + '% ') +
' <span style="font-style:italic">' +
filePath +
'</span>';
})
.then(r => {
task.status = 'APK file installed ok!! ' + filePath;
if (deleteAfter) {
this.appService.fs.unlink(filePath, err => {});
}
if (filePath.indexOf('com.weloveoculus.BMBF') > -1) {
return this.beatonService.setBeatOnPermission(this);
}
if (filePath.toLowerCase().indexOf('sidequest.legends') > -1) {
return this.setPermission('com.sidequest.legends', 'android.permission.RECORD_AUDIO');
}
if (filePath.toLowerCase().indexOf('pavlov') > -1) {
return this.setPermission('com.vankrupt.pavlov', 'android.permission.RECORD_AUDIO')
.then(() =>
this.setPermission('com.vankrupt.pavlov', 'android.permission.READ_EXTERNAL_STORAGE')
)
.then(() =>
this.setPermission('com.vankrupt.pavlov', 'android.permission.WRITE_EXTERNAL_STORAGE')
)
.then(() =>
this.adbCommand('shell', {
serial: this.deviceSerial,
command: 'echo null > /sdcard/pavlov.name.txt',
})
);
}
})
.catch(e => {
if (deleteAfter) {
this.appService.fs.unlink(filePath, err => {});
}
return Promise.reject(e.message ? e.message : e.code ? e.code : e.toString() + ' ' + filePath);
});
} else {
if (deleteAfter) {
this.appService.fs.unlink(filePath, err => {});
} }
updateStatus('Canceled Install.'); };
return Promise.resolve(); const checkReported: Promise<InstallDecision> = isLocal
} ? this.checkIsAPKReported(updateStatus, filePath)
}); : Promise.resolve('DoInstall');
}); return checkReported.then(installDecision => {
task.app_name = name;
if (installDecision === 'DoInstall') {
task.status = name + showTotal + 'Installing Apk... ';
return this.adbCommand(
'install',
{ serial: this.deviceSerial, path: filePath, isLocal: !!isLocal },
status => {
task.status =
(status.percent === 1
? name + showTotal + 'Installing Apk... '
: name + showTotal + 'Downloading APK... ' + Math.round(status.percent * 100) + '% ') +
' <span style="font-style:italic">' +
filePath +
'</span>';
}
)
.then(r => {
task.status = name + 'APK file installed ok!! ' + filePath;
if (deleteAfter) {
this.appService.fs.unlink(filePath, err => {});
}
if (filePath.indexOf('com.weloveoculus.BMBF') > -1) {
return this.beatonService.setBeatOnPermission(this);
}
if (filePath.toLowerCase().indexOf('sidequest.legends') > -1) {
return this.setPermission('com.sidequest.legends', 'android.permission.RECORD_AUDIO');
}
if (filePath.toLowerCase().indexOf('pavlov') > -1) {
return this.setPermission('com.vankrupt.pavlov', 'android.permission.RECORD_AUDIO')
.then(() =>
this.setPermission('com.vankrupt.pavlov', 'android.permission.READ_EXTERNAL_STORAGE')
)
.then(() =>
this.setPermission('com.vankrupt.pavlov', 'android.permission.WRITE_EXTERNAL_STORAGE')
)
.then(() =>
this.adbCommand('shell', {
serial: this.deviceSerial,
command: 'echo null > /sdcard/pavlov.name.txt',
})
);
}
})
.catch(e => {
if (deleteAfter) {
this.appService.fs.unlink(filePath, err => {});
}
return Promise.reject(e.message ? e.message : e.code ? e.code : e.toString() + ' ' + filePath);
});
} else {
if (deleteAfter) {
this.appService.fs.unlink(filePath, err => {});
}
updateStatus('Canceled Install.');
return Promise.resolve();
}
});
},
name
);
} }
async checkIsAPKReported(updateStatus: (string) => void, filePath: string): Promise<InstallDecision> { async checkIsAPKReported(updateStatus: (string) => void, filePath: string): Promise<InstallDecision> {
let isReported: boolean; let isReported: boolean;
@@ -904,33 +915,38 @@ export class AdbClientService {
}); });
}); });
} }
installObb(url, number?: number, total?: number) { installObb(url, number?: number, total?: number, name?: string) {
return this.processService.addItem('file_install', async task => { return this.processService.addItem(
task.status = 'Downloading OBB file...'; 'file_install',
return this.appService async task => {
.downloadFile( task.app_name = name;
url, task.status = (name ? name + ': ' : '') + 'Downloading OBB file...';
url, return this.appService
url, .downloadFile(
downloadUrl => { url,
return this.appService.path.join( url,
this.appService.appData, url,
downloadUrl downloadUrl => {
.split('/') return this.appService.path.join(
.pop() this.appService.appData,
.split('?') downloadUrl
.shift() .split('/')
); .pop()
}, .split('?')
task .shift()
) );
.then((_path: string) => { },
task.status = 'Installing OBB file...'; task
return this.installLocalObb(_path, false, null, number, total, task); )
}); .then((_path: string) => {
}); task.status = name + 'Installing OBB file...';
return this.installLocalObb(_path, false, null, number, total, task, name);
});
},
name
);
} }
installLocalObb(filepath: string, dontCatchError = false, cb = null, number?: number, total?: number, task?) { installLocalObb(filepath: string, dontCatchError = false, cb = null, number?: number, total?: number, task?, name?: string) {
let filename = this.appService.path.basename(filepath); let filename = this.appService.path.basename(filepath);
let packageId = filename.match(/main.[0-9]{1,}.([a-z]{1,}.[A-z]{1,}.[A-z]{1,}).obb/)[1]; let packageId = filename.match(/main.[0-9]{1,}.([a-z]{1,}.[A-z]{1,}.[A-z]{1,}).obb/)[1];
const showTotal = number && total ? '(' + number + '/' + total + ') ' : ''; const showTotal = number && total ? '(' + number + '/' + total + ') ' : '';
@@ -941,7 +957,7 @@ export class AdbClientService {
} }
p = p.then(() => { p = p.then(() => {
if (task) { if (task) {
task.status = 'File transferred successfully! ' + filepath; task.status = name + 'File transferred successfully! ' + filepath;
} else { } else {
this.statusService.showStatus('File transferred successfully!'); this.statusService.showStatus('File transferred successfully!');
} }
@@ -950,7 +966,7 @@ export class AdbClientService {
p = p.catch(e => { p = p.catch(e => {
if (task) { if (task) {
task.failed = true; task.failed = true;
task.status = 'Failed to transfer file!! - ' + filepath; task.status = name + 'Failed to transfer file!! - ' + filepath;
} else { } else {
this.spinnerService.hideLoader(); this.spinnerService.hideLoader();
this.statusService.showStatus(e.toString(), true); this.statusService.showStatus(e.toString(), true);
+1 -1
View File
@@ -25,7 +25,7 @@
border-top-left-radius: 40px; border-top-left-radius: 40px;
z-index: 9; z-index: 9;
} }
#beatView{ #mainWebView{
width: 100%; width: 100%;
height: calc(100% - 35px); height: calc(100% - 35px);
top: 35px; top: 35px;
+2 -1
View File
@@ -6,7 +6,8 @@
<app-loading-spinner #spinner></app-loading-spinner> <app-loading-spinner #spinner></app-loading-spinner>
<app-status-bar #status (getHelp)="getHelpModal.openModal(); helpStatus = $event"></app-status-bar> <app-status-bar #status (getHelp)="getHelpModal.openModal(); helpStatus = $event"></app-status-bar>
<webview id="beatView" #webview src="https://sidequestvr.com" allowpopups <webview id="mainWebView" #webview src="https://sidequestvr.com" allowpopups disablewebsecurity
useragent="Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko electron/ SideQuestAgent"
[ngStyle]="{'left':webService.isWebviewOpen?'0':'-100%'}" class="bsaber-webview"></webview> [ngStyle]="{'left':webService.isWebviewOpen?'0':'-100%'}" class="bsaber-webview"></webview>
<mz-modal #getHelpModal [fixedFooter]="true"> <mz-modal #getHelpModal [fixedFooter]="true">
+1
View File
@@ -47,6 +47,7 @@ export class AppComponent {
ngAfterViewInit() { ngAfterViewInit() {
this.spinnerService.setSpinner(this.spinner); this.spinnerService.setSpinner(this.spinner);
this.statusService.setStatus(this.status); this.statusService.setStatus(this.status);
console.log(this.webview);
this.webService.setWebView(this.webview.nativeElement); this.webService.setWebView(this.webview.nativeElement);
} }
} }
+10 -3
View File
@@ -104,6 +104,12 @@ export class AppService {
this.extractResolves[data.token].scb(data.stats); this.extractResolves[data.token].scb(data.stats);
} }
}); });
this.electron.ipcRenderer.on('download-url-fail', (event, data) => {
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) => { this.electron.ipcRenderer.on('download-url', (event, data) => {
if (!!this.downloadResolves[data.token]) { if (!!this.downloadResolves[data.token]) {
this.downloadResolves[data.token].resolve(); this.downloadResolves[data.token].resolve();
@@ -125,7 +131,7 @@ export class AppService {
this.extractResolves[token] = { this.extractResolves[token] = {
scb: stats => { scb: stats => {
if (task) { if (task) {
task.status = 'Extracting... ' + stats; task.status = (task.app_name ? task.app_name + ': ' : '') + 'Extracting... ' + stats;
} }
}, },
resolve, resolve,
@@ -267,15 +273,16 @@ export class AppService {
} }
downloadFileAPI(url, directory, filename, task?) { downloadFileAPI(url, directory, filename, task?) {
// Send request to application thread to download a file. Store the callback for the response. // Send request to application thread to download a file. Store the callback for the response.
return new Promise(resolve => { return new Promise((resolve, reject) => {
let token = this.uuidv4(); let token = this.uuidv4();
this.downloadResolves[token] = { this.downloadResolves[token] = {
scb: stats => { scb: stats => {
if (task) { if (task) {
task.status = 'Downloading... ' + stats + '%'; task.status = (task.app_name ? task.app_name + ': ' : '') + 'Downloading... ' + stats + '%';
} }
}, },
resolve, resolve,
reject,
}; };
this.electron.ipcRenderer.send('download-url', { token, url, directory, filename }); this.electron.ipcRenderer.send('download-url', { token, url, directory, filename });
}); });
-1
View File
@@ -211,7 +211,6 @@ export class BeatOnService {
return this.processService.addItem('song_download', async task => { return this.processService.addItem('song_download', async task => {
let parts = downloadUrl.split('/'); let parts = downloadUrl.split('/');
let zipPath = this.appService.path.join(this.appService.appData, this.appService.uuidv4() + '.zip'); let zipPath = this.appService.path.join(this.appService.appData, this.appService.uuidv4() + '.zip');
//let name = parts[parts.length - 1].split('.')[0];
const requestOptions = { const requestOptions = {
timeout: 30000, timeout: 30000,
'User-Agent': this.appService.getUserAgent(), 'User-Agent': this.appService.getUserAgent(),
@@ -6,5 +6,5 @@
</div> </div>
</div> </div>
<div class="col s2 package-height centered package-item"> <div class="col s2 package-height centered package-item">
<i *ngIf="task.status === 'Waiting...'||(task.running&&!task.succeeded&&!task.failed)" class="material-icons red-text cursor settings" (click)="task.running?processService.skipCurrent(task):deleteItem()">close</i> <i class="material-icons red-text cursor settings" (click)="task.running?processService.skipCurrent(task):deleteItem()">close</i>
</div> </div>
+55 -2
View File
@@ -1,4 +1,4 @@
import { Injectable } from '@angular/core'; import { Injectable, isDevMode } from '@angular/core';
import { AppService } from './app.service'; import { AppService } from './app.service';
import { RepoService } from './repo.service'; import { RepoService } from './repo.service';
import { StatusBarService } from './status-bar.service'; import { StatusBarService } from './status-bar.service';
@@ -65,6 +65,55 @@ export class ElectronService {
} }
} }
installFromToken(token) {
let options = {
url: 'https://api.sidequestvr.com/install-from-key',
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Origin: 'https://sidequestvr.com',
},
rejectUnauthorized: !isDevMode(),
json: { token: token },
};
console.log(options);
this.appService.request(options, async (error, response, body) => {
console.log(error, body);
if (!error && body.data && body.data.apps && body.data.apps.length) {
for (let i = 0; i < body.data.apps.length; i++) {
let app = body.data.apps[i];
if (Number(app.app_categories_id) === 1) {
let urls = app.urls.filter(l => l && ~['Github Release', 'APK', 'OBB'].indexOf(l.provider));
for (let i = 0; i < urls.length; i++) {
const etx = urls[i].link_url
.split('?')[0]
.split('.')
.pop()
.toLowerCase();
switch (etx) {
case 'obb':
await this.adbService.installObb(urls[i].link_url, i + 1, urls.length, app.name);
break;
default:
await this.adbService.installAPK(
urls[i].link_url,
false,
false,
i + 1,
urls.length,
false,
app.name
);
break;
}
}
}
}
}
});
}
setupIPC() { setupIPC() {
this.appService.electron.ipcRenderer.on('pre-open-url', (event, data) => { this.appService.electron.ipcRenderer.on('pre-open-url', (event, data) => {
this.spinnerService.showLoader(); this.spinnerService.showLoader();
@@ -104,10 +153,14 @@ export class ElectronService {
console.log(data.status); console.log(data.status);
} }
}); });
this.appService.electron.ipcRenderer.on('open-url', (event, data) => { this.appService.electron.ipcRenderer.on('open-url', async (event, data) => {
if (data) { if (data) {
let url = data.split('#'); let url = data.split('#');
switch (url[0]) { switch (url[0]) {
case 'sidequest://i/':
console.log(data);
this.installFromToken(url[1]);
break;
case 'sidequest://unload/': case 'sidequest://unload/':
this.adbService.uninstallAPK(url[1]); this.adbService.uninstallAPK(url[1]);
break; break;
@@ -259,6 +259,11 @@
Clear Failed Clear Failed
</div> </div>
&nbsp;&nbsp; &nbsp;&nbsp;
<div class="waves-effect waves-light btn small-button red" mz-tooltip position="bottom"
tooltip="Clear out the finished tasks." (click)="processService.clearAll()">
Clear All
</div>
&nbsp;&nbsp;
</div> </div>
<div id="searchFilterContainer" *ngIf="appService.showSearch"> <div id="searchFilterContainer" *ngIf="appService.showSearch">
+13 -5
View File
@@ -3,6 +3,7 @@ import { StatusBarService } from './status-bar.service';
export interface ProcessTask { export interface ProcessTask {
key: string; key: string;
name: string; name: string;
app_name?: string;
icon: string; icon: string;
status?: string; status?: string;
running?: boolean; running?: boolean;
@@ -26,9 +27,9 @@ export class ProcessBucketService {
this.processBucket(); this.processBucket();
} }
addItem(name, resolve) { addItem(name, resolve, app_name?) {
const key = (<any>window).require('uuid/v4')(); const key = (<any>window).require('uuid/v4')();
const status = 'Waiting...'; const status = (app_name ? app_name + ': ' : '') + 'Waiting...';
let icon = 'list'; let icon = 'list';
let _name = 'app install'; let _name = 'app install';
switch (name) { switch (name) {
@@ -67,15 +68,16 @@ export class ProcessBucketService {
this.tasks.push({ this.tasks.push({
key, key,
name, name,
app_name,
icon, icon,
status, status,
resolve, resolve,
}); });
this.left_length = this.tasks.filter(t => t.status === 'Waiting...').length; this.left_length = this.tasks.filter(t => !t.failed && !t.running && !t.cancelled && !t.succeeded).length;
} }
async processBucket() { async processBucket() {
const objects = this.tasks.filter(t => t.status === 'Waiting...'); 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(), 1000));
this.left_length = objects.length; this.left_length = objects.length;
if (objects.length) { if (objects.length) {
@@ -85,6 +87,7 @@ export class ProcessBucketService {
await task await task
.resolve(task) .resolve(task)
.then(() => { .then(() => {
task.running = false;
task.succeeded = true; task.succeeded = true;
if (!task.cancelled) { if (!task.cancelled) {
return timeout.then(() => this.processBucket()); return timeout.then(() => this.processBucket());
@@ -92,7 +95,8 @@ export class ProcessBucketService {
}) })
.catch(e => { .catch(e => {
task.running = false; task.running = false;
task.status = e.message ? e.message : e.code ? e.code : e.toString(); task.status =
(task.app_name ? task.app_name + ': ' : '') + (e.message ? e.message : e.code ? e.code : e.toString());
task.failed = true; task.failed = true;
this.statusService.showStatus(task.status, true); this.statusService.showStatus(task.status, true);
if (!task.cancelled) { if (!task.cancelled) {
@@ -144,4 +148,8 @@ export class ProcessBucketService {
clearFailed() { clearFailed() {
this.tasks = this.tasks.filter(t => !t.failed); this.tasks = this.tasks.filter(t => !t.failed);
} }
clearAll() {
igin;
this.tasks = [];
}
} }
+1
View File
@@ -14,6 +14,7 @@ export class WebviewService {
appService.setWebviewService(this); appService.setWebviewService(this);
} }
setWebView(webView) { setWebView(webView) {
console.log({ webView });
this.webView = webView; this.webView = webView;
this.setupWebview(); this.setupWebview();
} }
@@ -14,7 +14,6 @@ export class WebviewComponent implements OnInit {
appService.resetTop(); appService.resetTop();
webService.isWebviewOpen = true; webService.isWebviewOpen = true;
appService.showBrowserBar = true; appService.showBrowserBar = true;
appService.setTitle('<img src="assets/images/logo-textual.png" class="logo-img"/>');
} }
ngOnInit() {} ngOnInit() {}
+4 -3
View File
@@ -248,10 +248,11 @@ function setupApp() {
const adb = new ADB(); const adb = new ADB();
ipcMain.on('download-url', async (event, { url, token, directory, filename }) => { ipcMain.on('download-url', async (event, { url, token, directory, filename }) => {
await download(url, path.join(directory, filename), stats => { download(url, path.join(directory, filename), stats => {
return event.sender.send('download-progress', { stats, token }); return event.sender.send('download-progress', { stats, token });
}).catch(e => console.log(e)); })
event.sender.send('download-url', { token }); .then(() => event.sender.send('download-url', { token }))
.catch(e => event.sender.send('download-url-fail', { e, token }));
}); });
ipcMain.on('extract-file', async (event, { token, directory, filename }) => { ipcMain.on('extract-file', async (event, { token, directory, filename }) => {
extract( extract(
+4 -2
View File
@@ -21,7 +21,9 @@ module.exports = function(url, path, progress) {
callback(null, response); callback(null, response);
} }
}); });
request.on('error', function(err) {
callback(err);
});
request.setTimeout(TIMEOUT, function() { request.setTimeout(TIMEOUT, function() {
request.abort(); request.abort();
callback(new Error(`request timeout after ${TIMEOUT / 1000.0}s`)); callback(new Error(`request timeout after ${TIMEOUT / 1000.0}s`));
@@ -31,7 +33,7 @@ module.exports = function(url, path, progress) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
get(uri.href, (err, res) => { get(uri.href, (err, res) => {
if (err) { if (err) {
return console.log(err); return reject(err);
} }
const len = parseInt(res.headers['content-length'], 10); const len = parseInt(res.headers['content-length'], 10);
let downloaded = 0; let downloaded = 0;
+1
View File
@@ -59,6 +59,7 @@ export class AppWindow {
show: !showAfterSetup, show: !showAfterSetup,
frame: false, frame: false,
webPreferences: { webPreferences: {
webviewTag: true,
nodeIntegration: true, nodeIntegration: true,
}, },
}; };
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "SideQuest", "name": "SideQuest",
"version": "0.10.3", "version": "0.10.2",
"description": "A open app store for mobile android based VR devices such as the Levovo Mirage, Oculus Go, Oculus Quest, Vive Focus.", "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/the-expanse/SideQuest.git", "repository": "https://github.com/the-expanse/SideQuest.git",
"license": "MIT", "license": "MIT",
@@ -97,7 +97,7 @@
}, },
"devDependencies": { "devDependencies": {
"@angular/cli": "^8.0.3", "@angular/cli": "^8.0.3",
"electron": "^8.2.0", "electron": "^4.1.4",
"electron-builder": "^22.4.0", "electron-builder": "^22.4.0",
"electron-notarize": "^0.1.1", "electron-notarize": "^0.1.1",
"husky": "^2.3.0", "husky": "^2.3.0",