diff --git a/src/firefox/package-identifiers.js b/src/firefox/package-identifiers.js index 6cb61df630..de919c5ef2 100644 --- a/src/firefox/package-identifiers.js +++ b/src/firefox/package-identifiers.js @@ -8,3 +8,7 @@ export default [ 'org.mozilla.firefox', 'org.mozilla.reference.browser', ]; + +export const defaultApkComponents = { + 'org.mozilla.reference.browser': '.BrowserActivity', +}; diff --git a/src/util/adb.js b/src/util/adb.js index c61c041acc..213f0134fb 100644 --- a/src/util/adb.js +++ b/src/util/adb.js @@ -7,7 +7,9 @@ import { WebExtError, } from '../errors'; import {createLogger} from '../util/logger'; -import packageIdentifiers from '../firefox/package-identifiers'; +import packageIdentifiers, { + defaultApkComponents, +} from '../firefox/package-identifiers'; export const DEVICE_DIR_BASE = '/sdcard/'; export const ARTIFACTS_DIR_PREFIX = 'web-ext-artifacts-'; @@ -313,6 +315,9 @@ export default class ADBUtils { if (!apkComponent) { apkComponent = '.App'; + if (defaultApkComponents[apk]) { + apkComponent = defaultApkComponents[apk]; + } } else if (!apkComponent.includes('.')) { apkComponent = `.${apkComponent}`; } diff --git a/tests/unit/test-util/test.adb.js b/tests/unit/test-util/test.adb.js index 939937ff38..ac97324431 100644 --- a/tests/unit/test-util/test.adb.js +++ b/tests/unit/test-util/test.adb.js @@ -935,6 +935,52 @@ describe('utils/adb', () => { ); }); + async function testReferenceBrowserApkComponent( + firefoxApkComponent?: string, expectedApkComponent: string + ) { + const adb = getFakeADBKit({ + adbClient: { + startActivity: sinon.spy(() => Promise.resolve()), + }, + adbkitUtil: { + readAll: sinon.spy(() => Promise.resolve(Buffer.from('\n'))), + }, + }); + const adbUtils = new ADBUtils({adb}); + const apkName = 'org.mozilla.reference.browser'; + const component = `${apkName}/${apkName}.${expectedApkComponent}`; + const promise = adbUtils.startFirefoxAPK( + 'device1', + apkName, + firefoxApkComponent, + '/fake/custom/profile/path', + ); + + await assert.isFulfilled(promise); + sinon.assert.calledOnce(adb.fakeADBClient.startActivity); + sinon.assert.calledWithMatch( + adb.fakeADBClient.startActivity, 'device1', { + action: 'android.activity.MAIN', + component, + extras: [{ + key: 'args', + value: '-profile /fake/custom/profile/path', + }], + wait: true, + } + ); + } + + it('start reference browser without APK component', () => { + return testReferenceBrowserApkComponent(undefined, 'BrowserActivity'); + }); + + it('start reference browser with custom APK component', () => { + return testReferenceBrowserApkComponent( + 'CustomActivity', 'CustomActivity' + ); + }); + it('starts without specifying an APK component', async () => { const adb = getFakeADBKit({ adbClient: {