Skip to content

Commit 453e83a

Browse files
authored
Update emrun for Android: (#20228)
1. Firefox has changed the Android package main activity name, update to new name. 2. Drop old outdated package/activity names from the default list, and add support to recognize passing "package/activity" directly into the --browser= field for launching other browsers (Edge, Brave, Firefox Focus, Opera etc.) 3. Give a more readable error about root cause when writing to /mnt/sdcard fails.
1 parent dec7f7d commit 453e83a

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

emrun.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,13 +1646,9 @@ def run():
16461646
loge("Running on Android requires that you explicitly specify the browser to run with --browser <id>. Run emrun --android --list_browsers to obtain a list of installed browsers you can use.")
16471647
return 1
16481648
elif options.browser == 'firefox':
1649-
browser_app = 'org.mozilla.firefox/.App'
1650-
elif options.browser == 'firefox_beta':
1651-
browser_app = 'org.mozilla.firefox_beta/.App'
1652-
elif options.browser == 'firefox_aurora' or options.browser == 'fennec_aurora':
1653-
browser_app = 'org.mozilla.fennec_aurora/.App'
1654-
elif options.browser == 'firefox_nightly' or options.browser == 'fennec':
1655-
browser_app = 'org.mozilla.fennec/.App'
1649+
browser_app = 'org.mozilla.firefox/org.mozilla.gecko.BrowserApp'
1650+
elif options.browser == 'firefox_nightly' or options.browser == 'fenix':
1651+
browser_app = 'org.mozilla.fenix/org.mozilla.gecko.BrowserApp'
16561652
elif options.browser == 'chrome':
16571653
browser_app = 'com.android.chrome/com.google.android.apps.chrome.Main'
16581654
elif options.browser == 'chrome_beta':
@@ -1661,14 +1657,10 @@ def run():
16611657
browser_app = 'com.chrome.dev/com.google.android.apps.chrome.Main'
16621658
elif options.browser == 'chrome_canary':
16631659
browser_app = 'com.chrome.canary/com.google.android.apps.chrome.Main'
1664-
elif options.browser == 'opera':
1665-
browser_app = 'com.opera.browser/com.opera.Opera'
1666-
elif options.browser == 'opera_mini':
1667-
# Launching the URL works, but page seems to never load (Fails with 'Network problem' even when other browsers work)
1668-
browser_app = 'com.opera.mini.android/.Browser'
1669-
elif options.browser == 'dolphin':
1670-
# Current stable Dolphin as of 12/2013 does not have WebGL support.
1671-
browser_app = 'mobi.mgeek.TunnyBrowser/.BrowserActivity'
1660+
elif '.' in options.browser and '/' in options.browser:
1661+
# Browser command line contains both '.' and '/', so it looks like a string of form 'package/activity', use that
1662+
# as the browser.
1663+
browser_app = options.browser
16721664
else:
16731665
loge("Don't know how to launch browser " + options.browser + ' on Android!')
16741666
return 1
@@ -1738,11 +1730,16 @@ def run():
17381730

17391731
def run(cmd):
17401732
logi(str(cmd))
1741-
subprocess.call(cmd)
1733+
subprocess.check_call(cmd)
17421734

1743-
run(['adb', 'shell', 'rm', '-rf', '/mnt/sdcard/safe_firefox_profile'])
1744-
run(['adb', 'shell', 'mkdir', '/mnt/sdcard/safe_firefox_profile'])
1745-
run(['adb', 'push', os.path.join(profile_dir, 'prefs.js'), '/mnt/sdcard/safe_firefox_profile/prefs.js'])
1735+
try:
1736+
run(['adb', 'shell', 'rm', '-rf', '/mnt/sdcard/safe_firefox_profile'])
1737+
run(['adb', 'shell', 'mkdir', '/mnt/sdcard/safe_firefox_profile'])
1738+
run(['adb', 'push', os.path.join(profile_dir, 'prefs.js'), '/mnt/sdcard/safe_firefox_profile/prefs.js'])
1739+
except Exception as e:
1740+
loge('Creating Firefox profile prefs.js file to internal storage in /mnt/sdcard failed with error ' + str(e) + '!')
1741+
loge('Try running without --safe_firefox_profile flag if unattended execution mode is not important, or')
1742+
loge('enable rooted debugging on the Android device to allow adb to write files to /mnt/sdcard.')
17461743
browser += ['--es', 'args', '"--profile /mnt/sdcard/safe_firefox_profile"']
17471744

17481745
# Create temporary Firefox profile to run the page with. This is important to

0 commit comments

Comments
 (0)