2121import static android .app .admin .DevicePolicyResources .Strings .Core .RESOLVER_CANT_SHARE_WITH_PERSONAL ;
2222import static android .app .admin .DevicePolicyResources .Strings .Core .RESOLVER_CANT_SHARE_WITH_WORK ;
2323import static android .app .admin .DevicePolicyResources .Strings .Core .RESOLVER_CROSS_PROFILE_BLOCKED_TITLE ;
24- import static android .content .ContentProvider .getUserIdFromUri ;
2524import static android .stats .devicepolicy .DevicePolicyEnums .RESOLVER_EMPTY_STATE_NO_SHARING_TO_PERSONAL ;
2625import static android .stats .devicepolicy .DevicePolicyEnums .RESOLVER_EMPTY_STATE_NO_SHARING_TO_WORK ;
2726
162161import java .util .Map ;
163162import java .util .Objects ;
164163import java .util .function .Supplier ;
165- import java .util .stream .Collectors ;
166164
167165/**
168166 * The Chooser Activity handles intent resolution specifically for sharing intents -
@@ -1426,11 +1424,7 @@ private ViewGroup displayImageContentPreview(Intent targetIntent, LayoutInflater
14261424
14271425 String action = targetIntent .getAction ();
14281426 if (Intent .ACTION_SEND .equals (action )) {
1429- Uri uri = targetIntent .getParcelableExtra (Intent .EXTRA_STREAM , android .net .Uri .class );
1430- if (!validForContentPreview (uri )) {
1431- contentPreviewLayout .setVisibility (View .GONE );
1432- return contentPreviewLayout ;
1433- }
1427+ Uri uri = targetIntent .getParcelableExtra (Intent .EXTRA_STREAM );
14341428 imagePreview .findViewById (R .id .content_preview_image_1_large )
14351429 .setTransitionName (ChooserActivity .FIRST_IMAGE_PREVIEW_TRANSITION_NAME );
14361430 mPreviewCoord .loadUriIntoView (R .id .content_preview_image_1_large , uri , 0 );
@@ -1440,7 +1434,7 @@ private ViewGroup displayImageContentPreview(Intent targetIntent, LayoutInflater
14401434 List <Uri > uris = targetIntent .getParcelableArrayListExtra (Intent .EXTRA_STREAM );
14411435 List <Uri > imageUris = new ArrayList <>();
14421436 for (Uri uri : uris ) {
1443- if (validForContentPreview ( uri ) && isImageType (resolver .getType (uri ))) {
1437+ if (isImageType (resolver .getType (uri ))) {
14441438 imageUris .add (uri );
14451439 }
14461440 }
@@ -1550,16 +1544,9 @@ private ViewGroup displayFileContentPreview(Intent targetIntent, LayoutInflater
15501544 String action = targetIntent .getAction ();
15511545 if (Intent .ACTION_SEND .equals (action )) {
15521546 Uri uri = targetIntent .getParcelableExtra (Intent .EXTRA_STREAM );
1553- if (!validForContentPreview (uri )) {
1554- contentPreviewLayout .setVisibility (View .GONE );
1555- return contentPreviewLayout ;
1556- }
15571547 loadFileUriIntoView (uri , contentPreviewLayout );
15581548 } else {
15591549 List <Uri > uris = targetIntent .getParcelableArrayListExtra (Intent .EXTRA_STREAM );
1560- uris = uris .stream ()
1561- .filter (ChooserActivity ::validForContentPreview )
1562- .collect (Collectors .toList ());
15631550 int uriCount = uris .size ();
15641551
15651552 if (uriCount == 0 ) {
@@ -1618,24 +1605,6 @@ private void loadFileUriIntoView(final Uri uri, final View parent) {
16181605 }
16191606 }
16201607
1621- /**
1622- * Indicate if the incoming content URI should be allowed.
1623- *
1624- * @param uri the uri to test
1625- * @return true if the URI is allowed for content preview
1626- */
1627- private static boolean validForContentPreview (Uri uri ) throws SecurityException {
1628- if (uri == null ) {
1629- return false ;
1630- }
1631- int userId = getUserIdFromUri (uri , UserHandle .USER_CURRENT );
1632- if (userId != UserHandle .USER_CURRENT && userId != UserHandle .myUserId ()) {
1633- Log .e (TAG , "dropped invalid content URI belonging to user " + userId );
1634- return false ;
1635- }
1636- return true ;
1637- }
1638-
16391608 @ VisibleForTesting
16401609 protected boolean isImageType (String mimeType ) {
16411610 return mimeType != null && mimeType .startsWith ("image/" );
0 commit comments