Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: add isSettingsAppServiceRunningInForeground to check the settings' service existence better #715

Merged
merged 10 commits into from
Jan 9, 2024
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)) {
KazuCocoa marked this conversation as resolved.
Show resolved Hide resolved
return this;
}

log.debug('Starting Appium Settings app');
KazuCocoa marked this conversation as resolved.
Show resolved Hide resolved
let appPackage;
if (shouldRestoreCurrentApp) {
try {
Expand Down