From 9d005d9f60f4046850bafa6dcb35e32b132c5781 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Sun, 7 Jan 2024 18:40:52 -0800 Subject: [PATCH] feat: add forceStartSettingsApp in requireRunningSettingsApp --- lib/tools/settings-client-commands.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/tools/settings-client-commands.js b/lib/tools/settings-client-commands.js index 93890580..cfc3c51a 100644 --- a/lib/tools/settings-client-commands.js +++ b/lib/tools/settings-client-commands.js @@ -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. */ /** @@ -59,15 +61,17 @@ const commands = {}; * @returns {Promise} 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 {