SD-1177 - Redirect in VR app if they try to use the USB installer path.
This commit is contained in:
@@ -9,6 +9,7 @@ import { BeatOnService } from './beat-on.service';
|
||||
import { SynthriderService } from './synthrider.service';
|
||||
import { SongBeaterService } from './song-beater.service';
|
||||
import { AudicaService } from './audica.service';
|
||||
import { environment } from '../environments/environment';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -64,9 +65,7 @@ export class ElectronService {
|
||||
}
|
||||
|
||||
async installFromToken(token) {
|
||||
console.log("Install from token", token)
|
||||
let res = await this.adbService.adbCommand('installFromToken', { token });
|
||||
console.log("IT: res", res)
|
||||
res.forEach((l, i) => {
|
||||
switch (l.type) {
|
||||
case 'Mod':
|
||||
@@ -84,7 +83,6 @@ export class ElectronService {
|
||||
|
||||
setupIPC() {
|
||||
this.appService.electron.ipcRenderer.on('pre-open-url', (event, data) => {
|
||||
console.log('here', data);
|
||||
this.spinnerService.showLoader();
|
||||
this.spinnerService.setMessage('Do you want to install this file?<br><br>' + data.name);
|
||||
this.spinnerService.setupConfirm().then(() => {
|
||||
@@ -123,10 +121,12 @@ export class ElectronService {
|
||||
}
|
||||
});
|
||||
this.appService.electron.ipcRenderer.on('open-url', async (event, data) => {
|
||||
console.log("Open URL", data);
|
||||
if (data) {
|
||||
let url = data.split('#');
|
||||
switch (url[0]) {
|
||||
case 'sidequest://app/':
|
||||
this.webviewService.loadUrl(environment.configuration.web_url + '/app/' + url[1]);
|
||||
break;
|
||||
case 'sidequest://w/':
|
||||
this.adbService
|
||||
.runAdbCommand(
|
||||
@@ -146,7 +146,6 @@ export class ElectronService {
|
||||
this.adbService.uninstallAPK(url[1]);
|
||||
break;
|
||||
case 'sidequest://sideload-multi/':
|
||||
console.log("SQM", data)
|
||||
try {
|
||||
let urls = JSON.parse(
|
||||
data
|
||||
|
||||
@@ -533,6 +533,7 @@ let appWindow: AppWindow;
|
||||
let mainWindow: BrowserWindow;
|
||||
let popupWindow: BrowserWindow;
|
||||
let hasUpdate = false;
|
||||
let app_id=0;
|
||||
|
||||
if (app.requestSingleInstanceLock()) {
|
||||
const environment: EnvironmentConfig = { userDataPath: app.getPath('userData') };
|
||||
@@ -594,6 +595,22 @@ function addWindowDownloadHandler(window) {
|
||||
item.cancel();
|
||||
});
|
||||
}
|
||||
|
||||
function getSideQuestPackage(): Promise<number> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const api = getEnvCfg().http_url + "/v2/apps/get-sidequest-apk"
|
||||
let options = {
|
||||
headers: { 'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({ package_name: 'quest.side.vr' }),
|
||||
method: 'POST',
|
||||
}
|
||||
fetch(api, options).then(res => res.json()).then(json => {
|
||||
app_id = json.apps_id;
|
||||
resolve( json.apps_id);
|
||||
}).catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
function createWindow() {
|
||||
appWindow = new AppWindow(config);
|
||||
mainWindow = appWindow.window;
|
||||
@@ -658,6 +675,17 @@ function createWindow() {
|
||||
});
|
||||
|
||||
child.webContents.session.on('select-usb-device', (event, details, callback) => {
|
||||
// Redirect Code
|
||||
if (app_id == 0) {
|
||||
getSideQuestPackage().then(url => {
|
||||
console.log('redirecting to app', url);
|
||||
mainWindow.webContents.send('open-url', "sidequest://app/#" + url);
|
||||
});
|
||||
} else {
|
||||
mainWindow.webContents.send('open-url', "sidequest://app/#" + app_id);
|
||||
}
|
||||
|
||||
return;
|
||||
// Add events to handle devices being added or removed before the callback on
|
||||
// `select-usb-device` is called.
|
||||
|
||||
@@ -700,6 +728,8 @@ function createWindow() {
|
||||
};
|
||||
handleWindow(mainWindow);
|
||||
mainWindow.webContents.session.setUserAgent(mainWindow.webContents.session.getUserAgent() + ' SQ/' + app.getVersion());
|
||||
// This can run in the background
|
||||
getSideQuestPackage();
|
||||
}
|
||||
|
||||
function setupMenu() {
|
||||
|
||||
Reference in New Issue
Block a user