Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: revert --pct-syskeys 0 #745

Merged
merged 3 commits into from
May 19, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/commands/app-management.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ commands.queryAppState = async function queryAppState (appId) {
*/
commands.activateApp = async function activateApp (appId) {
this.log.debug(`Activating '${appId}'`);
const apiLevel = await this.adb.getApiLevel();
// Fallback to Monkey in older APIs
if (await this.adb.getApiLevel() < 24) {
if (apiLevel < 24) {
// The monkey command could raise an issue as https://stackoverflow.com/questions/44860475/how-to-use-the-monkey-command-with-an-android-system-that-doesnt-have-physical
// but '--pct-syskeys 0' could cause another background process issue. https://github.com/appium/appium/issues/16941#issuecomment-1129837285
// We should not add it to avoid it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this last sentence is redundant

const cmd = ['monkey',
// https://stackoverflow.com/questions/44860475/how-to-use-the-monkey-command-with-an-android-system-that-doesnt-have-physical
'--pct-syskeys', '0',
'-p', appId,
'-c', 'android.intent.category.LAUNCHER',
'1'];
Expand All @@ -77,7 +79,7 @@ commands.activateApp = async function activateApp (appId) {
}

const stdout = await this.adb.shell([
'am', 'start',
'am', (apiLevel < 26) ? 'start' : 'start-activity',
'-a', 'android.intent.action.MAIN',
'-c', 'android.intent.category.LAUNCHER',
// FLAG_ACTIVITY_REORDER_TO_FRONT | FLAG_ACTIVITY_BROUGHT_TO_FRONT | FLAG_ACTIVITY_NEW_TASK
Expand Down