Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3daf4890 authored by Eric Lin's avatar Eric Lin
Browse files

Fix WindowManagerServiceTests fail on Android Car.

The currentUserId is not 0 on Android Car environment. Get the current
user ID from the ActivityManager instead of assuming the default value.

Bug: 356738240
Change-Id: I5a114ec58d4e163f7058bb52be28b5b64ab7e68b
Test: source build/envsetup.sh; lunch cf_x86_64_auto-trunk_staging-userdebug; atest WmTests:WindowManagerServiceTests
Flag: com.android.window.flags.condense_configuration_change_for_simple_mode
parent 16d2494a
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.app.ActivityManager;
import android.app.ActivityThread;
import android.app.IApplicationThread;
import android.content.pm.ActivityInfo;
@@ -1522,7 +1523,7 @@ public class WindowManagerServiceTests extends WindowTestsBase {
    @EnableFlags(Flags.FLAG_CONDENSE_CONFIGURATION_CHANGE_FOR_SIMPLE_MODE)
    public void setConfigurationChangeSettingsForUser_createsFromParcel_callsSettingImpl()
            throws Settings.SettingNotFoundException {
        final int userId = 0;
        final int currentUserId = ActivityManager.getCurrentUser();
        final int forcedDensity = 400;
        final float forcedFontScaleFactor = 1.15f;
        final Parcelable.Creator<ConfigurationChangeSetting> creator =
@@ -1536,10 +1537,10 @@ public class WindowManagerServiceTests extends WindowTestsBase {

        mWm.setConfigurationChangeSettingsForUser(settings, UserHandle.USER_CURRENT);

        verify(mDisplayContent).setForcedDensity(forcedDensity, userId);
        verify(mDisplayContent).setForcedDensity(forcedDensity, currentUserId);
        assertEquals(forcedFontScaleFactor, Settings.System.getFloat(
                mContext.getContentResolver(), Settings.System.FONT_SCALE), 0.1f /* delta */);
        verify(mAtm).updateFontScaleIfNeeded(userId);
        verify(mAtm).updateFontScaleIfNeeded(currentUserId);
    }

    @Test