Remove obsolete classes ActionProxyReceiver and DeleteScreenshotReceiver

Unused since intents are now created and passed through
ActionIntentCreator/ActionIntentExecutor.

Screenshot deletion code has been obsolete for some time.

Bug: 287452614
Flag: NONE
Test: manual, atest
Change-Id: Ie802e1feb80c46f4128f778fb46cd8fd66d12b0f
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 98591e9..432efb1 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -528,15 +528,6 @@
             </intent-filter>
         </activity-alias>
 
-        <!-- Springboard for launching the share and edit activity. This needs to be in the main
-             system ui process since we need to notify the status bar to dismiss the keyguard -->
-        <receiver android:name=".screenshot.ActionProxyReceiver"
-            android:exported="false" />
-
-        <!-- Callback for deleting screenshot notification -->
-        <receiver android:name=".screenshot.DeleteScreenshotReceiver"
-            android:exported="false" />
-
         <!-- Callback for invoking a smart action from the screenshot notification. -->
         <receiver android:name=".screenshot.SmartActionsReceiver"
                   android:exported="false"/>
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/DefaultBroadcastReceiverBinder.java b/packages/SystemUI/src/com/android/systemui/dagger/DefaultBroadcastReceiverBinder.java
index 3d8e4cb..6aa5e8b 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/DefaultBroadcastReceiverBinder.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/DefaultBroadcastReceiverBinder.java
@@ -22,8 +22,6 @@
 import com.android.systemui.media.dialog.MediaOutputDialogReceiver;
 import com.android.systemui.people.widget.PeopleSpaceWidgetPinnedReceiver;
 import com.android.systemui.people.widget.PeopleSpaceWidgetProvider;
-import com.android.systemui.screenshot.ActionProxyReceiver;
-import com.android.systemui.screenshot.DeleteScreenshotReceiver;
 import com.android.systemui.screenshot.SmartActionsReceiver;
 import com.android.systemui.volume.VolumePanelDialogReceiver;
 
@@ -42,24 +40,6 @@
      */
     @Binds
     @IntoMap
-    @ClassKey(ActionProxyReceiver.class)
-    public abstract BroadcastReceiver bindActionProxyReceiver(
-            ActionProxyReceiver broadcastReceiver);
-
-    /**
-     *
-     */
-    @Binds
-    @IntoMap
-    @ClassKey(DeleteScreenshotReceiver.class)
-    public abstract BroadcastReceiver bindDeleteScreenshotReceiver(
-            DeleteScreenshotReceiver broadcastReceiver);
-
-    /**
-     *
-     */
-    @Binds
-    @IntoMap
     @ClassKey(SmartActionsReceiver.class)
     public abstract BroadcastReceiver bindSmartActionsReceiver(
             SmartActionsReceiver broadcastReceiver);
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ActionProxyReceiver.java b/packages/SystemUI/src/com/android/systemui/screenshot/ActionProxyReceiver.java
deleted file mode 100644
index 7e234ae..0000000
--- a/packages/SystemUI/src/com/android/systemui/screenshot/ActionProxyReceiver.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.screenshot;
-
-import static com.android.systemui.screenshot.ScreenshotController.ACTION_TYPE_EDIT;
-import static com.android.systemui.screenshot.ScreenshotController.ACTION_TYPE_SHARE;
-import static com.android.systemui.screenshot.ScreenshotController.EXTRA_ACTION_INTENT;
-import static com.android.systemui.screenshot.ScreenshotController.EXTRA_DISALLOW_ENTER_PIP;
-import static com.android.systemui.screenshot.ScreenshotController.EXTRA_ID;
-import static com.android.systemui.screenshot.ScreenshotController.EXTRA_SMART_ACTIONS_ENABLED;
-import static com.android.systemui.statusbar.phone.CentralSurfaces.SYSTEM_DIALOG_REASON_SCREENSHOT;
-
-import android.app.ActivityOptions;
-import android.app.PendingIntent;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.util.Log;
-import android.view.RemoteAnimationAdapter;
-import android.view.WindowManagerGlobal;
-
-import com.android.systemui.plugins.ActivityStarter;
-import com.android.systemui.settings.DisplayTracker;
-import com.android.systemui.shared.system.ActivityManagerWrapper;
-
-import javax.inject.Inject;
-
-/**
- * Receiver to proxy the share or edit intent, used to clean up the notification and send
- * appropriate signals to the system (ie. to dismiss the keyguard if necessary).
- */
-public class ActionProxyReceiver extends BroadcastReceiver {
-    private static final String TAG = "ActionProxyReceiver";
-
-    private final ActivityManagerWrapper mActivityManagerWrapper;
-    private final ScreenshotSmartActions mScreenshotSmartActions;
-    private final DisplayTracker mDisplayTracker;
-    private final ActivityStarter mActivityStarter;
-
-    @Inject
-    public ActionProxyReceiver(ActivityManagerWrapper activityManagerWrapper,
-            ScreenshotSmartActions screenshotSmartActions,
-            DisplayTracker displayTracker,
-            ActivityStarter activityStarter) {
-        mActivityManagerWrapper = activityManagerWrapper;
-        mScreenshotSmartActions = screenshotSmartActions;
-        mDisplayTracker = displayTracker;
-        mActivityStarter = activityStarter;
-    }
-
-    @Override
-    public void onReceive(Context context, final Intent intent) {
-        Runnable startActivityRunnable = () -> {
-            mActivityManagerWrapper.closeSystemWindows(SYSTEM_DIALOG_REASON_SCREENSHOT);
-
-            PendingIntent actionIntent = intent.getParcelableExtra(EXTRA_ACTION_INTENT);
-            ActivityOptions opts = ActivityOptions.makeBasic();
-            opts.setDisallowEnterPictureInPictureWhileLaunching(
-                    intent.getBooleanExtra(EXTRA_DISALLOW_ENTER_PIP, false));
-            opts.setPendingIntentBackgroundActivityStartMode(
-                    ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
-            try {
-                actionIntent.send(context, 0, null, null, null, null, opts.toBundle());
-                if (intent.getBooleanExtra(ScreenshotController.EXTRA_OVERRIDE_TRANSITION, false)) {
-                    RemoteAnimationAdapter runner = new RemoteAnimationAdapter(
-                            ScreenshotController.SCREENSHOT_REMOTE_RUNNER, 0, 0);
-                    try {
-                        WindowManagerGlobal.getWindowManagerService()
-                                .overridePendingAppTransitionRemote(runner,
-                                        mDisplayTracker.getDefaultDisplayId());
-                    } catch (Exception e) {
-                        Log.e(TAG, "Error overriding screenshot app transition", e);
-                    }
-                }
-            } catch (PendingIntent.CanceledException e) {
-                Log.e(TAG, "Pending intent canceled", e);
-            }
-
-        };
-
-        mActivityStarter.executeRunnableDismissingKeyguard(startActivityRunnable, null,
-                true /* dismissShade */, true /* afterKeyguardGone */,
-                true /* deferred */);
-
-        if (intent.getBooleanExtra(EXTRA_SMART_ACTIONS_ENABLED, false)) {
-            String actionType = Intent.ACTION_EDIT.equals(intent.getAction())
-                    ? ACTION_TYPE_EDIT
-                    : ACTION_TYPE_SHARE;
-            mScreenshotSmartActions.notifyScreenshotAction(
-                    intent.getStringExtra(EXTRA_ID), actionType, false, null);
-        }
-    }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/DeleteScreenshotReceiver.java b/packages/SystemUI/src/com/android/systemui/screenshot/DeleteScreenshotReceiver.java
deleted file mode 100644
index e0346f2..0000000
--- a/packages/SystemUI/src/com/android/systemui/screenshot/DeleteScreenshotReceiver.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.screenshot;
-
-import static com.android.systemui.screenshot.ScreenshotController.ACTION_TYPE_DELETE;
-import static com.android.systemui.screenshot.ScreenshotController.EXTRA_ID;
-import static com.android.systemui.screenshot.ScreenshotController.EXTRA_SMART_ACTIONS_ENABLED;
-import static com.android.systemui.screenshot.ScreenshotController.SCREENSHOT_URI_ID;
-
-import android.content.BroadcastReceiver;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-
-import com.android.systemui.dagger.qualifiers.Background;
-
-import java.util.concurrent.Executor;
-
-import javax.inject.Inject;
-
-/**
- * Removes the file at a provided URI.
- */
-public class DeleteScreenshotReceiver extends BroadcastReceiver {
-
-    private final ScreenshotSmartActions mScreenshotSmartActions;
-    private final Executor mBackgroundExecutor;
-
-    @Inject
-    public DeleteScreenshotReceiver(ScreenshotSmartActions screenshotSmartActions,
-            @Background Executor backgroundExecutor) {
-        mScreenshotSmartActions = screenshotSmartActions;
-        mBackgroundExecutor = backgroundExecutor;
-    }
-
-    @Override
-    public void onReceive(Context context, Intent intent) {
-        if (!intent.hasExtra(SCREENSHOT_URI_ID)) {
-            return;
-        }
-
-        // And delete the image from the media store
-        final Uri uri = Uri.parse(intent.getStringExtra(SCREENSHOT_URI_ID));
-        mBackgroundExecutor.execute(() -> {
-            ContentResolver resolver = context.getContentResolver();
-            resolver.delete(uri, null, null);
-        });
-        if (intent.getBooleanExtra(EXTRA_SMART_ACTIONS_ENABLED, false)) {
-            mScreenshotSmartActions.notifyScreenshotAction(
-                    intent.getStringExtra(EXTRA_ID), ACTION_TYPE_DELETE, false, null);
-        }
-    }
-}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ActionProxyReceiverTest.java b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ActionProxyReceiverTest.java
deleted file mode 100644
index 9ea30d67..0000000
--- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ActionProxyReceiverTest.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.screenshot;
-
-import static com.android.systemui.screenshot.ScreenshotController.ACTION_TYPE_SHARE;
-import static com.android.systemui.screenshot.ScreenshotController.EXTRA_ID;
-import static com.android.systemui.screenshot.ScreenshotController.EXTRA_SMART_ACTIONS_ENABLED;
-import static com.android.systemui.statusbar.phone.CentralSurfaces.SYSTEM_DIALOG_REASON_SCREENSHOT;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.ArgumentMatchers.isNull;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-
-import android.app.PendingIntent;
-import android.content.Intent;
-import android.os.Bundle;
-import android.testing.AndroidTestingRunner;
-
-import androidx.test.filters.SmallTest;
-
-import com.android.systemui.SysuiTestCase;
-import com.android.systemui.plugins.ActivityStarter;
-import com.android.systemui.settings.FakeDisplayTracker;
-import com.android.systemui.shared.system.ActivityManagerWrapper;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.stubbing.Answer;
-
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
-
-@RunWith(AndroidTestingRunner.class)
-@SmallTest
-public class ActionProxyReceiverTest extends SysuiTestCase {
-    @Mock
-    private ActivityManagerWrapper mMockActivityManagerWrapper;
-    @Mock
-    private ScreenshotSmartActions mMockScreenshotSmartActions;
-    @Mock
-    private PendingIntent mMockPendingIntent;
-    @Mock
-    private ActivityStarter mActivityStarter;
-
-    private Intent mIntent;
-    private FakeDisplayTracker mDisplayTracker = new FakeDisplayTracker(mContext);
-
-    @Before
-    public void setup() throws InterruptedException, ExecutionException, TimeoutException {
-        MockitoAnnotations.initMocks(this);
-        mIntent = new Intent(mContext, ActionProxyReceiver.class)
-                .putExtra(ScreenshotController.EXTRA_ACTION_INTENT, mMockPendingIntent);
-    }
-
-    @Test
-    public void testPendingIntentSentWithStatusBar() throws PendingIntent.CanceledException {
-        ActionProxyReceiver actionProxyReceiver = constructActionProxyReceiver();
-        // ensure that the pending intent call is passed through
-        doAnswer((Answer<Object>) invocation -> {
-            ((Runnable) invocation.getArgument(0)).run();
-            return null;
-        }).when(mActivityStarter).executeRunnableDismissingKeyguard(
-                any(Runnable.class), isNull(), anyBoolean(), anyBoolean(), anyBoolean());
-
-        actionProxyReceiver.onReceive(mContext, mIntent);
-
-        verify(mMockActivityManagerWrapper).closeSystemWindows(SYSTEM_DIALOG_REASON_SCREENSHOT);
-        verify(mActivityStarter).executeRunnableDismissingKeyguard(
-                any(Runnable.class), isNull(), eq(true), eq(true), eq(true));
-        verify(mMockPendingIntent).send(
-                eq(mContext), anyInt(), isNull(), isNull(), isNull(), isNull(), any(Bundle.class));
-    }
-
-    @Test
-    public void testSmartActionsNotNotifiedByDefault() {
-        ActionProxyReceiver actionProxyReceiver = constructActionProxyReceiver();
-
-        actionProxyReceiver.onReceive(mContext, mIntent);
-
-        verify(mMockScreenshotSmartActions, never())
-                .notifyScreenshotAction(anyString(), anyString(), anyBoolean(),
-                        any(Intent.class));
-    }
-
-    @Test
-    public void testSmartActionsNotifiedIfEnabled() {
-        ActionProxyReceiver actionProxyReceiver = constructActionProxyReceiver();
-        mIntent.putExtra(EXTRA_SMART_ACTIONS_ENABLED, true);
-        String testId = "testID";
-        mIntent.putExtra(EXTRA_ID, testId);
-
-        actionProxyReceiver.onReceive(mContext, mIntent);
-
-        verify(mMockScreenshotSmartActions).notifyScreenshotAction(
-                testId, ACTION_TYPE_SHARE, false, null);
-    }
-
-    private ActionProxyReceiver constructActionProxyReceiver() {
-        return new ActionProxyReceiver(
-                mMockActivityManagerWrapper,
-                mMockScreenshotSmartActions,
-                mDisplayTracker,
-                mActivityStarter
-        );
-    }
-}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/DeleteScreenshotReceiverTest.java b/packages/SystemUI/tests/src/com/android/systemui/screenshot/DeleteScreenshotReceiverTest.java
deleted file mode 100644
index d58f47a..0000000
--- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/DeleteScreenshotReceiverTest.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.screenshot;
-
-import static com.android.systemui.screenshot.ScreenshotController.ACTION_TYPE_DELETE;
-import static com.android.systemui.screenshot.ScreenshotController.EXTRA_ID;
-import static com.android.systemui.screenshot.ScreenshotController.EXTRA_SMART_ACTIONS_ENABLED;
-import static com.android.systemui.screenshot.ScreenshotController.SCREENSHOT_URI_ID;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.Intent;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.testing.AndroidTestingRunner;
-
-import androidx.test.filters.SmallTest;
-
-import com.android.systemui.SysuiTestCase;
-import com.android.systemui.util.concurrency.FakeExecutor;
-import com.android.systemui.util.time.FakeSystemClock;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-import java.io.File;
-import java.util.concurrent.Executor;
-
-@RunWith(AndroidTestingRunner.class)
-@SmallTest
-public class DeleteScreenshotReceiverTest extends SysuiTestCase {
-
-    @Mock
-    private ScreenshotSmartActions mMockScreenshotSmartActions;
-    @Mock
-    private Executor mMockExecutor;
-
-    private DeleteScreenshotReceiver mDeleteScreenshotReceiver;
-    private FakeExecutor mFakeExecutor = new FakeExecutor(new FakeSystemClock());
-
-    @Before
-    public void setup() {
-        MockitoAnnotations.initMocks(this);
-        mDeleteScreenshotReceiver =
-                new DeleteScreenshotReceiver(mMockScreenshotSmartActions, mMockExecutor);
-    }
-
-    @Test
-    public void testNoUriProvided() {
-        Intent intent = new Intent(mContext, DeleteScreenshotReceiver.class);
-
-        mDeleteScreenshotReceiver.onReceive(mContext, intent);
-
-        verify(mMockExecutor, never()).execute(any(Runnable.class));
-        verify(mMockScreenshotSmartActions, never()).notifyScreenshotAction(
-                any(String.class), any(String.class), anyBoolean(),
-                any(Intent.class));
-    }
-
-    @Test
-    public void testFileDeleted() {
-        DeleteScreenshotReceiver deleteScreenshotReceiver =
-                new DeleteScreenshotReceiver(mMockScreenshotSmartActions, mFakeExecutor);
-        ContentResolver contentResolver = mContext.getContentResolver();
-        final Uri testUri = contentResolver.insert(
-                MediaStore.Images.Media.EXTERNAL_CONTENT_URI, getFakeContentValues());
-        assertNotNull(testUri);
-
-        try {
-            Cursor cursor =
-                    contentResolver.query(testUri, null, null, null, null);
-            assertEquals(1, cursor.getCount());
-            Intent intent = new Intent(mContext, DeleteScreenshotReceiver.class)
-                    .putExtra(SCREENSHOT_URI_ID, testUri.toString());
-
-            deleteScreenshotReceiver.onReceive(mContext, intent);
-            int runCount = mFakeExecutor.runAllReady();
-
-            assertEquals(1, runCount);
-            cursor =
-                    contentResolver.query(testUri, null, null, null, null);
-            assertEquals(0, cursor.getCount());
-        } finally {
-            contentResolver.delete(testUri, null, null);
-        }
-
-        // ensure smart actions not called by default
-        verify(mMockScreenshotSmartActions, never()).notifyScreenshotAction(
-                any(String.class), any(String.class), anyBoolean(), any(Intent.class));
-    }
-
-    @Test
-    public void testNotifyScreenshotAction() {
-        Intent intent = new Intent(mContext, DeleteScreenshotReceiver.class);
-        String uriString = "testUri";
-        String testId = "testID";
-        intent.putExtra(SCREENSHOT_URI_ID, uriString);
-        intent.putExtra(EXTRA_ID, testId);
-        intent.putExtra(EXTRA_SMART_ACTIONS_ENABLED, true);
-
-        mDeleteScreenshotReceiver.onReceive(mContext, intent);
-
-        verify(mMockExecutor).execute(any(Runnable.class));
-        verify(mMockScreenshotSmartActions).notifyScreenshotAction(testId,
-                ACTION_TYPE_DELETE, false, null);
-    }
-
-    private static ContentValues getFakeContentValues() {
-        final ContentValues values = new ContentValues();
-        values.put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_PICTURES
-                + File.separator + Environment.DIRECTORY_SCREENSHOTS);
-        values.put(MediaStore.MediaColumns.DISPLAY_NAME, "test_screenshot");
-        values.put(MediaStore.MediaColumns.MIME_TYPE, "image/png");
-        values.put(MediaStore.MediaColumns.DATE_ADDED, 0);
-        values.put(MediaStore.MediaColumns.DATE_MODIFIED, 0);
-        return values;
-    }
-}