[core] add meta mobileWidth and mobileHeight params
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const exec = require('./exec');
|
||||
const run = require('../run/index');
|
||||
const {StringWritable} = require('./tail');
|
||||
const Command = require('../run/command');
|
||||
|
||||
const through = require('through2');
|
||||
@@ -125,10 +125,35 @@ class Android extends Sdk {
|
||||
});
|
||||
}
|
||||
|
||||
_installApk(filename, pack) {
|
||||
this.log.i('install *%s*', filename);
|
||||
return this.adb(['install', '-r', '-d', filename])
|
||||
.then(() => {
|
||||
return false;
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.includes('INSTALL_FAILED_UPDATE_INCOMPATIBLE')) {
|
||||
this.log.w('!INSTALL FAILED UPDATE INCOMPATIBLE!');
|
||||
return true;
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
})
|
||||
.then(reinstall => {
|
||||
if (reinstall) {
|
||||
this.log.i('uninstall *%s*', pack);
|
||||
return this.adb(['uninstall', pack]).then(() => {
|
||||
this.log.i('install *%s*', filename);
|
||||
return this.adb(['install', '-r', '-d', filename]);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
install() {
|
||||
const self = this;
|
||||
return through.obj(function(file, enc, callback) {
|
||||
self.adb(['install', '-r', file.path]).then(() => {
|
||||
self._installApk(file.path, file.package).then(() => {
|
||||
this.push(file);
|
||||
callback();
|
||||
});
|
||||
@@ -139,6 +164,7 @@ class Android extends Sdk {
|
||||
const self = this;
|
||||
return through.obj(function(file, enc, callback) {
|
||||
const name = `${file.package}/${file.activity}`;
|
||||
self.log.i('start *%s*', name);
|
||||
self.adb(['shell', 'am', 'start', '-n', name]).then(() => {
|
||||
setTimeout(() => {
|
||||
self.adb(['shell', `"ps | grep ${file.package}"`]).then(result => {
|
||||
@@ -155,7 +181,14 @@ class Android extends Sdk {
|
||||
const self = this;
|
||||
return through.obj(function(file, enc, callback) {
|
||||
const cmd = `${self.adbBin} logcat --pid ${file.pid}`;
|
||||
this.push(new Command(cmd).exec());
|
||||
const command = new Command(cmd).exec();
|
||||
this.push(command);
|
||||
command.contents.pipe(new StringWritable(line => {
|
||||
if (line.includes('SDL') && (line.includes('onDestroy()') || line.includes('onStop()'))) {
|
||||
callback();
|
||||
throw 'Exit'; // ToDo:
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,10 +42,13 @@ class Config {
|
||||
company: null,
|
||||
width: 800,
|
||||
height: 600,
|
||||
mobileWidth: null,
|
||||
mobileHeight: null,
|
||||
fps: 60,
|
||||
};
|
||||
if (params) {
|
||||
this.update(params);
|
||||
this.afterUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,12 +71,18 @@ class Config {
|
||||
if (this.meta.icon) this.icon = Config.absolutePath(this.meta.icon);
|
||||
}
|
||||
|
||||
afterUpdate() {
|
||||
if (this.meta.mobileWidth === null) this.meta.mobileWidth = this.meta.width;
|
||||
if (this.meta.mobileHeight === null) this.meta.mobileHeight = Math.round(this.meta.mobileWidth / 1.777777778);
|
||||
}
|
||||
|
||||
branch(params) {
|
||||
const result = new Config();
|
||||
for (const params of this._params) {
|
||||
result.update(params);
|
||||
}
|
||||
result.update(params);
|
||||
result.afterUpdate();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,8 +377,7 @@ class AndroidRunner extends Runner {
|
||||
|
||||
call() {
|
||||
const target = this.targetPath;
|
||||
const filename = path.resolve(target, this.config.meta.filename+'-debug.apk');
|
||||
return this.log(gulp.src(filename)
|
||||
return this.log(gulp.src(`${target}/${this.config.meta.filename}_*.apk`)
|
||||
.pipe(this.android.apk())
|
||||
.pipe(this.android.install())
|
||||
.pipe(this.android.start())
|
||||
|
||||
@@ -67,3 +67,4 @@ module.exports = (handler) => {
|
||||
};
|
||||
|
||||
module.exports.TailVinyl = TailVinyl;
|
||||
module.exports.StringWritable = StringWritable;
|
||||
|
||||
Reference in New Issue
Block a user