Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong SDCard folder on Android 5.1 #351

Open
Otacon opened this issue Dec 23, 2023 · 0 comments
Open

Wrong SDCard folder on Android 5.1 #351

Otacon opened this issue Dec 23, 2023 · 0 comments

Comments

@Otacon
Copy link

Otacon commented Dec 23, 2023

Expected behaviour

When emitting ADB commands the commands should point at the same directory AndroidStorageInfo is pointing.

  • /storage/sdcard on API Level < 22 (? - verify API level)
  • /storage/emulated/0 on API level >= 22 (? - verify API level)

Actual behaviour

On the stock Google Android Emulator 5.1 (API Level 22), the saved screenshots are pointing in the right path position /storage/sdcard/, however, the rm and pull adb commands are pointing to the wrong folder /storage/emulated/0.

This causes tests to fail.

Steps to reproduce

Install android emulator default, android-22;
Run the ui tests

Notice that Shot is trying to rm and pull from /storage/emulated/0. This folder doesn't exist

Version of the library

6.0.0

Suggestions

Approach 1 - Change path depending on API version

I would make the changes on my own, but I'm not that confident with Scala. So I've made some attempts and I think this might work by changing just this file core/android/ADB.scala

  1. Create a new function to dynamically gather the path
  private def baseStoragePath(device: String): String = {
    def result = executeAdbCommandWithResult(s"-s ${device} shell getprop ro.build.version.sdk")
    if(result.toInt >= 23){
      "/storage/sdcard/Downloads"
    } else {
      "/storage/emulated/0/Download"
    }
  }
  1. replace all the usages of $baseStoragePath with ${baseStoragePath(device)}
  2. remove object Adb { ... }

Approach 2 - Probably much more reliable and generic

Not sure how to implement this correctly, but probably I would:

  • check wether storage/emulated/0 exists on the device
  • If it doesn't, check for storage/sdcard.
  • If storage/sdcard folder doesn't exist as well, something's definitely wrong, so we shouldn't proceed with executing tests

Thank you very much for the support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant