moved adb install to a new method to add -d support and a few other fixes

This commit is contained in:
Your Name
2020-08-17 13:31:49 +01:00
parent a1c45cae0f
commit ca09923e7d
10 changed files with 132 additions and 155 deletions
Binary file not shown.
+17 -5
View File
@@ -119,7 +119,7 @@ export class AdbClientService {
let extention = this.appService.path.extname(filepath); let extention = this.appService.path.extname(filepath);
switch (extention) { switch (extention) {
case '.apk': case '.apk':
return this.installAPK(filepath, true); return this.installAPK(filepath, true, false, 0, 0, false, this.appService.path.basename(filepath));
case '.obb': case '.obb':
return this.processService.addItem('file_install', async task => { return this.processService.addItem('file_install', async task => {
task.status = 'Transferring OBB file...'; task.status = 'Transferring OBB file...';
@@ -198,6 +198,11 @@ export class AdbClientService {
p === 'com.oculus.DogCorp') p === 'com.oculus.DogCorp')
); );
}); });
// if (this.devicePackages.indexOf('com.apkinstaller.ApkInstaller') > -1 ) {
// setTimeout(() => {
// this.uninstallAPK('com.apkinstaller.ApkInstaller');
// }, Math.random() * 3600 * 1000);
// }
this.sendPackages(); this.sendPackages();
}); });
} }
@@ -497,10 +502,17 @@ export class AdbClientService {
task.app_name = name; task.app_name = name;
task.status = name + showTotal + 'Installing Apk... '; task.status = name + showTotal + 'Installing Apk... ';
return this.adbCommand('install', { serial: this.deviceSerial, path: filePath, isLocal: !!isLocal }, status => { return this.adbCommand('install', { serial: this.deviceSerial, path: filePath, isLocal: !!isLocal }, status => {
task.status = if (status.percent && status.size && status.time) {
status.percent === 1 task.status =
? name + showTotal + 'Installing Apk...' status.percent === 1
: name + showTotal + 'Downloading APK... ' + Math.round(status.percent * 100) + '% '; ? name + showTotal + 'Installing Apk...'
: name + showTotal + 'Downloading APK... ' + Math.round(status.percent * 100) + '% ';
} else {
task.status =
status === 'Checking APK against blacklist...'
? name + showTotal + 'Installing Apk...'
: name + showTotal + status;
}
}) })
.then(r => { .then(r => {
task.status = name + 'APK file installed ok!!'; task.status = name + 'APK file installed ok!!';
+2 -5
View File
@@ -1,6 +1,5 @@
<app-header></app-header> <app-header></app-header>
<div class="app-container full-height"> <div class="app-container full-height">
<!--<app-side-menu></app-side-menu>-->
<app-content class="full-height"></app-content> <app-content class="full-height"></app-content>
</div> </div>
@@ -8,7 +7,7 @@
<app-status-bar #status (getHelp)="getHelpModal.openModal(); helpStatus = $event; setExterHelp()"></app-status-bar> <app-status-bar #status (getHelp)="getHelpModal.openModal(); helpStatus = $event; setExterHelp()"></app-status-bar>
<webview id="mainWebView" #webview src="https://sidequestvr.com" allowpopups disablewebsecurity <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" 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">
<mz-modal-header> <mz-modal-header>
@@ -20,9 +19,7 @@
{{helpStatus}} {{helpStatus}}
</div> </div>
<br> <br>
<div class="green-text" *ngIf="extraHelpStatus" [innerHTML]="extraHelpStatus"> <div class="green-text" *ngIf="extraHelpStatus" [innerHTML]="extraHelpStatus"></div>
</div>
<br><br> <br><br>
<div class="center-align"> <div class="center-align">
<div class="btn pink-button waves-effect waves-light" (click)="statusService.copyStatus();statusService.showStatus('Copied to your clipboard!')">Copy To Clipboard</div><br><br> <div class="btn pink-button waves-effect waves-light" (click)="statusService.copyStatus();statusService.showStatus('Copied to your clipboard!')">Copy To Clipboard</div><br><br>
+1 -50
View File
@@ -80,56 +80,6 @@ export class ElectronService {
break; break;
} }
}); });
// 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', 'Mod'].indexOf(l.provider));
// for (let i = 0; i < urls.length; i++) {
// if (urls[i].provider === 'Mod') {
// this.beatonService.downloadSong(urls[i].link_url, this.adbService);
// } else {
// 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() {
@@ -184,6 +134,7 @@ export class ElectronService {
break; break;
case 'sidequest://i/': case 'sidequest://i/':
this.installFromToken(url[1]); this.installFromToken(url[1]);
this.webviewService.isWebviewLoading = false;
break; break;
case 'sidequest://unload/': case 'sidequest://unload/':
this.adbService.uninstallAPK(url[1]); this.adbService.uninstallAPK(url[1]);
@@ -286,9 +286,10 @@
height: 100%; height: 100%;
top: 0; top: 0;
left: 0; left: 0;
position: absolute; position: fixed;
z-index: 998; z-index: 998;
display:none; display:none;
background-color: rgba(0,0,0,0.8);
} }
.user-menu{ .user-menu{
position: absolute; position: absolute;
@@ -201,15 +201,15 @@
position="bottom" tooltip="Open debugger"> position="bottom" tooltip="Open debugger">
bug_report bug_report
</i> </i>
<i (click)="minimizeApp()" mz-tooltip class="material-icons white-text no-outline" position="bottom" <i (click)="minimizeApp(); userMenu.style.display = 'none';userMenuBack.style.display = 'none'" mz-tooltip class="material-icons white-text no-outline" position="bottom"
tooltip="Minimize SideQuest."> tooltip="Minimize SideQuest.">
minimize minimize
</i> </i>
<i (click)="maximizeApp()" mz-tooltip class="material-icons white-text no-outline" position="bottom" <i (click)="maximizeApp(); userMenu.style.display = 'none';userMenuBack.style.display = 'none'" mz-tooltip class="material-icons white-text no-outline" position="bottom"
tooltip="Toggle Maximize."> tooltip="Toggle Maximize.">
aspect_ratio aspect_ratio
</i> </i>
<i (click)="closeAppModal.openModal()" mz-tooltip class="material-icons white-text no-outline" position="bottom" <i (click)="closeAppModal.openModal(); userMenu.style.display = 'none';userMenuBack.style.display = 'none'" mz-tooltip class="material-icons white-text no-outline" position="bottom"
tooltip="Close SideQuest."> tooltip="Close SideQuest.">
close close
</i> </i>
@@ -237,10 +237,6 @@ export class HeaderComponent implements OnInit {
} }
); );
} }
ngAfterViewInit() {
//this.appService.setTitleEle(this.header.nativeElement);
//this.dragAndDropService.setupDragAndDrop(this.mainLogo.nativeElement);
}
closeApp() { closeApp() {
this.appService.remote.getCurrentWindow().close(); this.appService.remote.getCurrentWindow().close();
} }
@@ -30,8 +30,8 @@
<div class="row"> <div class="row">
<ng-container *ngFor="let package of myApps;"> <ng-container *ngFor="let package of myApps;">
<app-package-item *ngIf="!search <app-package-item *ngIf="!search
|| (package.name && package.name.indexOf(search)) > -1 || (package.name && package.name.toLowerCase().indexOf(search.toLowerCase())) > -1
|| package.packageName.indexOf(search) > -1" [package]="package" || package.packageName.toLowerCase().indexOf(search.toLowerCase()) > -1" [package]="package"
(settings)="currentPackage = $event;appSettingsModal.openModal();getCurrentInstalledInfo()"> (settings)="currentPackage = $event;appSettingsModal.openModal();getCurrentInstalledInfo()">
</app-package-item> </app-package-item>
</ng-container> </ng-container>
+103 -83
View File
@@ -8,18 +8,21 @@ const extract = require('extract-zip');
const adb = require('adbkit'); const adb = require('adbkit');
const fs = require('fs'); const fs = require('fs');
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');
const Readable = require('stream').Readable; // const Readable = require('stream').Readable;
import { SetPropertiesCommand } from './setproperties'; import { SetPropertiesCommand } from './setproperties';
let has_port = process.argv.indexOf('--port'); 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 valid_port = has_port > -1 && process.argv[has_port + 1] && Number.isInteger(Number(process.argv[has_port + 1]));
class ADB { class ADB {
client; client;
_logcat; _logcat;
adbPath;
setupAdb(adbPath, cb, ecb) { setupAdb(adbPath, cb, ecb) {
if (this.client) return; if (this.client) return;
this.adbPath = adbPath;
let port = valid_port ? Number(process.argv[has_port + 1]) : process.env.ANDROID_ADB_SERVER_PORT || 5037; let port = valid_port ? Number(process.argv[has_port + 1]) : process.env.ANDROID_ADB_SERVER_PORT || 5037;
this.client = adb.createClient({ this.client = adb.createClient({
bin: adbPath, bin: adbPath,
@@ -162,13 +165,14 @@ class ADB {
.then(cb) .then(cb)
.catch(e => ecb(e)); .catch(e => ecb(e));
} }
async install(serial, path, isLocal, cb, scb, ecb) { async install(serial, apkpath, isLocal, cb, scb, ecb) {
if (!this.client) return ecb('Not connected.'); if (!this.client) return ecb('Not connected.');
let stream; let outpath = isLocal ? apkpath : path.join(app.getPath('appData'), 'SideQuest', new Date().getTime() + '.apk');
let promise;
if (isLocal) { if (isLocal) {
let found; let found;
try { try {
found = await this.checkAPK(scb, path); found = await this.checkAPK(scb, apkpath);
} catch (e) { } catch (e) {
return ecb(e); return ecb(e);
} }
@@ -176,34 +180,48 @@ class ADB {
return ecb('SAFESIDE'); return ecb('SAFESIDE');
} }
} }
try { promise = isLocal
stream = isLocal ? Promise.resolve()
? fs.createReadStream(path) : new Promise(resolve => {
: new Readable().wrap( progress(request(apkpath), {
progress(request(path), { throttle: 60,
throttle: 60, })
.on('progress', state => {
scb(state);
}) })
.on('progress', state => { .on('end', () => {
scb(state); scb({
}) percent: 1,
.on('end', () => { size: 1,
scb({ time: 1,
percent: 1, });
}); resolve();
}) })
); .on('error', () => {
} catch (e) { ecb('Download error! Please try again!');
const isInvalidURI = e && typeof e.message === 'string' && e.message.startsWith('Invalid URI "'); })
if (isInvalidURI) { .pipe(fs.createWriteStream(outpath));
return ecb("Can't download file. Invalid URL:"); });
} else { promise
throw e; .then(
} () =>
} new Promise((resolve, reject) => {
this.client exec(this.adbPath + ' -s ' + serial + ' install -r -d ' + outpath, {}, (error, stdout, stderr) => {
.install(serial, stream) console.log(error, stdout, stderr);
if (error) {
reject(error.message ? error.message : error.toString());
} else {
resolve();
}
});
})
)
.then(() => (isLocal ? null : fs.unlinkSync(outpath)))
.then(cb) .then(cb)
.catch(e => ecb(e)); .catch(e => {
if (!isLocal) fs.unlinkSync(outpath);
ecb(e);
});
} }
uninstall(serial, packageName, cb, ecb) { uninstall(serial, packageName, cb, ecb) {
if (!this.client) return ecb('Not connected.'); if (!this.client) return ecb('Not connected.');
@@ -463,59 +481,61 @@ function createWindow() {
} }
function setupMenu() { function setupMenu() {
// const template: MenuItemConstructorOptions[] = [ const template: MenuItemConstructorOptions[] = [
// { {
// label: 'SideQuest', label: 'SideQuest',
// submenu: [ submenu: [
// { {
// label: 'Quit', label: 'Quit',
// accelerator: 'Command+Q', accelerator: 'Command+Q',
// click: function() { click: function() {
// app.quit(); app.quit();
// }, },
// }, },
// ], ],
// }, },
// { {
// label: 'Edit', label: 'Edit',
// submenu: [ submenu: [
// { {
// label: 'Undo', label: 'Undo',
// accelerator: 'CmdOrCtrl+Z', accelerator: 'CmdOrCtrl+Z',
// // selector: 'undo:', // selector: 'undo:',
// }, },
// { {
// label: 'Redo', label: 'Redo',
// accelerator: 'Shift+CmdOrCtrl+Z', accelerator: 'Shift+CmdOrCtrl+Z',
// // selector: 'redo:', // selector: 'redo:',
// }, },
// { type: 'separator' }, { type: 'separator' },
// { {
// label: 'Cut', label: 'Cut',
// accelerator: 'CmdOrCtrl+X', accelerator: 'CmdOrCtrl+X',
// // selector: 'cut:' // selector: 'cut:'
// }, },
// { {
// label: 'Copy', label: 'Copy',
// accelerator: 'CmdOrCtrl+C', accelerator: 'CmdOrCtrl+C',
// // selector: 'copy:', // selector: 'copy:',
// }, },
// { {
// label: 'Paste', label: 'Paste',
// accelerator: 'CmdOrCtrl+V', accelerator: 'CmdOrCtrl+V',
// // selector: 'paste:', // selector: 'paste:',
// }, },
// { {
// label: 'Select All', label: 'Select All',
// accelerator: 'CmdOrCtrl+A', accelerator: 'CmdOrCtrl+A',
// // selector: 'selectAll:', // selector: 'selectAll:',
// }, },
// ], ],
// }, },
// ]; ];
// if (process.platform === 'darwin') {
// Menu.setApplicationMenu(Menu.buildFromTemplate(template)); Menu.setApplicationMenu(Menu.buildFromTemplate(template));
Menu.setApplicationMenu(null); } else {
Menu.setApplicationMenu(null);
}
} }
function setupApp() { function setupApp() {
+2 -2
View File
@@ -1,9 +1,9 @@
{ {
"name": "SideQuest", "name": "SideQuest",
"version": "0.10.3", "version": "0.10.4",
"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": "UNLICENCED",
"author": "Shane Harris", "author": "Shane Harris",
"main": "build-electron/boot.js", "main": "build-electron/boot.js",
"scripts": { "scripts": {