diff --git a/nm-space/packages/device-server/src/internal/services/reset/android-reset.ts b/nm-space/packages/device-server/src/internal/services/reset/android-reset.ts index f2493f5ef..7f3b9dd3d 100644 --- a/nm-space/packages/device-server/src/internal/services/reset/android-reset.ts +++ b/nm-space/packages/device-server/src/internal/services/reset/android-reset.ts @@ -3,7 +3,6 @@ import { delay, filterAsync, loop, PrefixLogger, retry, stringify } from '@dogu- import { CheckTimer } from '@dogu-tech/node'; import semver from 'semver'; import { AppiumContextImpl } from '../../../appium/appium.context'; -import { env } from '../../../env'; import { AdbSerial, AppiumAdb } from '../../externals/index'; export interface AndroidResetInfo { lastResetTime: number; @@ -59,43 +58,32 @@ export class AndroidResetService { const { serial, logger } = this; await retry( async (): Promise => { - logger.info(`AndroidResetService.reset begin`, { serial, info }); - - if (env.DOGU_RUN_TYPE === 'local' && env.DOGU_DEVICE_SKIP_RESET_FOR_LOCAL) { - logger.info(`AndroidResetService.reset skipped for local`, { serial, info }); - } else { - await this.runReset(info, appiumAdb, appiumContext); + logger.info(`AndroidResetService.resetDevice begin`, { serial, info }); + try { + this._state = 'resetting'; + if (!this.isHarnessAvailable(info)) { + throw new Error(`AndroidResetService.resetDevice Android version must be 10 or higher. to use testharness, serial:${serial}. version:${info.version}`); + } + await this.check(`AndroidResetService.reset.enableTestharness`, this.adb.enableTestharness()); + } catch (e) { + await this.check(`AndroidResetService.reset.resetAccounts`, this.resetAccounts(appiumAdb, appiumContext)); + await this.check(`AndroidResetService.reset.runAppSettingsActivity`, this.adb.runActivity('android.settings.MANAGE_APPLICATIONS_SETTINGS')); + await this.check(`AndroidResetService.reset.resetSdcard`, this.adb.resetSdcard()); + await this.check(`AndroidResetService.reset.resetIMEList`, this.resetIMEList()); + await this.check(`AndroidResetService.reset.logcatClear`, this.adb.logcatClear()); + await this.check(`AndroidResetService.reset.resetPackages`, this.adb.resetPackages()); + await this.check(`AndroidResetService.reset.resetDirty`, this.resetDirty()); + await this.check(`AndroidResetService.reset.reboot`, this.adb.reboot()); + } finally { + this._state = null; } - - await this.check(`AndroidResetService.reset.reboot`, this.adb.reboot()); AndroidResetService.map.set(serial, { lastResetTime: Date.now() }); - this.logger.info(`AndroidResetService.reset end`, { serial, info }); + this.logger.info(`AndroidResetService.resetDevice end`, { serial, info }); }, { retryCount: 5, retryInterval: 1000, printable: new PrefixLogger(logger, 'AndroidResetService.reset') }, ); } - private async runReset(info: DeviceSystemInfo, appiumAdb: AppiumAdb, appiumContext: AppiumContextImpl): Promise { - const { serial } = this; - try { - this._state = 'resetting'; - if (!this.isHarnessAvailable(info)) { - throw new Error(`AndroidResetService.resetDevice Android version must be 10 or higher. to use testharness, serial:${serial}. version:${info.version}`); - } - await this.check(`AndroidResetService.reset.enableTestharness`, this.adb.enableTestharness()); - } catch (e) { - await this.check(`AndroidResetService.reset.resetAccounts`, this.resetAccounts(appiumAdb, appiumContext)); - await this.check(`AndroidResetService.reset.runAppSettingsActivity`, this.adb.runActivity('android.settings.MANAGE_APPLICATIONS_SETTINGS')); - await this.check(`AndroidResetService.reset.resetSdcard`, this.adb.resetSdcard()); - await this.check(`AndroidResetService.reset.resetIMEList`, this.resetIMEList()); - await this.check(`AndroidResetService.reset.logcatClear`, this.adb.logcatClear()); - await this.check(`AndroidResetService.reset.resetPackages`, this.adb.resetPackages()); - await this.check(`AndroidResetService.reset.resetDirty`, this.resetDirty()); - } finally { - this._state = null; - } - } - private isHarnessAvailable(systemInfo: DeviceSystemInfo): boolean { const version = semver.coerce(systemInfo.version); if (!version) { diff --git a/nm-space/packages/device-server/src/internal/services/reset/ios-reset.ts b/nm-space/packages/device-server/src/internal/services/reset/ios-reset.ts index f168d5069..35e5a5ce2 100644 --- a/nm-space/packages/device-server/src/internal/services/reset/ios-reset.ts +++ b/nm-space/packages/device-server/src/internal/services/reset/ios-reset.ts @@ -3,7 +3,6 @@ import { delay, filterAsync, loop, loopTime, PrefixLogger, Repeat, retry, TimeOp import { CheckTimer } from '@dogu-tech/node'; import { boxBox } from 'intersects'; import { AppiumContextImpl, WDIOElement } from '../../../appium/appium.context'; -import { env } from '../../../env'; import { IosDriver } from '../../driver/ios-driver'; import { IdeviceInstaller } from '../../externals/cli/ideviceinstaller'; import { WebdriverAgentProcess } from '../../externals/cli/webdriver-agent-process'; @@ -235,6 +234,8 @@ export class IosResetService { if (!driver) { throw new Error(`IosResetService.reset driver is null`); } + const iosDriver = new IosWebDriver(driver, wda, iosWebDriverInfo, logger); + const helper = new IosResetHelper(iosDriver); await usingAsnyc( { @@ -249,11 +250,22 @@ export class IosResetService { }, }, async () => { - if (env.DOGU_RUN_TYPE === 'local' && env.DOGU_DEVICE_SKIP_RESET_FOR_LOCAL) { - logger.info(`IosResetService.reset skipped for local`, { serial }); - } else { - await this.runReset(appiumContext, wda); - } + await iosDriver.homeAndDismissAlert(); + await this.check('IosResetService.reset.removeSystemApps', this.removeSystemApps()); + await iosDriver.homeAndDismissAlert(); + await this.check('IosResetService.reset.logoutAppleAccount', this.logoutAppleAccount(iosDriver)); + await this.check('IosResetService.reset.clearSafariCache', this.clearSafariCache(iosDriver)); + await this.check('IosResetService.reset.clearPhotoImages', this.clearPhotoImages(iosDriver)); + await this.check('IosResetService.reset.clearPhotoAlbums', this.clearPhotoAlbums(iosDriver)); + await this.check('IosResetService.reset.clearPhotosRecentlyDeleted', this.clearPhotosRecentlyDeleted(iosDriver)); + await this.check('IosResetService.reset.clearPhotosSuggestionAndFeedbacks', this.clearPhotosSuggestionAndFeedbacks(iosDriver)); + await this.check('IosResetService.reset.clearFilesOnMyiPhone', this.clearFilesOnMyiPhone(iosDriver, helper)); + await this.check('IosResetService.reset.clearFilesTags', this.clearFilesTags(iosDriver, helper)); + await this.check('IosResetService.reset.clearFilesRecentlyDeleted', this.clearFilesRecentlyDeleted(iosDriver, helper)); + await this.check('IosResetService.reset.resetSettings', this.resetSettings(iosDriver)); + await this.check('IosResetService.reset.removeWidgets', this.removeWidgets(iosDriver)); + await this.check('IosResetService.reset.clearNotifications', this.clearNotifications(iosDriver)); + await this.check('IosResetService.reset.removeUserApps', this.removeUserApps()); // last step because this removes appium await this.check( 'IosResetService.reset.restart', retry(async (): Promise => await IdeviceDiagnostics.restart(serial, logger), { retryCount: 5, retryInterval: 1000 }).catch((e) => { @@ -269,29 +281,6 @@ export class IosResetService { ); } - private async runReset(appiumContext: AppiumContextImpl, wda: WebdriverAgentProcess): Promise { - const { serial, iosWebDriverInfo, logger } = this; - const iosDriver = new IosWebDriver(driver, wda, iosWebDriverInfo, logger); - const helper = new IosResetHelper(iosDriver); - - await iosDriver.homeAndDismissAlert(); - await this.check('IosResetService.reset.removeSystemApps', this.removeSystemApps()); - await iosDriver.homeAndDismissAlert(); - await this.check('IosResetService.reset.logoutAppleAccount', this.logoutAppleAccount(iosDriver)); - await this.check('IosResetService.reset.clearSafariCache', this.clearSafariCache(iosDriver)); - await this.check('IosResetService.reset.clearPhotoImages', this.clearPhotoImages(iosDriver)); - await this.check('IosResetService.reset.clearPhotoAlbums', this.clearPhotoAlbums(iosDriver)); - await this.check('IosResetService.reset.clearPhotosRecentlyDeleted', this.clearPhotosRecentlyDeleted(iosDriver)); - await this.check('IosResetService.reset.clearPhotosSuggestionAndFeedbacks', this.clearPhotosSuggestionAndFeedbacks(iosDriver)); - await this.check('IosResetService.reset.clearFilesOnMyiPhone', this.clearFilesOnMyiPhone(iosDriver, helper)); - await this.check('IosResetService.reset.clearFilesTags', this.clearFilesTags(iosDriver, helper)); - await this.check('IosResetService.reset.clearFilesRecentlyDeleted', this.clearFilesRecentlyDeleted(iosDriver, helper)); - await this.check('IosResetService.reset.resetSettings', this.resetSettings(iosDriver)); - await this.check('IosResetService.reset.removeWidgets', this.removeWidgets(iosDriver)); - await this.check('IosResetService.reset.clearNotifications', this.clearNotifications(iosDriver)); - await this.check('IosResetService.reset.removeUserApps', this.removeUserApps()); // last step because this removes appium - } - private async removeSystemApps(): Promise { const installer = new IdeviceInstaller(this.serial, this.logger); const uninstallApps = BlockAppList.filter((item) => item.uninstall).map((item) => item.bundleId); diff --git a/nm-space/packages/dogu-agent-core/src/app/child/device-server/child.ts b/nm-space/packages/dogu-agent-core/src/app/child/device-server/child.ts index af697cda6..a529c368f 100644 --- a/nm-space/packages/dogu-agent-core/src/app/child/device-server/child.ts +++ b/nm-space/packages/dogu-agent-core/src/app/child/device-server/child.ts @@ -44,7 +44,6 @@ export class DeviceServerChild implements Child { const DOGU_LINUX_DEVICE_SERIAL = appConfigService.getOrDefault('DOGU_LINUX_DEVICE_SERIAL', ''); const DOGU_WIFI_SSID = appConfigService.getOrDefault('DOGU_WIFI_SSID', ''); const DOGU_WIFI_PASSWORD = appConfigService.getOrDefault('DOGU_WIFI_PASSWORD', ''); - const DOGU_DEVICE_SKIP_RESET_FOR_LOCAL = appConfigService.getOrDefault('DOGU_DEVICE_SKIP_RESET_FOR_LOCAL', false); const DOGU_USE_SENTRY = this.featureConfigService.get('useSentry'); if (!isValidDoguRunType(DOGU_RUN_TYPE)) { @@ -81,7 +80,6 @@ export class DeviceServerChild implements Child { DOGU_WIFI_PASSWORD, DOGU_USE_SENTRY: DOGU_USE_SENTRY ? 'true' : 'false', DOGU_SECRET_INITIAL_ADMIN_TOKEN: this.authService.adminToken.value, - DOGU_DEVICE_SKIP_RESET_FOR_LOCAL: DOGU_DEVICE_SKIP_RESET_FOR_LOCAL ? 'true' : 'false', }, }, childLogger: this.logger, diff --git a/nm-space/packages/dogu-agent-core/src/shares/app-config.ts b/nm-space/packages/dogu-agent-core/src/shares/app-config.ts index 1a0a76c89..b1f90de4c 100644 --- a/nm-space/packages/dogu-agent-core/src/shares/app-config.ts +++ b/nm-space/packages/dogu-agent-core/src/shares/app-config.ts @@ -47,9 +47,6 @@ export const AppConfigSchema = { DOGU_WIFI_PASSWORD: { type: 'string', }, - DOGU_DEVICE_SKIP_RESET_FOR_LOCAL: { - type: 'boolean', - }, is_show_devui: { type: 'boolean', }, diff --git a/nm-space/packages/dost-children/src/envs/device-server.ts b/nm-space/packages/dost-children/src/envs/device-server.ts index b74cd0b8a..85f3c2fcf 100644 --- a/nm-space/packages/dost-children/src/envs/device-server.ts +++ b/nm-space/packages/dost-children/src/envs/device-server.ts @@ -62,8 +62,4 @@ export class DeviceServerEnv extends PreloadDeviceServerEnv { @IsFilledString() DOGU_SECRET_INITIAL_ADMIN_TOKEN = ''; - - @IsBoolean() - @TransformBooleanString() - DOGU_DEVICE_SKIP_RESET_FOR_LOCAL = false; }