Skip to content

Commit

Permalink
fix: io.appium.settings process check with isSettingsAppServiceRunnin…
Browse files Browse the repository at this point in the history
…gInForeground (#895)

* fix: io.appium.settings starts every new session

* chore: revert auto lint fixes

* Update android.ts

* chore: bump appium-adb

* fix: revert lint fixes to reduce diff

* test: update test

* test: update test
  • Loading branch information
KazuCocoa authored Jan 9, 2024
1 parent 6498a6f commit b9082c5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
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. ` +
`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

0 comments on commit b9082c5

Please sign in to comment.