Stop processing on IOException.
IOException usually means that the file is corrupted and further processing is dangerous and should be stopped. Bug: 269049175 Bug: 246540168 Fixes: 269049175 Test: atest ShortcutManagerTest1 Change-Id: I493c2658298dc23d45b37776663f316d31238b52
This commit is contained in:
@@ -2048,6 +2048,9 @@ class ShortcutPackage extends ShortcutPackageItem {
|
||||
shortcutUser.getUserId(), fromBackup);
|
||||
// Don't use addShortcut(), we don't need to save the icon.
|
||||
ret.mShortcuts.put(si.getId(), si);
|
||||
} catch (IOException e) {
|
||||
// Don't ignore IO exceptions.
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
// b/246540168 malformed shortcuts should be ignored
|
||||
Slog.e(TAG, "Failed parsing shortcut.", e);
|
||||
|
||||
@@ -115,6 +115,7 @@ android_test {
|
||||
":StubTestApp",
|
||||
":SuspendTestApp",
|
||||
":MediaButtonReceiverHolderTestHelperApp",
|
||||
"data/broken_shortcut.xml",
|
||||
],
|
||||
|
||||
java_resources: [
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
<option name="cleanup" value="true" />
|
||||
<option name="push-file" key="SimpleServiceTestApp3.apk"
|
||||
value="/data/local/tmp/cts/content/SimpleServiceTestApp3.apk" />
|
||||
<option name="push-file" key="broken_shortcut.xml"
|
||||
value="/data/local/tmp/cts/content/broken_shortcut.xml" />
|
||||
</target_preparer>
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
|
||||
|
||||
BIN
services/tests/servicestests/data/broken_shortcut.xml
Normal file
BIN
services/tests/servicestests/data/broken_shortcut.xml
Normal file
Binary file not shown.
@@ -4007,6 +4007,18 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest {
|
||||
// TODO Check all other fields
|
||||
}
|
||||
|
||||
public void testLoadCorruptedShortcuts() throws Exception {
|
||||
initService();
|
||||
|
||||
addPackage("com.android.chrome", 0, 0);
|
||||
|
||||
ShortcutUser user = new ShortcutUser(mService, 0);
|
||||
|
||||
File corruptedShortcutPackage = new File("/data/local/tmp/cts/content/",
|
||||
"broken_shortcut.xml");
|
||||
assertNull(ShortcutPackage.loadFromFile(mService, user, corruptedShortcutPackage, false));
|
||||
}
|
||||
|
||||
public void testSaveCorruptAndLoadUser() throws Exception {
|
||||
// First, create some shortcuts and save.
|
||||
runWithCaller(CALLING_PACKAGE_1, UserHandle.USER_SYSTEM, () -> {
|
||||
|
||||
Reference in New Issue
Block a user