UserTypeFactory: use method, not static final int
For certain mocking tests, usage of a static final int causes problems, since the constant sometimes happens to be evaluated first by a test fakes some of the values, resulting in a wrong constant for all subsequent tests in the suite. To fix this, we use a method, and recalculate the value each time. In real life, this is only 3 evaluations, which are very cheap, so this workaround is fine. For posterity, note that the without this cl, running the test atest UserManagerServiceMockedTest works fine, since the evaluated constant happens to be correct, but when run as part of a larger suite, say via atest FrameworksMockingServicesTests:com.android.server.pm the tests would fail due to an earlier test misinitializing the constant. Bug: 436331608 Flag: EXEMPT BUGFIX Test: atest FrameworksMockingServicesTests:com.android.server.pm Change-Id: I41ba1533397b979f48913e20d07af8cbac6a1386
Loading
Please register or sign in to comment