Skip to content

Commit 0f0bcb1

Browse files
zmckenneyZac McKenney
authored andcommitted
fix: Android 13 startActivity with correct intent action and category (#2734)
Co-authored-by: Zac McKenney <[email protected]>
1 parent 37c0242 commit 0f0bcb1

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

src/util/adb.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,26 @@ export default class ADBUtils {
352352
const component = `${apk}/${apkComponent}`;
353353

354354
await wrapADBCall(async () => {
355-
await adbClient.getDevice(deviceId).startActivity({
356-
wait: true,
357-
action: 'android.activity.MAIN',
358-
component,
359-
extras,
360-
});
355+
try {
356+
// TODO: once Fenix (release) uses Android 13, we can get rid of this
357+
// call and only use the second call in the `catch` block.
358+
await adbClient.getDevice(deviceId).startActivity({
359+
wait: true,
360+
action: 'android.activity.MAIN',
361+
component,
362+
extras,
363+
});
364+
} catch {
365+
// Android 13+ requires a different action/category but we still need
366+
// to support older Fenix builds.
367+
await adbClient.getDevice(deviceId).startActivity({
368+
wait: true,
369+
action: 'android.intent.action.MAIN',
370+
category: 'android.intent.category.LAUNCHER',
371+
component,
372+
extras,
373+
});
374+
}
361375
});
362376
}
363377

tests/unit/test-util/test.adb.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ describe('utils/adb', () => {
819819
},
820820
});
821821

822-
sinon.assert.calledOnce(adb.fakeADBDevice.startActivity);
822+
sinon.assert.calledTwice(adb.fakeADBDevice.startActivity);
823823
sinon.assert.calledWithMatch(adb.fakeADBDevice.startActivity, {
824824
action: 'android.activity.MAIN',
825825
component: 'org.mozilla.firefox_mybuild/.App',
@@ -831,6 +831,18 @@ describe('utils/adb', () => {
831831
],
832832
wait: true,
833833
});
834+
sinon.assert.calledWithMatch(adb.fakeADBDevice.startActivity, {
835+
action: 'android.intent.action.MAIN',
836+
category: 'android.intent.category.LAUNCHER',
837+
component: 'org.mozilla.firefox_mybuild/.App',
838+
extras: [
839+
{
840+
key: 'args',
841+
value: '-profile /fake/custom/profile/path',
842+
},
843+
],
844+
wait: true,
845+
});
834846
});
835847

836848
it('starts Firefox APK on a custom profile (only used by Fennec)', async () => {

0 commit comments

Comments
 (0)