init: Disable 'on' for non-Vendor APEXes
Mainline modules are not supposed to rely on 'on' action triggers in their init scripts because events/properties are not guranteed to be stable across many devices. To reduce the potential risk of enabling 'on' for APEXes, for now, we enable it for only Vendor APEXes. When an init script in a non-Vendor APEX contains 'on' section, init emits an error on parsing the script and skip the section. For example, when init.rc in the ADBD APEX has 'on' section, the following error is emitted on parsing the script. init: Parsing file /apex/com.android.adbd/etc/init.rc... init: /apex/com.android.adbd/etc/init.rc: 8: ParseSection() failed: 'on' is supported for only Vendor APEXes. Bug: 232543017 Test: see above Change-Id: I6509c8d2c6b632369d215128f740f9ed78858605
This commit is contained in:
parent
1a3572b0b3
commit
99fa346c35
1 changed files with 8 additions and 0 deletions
|
@ -142,6 +142,14 @@ Result<void> ActionParser::ParseSection(std::vector<std::string>&& args,
|
|||
action_subcontext = subcontext_;
|
||||
}
|
||||
|
||||
// We support 'on' for only Vendor APEXes from /{vendor, odm}.
|
||||
// It is to prevent mainline modules from using 'on' triggers because events/properties are
|
||||
// not stable for mainline modules.
|
||||
// Note that this relies on Subcontext::PathMatchesSubcontext() to identify Vendor APEXes.
|
||||
if (StartsWith(filename, "/apex/") && !action_subcontext) {
|
||||
return Error() << "ParseSection() failed: 'on' is supported for only Vendor APEXes.";
|
||||
}
|
||||
|
||||
std::string event_trigger;
|
||||
std::map<std::string, std::string> property_triggers;
|
||||
|
||||
|
|
Loading…
Reference in a new issue