Merge "Pass Intent as additional parameter in ContentSuggestionsServiceClient#notifyAction. This allows QuickShareProcessor to report share event in notifyInteraction. SystemUI side change." into sc-dev
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user