From c38e48769a078e6a21d846e9d536797fea327def Mon Sep 17 00:00:00 2001 From: Shane Harris Date: Fri, 5 Aug 2022 07:53:21 +0200 Subject: [PATCH] fixed a bug in apps not showing with no permissions, and fixed a bug in the adb command screen --- desktop-app/src/app/adb-client.service.ts | 37 +++++++++++++------ desktop-app/src/app/electron.service.ts | 8 ++-- .../header-banner/header-banner.component.ts | 6 +-- .../src/app/header/header.component.html | 2 +- .../src/app/packages/packages.component.ts | 9 ++--- .../wireless-connection.component.ts | 6 +-- desktop-app/src/styles.scss | 8 +++- package.json | 2 +- 8 files changed, 48 insertions(+), 30 deletions(-) diff --git a/desktop-app/src/app/adb-client.service.ts b/desktop-app/src/app/adb-client.service.ts index 38e06d1..889d4c0 100644 --- a/desktop-app/src/app/adb-client.service.ts +++ b/desktop-app/src/app/adb-client.service.ts @@ -134,11 +134,13 @@ export class AdbClientService { get isReady(): boolean { return this.deviceStatus === ConnectionStatus.CONNECTED; } - runAdbCommand(adbCommandToRun) { + runAdbCommand(adbCommandToRun, skipSettingResponse?: boolean) { if (this.deviceStatus !== ConnectionStatus.CONNECTED) { return Promise.reject('Adb command failed - No device connected!'); } - this.adbResponse = 'Loading...'; + if (!skipSettingResponse) { + this.adbResponse = 'Loading...'; + } let command = adbCommandToRun.trim(); if (command.substr(0, 3).toLowerCase() === 'adb') { command = command.substr(3); @@ -155,8 +157,12 @@ export class AdbClientService { } ); }).then((resp: string) => { - this.adbResponse = resp.trim() || 'Command Completed.'; - return this.adbResponse; + if (skipSettingResponse) { + return resp.trim() || 'Command Completed.'; + } else { + this.adbResponse = resp.trim() || 'Command Completed.'; + return this.adbResponse; + } }); } launchApp(packageName) { @@ -432,7 +438,7 @@ This can sometimes be caused by changes to your hosts file. Don't make changes u clipboard.writeText(value); } async getAppVersion(isCode: boolean): Promise { - const versionInfo = await this.runAdbCommand('shell dumpsys package ' + this.VR_APP_PACKAGE); + const versionInfo = await this.runAdbCommand('shell dumpsys package ' + this.VR_APP_PACKAGE, true); this.notInstalled = versionInfo.includes('Unable to find package'); const versionParts = versionInfo .split('\n') @@ -1008,7 +1014,7 @@ This can sometimes be caused by changes to your hosts file. Don't make changes u name = name || packageId; const showTotal = number && total ? '(' + number + '/' + total + ') ' : ''; if (!task) this.spinnerService.showLoader(); - let p: any = this.runAdbCommand('adb push "' + filepath + '" /sdcard/Android/obb/' + packageId + '/' + filename); + let p: any = this.runAdbCommand('adb push "' + filepath + '" /sdcard/Android/obb/' + packageId + '/' + filename, true); if (cb) { cb(); } @@ -1102,25 +1108,32 @@ This can sometimes be caused by changes to your hosts file. Don't make changes u } async getPackagePermissions(packagename) { - let requested_permissions = await this.runAdbCommand( - `adb shell "dumpsys package ${packagename} | grep permission | sed -n '/runtime permissions/,$p' | grep -v 'runtime'"` - ); + let requested_permissions = ''; + try { + requested_permissions = await this.runAdbCommand( + `adb shell "dumpsys package ${packagename} | grep permission | sed -n '/runtime permissions/,$p' | grep -v 'runtime'"`, + true + ); + } catch {} let granted_audio = '', granted_read_storage = '', granted_write_storage = ''; try { granted_audio = await this.runAdbCommand( - `adb shell "dumpsys package ${packagename} | grep 'android.permission.RECORD_AUDIO: granted=true'"` + `adb shell "dumpsys package ${packagename} | grep 'android.permission.RECORD_AUDIO: granted=true'"`, + true ); } catch {} try { granted_write_storage = await this.runAdbCommand( - `adb shell "dumpsys package ${packagename} | grep 'android.permission.WRITE_EXTERNAL_STORAGE: granted=true'"` + `adb shell "dumpsys package ${packagename} | grep 'android.permission.WRITE_EXTERNAL_STORAGE: granted=true'"`, + true ); } catch {} try { granted_read_storage = await this.runAdbCommand( - `adb shell "dumpsys package ${packagename} | grep 'android.permission.READ_EXTERNAL_STORAGE: granted=true'"` + `adb shell "dumpsys package ${packagename} | grep 'android.permission.READ_EXTERNAL_STORAGE: granted=true'"`, + true ); } catch {} let read_perm = 'android.permission.READ_EXTERNAL_STORAGE'; diff --git a/desktop-app/src/app/electron.service.ts b/desktop-app/src/app/electron.service.ts index 18a768e..c8447a8 100644 --- a/desktop-app/src/app/electron.service.ts +++ b/desktop-app/src/app/electron.service.ts @@ -125,9 +125,11 @@ export class ElectronService { let url = data.split('#'); switch (url[0]) { case 'sidequest://w/': - this.adbService.runAdbCommand('adb shell am start -a android.intent.action.VIEW -d ' + url[1]).then(() => { - this.statusService.showStatus('Launching WebXR in browser...', false, true); - }); + this.adbService + .runAdbCommand('adb shell am start -a android.intent.action.VIEW -d ' + url[1], true) + .then(() => { + this.statusService.showStatus('Launching WebXR in browser...', false, true); + }); this.webviewService.isWebviewLoading = false; break; case 'sidequest://i/': diff --git a/desktop-app/src/app/header-banner/header-banner.component.ts b/desktop-app/src/app/header-banner/header-banner.component.ts index f4aa15c..01543e1 100644 --- a/desktop-app/src/app/header-banner/header-banner.component.ts +++ b/desktop-app/src/app/header-banner/header-banner.component.ts @@ -124,8 +124,8 @@ export class HeaderBannerComponent implements OnInit { console.warn(e); this.useBundledAPK(); } - await this.adb.runAdbCommand('push "' + this.appService.apkPath + '" /data/local/tmp/sq.apk'); - await this.adb.runAdbCommand('shell pm install -r /data/local/tmp/sq.apk'); + await this.adb.runAdbCommand('push "' + this.appService.apkPath + '" /data/local/tmp/sq.apk', true); + await this.adb.runAdbCommand('shell pm install -r /data/local/tmp/sq.apk', true); // this.toast.show('SideQuest installed to headset!'); // this.showConfetti = true; this.adb.appVersionCode = await this.adb.getAppVersion(true); @@ -168,7 +168,7 @@ export class HeaderBannerComponent implements OnInit { } async uninstall() { - await this.adb.runAdbCommand('uninstall ' + this.adb.VR_APP_PACKAGE); + await this.adb.runAdbCommand('uninstall ' + this.adb.VR_APP_PACKAGE, true); } async userUninstall() { diff --git a/desktop-app/src/app/header/header.component.html b/desktop-app/src/app/header/header.component.html index 72e0304..412d9ec 100644 --- a/desktop-app/src/app/header/header.component.html +++ b/desktop-app/src/app/header/header.component.html @@ -305,7 +305,7 @@
Close
-
Run Command
+
Run Command
diff --git a/desktop-app/src/app/packages/packages.component.ts b/desktop-app/src/app/packages/packages.component.ts index 72cdd7b..932b25a 100644 --- a/desktop-app/src/app/packages/packages.component.ts +++ b/desktop-app/src/app/packages/packages.component.ts @@ -107,14 +107,13 @@ export class PackagesComponent implements OnInit { async triggerCloudBackup() { this.cloudBackupLoading = true; this.cloudBackupStatus = 'Starting backup...'; - await this.adbService.runAdbCommand('adb shell bmgr backup @pm@'); - await this.adbService.runAdbCommand('adb shell bmgr run'); - await this.adbService.runAdbCommand('adb shell cmd package list packages'); - let packages: any = this.adbService.adbResponse; + await this.adbService.runAdbCommand('adb shell bmgr backup @pm@', true); + await this.adbService.runAdbCommand('adb shell bmgr run', true); + let packages: any = await this.adbService.runAdbCommand('adb shell cmd package list packages', true); packages = packages.split('\n').map(line => line.replace(/^package:/, '')); for (let i = 0; i < packages.length; i++) { this.cloudBackupStatus = `Backing up ${Math.round(((i + 1) / packages.length) * 100)}%`; - await this.adbService.runAdbCommand('adb shell bmgr fullbackup ' + packages[i]).then(o => console.log(o)); + await this.adbService.runAdbCommand('adb shell bmgr fullbackup ' + packages[i], true).then(o => console.log(o)); } this.cloudBackupLoading = false; this.cloudBackupDone = true; diff --git a/desktop-app/src/app/wireless-connection/wireless-connection.component.ts b/desktop-app/src/app/wireless-connection/wireless-connection.component.ts index 93f8fc3..62c3db8 100644 --- a/desktop-app/src/app/wireless-connection/wireless-connection.component.ts +++ b/desktop-app/src/app/wireless-connection/wireless-connection.component.ts @@ -20,15 +20,15 @@ export class WirelessConnectionComponent implements OnInit { let status = 'Attempting wifi connection...'; this.statusService.showStatus(status, false, true); this.adbService.deviceStatusMessage = status; - ((this.adbService.isReady ? this.adbService.runAdbCommand('adb tcpip 5555') : Promise.resolve()) as any).then(() => { + ((this.adbService.isReady ? this.adbService.runAdbCommand('adb tcpip 5555', true) : Promise.resolve()) as any).then(() => { setTimeout(() => { - this.adbService.runAdbCommand('adb connect ' + this.adbService.deviceIp + ':5555'); + this.adbService.runAdbCommand('adb connect ' + this.adbService.deviceIp + ':5555', true); }, 3000); }); } reset() { - this.adbService.runAdbCommand('adb disconnect'); + this.adbService.runAdbCommand('adb disconnect', true); this.statusService.showStatus('Resetting ADB connection...', false, true); } diff --git a/desktop-app/src/styles.scss b/desktop-app/src/styles.scss index 466e25f..702377e 100644 --- a/desktop-app/src/styles.scss +++ b/desktop-app/src/styles.scss @@ -315,7 +315,9 @@ code > pre, .code{ margin-bottom: 1em; margin-right: 30px; } - +.pure-material-button-contained.spaced:last-child { + margin-right: 2px; +} .pure-material-button-contained.slim{ padding: 5px 10px; height: 25px; @@ -330,7 +332,9 @@ code > pre, .code{ background: transparent; border: 2px solid #afafaf; color: #afafaf; - height: 40px; + padding: 0 8px; + line-height: 30px; + height: 34px } .pure-material-button-contained.small{ padding: 0 8px; diff --git a/package.json b/package.json index 4223087..24df90b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "SideQuest", "productName": "SideQuest", - "version": "0.10.29", + "version": "0.10.30", "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/SideQuestVR/SideQuest.git", "license": "UNLICENCED",