Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-15841] Fixed bugs with sd card detection and emulator launching. #5076

Merged
merged 1 commit into from
Dec 6, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ AndroidBuilder.prototype.config = function config(logger, config, cli) {
version: emu['sdk-version'],
abi: emu.abi,
type: emu.type,
googleApis: emu.googleApis
googleApis: emu.googleApis,
sdcard: emu.sdcard
};
} else if (emu.type == 'genymotion') {
return {
Expand All @@ -234,7 +235,8 @@ AndroidBuilder.prototype.config = function config(logger, config, cli) {
version: emu['sdk-version'],
abi: emu.abi,
type: emu.type,
googleApis: emu.googleApis
googleApis: emu.googleApis,
sdcard: true
};
}
return emu; // not good
Expand Down Expand Up @@ -1206,6 +1208,17 @@ AndroidBuilder.prototype.validate = function validate(logger, config, cli) {

process.exit(1);
}

// if debugging/profiling, make sure we have a sd card
if (this.target == 'emulator' && (this.allowDebugging || this.allowProfiling) && !device.sdcard) {
logger.error(__('The selected emulator "%s" does not have an SD card.', devices[i].name));
if (this.allowProfiling) {
logger.error(__('An SD card is required for profiling.') + '\n');
} else {
logger.error(__('An SD card is required for debugging.') + '\n');
}
process.exit(1);
}
}, this);
}
}
Expand Down
32 changes: 27 additions & 5 deletions android/cli/hooks/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ exports.init = function (logger, config, cli) {

cb();
});
})(builder.deviceId, { logger: logger }, function (err, results, opts) {
})(builder.deviceId, {
logger: logger,
checkMounts: builder.allowDebugging || builder.allowProfiling
}, function (err, results, opts) {
finished();
});

Expand Down Expand Up @@ -161,13 +164,32 @@ exports.init = function (logger, config, cli) {
// push deploy.json
var deployJsonFile = path.join(builder.buildDir, 'bin', 'deploy.json');
fs.writeFileSync(deployJsonFile, JSON.stringify(deployData));
logger.info(__('Pushing %s to sdcard', deployJsonFile.cyan));
adb.shell(device.id, 'mkdir /sdcard/' + builder.appid + ' || echo', function () {
logger.info(__('Pushing %s to SD card', deployJsonFile.cyan));
adb.shell(device.id, [
'if [ -d "/sdcard/' + builder.appid + '" ]; then',
' echo "SUCCESS"',
'else',
' mkdir "/sdcard/' + builder.appid + '"',
' if [ $? -ne 0 ]; then',
' echo "FAILED"',
' else',
' echo "SUCCESS"',
' fi',
'fi'
].join('\n'), function (err, output) {
if (err || output.toString().trim().split('\n').shift().trim() == 'FAILED') {
if (builder.target == 'device') {
logger.error(__('Failed to copy "deploy.json" to Android device\'s SD card. Perhaps it\'s read only or out of space.') + '\n');
} else {
logger.error(__('Failed to copy "deploy.json" to Android emulator\'s SD card. Perhaps it\'s read only or out of space.') + '\n');
}
process.exit(1);
}
adb.push(device.id, deployJsonFile, '/sdcard/' + builder.appid + '/deploy.json', cb);
});
} else {
logger.info(__('Removing %s from sdcard', 'deploy.json'.cyan));
adb.shell(device.id, '[ -f "/sdcard/' + builder.appid + '/deploy.json"] && rm -f "/sdcard/' + builder.appid + '/deploy.json" || echo ""', cb);
logger.info(__('Removing %s from SD card', 'deploy.json'.cyan));
adb.shell(device.id, '[ -f "/sdcard/' + builder.appid + '/deploy.json" ] && rm -f "/sdcard/' + builder.appid + '/deploy.json"\necho "DONE"', cb);
}
};
}), next);
Expand Down
9 changes: 7 additions & 2 deletions android/cli/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
},
"Supported ABIs: %s": "Supported ABIs: %s",
"You need to add at least one of the device's supported ABIs to the tiapp.xml": "You need to add at least one of the device's supported ABIs to the tiapp.xml",
"The selected emulator \"%s\" does not have an SD card.": "The selected emulator \"%s\" does not have an SD card.",
"An SD card is required for profiling.": "An SD card is required for profiling.",
"An SD card is required for debugging.": "An SD card is required for debugging.",
"Invalid %s host \"%s\"": "Invalid %s host \"%s\"",
"The %s host must be in the format \"host:port\".": "The %s host must be in the format \"host:port\".",
"The port must be a valid integer between 1 and 65535.": "The port must be a valid integer between 1 and 65535.",
Expand Down Expand Up @@ -281,8 +284,10 @@
"Emulator failed to start in a timely manner": "Emulator failed to start in a timely manner",
"The current timeout is set to %s ms": "The current timeout is set to %s ms",
"You can increase this timeout by running: %s": "You can increase this timeout by running: %s",
"Pushing %s to sdcard": "Pushing %s to sdcard",
"Removing %s from sdcard": "Removing %s from sdcard",
"Pushing %s to SD card": "Pushing %s to SD card",
"Failed to copy \"deploy.json\" to Android device's SD card. Perhaps it's read only or out of space.": "Failed to copy \"deploy.json\" to Android device's SD card. Perhaps it's read only or out of space.",
"Failed to copy \"deploy.json\" to Android emulator's SD card. Perhaps it's read only or out of space.": "Failed to copy \"deploy.json\" to Android emulator's SD card. Perhaps it's read only or out of space.",
"Removing %s from SD card": "Removing %s from SD card",
"Installing apk: %s": "Installing apk: %s",
"Installing app on device: %s": "Installing app on device: %s",
"Failed to install apk on \"%s\"": "Failed to install apk on \"%s\"",
Expand Down
5 changes: 5 additions & 0 deletions node_modules/titanium-sdk/lib/android.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 64 additions & 14 deletions node_modules/titanium-sdk/lib/emulator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions node_modules/titanium-sdk/locales/en.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.