diff options
8 files changed, 23 insertions, 14 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ActionProxyReceiver.java b/packages/SystemUI/src/com/android/systemui/screenshot/ActionProxyReceiver.java index df9fc63a33f0..17e94c4b3f69 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ActionProxyReceiver.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ActionProxyReceiver.java @@ -88,7 +88,7 @@ public class ActionProxyReceiver extends BroadcastReceiver { ? ACTION_TYPE_EDIT : ACTION_TYPE_SHARE; mScreenshotSmartActions.notifyScreenshotAction( - context, intent.getStringExtra(EXTRA_ID), actionType, false); + context, 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 index 35839f39b491..8d44205bef30 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/DeleteScreenshotReceiver.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/DeleteScreenshotReceiver.java @@ -62,7 +62,7 @@ public class DeleteScreenshotReceiver extends BroadcastReceiver { }); if (intent.getBooleanExtra(EXTRA_SMART_ACTIONS_ENABLED, false)) { mScreenshotSmartActions.notifyScreenshotAction( - context, intent.getStringExtra(EXTRA_ID), ACTION_TYPE_DELETE, false); + context, intent.getStringExtra(EXTRA_ID), ACTION_TYPE_DELETE, false, null); } } } diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotNotificationSmartActionsProvider.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotNotificationSmartActionsProvider.java index 6ebab8a60887..3eafbfbf37d7 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotNotificationSmartActionsProvider.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotNotificationSmartActionsProvider.java @@ -21,6 +21,7 @@ import static com.android.systemui.screenshot.LogConfig.logTag; import android.app.Notification; import android.content.ComponentName; +import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; import android.os.UserHandle; @@ -107,7 +108,8 @@ public class ScreenshotNotificationSmartActionsProvider { * @param action type of notification action invoked. * @param isSmartAction whether action invoked was a smart action. */ - public void notifyAction(String screenshotId, String action, boolean isSmartAction) { + public void notifyAction(String screenshotId, String action, boolean isSmartAction, + Intent intent) { if (DEBUG_ACTIONS) { Log.d(TAG, "SmartActions: notifyAction: return without notify"); } diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotSmartActions.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotSmartActions.java index 99238cd2c267..0527818135dd 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotSmartActions.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotSmartActions.java @@ -26,6 +26,7 @@ import android.app.ActivityManager; import android.app.Notification; import android.content.ComponentName; import android.content.Context; +import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; import android.os.Handler; @@ -165,7 +166,7 @@ public class ScreenshotSmartActions { } void notifyScreenshotAction(Context context, String screenshotId, String action, - boolean isSmartAction) { + boolean isSmartAction, Intent intent) { try { ScreenshotNotificationSmartActionsProvider provider = SystemUIFactory.getInstance().createScreenshotNotificationSmartActionsProvider( @@ -174,7 +175,7 @@ public class ScreenshotSmartActions { Log.d(TAG, String.format("%s notifyAction: %s id=%s, isSmartAction=%b", provider.getClass(), action, screenshotId, isSmartAction)); } - provider.notifyAction(screenshotId, action, isSmartAction); + provider.notifyAction(screenshotId, action, isSmartAction, intent); } catch (Throwable e) { Log.e(TAG, "Error in notifyScreenshotAction: ", e); } diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/SmartActionsReceiver.java b/packages/SystemUI/src/com/android/systemui/screenshot/SmartActionsReceiver.java index 3ad922b57c7c..f703058f4a0f 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/SmartActionsReceiver.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/SmartActionsReceiver.java @@ -60,6 +60,7 @@ public class SmartActionsReceiver extends BroadcastReceiver { } mScreenshotSmartActions.notifyScreenshotAction( - context, intent.getStringExtra(EXTRA_ID), actionType, true); + context, intent.getStringExtra(EXTRA_ID), actionType, true, + pendingIntent.getIntent()); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ActionProxyReceiverTest.java b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ActionProxyReceiverTest.java index 9a1126f2aa3d..bfe875ccd60d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ActionProxyReceiverTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ActionProxyReceiverTest.java @@ -115,7 +115,8 @@ public class ActionProxyReceiverTest extends SysuiTestCase { actionProxyReceiver.onReceive(mContext, mIntent); verify(mMockScreenshotSmartActions, never()) - .notifyScreenshotAction(any(Context.class), anyString(), anyString(), anyBoolean()); + .notifyScreenshotAction(any(Context.class), anyString(), anyString(), anyBoolean(), + any(Intent.class)); } @Test @@ -128,7 +129,7 @@ public class ActionProxyReceiverTest extends SysuiTestCase { actionProxyReceiver.onReceive(mContext, mIntent); verify(mMockScreenshotSmartActions).notifyScreenshotAction( - mContext, testId, ACTION_TYPE_SHARE, false); + mContext, testId, ACTION_TYPE_SHARE, false, null); } private ActionProxyReceiver constructActionProxyReceiver(boolean withStatusBar) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/DeleteScreenshotReceiverTest.java b/packages/SystemUI/tests/src/com/android/systemui/screenshot/DeleteScreenshotReceiverTest.java index 14c76798e0ef..664c125533d1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/DeleteScreenshotReceiverTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/screenshot/DeleteScreenshotReceiverTest.java @@ -81,7 +81,8 @@ public class DeleteScreenshotReceiverTest extends SysuiTestCase { verify(mMockExecutor, never()).execute(any(Runnable.class)); verify(mMockScreenshotSmartActions, never()).notifyScreenshotAction( - any(Context.class), any(String.class), any(String.class), anyBoolean()); + any(Context.class), any(String.class), any(String.class), anyBoolean(), + any(Intent.class)); } @Test @@ -112,8 +113,8 @@ public class DeleteScreenshotReceiverTest extends SysuiTestCase { } // ensure smart actions not called by default - verify(mMockScreenshotSmartActions, never()).notifyScreenshotAction( - any(Context.class), any(String.class), any(String.class), anyBoolean()); + verify(mMockScreenshotSmartActions, never()).notifyScreenshotAction(any(Context.class), + any(String.class), any(String.class), anyBoolean(), any(Intent.class)); } @Test @@ -128,8 +129,8 @@ public class DeleteScreenshotReceiverTest extends SysuiTestCase { mDeleteScreenshotReceiver.onReceive(mContext, intent); verify(mMockExecutor).execute(any(Runnable.class)); - verify(mMockScreenshotSmartActions).notifyScreenshotAction( - mContext, testId, ACTION_TYPE_DELETE, false); + verify(mMockScreenshotSmartActions).notifyScreenshotAction(mContext, testId, + ACTION_TYPE_DELETE, false, null); } private static ContentValues getFakeContentValues() { diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/SmartActionsReceiverTest.java b/packages/SystemUI/tests/src/com/android/systemui/screenshot/SmartActionsReceiverTest.java index 6f3a4a17a4a5..011e6b7b1071 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/SmartActionsReceiverTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/screenshot/SmartActionsReceiverTest.java @@ -23,6 +23,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import android.app.PendingIntent; import android.content.Intent; @@ -65,12 +66,14 @@ public class SmartActionsReceiverTest extends SysuiTestCase { String testActionType = "testActionType"; mIntent.putExtra(EXTRA_ID, testId); mIntent.putExtra(EXTRA_ACTION_TYPE, testActionType); + Intent intent = new Intent(); + when(mMockPendingIntent.getIntent()).thenReturn(intent); mSmartActionsReceiver.onReceive(mContext, mIntent); verify(mMockPendingIntent).send( eq(mContext), eq(0), isNull(), isNull(), isNull(), isNull(), any(Bundle.class)); verify(mMockScreenshotSmartActions).notifyScreenshotAction( - mContext, testId, testActionType, true); + mContext, testId, testActionType, true, intent); } } |