[Do Not Merge] Ignore malformed shortcuts

After an app publishes a shortcut that contains malformed intent, the
system can be stuck in boot-loop due to uncaught exception caused by
parsing the malformed intent.

This CL ignores that particular malformed entry. Since shortcuts are
constantly writes back into the xml from system memory, the malformed
entry will be removed from the xml the next time system persists
shortcuts from memory to file system.

Bug: 246540168
Change-Id: Ie1e39005a5f9d8038bd703a5bc845779c2f46e94
Test: manual
This commit is contained in:
Pinyao Ting
2022-09-21 23:03:11 +00:00
parent b625b562c4
commit 9b0dd514d2

View File

@@ -1629,11 +1629,15 @@ class ShortcutPackage extends ShortcutPackageItem {
continue; continue;
case TAG_SHORTCUT: case TAG_SHORTCUT:
final ShortcutInfo si = parseShortcut(parser, packageName, try {
shortcutUser.getUserId(), fromBackup); final ShortcutInfo si = parseShortcut(parser, packageName,
shortcutUser.getUserId(), fromBackup);
// Don't use addShortcut(), we don't need to save the icon. // Don't use addShortcut(), we don't need to save the icon.
ret.mShortcuts.put(si.getId(), si); ret.mShortcuts.put(si.getId(), si);
} catch (Exception e) {
// b/246540168 malformed shortcuts should be ignored
Slog.e(TAG, "Failed parsing shortcut.", e);
}
continue; continue;
case TAG_SHARE_TARGET: case TAG_SHARE_TARGET:
ret.mShareTargets.add(ShareTargetInfo.loadFromXml(parser)); ret.mShareTargets.add(ShareTargetInfo.loadFromXml(parser));