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

fix: io.appium.settings process check with isSettingsAppServiceRunningInForeground #895

Merged
merged 7 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/helpers/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ const AndroidHelpers: AndroidHelpers = {

// Reinstall would stop the settings helper process anyway, so
// there is no need to continue if the application is still running
if (await adb.processExists(SETTINGS_HELPER_PKG_ID)) {
if (await adb.isSettingsAppServiceRunningInForeground()) {
logger.debug(
`${SETTINGS_HELPER_PKG_ID} is already running. ` +
KazuCocoa marked this conversation as resolved.
Show resolved Hide resolved
`There is no need to reset its permissions.`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"dependencies": {
"@appium/support": "^4.2.0",
"@colors/colors": "^1.6.0",
"appium-adb": "^11.0.1",
"appium-adb": "^11.1.0",
"appium-chromedriver": "^5.5.1",
"asyncbox": "^3.0.0",
"axios": "^1.x",
Expand Down
8 changes: 4 additions & 4 deletions test/unit/android-helper-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,31 +635,31 @@ describe('Android Helpers', function () {
withMocks({adb}, (mocks) => {
it('should skip granting permissions if the app is already running on over API level 23+ devices', async function () {
mocks.adb.expects('installOrUpgrade').once().returns(true);
mocks.adb.expects('processExists').withExactArgs('io.appium.settings').once().returns(true);
mocks.adb.expects('isSettingsAppServiceRunningInForeground').once().returns(true);
mocks.adb.expects('getApiLevel').never();
mocks.adb.expects('grantPermissions').never();
await helpers.pushSettingsApp(adb);
mocks.adb.verify();
});
it('should not skip granting permissions if the app is already running on under API level 22 devices', async function () {
mocks.adb.expects('installOrUpgrade').once().returns(true);
mocks.adb.expects('processExists').once().returns(true);
mocks.adb.expects('isSettingsAppServiceRunningInForeground').once().returns(true);
mocks.adb.expects('getApiLevel').never();
mocks.adb.expects('grantPermissions').never();
await helpers.pushSettingsApp(adb);
mocks.adb.verify();
});
it('should launch settings app if it isnt running on over API level 24 devices', async function () {
mocks.adb.expects('installOrUpgrade').once().returns(true);
mocks.adb.expects('processExists').once().returns(false);
mocks.adb.expects('isSettingsAppServiceRunningInForeground').once().returns(false);
mocks.adb.expects('getApiLevel').once().returns(24);
mocks.adb.expects('requireRunningSettingsApp').once();
await helpers.pushSettingsApp(adb);
mocks.adb.verify();
});
it('should launch settings app if it isnt running on under API level 23 devices', async function () {
mocks.adb.expects('installOrUpgrade').once().returns(true);
mocks.adb.expects('processExists').once().returns(false);
mocks.adb.expects('isSettingsAppServiceRunningInForeground').once().returns(false);
mocks.adb.expects('getApiLevel').once().returns(23);
mocks.adb
.expects('grantPermissions')
Expand Down
Loading