From 138ebf4228520c6608f8209f0cf8bd8a85d13e70 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Wed, 18 May 2022 17:36:01 -0700 Subject: [PATCH] fix: revert --pct-syskeys 0 (#745) * fix: remove "--pct-syskeys 0" as regular usage * use start-activity * Update app-management.js --- lib/commands/app-management.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/commands/app-management.js b/lib/commands/app-management.js index 1827125f..47554987 100644 --- a/lib/commands/app-management.js +++ b/lib/commands/app-management.js @@ -55,11 +55,12 @@ 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 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']; @@ -77,7 +78,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