diff --git a/.changeset/session-emulator-animations.md b/.changeset/session-emulator-animations.md new file mode 100644 index 0000000000..2257773c3b --- /dev/null +++ b/.changeset/session-emulator-animations.md @@ -0,0 +1,5 @@ +--- +'@expo/build-tools': patch +--- + +Keep the default Android animation scales on emulators that device run sessions start, so Reduce motion shows the real device default; builds and tests still disable animations. diff --git a/packages/build-tools/src/steps/functions/__tests__/startAgentDeviceSession.test.ts b/packages/build-tools/src/steps/functions/__tests__/startAgentDeviceSession.test.ts index 15d01dd6c8..f275015f49 100644 --- a/packages/build-tools/src/steps/functions/__tests__/startAgentDeviceSession.test.ts +++ b/packages/build-tools/src/steps/functions/__tests__/startAgentDeviceSession.test.ts @@ -431,6 +431,7 @@ describe(createStartAgentDeviceSessionBuildFunction, () => { lcdWidth: 720, lcdHeight: 1600, lcdDensity: 300, + adjustAnimationScale: false, }) ); expect(downloadBuildAsync).toHaveBeenCalledWith( diff --git a/packages/build-tools/src/steps/functions/__tests__/startAndroidEmulator.test.ts b/packages/build-tools/src/steps/functions/__tests__/startAndroidEmulator.test.ts index b1657899b1..bf140646b7 100644 --- a/packages/build-tools/src/steps/functions/__tests__/startAndroidEmulator.test.ts +++ b/packages/build-tools/src/steps/functions/__tests__/startAndroidEmulator.test.ts @@ -377,6 +377,23 @@ describe(createStartAndroidEmulatorBuildFunction, () => { expect(mockedAndroidUtils.disableWindowAndTransitionAnimationsAsync).not.toHaveBeenCalled(); }); + it('disables animations outside a device run session', async () => { + await createStep().executeAsync(); + + expect(mockedAndroidUtils.disableWindowAndTransitionAnimationsAsync).toHaveBeenCalledWith( + expect.objectContaining({ serialId: 'emulator-default' }) + ); + }); + + it('keeps the default animation scales in a device run session', async () => { + const step = createStep({ count: 2 }, { DEVICE_RUN_SESSION_ID: 'session-id' }); + + await step.executeAsync(); + + expect(mockedAndroidUtils.waitForReadyAsync).toHaveBeenCalledTimes(3); + expect(mockedAndroidUtils.disableWindowAndTransitionAnimationsAsync).not.toHaveBeenCalled(); + }); + it('fails early on Linux when emulator host support check fails', async () => { mockedSpawn.mockRejectedValueOnce(new Error('accel check failed') as any); diff --git a/packages/build-tools/src/steps/functions/startAgentDeviceSession.ts b/packages/build-tools/src/steps/functions/startAgentDeviceSession.ts index a2cc2535de..52f555a40b 100644 --- a/packages/build-tools/src/steps/functions/startAgentDeviceSession.ts +++ b/packages/build-tools/src/steps/functions/startAgentDeviceSession.ts @@ -213,6 +213,8 @@ export function createStartAgentDeviceSessionBuildFunction(ctx: CustomBuildConte lcdWidth: inputs.lcd_width.value as number | undefined, lcdHeight: inputs.lcd_height.value as number | undefined, lcdDensity: inputs.lcd_density.value as number | undefined, + // Keep Android's default animation scales, so the session shows the real device. + adjustAnimationScale: false, logcatDirectory, env, logger: taskLogger, diff --git a/packages/build-tools/src/steps/functions/startAndroidEmulator.ts b/packages/build-tools/src/steps/functions/startAndroidEmulator.ts index 2c5764c6cc..7972b10f6c 100644 --- a/packages/build-tools/src/steps/functions/startAndroidEmulator.ts +++ b/packages/build-tools/src/steps/functions/startAndroidEmulator.ts @@ -94,6 +94,9 @@ export function createStartAndroidEmulatorBuildFunction(): BuildFunction { lcdWidth: inputs.lcd_width.value as number | undefined, lcdHeight: inputs.lcd_height.value as number | undefined, lcdDensity: inputs.lcd_density.value as number | undefined, + // Device run sessions show the device to a person, so they keep Android's default + // animation scales. Only test and build jobs disable animations. + adjustAnimationScale: !env.DEVICE_RUN_SESSION_ID, logcatDirectory, env, logger, @@ -201,6 +204,7 @@ export async function startAndroidEmulatorAsync({ lcdWidth, lcdHeight, lcdDensity, + adjustAnimationScale = true, logcatDirectory, env, logger, @@ -211,6 +215,11 @@ export async function startAndroidEmulatorAsync({ lcdWidth?: number; lcdHeight?: number; lcdDensity?: number; + /** + * Set the window and transition animation scales to 0 after boot. Defaults to true. + * $ANDROID_EMULATOR_ADJUST_ANIMATION_SCALE can still turn the adjustment off. + */ + adjustAnimationScale?: boolean; logcatDirectory: string; env: BuildStepEnv; logger: bunyan; @@ -237,10 +246,13 @@ export async function startAndroidEmulatorAsync({ } const shouldAdjustAnimationScale = + adjustAnimationScale && env.ANDROID_EMULATOR_ADJUST_ANIMATION_SCALE !== 'false' && env.ANDROID_EMULATOR_ADJUST_ANIMATION_SCALE !== '0'; - if (!shouldAdjustAnimationScale) { + if (!adjustAnimationScale) { + logger.info('Keeping the default Android emulator animation scales.'); + } else if (!shouldAdjustAnimationScale) { logger.info( 'Skipping Android emulator animation scale adjustments because $ANDROID_EMULATOR_ADJUST_ANIMATION_SCALE is disabled.' );