Merge "Stop processing on IOException." into udc-dev am: d470717be9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21675441

Change-Id: I19bb2415c8e6a3974e84b26cfb2775c7c8bec01f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Alex Buynytskyy
2023-03-03 02:11:19 +00:00
committed by Automerger Merge Worker
5 changed files with 18 additions and 0 deletions

View File

@@ -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);

View File

@@ -115,6 +115,7 @@ android_test {
":StubTestApp",
":SuspendTestApp",
":MediaButtonReceiverHolderTestHelperApp",
"data/broken_shortcut.xml",
],
java_resources: [

View File

@@ -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">

Binary file not shown.

View File

@@ -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, () -> {