screenshot-tests-for-android icon indicating copy to clipboard operation
screenshot-tests-for-android copied to clipboard

Use public download directoty to by-pass scoped storage (API 30)

Open TimoPtr opened this issue 4 years ago • 5 comments

https://github.com/facebook/screenshot-tests-for-android/issues/162#issuecomment-745454096 I did some try and error on the API 30 and it seems that the only solution that I've found to make it work on API 30 is to use public download dir on external storage.

I first try using specific folder within scoped storage but the files are removed at the end of connected task. I did use download dir because there is some restriction on Picture (filter on the extension).

This solution works but one day this public api is going to be removed.

Also I found out that there is an issue with the orchestrator library and API 30, https://github.com/android/android-test/issues/743 I did try the last alpha but it was not working as expected on the sample project so for now on my side I won't use the orchestrator on API 30.

TimoPtr avatar Dec 16 '20 10:12 TimoPtr

Really appreciate your effort here, as evolving android is ever-trying to make our lives more "fun".

I cherry-picked the commit and tried it together with whatever master has, not working under Pixel 5 API30 (Android 11) emulator.

Caused by: java.lang.RuntimeException: java.io.IOException: Operation not permitted at com.facebook.testing.screenshot.internal.ScreenshotImpl.storeBitmap(ScreenshotImpl.java:200) at com.facebook.testing.screenshot.internal.ScreenshotImpl.record(ScreenshotImpl.java:271)

Can be tested under https://maven.pkg.github.com/oradkovsky/screenshot-tests-for-android ver 0.14.2-SNAPSHOT.

oradkovsky avatar Oct 06 '21 05:10 oradkovsky

Interestingly enough, tests are not crashing under physical device (FTL Pixel 5e redfin, API 30) BUT cloud artifacts no longer have screenshots :(

oradkovsky avatar Oct 06 '21 06:10 oradkovsky

I have the same problem with API 30, The test can't read the file. Is there any update on this PR?

mo0rti avatar Oct 11 '21 12:10 mo0rti

Sorry for the (severely) late review. I think the easiest way to maybe get around this would be to move the library to persist screenshots into private app storage and use adb shell run-as when pulling since the APK should be debuggable, although I'm not sure if this will cause issues on real devices off the top of my head.

xiphirx avatar Feb 02 '22 22:02 xiphirx

@xiphirx Hey mate, Is there any chance you merge this PR ?

Dr-Bootman avatar May 11 '22 02:05 Dr-Bootman