AOSP/Gallery - Deleted "Set As" menu item and ability to ATTACH_DATA.

Fixes Gallery2 ATTACH_DATA Intent Action Could be Intercepted to Grant
Access of Its Own Non-picture Private Files to OutSide.

Bug: 201535148
Test: manual
+ Will attach the test results to the above bug.

Change-Id: Ie47945cc3519099cb685a26eee81130c2766be80
(cherry picked from commit 35ab9cd99173079886c3cd636b0606f55fefd846)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c0a4ba8..b055c1a 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -239,11 +239,6 @@
                 android:configChanges="keyboardHidden|orientation|screenSize"
                 android:exported="true"
                 android:theme="@style/android:Theme.Translucent.NoTitleBar">
-            <intent-filter android:label="@string/camera_setas_wallpaper">
-                <action android:name="android.intent.action.ATTACH_DATA" />
-                <data android:mimeType="image/*" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <intent-filter android:label="@string/app_name">
                 <action android:name="android.intent.action.SET_WALLPAPER" />
                 <category android:name="android.intent.category.DEFAULT" />
diff --git a/res/menu/gallery_multiselect.xml b/res/menu/gallery_multiselect.xml
index 685ae6b..3a205b4 100644
--- a/res/menu/gallery_multiselect.xml
+++ b/res/menu/gallery_multiselect.xml
@@ -25,8 +25,4 @@
             android:title="@string/mute_action"
             android:visible="false"
             android:showAsAction="never" />
-    <item android:id="@+id/menu_set_as"
-            android:title="@string/set_as"
-            android:visible="false"
-            android:showAsAction="never" />
 </menu>
diff --git a/res/menu/operation.xml b/res/menu/operation.xml
index 0647cad..dccb2ef 100644
--- a/res/menu/operation.xml
+++ b/res/menu/operation.xml
@@ -55,10 +55,6 @@
             android:title="@string/crop_action"
             android:showAsAction="never"
             android:visible="false" />
-    <item android:id="@+id/action_setas"
-            android:title="@string/set_image"
-            android:showAsAction="never"
-            android:visible="false" />
     <item android:id="@+id/action_details"
             android:icon="@drawable/ic_menu_info_details"
             android:title="@string/details"
diff --git a/res/menu/photo.xml b/res/menu/photo.xml
index b388d08..cd5db62 100644
--- a/res/menu/photo.xml
+++ b/res/menu/photo.xml
@@ -64,9 +64,6 @@
     <item android:id="@+id/action_mute"
             android:title="@string/mute_action"
             android:showAsAction="never" />
-    <item android:id="@+id/action_setas"
-            android:title="@string/set_image"
-            android:showAsAction="never" />
     <item android:id="@+id/action_details"
             android:title="@string/details"
             android:showAsAction="never" />
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index 2f4eb21..b702de3 100755
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -1282,7 +1282,6 @@
             case R.id.action_delete:
                 confirmMsg = mActivity.getResources().getQuantityString(
                         R.plurals.delete_selection, 1);
-            case R.id.action_setas:
             //case R.id.action_rotate_ccw:
             //case R.id.action_rotate_cw:
             case R.id.action_show_on_map:
diff --git a/src/com/android/gallery3d/app/Wallpaper.java b/src/com/android/gallery3d/app/Wallpaper.java
index 5c19d90..4d63ff3 100644
--- a/src/com/android/gallery3d/app/Wallpaper.java
+++ b/src/com/android/gallery3d/app/Wallpaper.java
@@ -155,7 +155,7 @@
                     .putExtra(CropExtras.KEY_SPOTLIGHT_Y, spotlightY)
                     .putExtra(CropExtras.KEY_SCALE, true)
                     .putExtra(CropExtras.KEY_SCALE_UP_IF_NEEDED, true)
-                    .putExtra(CropExtras.KEY_SET_AS_WALLPAPER, !fromScreenColor);
+                    .putExtra(CropExtras.KEY_SET_AS_WALLPAPER, false);
                 startActivity(cropAndSetWallpaperIntent);
                 finish();
             }
diff --git a/src/com/android/gallery3d/filtershow/crop/CropExtras.java b/src/com/android/gallery3d/filtershow/crop/CropExtras.java
index 60fe9af..d6c47b1 100644
--- a/src/com/android/gallery3d/filtershow/crop/CropExtras.java
+++ b/src/com/android/gallery3d/filtershow/crop/CropExtras.java
@@ -92,7 +92,7 @@
     }
 
     public boolean getSetAsWallpaper() {
-        return mSetAsWallpaper;
+        return false;
     }
 
     public boolean getReturnData() {
diff --git a/src/com/android/gallery3d/ui/MenuExecutor.java b/src/com/android/gallery3d/ui/MenuExecutor.java
index 2d8697e..d604eb5 100644
--- a/src/com/android/gallery3d/ui/MenuExecutor.java
+++ b/src/com/android/gallery3d/ui/MenuExecutor.java
@@ -178,7 +178,6 @@
         boolean supportTrim = (supported & MediaObject.SUPPORT_TRIM) != 0;
         boolean supportMute = (supported & MediaObject.SUPPORT_MUTE) != 0;
         boolean supportShare = (supported & MediaObject.SUPPORT_SHARE) != 0;
-        boolean supportSetAs = (supported & MediaObject.SUPPORT_SETAS) != 0;
         boolean supportShowOnMap = (supported & MediaObject.SUPPORT_SHOW_ON_MAP) != 0;
         boolean supportCache = (supported & MediaObject.SUPPORT_CACHE) != 0;
         boolean supportEdit = (supported & MediaObject.SUPPORT_EDIT) != 0;
@@ -195,7 +194,6 @@
         // Hide panorama until call to updateMenuForPanorama corrects it
         setMenuItemVisible(menu, R.id.action_share_panorama, false);
         setMenuItemVisible(menu, R.id.action_share, supportShare);
-        setMenuItemVisible(menu, R.id.action_setas, supportSetAs);
         setMenuItemVisible(menu, R.id.action_show_on_map, supportShowOnMap);
         setMenuItemVisible(menu, R.id.action_edit, supportEdit);
         // setMenuItemVisible(menu, R.id.action_simple_edit, supportEdit);
@@ -281,26 +279,6 @@
                 }
                 return;
             }
-            case R.id.action_setas: {
-                Intent intent = getIntentBySingleSelectedPath(Intent.ACTION_ATTACH_DATA);
-                if (intent != null) {
-                    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
-                    intent.putExtra("mimeType", intent.getType());
-
-                    // DRM files can be set as wallpaper only. Don't show other options
-                    // to set as.
-                    Uri uri = intent.getData();
-//                if (DrmHelper.isDrmFile(DrmHelper.getFilePath(mActivity, uri))) {
-//                    intent.setPackage("com.android.gallery3d");
-//                }
-
-                    Activity activity = mActivity;
-                    mActivity.isTopMenuShow = true;
-                    activity.startActivity(Intent.createChooser(
-                            intent, activity.getString(R.string.set_as)));
-                }
-                return;
-            }
             case R.id.action_delete:
                 title = R.string.delete;
                 break;
diff --git a/src/com/android/photos/MultiChoiceManager.java b/src/com/android/photos/MultiChoiceManager.java
index 6ec4a61..fe9ce21 100644
--- a/src/com/android/photos/MultiChoiceManager.java
+++ b/src/com/android/photos/MultiChoiceManager.java
@@ -134,7 +134,6 @@
         MenuItem cropItem = menu.findItem(R.id.menu_crop);
         MenuItem trimItem = menu.findItem(R.id.menu_trim);
         MenuItem muteItem = menu.findItem(R.id.menu_mute);
-        MenuItem setAsItem = menu.findItem(R.id.menu_set_as);
 
         editItem.setVisible((supportedOperations & MediaObject.SUPPORT_EDIT) > 0);
         deleteItem.setVisible((supportedOperations & MediaObject.SUPPORT_DELETE) > 0);
@@ -142,7 +141,6 @@
         cropItem.setVisible((supportedOperations & MediaObject.SUPPORT_CROP) > 0);
         trimItem.setVisible((supportedOperations & MediaObject.SUPPORT_TRIM) > 0);
         muteItem.setVisible((supportedOperations & MediaObject.SUPPORT_MUTE) > 0);
-        setAsItem.setVisible((supportedOperations & MediaObject.SUPPORT_SETAS) > 0);
     }
 
     @Override
@@ -220,7 +218,6 @@
             case R.id.menu_crop:
             case R.id.menu_trim:
             case R.id.menu_mute:
-            case R.id.menu_set_as:
                 singleItemAction(getSelectedItem(), actionItemId);
                 mode.finish();
                 return true;
@@ -259,14 +256,6 @@
                 muteVideo.muteInBackground();
                 */
                 return;
-            case R.id.menu_set_as:
-                intent.setDataAndType(uri, mime)
-                      .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
-                      .setAction(Intent.ACTION_ATTACH_DATA)
-                      .putExtra("mimeType", mime);
-                mContext.startActivity(Intent.createChooser(
-                        intent, mContext.getString(R.string.set_as)));
-                return;
             default:
                 return;
         }
diff --git a/src/com/android/photos/SelectionManager.java b/src/com/android/photos/SelectionManager.java
index 1ab7691..1b2b401 100644
--- a/src/com/android/photos/SelectionManager.java
+++ b/src/com/android/photos/SelectionManager.java
@@ -89,9 +89,6 @@
         if ((itemSupportedOperations & MediaObject.SUPPORT_CROP) > 0) {
             mSelectedCroppableCount += increment;
         }
-        if ((itemSupportedOperations & MediaObject.SUPPORT_SETAS) > 0) {
-            mSelectedSetableCount += increment;
-        }
         if ((itemSupportedOperations & MediaObject.SUPPORT_TRIM) > 0) {
             mSelectedTrimmableCount += increment;
         }
@@ -145,9 +142,6 @@
             if (mSelectedEditableCount == 1) {
                 supported |= MediaObject.SUPPORT_EDIT;
             }
-            if (mSelectedSetableCount == 1) {
-                supported |= MediaObject.SUPPORT_SETAS;
-            }
             if (mSelectedTrimmableCount == 1) {
                 supported |= MediaObject.SUPPORT_TRIM;
             }