Skip to content

Commit 9cb660f

Browse files
jsharkeyAndroid (Google) Code Review
authored andcommitted
Merge "Guard against apps breaking CHOOSER contract." into jb-dev
2 parents e312c61 + 1c29700 commit 9cb660f

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

core/java/android/content/Intent.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6653,17 +6653,20 @@ public boolean migrateExtraStreamToClipData() {
66536653

66546654
final String action = getAction();
66556655
if (ACTION_CHOOSER.equals(action)) {
6656-
// Inspect target intent to see if we need to migrate
6657-
final Intent target = getParcelableExtra(EXTRA_INTENT);
6658-
if (target.migrateExtraStreamToClipData()) {
6659-
// Since we migrated in child, we need to promote ClipData and
6660-
// flags to ourselves to grant.
6661-
setClipData(target.getClipData());
6662-
addFlags(target.getFlags()
6663-
& (FLAG_GRANT_READ_URI_PERMISSION | FLAG_GRANT_WRITE_URI_PERMISSION));
6664-
return true;
6665-
} else {
6666-
return false;
6656+
try {
6657+
// Inspect target intent to see if we need to migrate
6658+
final Intent target = getParcelableExtra(EXTRA_INTENT);
6659+
if (target != null && target.migrateExtraStreamToClipData()) {
6660+
// Since we migrated in child, we need to promote ClipData
6661+
// and flags to ourselves to grant.
6662+
setClipData(target.getClipData());
6663+
addFlags(target.getFlags()
6664+
& (FLAG_GRANT_READ_URI_PERMISSION | FLAG_GRANT_WRITE_URI_PERMISSION));
6665+
return true;
6666+
} else {
6667+
return false;
6668+
}
6669+
} catch (ClassCastException e) {
66676670
}
66686671

66696672
} else if (ACTION_SEND.equals(action)) {

0 commit comments

Comments
 (0)