Skip to content

Commit

Permalink
feat: add forceStartSettingsApp in requireRunningSettingsApp
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuCocoa committed Jan 8, 2024
1 parent 1cac1ae commit 9d005d9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/tools/settings-client-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const commands = {};
* to wait until the app has started
* @property {boolean} [shouldRestoreCurrentApp=false] Whether to restore
* the activity which was the current one before Settings startup
* @property {boolean} [forceStartSettingsApp=false] Whether to start
* the Settings app forcefully regardless of the current app process status.
*/

/**
Expand All @@ -59,15 +61,17 @@ const commands = {};
* @returns {Promise<import('../adb.js').ADB>} self instance for chaining
*/
commands.requireRunningSettingsApp = async function requireRunningSettingsApp (opts = {}) {
if (await this.processExists(SETTINGS_HELPER_ID)) {
return this;
}

log.debug('Starting Appium Settings app');
const {
timeout = 5000,
shouldRestoreCurrentApp = false,
forceStartSettingsApp = false
} = opts;

if (forceStartSettingsApp === false && await this.processExists(SETTINGS_HELPER_ID)) {
return this;
}

log.debug('Starting Appium Settings app');
let appPackage;
if (shouldRestoreCurrentApp) {
try {
Expand Down

0 comments on commit 9d005d9

Please sign in to comment.