Skip to content

Commit

Permalink
fix: Android 13 startActivity with correct intent action and category (
Browse files Browse the repository at this point in the history
…#2734)

Co-authored-by: Zac McKenney <zmckenney@mozilla.com>
  • Loading branch information
2 people authored and willdurand committed Apr 25, 2023
1 parent 37c0242 commit 0f0bcb1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
26 changes: 20 additions & 6 deletions src/util/adb.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,26 @@ export default class ADBUtils {
const component = `${apk}/${apkComponent}`;

await wrapADBCall(async () => {
await adbClient.getDevice(deviceId).startActivity({
wait: true,
action: 'android.activity.MAIN',
component,
extras,
});
try {
// TODO: once Fenix (release) uses Android 13, we can get rid of this
// call and only use the second call in the `catch` block.
await adbClient.getDevice(deviceId).startActivity({
wait: true,
action: 'android.activity.MAIN',
component,
extras,
});
} catch {
// Android 13+ requires a different action/category but we still need
// to support older Fenix builds.
await adbClient.getDevice(deviceId).startActivity({
wait: true,
action: 'android.intent.action.MAIN',
category: 'android.intent.category.LAUNCHER',
component,
extras,
});
}
});
}

Expand Down
14 changes: 13 additions & 1 deletion tests/unit/test-util/test.adb.js
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ describe('utils/adb', () => {
},
});

sinon.assert.calledOnce(adb.fakeADBDevice.startActivity);
sinon.assert.calledTwice(adb.fakeADBDevice.startActivity);
sinon.assert.calledWithMatch(adb.fakeADBDevice.startActivity, {
action: 'android.activity.MAIN',
component: 'org.mozilla.firefox_mybuild/.App',
Expand All @@ -831,6 +831,18 @@ describe('utils/adb', () => {
],
wait: true,
});
sinon.assert.calledWithMatch(adb.fakeADBDevice.startActivity, {
action: 'android.intent.action.MAIN',
category: 'android.intent.category.LAUNCHER',
component: 'org.mozilla.firefox_mybuild/.App',
extras: [
{
key: 'args',
value: '-profile /fake/custom/profile/path',
},
],
wait: true,
});
});

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

0 comments on commit 0f0bcb1

Please sign in to comment.