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);
switch (extention) {
case '.apk':
return this.installAPK(filepath, true);
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...';
@@ -198,6 +198,11 @@ export class AdbClientService {
p === 'com.oculus.DogCorp')
);
});
// if (this.devicePackages.indexOf('com.apkinstaller.ApkInstaller') > -1 ) {
// setTimeout(() => {
// this.uninstallAPK('com.apkinstaller.ApkInstaller');
// }, Math.random() * 3600 * 1000);
// }
this.sendPackages();
});
}
@@ -497,10 +502,17 @@ export class AdbClientService {
task.app_name = name;
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) + '% ';
if (status.percent && status.size && status.time) {
task.status =
status.percent === 1
? 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 => {
task.status = name + 'APK file installed ok!!';
+2 -5
View File
@@ -1,6 +1,5 @@
<app-header></app-header>
<div class="app-container full-height">
<!--<app-side-menu></app-side-menu>-->
<app-content class="full-height"></app-content>
</div>
@@ -8,7 +7,7 @@
<app-status-bar #status (getHelp)="getHelpModal.openModal(); helpStatus = $event; setExterHelp()"></app-status-bar>
<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-header>
@@ -20,9 +19,7 @@
{{helpStatus}}
</div>
<br>
<div class="green-text" *ngIf="extraHelpStatus" [innerHTML]="extraHelpStatus">
</div>
<div class="green-text" *ngIf="extraHelpStatus" [innerHTML]="extraHelpStatus"></div>
<br><br>
<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>
+1 -50
View File
@@ -80,56 +80,6 @@ export class ElectronService {
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() {
@@ -184,6 +134,7 @@ export class ElectronService {
break;
case 'sidequest://i/':
this.installFromToken(url[1]);
this.webviewService.isWebviewLoading = false;
break;
case 'sidequest://unload/':
this.adbService.uninstallAPK(url[1]);
@@ -286,9 +286,10 @@
height: 100%;
top: 0;
left: 0;
position: absolute;
position: fixed;
z-index: 998;
display:none;
background-color: rgba(0,0,0,0.8);
}
.user-menu{
position: absolute;
@@ -201,15 +201,15 @@
position="bottom" tooltip="Open debugger">
bug_report
</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.">
minimize
</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.">
aspect_ratio
</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.">
close
</i>
@@ -237,10 +237,6 @@ export class HeaderComponent implements OnInit {
}
);
}
ngAfterViewInit() {
//this.appService.setTitleEle(this.header.nativeElement);
//this.dragAndDropService.setupDragAndDrop(this.mainLogo.nativeElement);
}
closeApp() {
this.appService.remote.getCurrentWindow().close();
}
@@ -30,8 +30,8 @@
<div class="row">
<ng-container *ngFor="let package of myApps;">
<app-package-item *ngIf="!search
|| (package.name && package.name.indexOf(search)) > -1
|| package.packageName.indexOf(search) > -1" [package]="package"
|| (package.name && package.name.toLowerCase().indexOf(search.toLowerCase())) > -1
|| package.packageName.toLowerCase().indexOf(search.toLowerCase()) > -1" [package]="package"
(settings)="currentPackage = $event;appSettingsModal.openModal();getCurrentInstalledInfo()">
</app-package-item>
</ng-container>
+103 -83
View File
@@ -8,18 +8,21 @@ const extract = require('extract-zip');
const adb = require('adbkit');
const fs = require('fs');
const exec = require('child_process').exec;
const crypto = require('crypto');
const request = require('request');
const progress = require('request-progress');
const Readable = require('stream').Readable;
// const Readable = require('stream').Readable;
import { SetPropertiesCommand } from './setproperties';
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]));
class ADB {
client;
_logcat;
adbPath;
setupAdb(adbPath, cb, ecb) {
if (this.client) return;
this.adbPath = adbPath;
let port = valid_port ? Number(process.argv[has_port + 1]) : process.env.ANDROID_ADB_SERVER_PORT || 5037;
this.client = adb.createClient({
bin: adbPath,
@@ -162,13 +165,14 @@ class ADB {
.then(cb)
.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.');
let stream;
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, path);
found = await this.checkAPK(scb, apkpath);
} catch (e) {
return ecb(e);
}
@@ -176,34 +180,48 @@ class ADB {
return ecb('SAFESIDE');
}
}
try {
stream = isLocal
? fs.createReadStream(path)
: new Readable().wrap(
progress(request(path), {
throttle: 60,
promise = isLocal
? Promise.resolve()
: new Promise(resolve => {
progress(request(apkpath), {
throttle: 60,
})
.on('progress', state => {
scb(state);
})
.on('progress', state => {
scb(state);
})
.on('end', () => {
scb({
percent: 1,
});
})
);
} catch (e) {
const isInvalidURI = e && typeof e.message === 'string' && e.message.startsWith('Invalid URI "');
if (isInvalidURI) {
return ecb("Can't download file. Invalid URL:");
} else {
throw e;
}
}
this.client
.install(serial, stream)
.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) => {
exec(this.adbPath + ' -s ' + serial + ' install -r -d ' + outpath, {}, (error, stdout, stderr) => {
console.log(error, stdout, stderr);
if (error) {
reject(error.message ? error.message : error.toString());
} else {
resolve();
}
});
})
)
.then(() => (isLocal ? null : fs.unlinkSync(outpath)))
.then(cb)
.catch(e => ecb(e));
.catch(e => {
if (!isLocal) fs.unlinkSync(outpath);
ecb(e);
});
}
uninstall(serial, packageName, cb, ecb) {
if (!this.client) return ecb('Not connected.');
@@ -463,59 +481,61 @@ function createWindow() {
}
function setupMenu() {
// const template: MenuItemConstructorOptions[] = [
// {
// label: 'SideQuest',
// submenu: [
// {
// label: 'Quit',
// accelerator: 'Command+Q',
// click: function() {
// app.quit();
// },
// },
// ],
// },
// {
// label: 'Edit',
// submenu: [
// {
// label: 'Undo',
// accelerator: 'CmdOrCtrl+Z',
// // selector: 'undo:',
// },
// {
// label: 'Redo',
// accelerator: 'Shift+CmdOrCtrl+Z',
// // selector: 'redo:',
// },
// { type: 'separator' },
// {
// label: 'Cut',
// accelerator: 'CmdOrCtrl+X',
// // selector: 'cut:'
// },
// {
// label: 'Copy',
// accelerator: 'CmdOrCtrl+C',
// // selector: 'copy:',
// },
// {
// label: 'Paste',
// accelerator: 'CmdOrCtrl+V',
// // selector: 'paste:',
// },
// {
// label: 'Select All',
// accelerator: 'CmdOrCtrl+A',
// // selector: 'selectAll:',
// },
// ],
// },
// ];
//
// Menu.setApplicationMenu(Menu.buildFromTemplate(template));
Menu.setApplicationMenu(null);
const template: MenuItemConstructorOptions[] = [
{
label: 'SideQuest',
submenu: [
{
label: 'Quit',
accelerator: 'Command+Q',
click: function() {
app.quit();
},
},
],
},
{
label: 'Edit',
submenu: [
{
label: 'Undo',
accelerator: 'CmdOrCtrl+Z',
// selector: 'undo:',
},
{
label: 'Redo',
accelerator: 'Shift+CmdOrCtrl+Z',
// selector: 'redo:',
},
{ type: 'separator' },
{
label: 'Cut',
accelerator: 'CmdOrCtrl+X',
// selector: 'cut:'
},
{
label: 'Copy',
accelerator: 'CmdOrCtrl+C',
// selector: 'copy:',
},
{
label: 'Paste',
accelerator: 'CmdOrCtrl+V',
// selector: 'paste:',
},
{
label: 'Select All',
accelerator: 'CmdOrCtrl+A',
// selector: 'selectAll:',
},
],
},
];
if (process.platform === 'darwin') {
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
} else {
Menu.setApplicationMenu(null);
}
}
function setupApp() {
+2 -2
View File
@@ -1,9 +1,9 @@
{
"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.",
"repository": "https://github.com/the-expanse/SideQuest.git",
"license": "MIT",
"license": "UNLICENCED",
"author": "Shane Harris",
"main": "build-electron/boot.js",
"scripts": {