summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/clipboardoverlay/IntentCreator.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/screenshot/ActionIntentCreator.kt4
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/IntentCreatorTest.java1
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/screenshot/ActionIntentCreatorTest.kt68
4 files changed, 43 insertions, 35 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/IntentCreator.java b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/IntentCreator.java
index 566a74ae3e07..d58fab45093d 100644
--- a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/IntentCreator.java
+++ b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/IntentCreator.java
@@ -27,7 +27,8 @@ import android.text.TextUtils;
import com.android.systemui.R;
class IntentCreator {
- private static final String EXTRA_EDIT_SOURCE_CLIPBOARD = "edit_source_clipboard";
+ private static final String EXTRA_EDIT_SOURCE = "edit_source";
+ private static final String EDIT_SOURCE_CLIPBOARD = "clipboard";
private static final String REMOTE_COPY_ACTION = "android.intent.action.REMOTE_COPY";
static Intent getTextEditorIntent(Context context) {
@@ -74,7 +75,7 @@ class IntentCreator {
editIntent.setDataAndType(uri, "image/*");
editIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
editIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
- editIntent.putExtra(EXTRA_EDIT_SOURCE_CLIPBOARD, true);
+ editIntent.putExtra(EXTRA_EDIT_SOURCE, EDIT_SOURCE_CLIPBOARD);
return editIntent;
}
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ActionIntentCreator.kt b/packages/SystemUI/src/com/android/systemui/screenshot/ActionIntentCreator.kt
index 05a0416f8f64..ab2a8d9c6e95 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/ActionIntentCreator.kt
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/ActionIntentCreator.kt
@@ -82,11 +82,15 @@ object ActionIntentCreator {
return editIntent
.setDataAndType(uri, "image/png")
+ .putExtra(EXTRA_EDIT_SOURCE, EDIT_SOURCE_SCREENSHOT)
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
}
+
+ private const val EXTRA_EDIT_SOURCE = "edit_source"
+ private const val EDIT_SOURCE_SCREENSHOT = "screenshot"
}
/**
diff --git a/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/IntentCreatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/IntentCreatorTest.java
index 7628be44755d..662c89c268e6 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/IntentCreatorTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/clipboardoverlay/IntentCreatorTest.java
@@ -80,6 +80,7 @@ public class IntentCreatorTest extends SysuiTestCase {
assertEquals(Intent.ACTION_EDIT, intent.getAction());
assertEquals("image/*", intent.getType());
assertEquals(null, intent.getComponent());
+ assertEquals("clipboard", intent.getStringExtra("edit_source"));
assertFlags(intent, EXTERNAL_INTENT_FLAGS);
// try again with an editor component
diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ActionIntentCreatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ActionIntentCreatorTest.kt
index 2d3ee0e5cff9..ca4486b533ff 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ActionIntentCreatorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ActionIntentCreatorTest.kt
@@ -20,12 +20,13 @@ import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.net.Uri
-import androidx.test.ext.truth.content.IntentSubject.assertThat
+import androidx.test.ext.truth.content.IntentSubject.assertThat as assertThatIntent
import androidx.test.filters.SmallTest
import com.android.systemui.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.util.mockito.eq
import com.android.systemui.util.mockito.mock
+import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
import org.junit.Test
import org.mockito.Mockito.`when` as whenever
@@ -39,23 +40,23 @@ class ActionIntentCreatorTest : SysuiTestCase() {
val output = ActionIntentCreator.createShare(uri)
- assertThat(output).hasAction(Intent.ACTION_CHOOSER)
- assertThat(output)
+ assertThatIntent(output).hasAction(Intent.ACTION_CHOOSER)
+ assertThatIntent(output)
.hasFlags(
Intent.FLAG_ACTIVITY_NEW_TASK or
Intent.FLAG_ACTIVITY_CLEAR_TASK or
Intent.FLAG_GRANT_READ_URI_PERMISSION
)
- assertThat(output).extras().parcelable<Intent>(Intent.EXTRA_INTENT).isNotNull()
+ assertThatIntent(output).extras().parcelable<Intent>(Intent.EXTRA_INTENT).isNotNull()
val wrappedIntent = output.getParcelableExtra(Intent.EXTRA_INTENT, Intent::class.java)
- assertThat(wrappedIntent).hasAction(Intent.ACTION_SEND)
- assertThat(wrappedIntent).hasData(uri)
- assertThat(wrappedIntent).hasType("image/png")
- assertThat(wrappedIntent).extras().doesNotContainKey(Intent.EXTRA_SUBJECT)
- assertThat(wrappedIntent).extras().doesNotContainKey(Intent.EXTRA_TEXT)
- assertThat(wrappedIntent).extras().parcelable<Uri>(Intent.EXTRA_STREAM).isEqualTo(uri)
+ assertThatIntent(wrappedIntent).hasAction(Intent.ACTION_SEND)
+ assertThatIntent(wrappedIntent).hasData(uri)
+ assertThatIntent(wrappedIntent).hasType("image/png")
+ assertThatIntent(wrappedIntent).extras().doesNotContainKey(Intent.EXTRA_SUBJECT)
+ assertThatIntent(wrappedIntent).extras().doesNotContainKey(Intent.EXTRA_TEXT)
+ assertThatIntent(wrappedIntent).extras().parcelable<Uri>(Intent.EXTRA_STREAM).isEqualTo(uri)
}
@Test
@@ -64,7 +65,7 @@ class ActionIntentCreatorTest : SysuiTestCase() {
val output = ActionIntentCreator.createShare(uri)
- assertThat(output.getParcelableExtra(Intent.EXTRA_INTENT, Intent::class.java))
+ assertThatIntent(output.getParcelableExtra(Intent.EXTRA_INTENT, Intent::class.java))
.hasData(Uri.parse("content://fake"))
}
@@ -75,8 +76,8 @@ class ActionIntentCreatorTest : SysuiTestCase() {
val output = ActionIntentCreator.createShareWithSubject(uri, subject)
- assertThat(output).hasAction(Intent.ACTION_CHOOSER)
- assertThat(output)
+ assertThatIntent(output).hasAction(Intent.ACTION_CHOOSER)
+ assertThatIntent(output)
.hasFlags(
Intent.FLAG_ACTIVITY_NEW_TASK or
Intent.FLAG_ACTIVITY_CLEAR_TASK or
@@ -84,12 +85,12 @@ class ActionIntentCreatorTest : SysuiTestCase() {
)
val wrappedIntent = output.getParcelableExtra(Intent.EXTRA_INTENT, Intent::class.java)
- assertThat(wrappedIntent).hasAction(Intent.ACTION_SEND)
- assertThat(wrappedIntent).hasData(uri)
- assertThat(wrappedIntent).hasType("image/png")
- assertThat(wrappedIntent).extras().string(Intent.EXTRA_SUBJECT).isEqualTo(subject)
- assertThat(wrappedIntent).extras().doesNotContainKey(Intent.EXTRA_TEXT)
- assertThat(wrappedIntent).extras().parcelable<Uri>(Intent.EXTRA_STREAM).isEqualTo(uri)
+ assertThatIntent(wrappedIntent).hasAction(Intent.ACTION_SEND)
+ assertThatIntent(wrappedIntent).hasData(uri)
+ assertThatIntent(wrappedIntent).hasType("image/png")
+ assertThatIntent(wrappedIntent).extras().string(Intent.EXTRA_SUBJECT).isEqualTo(subject)
+ assertThatIntent(wrappedIntent).extras().doesNotContainKey(Intent.EXTRA_TEXT)
+ assertThatIntent(wrappedIntent).extras().parcelable<Uri>(Intent.EXTRA_STREAM).isEqualTo(uri)
}
@Test
@@ -99,8 +100,8 @@ class ActionIntentCreatorTest : SysuiTestCase() {
val output = ActionIntentCreator.createShareWithText(uri, extraText)
- assertThat(output).hasAction(Intent.ACTION_CHOOSER)
- assertThat(output)
+ assertThatIntent(output).hasAction(Intent.ACTION_CHOOSER)
+ assertThatIntent(output)
.hasFlags(
Intent.FLAG_ACTIVITY_NEW_TASK or
Intent.FLAG_ACTIVITY_CLEAR_TASK or
@@ -108,12 +109,12 @@ class ActionIntentCreatorTest : SysuiTestCase() {
)
val wrappedIntent = output.getParcelableExtra(Intent.EXTRA_INTENT, Intent::class.java)
- assertThat(wrappedIntent).hasAction(Intent.ACTION_SEND)
- assertThat(wrappedIntent).hasData(uri)
- assertThat(wrappedIntent).hasType("image/png")
- assertThat(wrappedIntent).extras().doesNotContainKey(Intent.EXTRA_SUBJECT)
- assertThat(wrappedIntent).extras().string(Intent.EXTRA_TEXT).isEqualTo(extraText)
- assertThat(wrappedIntent).extras().parcelable<Uri>(Intent.EXTRA_STREAM).isEqualTo(uri)
+ assertThatIntent(wrappedIntent).hasAction(Intent.ACTION_SEND)
+ assertThatIntent(wrappedIntent).hasData(uri)
+ assertThatIntent(wrappedIntent).hasType("image/png")
+ assertThatIntent(wrappedIntent).extras().doesNotContainKey(Intent.EXTRA_SUBJECT)
+ assertThatIntent(wrappedIntent).extras().string(Intent.EXTRA_TEXT).isEqualTo(extraText)
+ assertThatIntent(wrappedIntent).extras().parcelable<Uri>(Intent.EXTRA_STREAM).isEqualTo(uri)
}
@Test
@@ -125,11 +126,12 @@ class ActionIntentCreatorTest : SysuiTestCase() {
val output = ActionIntentCreator.createEdit(uri, context)
- assertThat(output).hasAction(Intent.ACTION_EDIT)
- assertThat(output).hasData(uri)
- assertThat(output).hasType("image/png")
+ assertThatIntent(output).hasAction(Intent.ACTION_EDIT)
+ assertThatIntent(output).hasData(uri)
+ assertThatIntent(output).hasType("image/png")
assertWithMessage("getComponent()").that(output.component).isNull()
- assertThat(output)
+ assertThat(output.getStringExtra("edit_source")).isEqualTo("screenshot")
+ assertThatIntent(output)
.hasFlags(
Intent.FLAG_GRANT_READ_URI_PERMISSION or
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or
@@ -146,7 +148,7 @@ class ActionIntentCreatorTest : SysuiTestCase() {
val output = ActionIntentCreator.createEdit(uri, context)
- assertThat(output).hasData(Uri.parse("content://fake"))
+ assertThatIntent(output).hasData(Uri.parse("content://fake"))
}
@Test
@@ -160,6 +162,6 @@ class ActionIntentCreatorTest : SysuiTestCase() {
val output = ActionIntentCreator.createEdit(uri, context)
- assertThat(output).hasComponent(component)
+ assertThatIntent(output).hasComponent(component)
}
}