Skip to content

Commit 5be16c1

Browse files
Zac McKenneywilldurand
authored andcommitted
fix: update startActivity to fix Android 13 intent filter changes
1 parent 51a1c93 commit 5be16c1

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
@@ -355,12 +355,26 @@ export default class ADBUtils {
355355
}
356356

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

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)