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

Error testing addon with web-ext in Android. Unable to retrieve current user #3315

Open
orsonwelles1941 opened this issue Nov 29, 2024 · 1 comment

Comments

@orsonwelles1941
Copy link

orsonwelles1941 commented Nov 29, 2024

Is this a feature request or a bug?

bug

What is the current behavior?

Command:
web-ext run --target=firefox-android --android-device=55555555 --firefox-apk=org.mozilla.fenix

Error:

WebExtError: Unable to retrieve current user on 55555555
    at ADBUtils.getCurrentUser (file:///usr/lib/node_modules/web-ext/lib/util/adb.js:72:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ADBUtils.discoverInstalledFirefoxAPKs (file:///usr/lib/node_modules/web-ext/lib/util/adb.js:77:20)
    at async FirefoxAndroidExtensionRunner.apkPackagesDiscoveryAndSelect (file:///usr/lib/node_modules/web-ext/lib/extension-runners/firefox-android.js:257:22)
    at async FirefoxAndroidExtensionRunner.run (file:///usr/lib/node_modules/web-ext/lib/extension-runners/firefox-android.js:76:5)
    at async Promise.all (index 0)
    at async MultiExtensionRunner.run (file:///usr/lib/node_modules/web-ext/lib/extension-runners/index.js:67:5)
    at async run (file:///usr/lib/node_modules/web-ext/lib/cmd/run.js:173:3)
    at async Program.execute (file:///usr/lib/node_modules/web-ext/lib/program.js:270:7)
    at async file:///usr/lib/node_modules/web-ext/bin/web-ext.js:13:1

What is the expected or desired behavior?

The function:

  async getCurrentUser(deviceId) {
    log.debug(`Retrieving  current user on ${deviceId}`);
    const currentUser = await this.runShellCommand(deviceId, ['am', 'get-current-user']);
    const userId = parseInt(currentUser.trim());
    if (isNaN(userId)) {
      throw new WebExtError(`Unable to retrieve current user on ${deviceId}`);
    }
    return userId;
  }

in /usr/lib/node_modules/web-ext/lib/util/adb.js is not working for Android 6.0.1.
I have tested:

  async getCurrentUser(deviceId) {
    return 0;
  }

and it works. Obviously not a good solution.

Solution:
Add support for Android 6.0.1. If support for Android 6.0.1 is not planned to be added, this should be indicated in the documentation.

Version information (for bug reports)

  • Firefox version:
    Firefox Nightly 134.0a1 for Android
  • Your OS and version:
    Tested in Archlinux and Fedora Workstation 41. Android 6.0.1
node --version && npm --version && web-ext --version

v20.18.0
10.9.0
8.3.0

@Rob--W
Copy link
Member

Rob--W commented Dec 5, 2024

Firefox for Android appears to still support Android 5.0+ according to https://en.wikipedia.org/wiki/Template:Firefox_for_Android_release_compatibility, so I would not oppose support for that in web-ext either.

What is the actual value of currentUser in your case?

What is the output of adb shell am get-current-user ?

What is the output of adb shell getprop ro.build.version.release ? (I expect 6.0.1 in your case).

What we could do here is to fall back to 0 if we detect an unexpected/unsupported return value.
Are you willing to provide a patch?

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

2 participants