diff options
| author | 2023-04-06 15:07:59 +0000 | |
|---|---|---|
| committer | 2023-04-06 15:07:59 +0000 | |
| commit | 1a9b6b147096cedd88ae597a345a66b27780a92d (patch) | |
| tree | cda6feaab78ced44791dfaa9c333abfdce99fea1 | |
| parent | 2fd5e8d6a4400439c4970bd294fa975402a78fb6 (diff) | |
| parent | 59bc5be04e0850727a69403aa97a756e97a7f604 (diff) | |
Merge "Remove CLIPBOARD_MINIMIZED_LAYOUT flag" into udc-dev
7 files changed, 6 insertions, 445 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardListener.java b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardListener.java index edda87527b1d..63b4288ce055 100644 --- a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardListener.java +++ b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardListener.java @@ -21,7 +21,6 @@ import static android.content.ClipDescription.CLASSIFICATION_COMPLETE; import static com.android.systemui.clipboardoverlay.ClipboardOverlayEvent.CLIPBOARD_OVERLAY_ENTERED; import static com.android.systemui.clipboardoverlay.ClipboardOverlayEvent.CLIPBOARD_OVERLAY_UPDATED; import static com.android.systemui.clipboardoverlay.ClipboardOverlayEvent.CLIPBOARD_TOAST_SHOWN; -import static com.android.systemui.flags.Flags.CLIPBOARD_MINIMIZED_LAYOUT; import static com.google.android.setupcompat.util.WizardManagerHelper.SETTINGS_SECURE_USER_SETUP_COMPLETE; @@ -36,7 +35,6 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.logging.UiEventLogger; import com.android.systemui.CoreStartable; import com.android.systemui.dagger.SysUISingleton; -import com.android.systemui.flags.FeatureFlags; import javax.inject.Inject; import javax.inject.Provider; @@ -59,7 +57,6 @@ public class ClipboardListener implements private final Provider<ClipboardOverlayController> mOverlayProvider; private final ClipboardToast mClipboardToast; private final ClipboardManager mClipboardManager; - private final FeatureFlags mFeatureFlags; private final UiEventLogger mUiEventLogger; private ClipboardOverlay mClipboardOverlay; @@ -68,13 +65,11 @@ public class ClipboardListener implements Provider<ClipboardOverlayController> clipboardOverlayControllerProvider, ClipboardToast clipboardToast, ClipboardManager clipboardManager, - FeatureFlags featureFlags, UiEventLogger uiEventLogger) { mContext = context; mOverlayProvider = clipboardOverlayControllerProvider; mClipboardToast = clipboardToast; mClipboardManager = clipboardManager; - mFeatureFlags = featureFlags; mUiEventLogger = uiEventLogger; } @@ -113,11 +108,7 @@ public class ClipboardListener implements } else { mUiEventLogger.log(CLIPBOARD_OVERLAY_UPDATED, 0, clipSource); } - if (mFeatureFlags.isEnabled(CLIPBOARD_MINIMIZED_LAYOUT)) { - mClipboardOverlay.setClipData(clipData, clipSource); - } else { - mClipboardOverlay.setClipDataLegacy(clipData, clipSource); - } + mClipboardOverlay.setClipData(clipData, clipSource); mClipboardOverlay.setOnSessionCompleteListener(() -> { // Session is complete, free memory until it's needed again. mClipboardOverlay = null; @@ -160,8 +151,6 @@ public class ClipboardListener implements } interface ClipboardOverlay { - void setClipDataLegacy(ClipData clipData, String clipSource); - void setClipData(ClipData clipData, String clipSource); void setOnSessionCompleteListener(Runnable runnable); diff --git a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayController.java b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayController.java index e6affb06cacc..5230159aaef4 100644 --- a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayController.java +++ b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayController.java @@ -32,7 +32,6 @@ import static com.android.systemui.clipboardoverlay.ClipboardOverlayEvent.CLIPBO import static com.android.systemui.clipboardoverlay.ClipboardOverlayEvent.CLIPBOARD_OVERLAY_SWIPE_DISMISSED; import static com.android.systemui.clipboardoverlay.ClipboardOverlayEvent.CLIPBOARD_OVERLAY_TAP_OUTSIDE; import static com.android.systemui.clipboardoverlay.ClipboardOverlayEvent.CLIPBOARD_OVERLAY_TIMED_OUT; -import static com.android.systemui.flags.Flags.CLIPBOARD_MINIMIZED_LAYOUT; import static com.android.systemui.flags.Flags.CLIPBOARD_REMOTE_BEHAVIOR; import android.animation.Animator; @@ -40,20 +39,14 @@ import android.animation.AnimatorListenerAdapter; import android.app.RemoteAction; import android.content.BroadcastReceiver; import android.content.ClipData; -import android.content.ClipDescription; -import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; -import android.graphics.Bitmap; import android.hardware.input.InputManager; import android.net.Uri; import android.os.Looper; import android.provider.DeviceConfig; -import android.text.TextUtils; -import android.util.Log; -import android.util.Size; import android.view.InputEvent; import android.view.InputEventReceiver; import android.view.InputMonitor; @@ -72,7 +65,6 @@ import com.android.systemui.dagger.qualifiers.Background; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.screenshot.TimeoutHandler; -import java.io.IOException; import java.util.Optional; import java.util.concurrent.Executor; @@ -170,9 +162,7 @@ public class ClipboardOverlayController implements ClipboardListener.ClipboardOv @Override public void onMinimizedViewTapped() { - if (mFeatureFlags.isEnabled(CLIPBOARD_MINIMIZED_LAYOUT)) { - animateFromMinimized(); - } + animateFromMinimized(); } }; @@ -255,11 +245,9 @@ public class ClipboardOverlayController implements ClipboardListener.ClipboardOv @VisibleForTesting void onInsetsChanged(WindowInsets insets, int orientation) { mView.setInsets(insets, orientation); - if (mFeatureFlags.isEnabled(CLIPBOARD_MINIMIZED_LAYOUT)) { - if (shouldShowMinimized(insets) && !mIsMinimized) { - mIsMinimized = true; - mView.setMinimized(true); - } + if (shouldShowMinimized(insets) && !mIsMinimized) { + mIsMinimized = true; + mView.setMinimized(true); } } @@ -401,61 +389,6 @@ public class ClipboardOverlayController implements ClipboardListener.ClipboardOv }); } - @Override // ClipboardListener.ClipboardOverlay - public void setClipDataLegacy(ClipData clipData, String clipSource) { - if (mExitAnimator != null && mExitAnimator.isRunning()) { - mExitAnimator.cancel(); - } - reset(); - mClipboardLogger.setClipSource(clipSource); - String accessibilityAnnouncement = mContext.getString(R.string.clipboard_content_copied); - - boolean isSensitive = clipData != null && clipData.getDescription().getExtras() != null - && clipData.getDescription().getExtras() - .getBoolean(ClipDescription.EXTRA_IS_SENSITIVE); - boolean isRemote = mFeatureFlags.isEnabled(CLIPBOARD_REMOTE_BEHAVIOR) - && mClipboardUtils.isRemoteCopy(mContext, clipData, clipSource); - if (clipData == null || clipData.getItemCount() == 0) { - mView.showDefaultTextPreview(); - } else if (!TextUtils.isEmpty(clipData.getItemAt(0).getText())) { - ClipData.Item item = clipData.getItemAt(0); - if (isRemote || DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI, - CLIPBOARD_OVERLAY_SHOW_ACTIONS, false)) { - if (item.getTextLinks() != null) { - classifyText(clipData.getItemAt(0), clipSource); - } - } - if (isSensitive) { - showEditableText(mContext.getString(R.string.clipboard_asterisks), true); - } else { - showEditableText(item.getText(), false); - } - mOnShareTapped = () -> shareContent(clipData); - mView.showShareChip(); - accessibilityAnnouncement = mContext.getString(R.string.clipboard_text_copied); - } else if (clipData.getItemAt(0).getUri() != null) { - if (tryShowEditableImage(clipData.getItemAt(0).getUri(), isSensitive)) { - accessibilityAnnouncement = mContext.getString(R.string.clipboard_image_copied); - } - mOnShareTapped = () -> shareContent(clipData); - mView.showShareChip(); - } else { - mView.showDefaultTextPreview(); - } - if (!isRemote) { - maybeShowRemoteCopy(clipData); - } - animateIn(); - mView.announceForAccessibility(accessibilityAnnouncement); - if (isRemote) { - mTimeoutHandler.cancelTimeout(); - mOnUiUpdate = null; - } else { - mOnUiUpdate = mTimeoutHandler::resetTimeout; - mOnUiUpdate.run(); - } - } - private void maybeShowRemoteCopy(ClipData clipData) { Intent remoteCopyIntent = IntentCreator.getRemoteCopyIntent(clipData, mContext); // Only show remote copy if it's available. @@ -478,22 +411,6 @@ public class ClipboardOverlayController implements ClipboardListener.ClipboardOv mOnSessionCompleteListener = runnable; } - private void classifyText(ClipData.Item item, String source) { - mBgExecutor.execute(() -> { - Optional<RemoteAction> action = mClipboardUtils.getAction(item, source); - mView.post(() -> { - mView.resetActionChips(); - action.ifPresent(remoteAction -> { - mView.setActionChip(remoteAction, () -> { - mClipboardLogger.logSessionComplete(CLIPBOARD_OVERLAY_ACTION_TAPPED); - animateOut(); - }); - mClipboardLogger.logUnguarded(CLIPBOARD_OVERLAY_ACTION_SHOWN); - }); - }); - }); - } - private void monitorOutsideTouches() { InputManager inputManager = mContext.getSystemService(InputManager.class); mInputMonitor = inputManager.monitorGestureInput("clipboard overlay", 0); @@ -534,43 +451,6 @@ public class ClipboardOverlayController implements ClipboardListener.ClipboardOv animateOut(); } - private void showEditableText(CharSequence text, boolean hidden) { - mView.showTextPreview(text.toString(), hidden); - mView.setEditAccessibilityAction(true); - mOnPreviewTapped = this::editText; - } - - private boolean tryShowEditableImage(Uri uri, boolean isSensitive) { - Runnable listener = () -> editImage(uri); - ContentResolver resolver = mContext.getContentResolver(); - String mimeType = resolver.getType(uri); - boolean isEditableImage = mimeType != null && mimeType.startsWith("image"); - if (isSensitive) { - mView.showImagePreview(null); - if (isEditableImage) { - mOnPreviewTapped = listener; - mView.setEditAccessibilityAction(true); - } - } else if (isEditableImage) { // if the MIMEtype is image, try to load - try { - int size = mContext.getResources().getDimensionPixelSize(R.dimen.overlay_x_scale); - // The width of the view is capped, height maintains aspect ratio, so allow it to be - // taller if needed. - Bitmap thumbnail = resolver.loadThumbnail(uri, new Size(size, size * 4), null); - mView.showImagePreview(thumbnail); - mView.setEditAccessibilityAction(true); - mOnPreviewTapped = listener; - } catch (IOException e) { - Log.e(TAG, "Thumbnail loading failed", e); - mView.showDefaultTextPreview(); - isEditableImage = false; - } - } else { - mView.showDefaultTextPreview(); - } - return isEditableImage; - } - private void animateIn() { if (mEnterAnimator != null && mEnterAnimator.isRunning()) { return; diff --git a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayUtils.java b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayUtils.java index 25caaeac2c38..758a6563323e 100644 --- a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayUtils.java +++ b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayUtils.java @@ -88,25 +88,4 @@ class ClipboardOverlayUtils { } return actions; } - - public Optional<RemoteAction> getAction(ClipData.Item item, String source) { - return getActions(item).stream().filter(remoteAction -> { - ComponentName component = remoteAction.getActionIntent().getIntent().getComponent(); - return component != null && !TextUtils.equals(source, component.getPackageName()); - }).findFirst(); - } - - private ArrayList<RemoteAction> getActions(ClipData.Item item) { - ArrayList<RemoteAction> actions = new ArrayList<>(); - for (TextLinks.TextLink link : item.getTextLinks().getLinks()) { - // skip classification for incidental entities - if (link.getEnd() - link.getStart() - >= item.getText().length() * MINIMUM_ENTITY_PROPORTION) { - TextClassification classification = mTextClassifier.classifyText( - item.getText(), link.getStart(), link.getEnd(), null); - actions.addAll(classification.getActions()); - } - } - return actions; - } } diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt index 0bc8506f272d..8953beba842f 100644 --- a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt +++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt @@ -610,8 +610,6 @@ object Flags { // 1700 - clipboard @JvmField val CLIPBOARD_REMOTE_BEHAVIOR = releasedFlag(1701, "clipboard_remote_behavior") - // TODO(b/267162944): Tracking bug - @JvmField val CLIPBOARD_MINIMIZED_LAYOUT = releasedFlag(1702, "clipboard_data_model") // 1800 - shade container @JvmField diff --git a/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardListenerTest.java b/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardListenerTest.java index fd6e31ba3bee..18515825967f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardListenerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardListenerTest.java @@ -16,8 +16,6 @@ package com.android.systemui.clipboardoverlay; -import static com.android.systemui.flags.Flags.CLIPBOARD_MINIMIZED_LAYOUT; - import static com.google.android.setupcompat.util.WizardManagerHelper.SETTINGS_SECURE_USER_SETUP_COMPLETE; import static org.junit.Assert.assertEquals; @@ -40,7 +38,6 @@ import androidx.test.runner.AndroidJUnit4; import com.android.internal.logging.UiEventLogger; import com.android.systemui.SysuiTestCase; -import com.android.systemui.flags.FakeFeatureFlags; import org.junit.Before; import org.junit.Test; @@ -65,7 +62,6 @@ public class ClipboardListenerTest extends SysuiTestCase { private ClipboardOverlayController mOverlayController; @Mock private ClipboardToast mClipboardToast; - private FakeFeatureFlags mFeatureFlags = new FakeFeatureFlags(); @Mock private UiEventLogger mUiEventLogger; @@ -99,10 +95,8 @@ public class ClipboardListenerTest extends SysuiTestCase { when(mClipboardManager.getPrimaryClip()).thenReturn(mSampleClipData); when(mClipboardManager.getPrimaryClipSource()).thenReturn(mSampleSource); - mFeatureFlags.set(CLIPBOARD_MINIMIZED_LAYOUT, true); - mClipboardListener = new ClipboardListener(getContext(), mOverlayControllerProvider, - mClipboardToast, mClipboardManager, mFeatureFlags, mUiEventLogger); + mClipboardToast, mClipboardManager, mUiEventLogger); } @@ -222,34 +216,4 @@ public class ClipboardListenerTest extends SysuiTestCase { verify(mClipboardToast, times(1)).showCopiedToast(); verifyZeroInteractions(mOverlayControllerProvider); } - - @Test - public void test_minimizedLayoutFlagOff_usesLegacy() { - mFeatureFlags.set(CLIPBOARD_MINIMIZED_LAYOUT, false); - - mClipboardListener.start(); - mClipboardListener.onPrimaryClipChanged(); - - verify(mOverlayControllerProvider).get(); - - verify(mOverlayController).setClipDataLegacy( - mClipDataCaptor.capture(), mStringCaptor.capture()); - - assertEquals(mSampleClipData, mClipDataCaptor.getValue()); - assertEquals(mSampleSource, mStringCaptor.getValue()); - } - - @Test - public void test_minimizedLayoutFlagOn_usesNew() { - mClipboardListener.start(); - mClipboardListener.onPrimaryClipChanged(); - - verify(mOverlayControllerProvider).get(); - - verify(mOverlayController).setClipData( - mClipDataCaptor.capture(), mStringCaptor.capture()); - - assertEquals(mSampleClipData, mClipDataCaptor.getValue()); - assertEquals(mSampleSource, mStringCaptor.getValue()); - } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardOverlayControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardOverlayControllerTest.java index 299869c04d34..8600b7c48d33 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardOverlayControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardOverlayControllerTest.java @@ -25,7 +25,6 @@ import static com.android.systemui.clipboardoverlay.ClipboardOverlayEvent.CLIPBO import static com.android.systemui.clipboardoverlay.ClipboardOverlayEvent.CLIPBOARD_OVERLAY_SHOWN_EXPANDED; import static com.android.systemui.clipboardoverlay.ClipboardOverlayEvent.CLIPBOARD_OVERLAY_SHOWN_MINIMIZED; import static com.android.systemui.clipboardoverlay.ClipboardOverlayEvent.CLIPBOARD_OVERLAY_SWIPE_DISMISSED; -import static com.android.systemui.flags.Flags.CLIPBOARD_MINIMIZED_LAYOUT; import static com.android.systemui.flags.Flags.CLIPBOARD_REMOTE_BEHAVIOR; import static org.mockito.ArgumentMatchers.any; @@ -123,7 +122,6 @@ public class ClipboardOverlayControllerTest extends SysuiTestCase { new ClipData.Item("Test Item")); mFeatureFlags.set(CLIPBOARD_REMOTE_BEHAVIOR, false); - mFeatureFlags.set(CLIPBOARD_MINIMIZED_LAYOUT, true); // turned off for legacy tests mOverlayController = new ClipboardOverlayController( mContext, @@ -146,178 +144,6 @@ public class ClipboardOverlayControllerTest extends SysuiTestCase { } @Test - public void test_setClipData_invalidImageData_legacy() { - mFeatureFlags.set(CLIPBOARD_MINIMIZED_LAYOUT, false); - ClipData clipData = new ClipData("", new String[]{"image/png"}, - new ClipData.Item(Uri.parse(""))); - - mOverlayController.setClipDataLegacy(clipData, ""); - - verify(mClipboardOverlayView, times(1)).showDefaultTextPreview(); - verify(mClipboardOverlayView, times(1)).showShareChip(); - verify(mClipboardOverlayView, times(1)).getEnterAnimation(); - } - - @Test - public void test_setClipData_nonImageUri_legacy() { - mFeatureFlags.set(CLIPBOARD_MINIMIZED_LAYOUT, false); - ClipData clipData = new ClipData("", new String[]{"resource/png"}, - new ClipData.Item(Uri.parse(""))); - - mOverlayController.setClipDataLegacy(clipData, ""); - - verify(mClipboardOverlayView, times(1)).showDefaultTextPreview(); - verify(mClipboardOverlayView, times(1)).showShareChip(); - verify(mClipboardOverlayView, times(1)).getEnterAnimation(); - } - - @Test - public void test_setClipData_textData_legacy() { - mFeatureFlags.set(CLIPBOARD_MINIMIZED_LAYOUT, false); - - mOverlayController.setClipDataLegacy(mSampleClipData, ""); - - verify(mClipboardOverlayView, times(1)).showTextPreview("Test Item", false); - verify(mClipboardOverlayView, times(1)).showShareChip(); - verify(mClipboardOverlayView, times(1)).getEnterAnimation(); - } - - @Test - public void test_setClipData_sensitiveTextData_legacy() { - mFeatureFlags.set(CLIPBOARD_MINIMIZED_LAYOUT, false); - - ClipDescription description = mSampleClipData.getDescription(); - PersistableBundle b = new PersistableBundle(); - b.putBoolean(ClipDescription.EXTRA_IS_SENSITIVE, true); - description.setExtras(b); - ClipData data = new ClipData(description, mSampleClipData.getItemAt(0)); - mOverlayController.setClipDataLegacy(data, ""); - - verify(mClipboardOverlayView, times(1)).showTextPreview("••••••", true); - verify(mClipboardOverlayView, times(1)).showShareChip(); - verify(mClipboardOverlayView, times(1)).getEnterAnimation(); - } - - @Test - public void test_setClipData_repeatedCalls_legacy() { - mFeatureFlags.set(CLIPBOARD_MINIMIZED_LAYOUT, false); - when(mAnimator.isRunning()).thenReturn(true); - - mOverlayController.setClipDataLegacy(mSampleClipData, ""); - mOverlayController.setClipDataLegacy(mSampleClipData, ""); - - verify(mClipboardOverlayView, times(1)).getEnterAnimation(); - } - - @Test - public void test_viewCallbacks_onShareTapped_legacy() { - mFeatureFlags.set(CLIPBOARD_MINIMIZED_LAYOUT, false); - mOverlayController.setClipDataLegacy(mSampleClipData, ""); - - mCallbacks.onShareButtonTapped(); - - verify(mUiEventLogger, times(1)).log(CLIPBOARD_OVERLAY_SHARE_TAPPED, 0, ""); - verify(mClipboardOverlayView, times(1)).getExitAnimation(); - } - - @Test - public void test_viewCallbacks_onDismissTapped_legacy() { - mFeatureFlags.set(CLIPBOARD_MINIMIZED_LAYOUT, false); - mOverlayController.setClipDataLegacy(mSampleClipData, ""); - - mCallbacks.onDismissButtonTapped(); - - verify(mUiEventLogger, times(1)).log(CLIPBOARD_OVERLAY_DISMISS_TAPPED, 0, ""); - verify(mClipboardOverlayView, times(1)).getExitAnimation(); - } - - @Test - public void test_multipleDismissals_dismissesOnce_legacy() { - mFeatureFlags.set(CLIPBOARD_MINIMIZED_LAYOUT, false); - - mCallbacks.onSwipeDismissInitiated(mAnimator); - mCallbacks.onDismissButtonTapped(); - mCallbacks.onSwipeDismissInitiated(mAnimator); - mCallbacks.onDismissButtonTapped(); - - verify(mUiEventLogger, times(1)).log(CLIPBOARD_OVERLAY_SWIPE_DISMISSED, 0, null); - verify(mUiEventLogger, never()).log(CLIPBOARD_OVERLAY_DISMISS_TAPPED); - } - - @Test - public void test_remoteCopy_withFlagOn_legacy() { - mFeatureFlags.set(CLIPBOARD_MINIMIZED_LAYOUT, false); - mFeatureFlags.set(CLIPBOARD_REMOTE_BEHAVIOR, true); - when(mClipboardUtils.isRemoteCopy(any(), any(), any())).thenReturn(true); - - mOverlayController.setClipDataLegacy(mSampleClipData, ""); - - verify(mTimeoutHandler, never()).resetTimeout(); - } - - @Test - public void test_remoteCopy_withFlagOff_legacy() { - mFeatureFlags.set(CLIPBOARD_MINIMIZED_LAYOUT, false); - when(mClipboardUtils.isRemoteCopy(any(), any(), any())).thenReturn(true); - - mOverlayController.setClipDataLegacy(mSampleClipData, ""); - - verify(mTimeoutHandler).resetTimeout(); - } - - @Test - public void test_nonRemoteCopy_legacy() { - mFeatureFlags.set(CLIPBOARD_MINIMIZED_LAYOUT, false); - mFeatureFlags.set(CLIPBOARD_REMOTE_BEHAVIOR, true); - when(mClipboardUtils.isRemoteCopy(any(), any(), any())).thenReturn(false); - - mOverlayController.setClipDataLegacy(mSampleClipData, ""); - - verify(mTimeoutHandler).resetTimeout(); - } - - @Test - public void test_logsUseLastClipSource_legacy() { - mFeatureFlags.set(CLIPBOARD_MINIMIZED_LAYOUT, false); - - mOverlayController.setClipDataLegacy(mSampleClipData, "first.package"); - mCallbacks.onDismissButtonTapped(); - mOverlayController.setClipDataLegacy(mSampleClipData, "second.package"); - mCallbacks.onDismissButtonTapped(); - - verify(mUiEventLogger).log(CLIPBOARD_OVERLAY_DISMISS_TAPPED, 0, "first.package"); - verify(mUiEventLogger).log(CLIPBOARD_OVERLAY_DISMISS_TAPPED, 0, "second.package"); - verifyNoMoreInteractions(mUiEventLogger); - } - - @Test - public void test_logOnClipboardActionsShown_legacy() { - mFeatureFlags.set(CLIPBOARD_MINIMIZED_LAYOUT, false); - ClipData.Item item = mSampleClipData.getItemAt(0); - item.setTextLinks(Mockito.mock(TextLinks.class)); - mFeatureFlags.set(CLIPBOARD_REMOTE_BEHAVIOR, true); - when(mClipboardUtils.isRemoteCopy(any(Context.class), any(ClipData.class), anyString())) - .thenReturn(true); - when(mClipboardUtils.getAction(any(ClipData.Item.class), anyString())) - .thenReturn(Optional.of(Mockito.mock(RemoteAction.class))); - when(mClipboardOverlayView.post(any(Runnable.class))).thenAnswer(new Answer<Object>() { - @Override - public Object answer(InvocationOnMock invocation) throws Throwable { - ((Runnable) invocation.getArgument(0)).run(); - return null; - } - }); - - mOverlayController.setClipDataLegacy( - new ClipData(mSampleClipData.getDescription(), item), "actionShownSource"); - mExecutor.runAllReady(); - - verify(mUiEventLogger).log(CLIPBOARD_OVERLAY_ACTION_SHOWN, 0, "actionShownSource"); - verifyNoMoreInteractions(mUiEventLogger); - } - - // start of refactored setClipData tests - @Test public void test_setClipData_invalidImageData() { ClipData clipData = new ClipData("", new String[]{"image/png"}, new ClipData.Item(Uri.parse(""))); diff --git a/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardOverlayUtilsTest.java b/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardOverlayUtilsTest.java index 3d8f04e08825..673b5eb5dc3c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardOverlayUtilsTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/ClipboardOverlayUtilsTest.java @@ -142,81 +142,6 @@ public class ClipboardOverlayUtilsTest extends SysuiTestCase { assertEquals(actionB, result); } - // TODO(b/267162944): Next four tests (marked "legacy") are obsolete once - // CLIPBOARD_MINIMIZED_LAYOUT flag is released and removed - @Test - public void test_getAction_noLinks_returnsEmptyOptional_legacy() { - ClipData.Item item = new ClipData.Item("no text links"); - item.setTextLinks(Mockito.mock(TextLinks.class)); - - Optional<RemoteAction> action = mClipboardUtils.getAction(item, ""); - - assertTrue(action.isEmpty()); - } - - @Test - public void test_getAction_returnsFirstLink_legacy() { - when(mClipDataItem.getTextLinks()).thenReturn(getFakeTextLinksBuilder().build()); - when(mClipDataItem.getText()).thenReturn(""); - RemoteAction actionA = constructRemoteAction("abc"); - RemoteAction actionB = constructRemoteAction("def"); - TextClassification classificationA = Mockito.mock(TextClassification.class); - when(classificationA.getActions()).thenReturn(Lists.newArrayList(actionA)); - TextClassification classificationB = Mockito.mock(TextClassification.class); - when(classificationB.getActions()).thenReturn(Lists.newArrayList(actionB)); - when(mTextClassifier.classifyText(anyString(), anyInt(), anyInt(), isNull())).thenReturn( - classificationA, classificationB); - - RemoteAction result = mClipboardUtils.getAction(mClipDataItem, "test").orElse(null); - - assertEquals(actionA, result); - } - - @Test - public void test_getAction_skipsMatchingComponent_legacy() { - when(mClipDataItem.getTextLinks()).thenReturn(getFakeTextLinksBuilder().build()); - when(mClipDataItem.getText()).thenReturn(""); - RemoteAction actionA = constructRemoteAction("abc"); - RemoteAction actionB = constructRemoteAction("def"); - TextClassification classificationA = Mockito.mock(TextClassification.class); - when(classificationA.getActions()).thenReturn(Lists.newArrayList(actionA)); - TextClassification classificationB = Mockito.mock(TextClassification.class); - when(classificationB.getActions()).thenReturn(Lists.newArrayList(actionB)); - when(mTextClassifier.classifyText(anyString(), anyInt(), anyInt(), isNull())).thenReturn( - classificationA, classificationB); - - RemoteAction result = mClipboardUtils.getAction(mClipDataItem, "abc").orElse(null); - - assertEquals(actionB, result); - } - - @Test - public void test_getAction_skipsShortEntity_legacy() { - TextLinks.Builder textLinks = new TextLinks.Builder("test text of length 22"); - final Map<String, Float> scores = new ArrayMap<>(); - scores.put(TextClassifier.TYPE_EMAIL, 1f); - textLinks.addLink(20, 22, scores); - textLinks.addLink(0, 22, scores); - - when(mClipDataItem.getTextLinks()).thenReturn(textLinks.build()); - when(mClipDataItem.getText()).thenReturn(textLinks.build().getText()); - - RemoteAction actionA = constructRemoteAction("abc"); - RemoteAction actionB = constructRemoteAction("def"); - TextClassification classificationA = Mockito.mock(TextClassification.class); - when(classificationA.getActions()).thenReturn(Lists.newArrayList(actionA)); - TextClassification classificationB = Mockito.mock(TextClassification.class); - when(classificationB.getActions()).thenReturn(Lists.newArrayList(actionB)); - when(mTextClassifier.classifyText(anyString(), eq(20), eq(22), isNull())).thenReturn( - classificationA); - when(mTextClassifier.classifyText(anyString(), eq(0), eq(22), isNull())).thenReturn( - classificationB); - - RemoteAction result = mClipboardUtils.getAction(mClipDataItem, "test").orElse(null); - - assertEquals(actionB, result); - } - @Test public void test_extra_withPackage_returnsTrue() { PersistableBundle b = new PersistableBundle(); |