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 { SynthriderService } from './synthrider.service';
|
||||||
import { SongBeaterService } from './song-beater.service';
|
import { SongBeaterService } from './song-beater.service';
|
||||||
import { AudicaService } from './audica.service';
|
import { AudicaService } from './audica.service';
|
||||||
|
import { environment } from '../environments/environment';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@@ -64,9 +65,7 @@ export class ElectronService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async installFromToken(token) {
|
async installFromToken(token) {
|
||||||
console.log("Install from token", token)
|
|
||||||
let res = await this.adbService.adbCommand('installFromToken', { token });
|
let res = await this.adbService.adbCommand('installFromToken', { token });
|
||||||
console.log("IT: res", res)
|
|
||||||
res.forEach((l, i) => {
|
res.forEach((l, i) => {
|
||||||
switch (l.type) {
|
switch (l.type) {
|
||||||
case 'Mod':
|
case 'Mod':
|
||||||
@@ -84,7 +83,6 @@ export class ElectronService {
|
|||||||
|
|
||||||
setupIPC() {
|
setupIPC() {
|
||||||
this.appService.electron.ipcRenderer.on('pre-open-url', (event, data) => {
|
this.appService.electron.ipcRenderer.on('pre-open-url', (event, data) => {
|
||||||
console.log('here', data);
|
|
||||||
this.spinnerService.showLoader();
|
this.spinnerService.showLoader();
|
||||||
this.spinnerService.setMessage('Do you want to install this file?<br><br>' + data.name);
|
this.spinnerService.setMessage('Do you want to install this file?<br><br>' + data.name);
|
||||||
this.spinnerService.setupConfirm().then(() => {
|
this.spinnerService.setupConfirm().then(() => {
|
||||||
@@ -123,10 +121,12 @@ export class ElectronService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.appService.electron.ipcRenderer.on('open-url', async (event, data) => {
|
this.appService.electron.ipcRenderer.on('open-url', async (event, data) => {
|
||||||
console.log("Open URL", data);
|
|
||||||
if (data) {
|
if (data) {
|
||||||
let url = data.split('#');
|
let url = data.split('#');
|
||||||
switch (url[0]) {
|
switch (url[0]) {
|
||||||
|
case 'sidequest://app/':
|
||||||
|
this.webviewService.loadUrl(environment.configuration.web_url + '/app/' + url[1]);
|
||||||
|
break;
|
||||||
case 'sidequest://w/':
|
case 'sidequest://w/':
|
||||||
this.adbService
|
this.adbService
|
||||||
.runAdbCommand(
|
.runAdbCommand(
|
||||||
@@ -146,7 +146,6 @@ export class ElectronService {
|
|||||||
this.adbService.uninstallAPK(url[1]);
|
this.adbService.uninstallAPK(url[1]);
|
||||||
break;
|
break;
|
||||||
case 'sidequest://sideload-multi/':
|
case 'sidequest://sideload-multi/':
|
||||||
console.log("SQM", data)
|
|
||||||
try {
|
try {
|
||||||
let urls = JSON.parse(
|
let urls = JSON.parse(
|
||||||
data
|
data
|
||||||
|
|||||||
@@ -533,6 +533,7 @@ let appWindow: AppWindow;
|
|||||||
let mainWindow: BrowserWindow;
|
let mainWindow: BrowserWindow;
|
||||||
let popupWindow: BrowserWindow;
|
let popupWindow: BrowserWindow;
|
||||||
let hasUpdate = false;
|
let hasUpdate = false;
|
||||||
|
let app_id=0;
|
||||||
|
|
||||||
if (app.requestSingleInstanceLock()) {
|
if (app.requestSingleInstanceLock()) {
|
||||||
const environment: EnvironmentConfig = { userDataPath: app.getPath('userData') };
|
const environment: EnvironmentConfig = { userDataPath: app.getPath('userData') };
|
||||||
@@ -594,6 +595,22 @@ function addWindowDownloadHandler(window) {
|
|||||||
item.cancel();
|
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() {
|
function createWindow() {
|
||||||
appWindow = new AppWindow(config);
|
appWindow = new AppWindow(config);
|
||||||
mainWindow = appWindow.window;
|
mainWindow = appWindow.window;
|
||||||
@@ -658,6 +675,17 @@ function createWindow() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
child.webContents.session.on('select-usb-device', (event, details, callback) => {
|
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
|
// Add events to handle devices being added or removed before the callback on
|
||||||
// `select-usb-device` is called.
|
// `select-usb-device` is called.
|
||||||
|
|
||||||
@@ -700,6 +728,8 @@ function createWindow() {
|
|||||||
};
|
};
|
||||||
handleWindow(mainWindow);
|
handleWindow(mainWindow);
|
||||||
mainWindow.webContents.session.setUserAgent(mainWindow.webContents.session.getUserAgent() + ' SQ/' + app.getVersion());
|
mainWindow.webContents.session.setUserAgent(mainWindow.webContents.session.getUserAgent() + ' SQ/' + app.getVersion());
|
||||||
|
// This can run in the background
|
||||||
|
getSideQuestPackage();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupMenu() {
|
function setupMenu() {
|
||||||
|
|||||||
Reference in New Issue
Block a user