Ensure that we have an valid intent before we launch it
This commit is contained in:
parent
4a5ce92553
commit
edd8960009
6 changed files with 46 additions and 0 deletions
|
|
@ -21,6 +21,12 @@
|
|||
|
||||
namespace anbox {
|
||||
namespace android {
|
||||
bool Intent::valid() const {
|
||||
// At the moment we only support component+package for intents
|
||||
// (see android/service/android_api_skeleton.cpp for more details)
|
||||
return !(component.empty() && package.empty());
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const Intent &intent) {
|
||||
out << "[";
|
||||
if (!intent.action.empty())
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ struct Intent {
|
|||
std::string package;
|
||||
std::string component;
|
||||
std::vector<std::string> categories;
|
||||
|
||||
bool valid() const;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const Intent &intent);
|
||||
|
|
|
|||
|
|
@ -79,6 +79,11 @@ anbox::cmds::Launch::Launch()
|
|||
stack_));
|
||||
|
||||
action([this](const cli::Command::Context&) {
|
||||
if (!intent_.valid()) {
|
||||
ERROR("The intent you provided is invalid. Please provide a correct launch intent.");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
auto trap = core::posix::trap_signals_for_process({core::posix::Signal::sig_term, core::posix::Signal::sig_int});
|
||||
trap->signal_raised().connect([trap](const core::posix::Signal& signal) {
|
||||
INFO("Signal %i received. Good night.", static_cast<int>(signal));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue