summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ben Reich <benreich@google.com> 2025-02-24 10:31:57 +1100
committer Ben Reich <benreich@google.com> 2025-02-24 10:35:12 +1100
commit315018fac100f9043183fd61f001f60afd79ff17 (patch)
tree364eee24a387f48d78ee3a176238feb01a295735
parentf19c8fea9a08e24890faaac8146f5f333eb4816e (diff)
Add additional debug information for TrampolineActivity
It seems like the TrampolineActivity is failing on a few devices. Currently there are no logs available, however, when testing it locally on a bluejay it appears like the PhotopickerGetContentActivity was disabled. Adding some logs to see if that's the case on the bots. This also clears up the error messages in the tests which were just showing up "Assertion failed" which required some small level of leaps to associate with the test name. Let's just make it obvious in the failure message what happened and what was expected. Bug: 398402760 Test: atest com.android.documentsui.picker.TrampolineActivity Flag: com.android.documentsui.flags.redirect_get_content Change-Id: I6843d9869bcc3bc0b14d01ac56e5b2585b3f7742
-rw-r--r--src/com/android/documentsui/picker/TrampolineActivity.kt9
-rw-r--r--tests/functional/com/android/documentsui/TrampolineActivityTest.kt42
2 files changed, 40 insertions, 11 deletions
diff --git a/src/com/android/documentsui/picker/TrampolineActivity.kt b/src/com/android/documentsui/picker/TrampolineActivity.kt
index e9e9739a3..dba09f2f3 100644
--- a/src/com/android/documentsui/picker/TrampolineActivity.kt
+++ b/src/com/android/documentsui/picker/TrampolineActivity.kt
@@ -24,7 +24,9 @@ import android.os.Build
import android.os.Bundle
import android.os.ext.SdkExtensions
import android.provider.MediaStore.ACTION_PICK_IMAGES
+import android.util.Log
import androidx.appcompat.app.AppCompatActivity
+import com.android.documentsui.base.SharedMinimal.DEBUG
/**
* DocumentsUI PickActivity currently defers picking of media mime types to the Photopicker. This
@@ -32,6 +34,10 @@ import androidx.appcompat.app.AppCompatActivity
* there are non-media mime types to handle.
*/
class TrampolineActivity : AppCompatActivity() {
+ companion object {
+ const val TAG = "TrampolineActivity"
+ }
+
override fun onCreate(savedInstanceBundle: Bundle?) {
super.onCreate(savedInstanceBundle)
@@ -98,6 +104,9 @@ class TrampolineActivity : AppCompatActivity() {
// Ensure the `ACTION_GET_CONTENT` activity is enabled.
if (!isComponentEnabled(photopickerGetContentComponent)) {
+ if (DEBUG) {
+ Log.d(TAG, "Photopicker PICK_IMAGES component has no enabled GET_CONTENT handler")
+ }
return null
}
diff --git a/tests/functional/com/android/documentsui/TrampolineActivityTest.kt b/tests/functional/com/android/documentsui/TrampolineActivityTest.kt
index 48e6b7614..76d703701 100644
--- a/tests/functional/com/android/documentsui/TrampolineActivityTest.kt
+++ b/tests/functional/com/android/documentsui/TrampolineActivityTest.kt
@@ -32,6 +32,7 @@ import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.Until
import com.android.documentsui.flags.Flags.FLAG_REDIRECT_GET_CONTENT
import com.android.documentsui.picker.TrampolineActivity
+import java.util.Optional
import java.util.regex.Pattern
import org.junit.After
import org.junit.Assert.assertNotNull
@@ -88,11 +89,11 @@ class TrampolineActivityTest() {
data class GetContentIntentData(
val mimeType: String,
val expectedApp: AppType,
- val extraMimeTypes: Array<String>? = null,
+ val extraMimeTypes: Optional<Array<String>> = Optional.empty(),
) {
override fun toString(): String {
- if (extraMimeTypes != null) {
- return "${mimeType}_${extraMimeTypes.joinToString("_")}"
+ if (extraMimeTypes.isPresent) {
+ return "${mimeType}_${extraMimeTypes.get().joinToString("_")}"
}
return mimeType
}
@@ -117,32 +118,32 @@ class TrampolineActivityTest() {
),
GetContentIntentData(
mimeType = "image/*",
- extraMimeTypes = arrayOf("video/*"),
+ extraMimeTypes = Optional.of(arrayOf("video/*")),
expectedApp = AppType.PHOTOPICKER,
),
GetContentIntentData(
mimeType = "video/*",
- extraMimeTypes = arrayOf("image/*"),
+ extraMimeTypes = Optional.of(arrayOf("image/*")),
expectedApp = AppType.PHOTOPICKER,
),
GetContentIntentData(
mimeType = "video/*",
- extraMimeTypes = arrayOf("text/*"),
+ extraMimeTypes = Optional.of(arrayOf("text/*")),
expectedApp = AppType.DOCUMENTSUI,
),
GetContentIntentData(
mimeType = "video/*",
- extraMimeTypes = arrayOf("image/*", "text/*"),
+ extraMimeTypes = Optional.of(arrayOf("image/*", "text/*")),
expectedApp = AppType.DOCUMENTSUI,
),
GetContentIntentData(
mimeType = "*/*",
- extraMimeTypes = arrayOf("image/*", "video/*"),
+ extraMimeTypes = Optional.of(arrayOf("image/*", "video/*")),
expectedApp = AppType.PHOTOPICKER,
),
GetContentIntentData(
mimeType = "image/*",
- extraMimeTypes = arrayOf(),
+ extraMimeTypes = Optional.of(arrayOf()),
expectedApp = AppType.DOCUMENTSUI,
)
)
@@ -161,7 +162,10 @@ class TrampolineActivityTest() {
intent.setClass(context, TrampolineActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.setType(testData.mimeType)
- testData.extraMimeTypes?.let { intent.putExtra(Intent.EXTRA_MIME_TYPES, it) }
+ if (testData.extraMimeTypes.isPresent) {
+ testData.extraMimeTypes.get()
+ .forEach { intent.putExtra(Intent.EXTRA_MIME_TYPES, it) }
+ }
context.startActivity(intent)
}
@@ -178,7 +182,23 @@ class TrampolineActivityTest() {
else -> By.pkg(DOCUMENTSUI_PACKAGE_REGEX)
}
- assertNotNull(device.wait(Until.findObject(bySelector), UI_TIMEOUT))
+ val builder = StringBuilder()
+ builder.append("Intent with mimetype ${testData.mimeType}")
+ if (testData.extraMimeTypes.isPresent) {
+ builder.append(
+ " and EXTRA_MIME_TYPES of ${
+ testData.extraMimeTypes.get().joinToString(", ")
+ }"
+ )
+ }
+ builder.append(
+ " didn't cause ${testData.expectedApp.name} to appear after ${UI_TIMEOUT}ms"
+ )
+
+ assertNotNull(
+ builder.toString(),
+ device.wait(Until.findObject(bySelector), UI_TIMEOUT)
+ )
}
}