Skip to content

Commit

Permalink
fix: revert --pct-syskeys 0 (#745)
Browse files Browse the repository at this point in the history
* fix: remove "--pct-syskeys 0" as regular usage

* use start-activity

* Update app-management.js
  • Loading branch information
KazuCocoa authored May 19, 2022
1 parent 2a68022 commit 138ebf4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/commands/app-management.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -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
Expand Down

0 comments on commit 138ebf4

Please sign in to comment.