Skip to content
Closed
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
5 changes: 5 additions & 0 deletions .changeset/session-emulator-animations.md
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ describe(createStartAgentDeviceSessionBuildFunction, () => {
lcdWidth: 720,
lcdHeight: 1600,
lcdDensity: 300,
adjustAnimationScale: false,
})
);
expect(downloadBuildAsync).toHaveBeenCalledWith(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 13 additions & 1 deletion packages/build-tools/src/steps/functions/startAndroidEmulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -201,6 +204,7 @@ export async function startAndroidEmulatorAsync({
lcdWidth,
lcdHeight,
lcdDensity,
adjustAnimationScale = true,
logcatDirectory,
env,
logger,
Expand All @@ -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;
Expand All @@ -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.'
);
Expand Down
Loading