Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Subject config flag to avoid WindowManager bug #683

Merged
merged 2 commits into from
Apr 17, 2024

Conversation

mscwilson
Copy link
Contributor

For issue #657.

This bug occurs during tracker initialisation when a) an Android application context from a dependency injection framework is passed in, and b) the Android StrictMode rule detectIncorrectContextUse() is set for the app.

That rule is violated when creating Subject, in Subject.setDefaultScreenResolution(), because it uses a deprecated method, via WindowManager, to fetch the screen size. The resolution set there in Subject is added to the payload as the "res" property, which eventually becomes the "dvce_screenwidth/height" columns.

The current preferred way is DisplayManager or from the context.resources. We already use the context Resources to get the screen resolution for the mobile/platform context entity.

Unfortunately, WindowManager gives a different answer from DisplayManager/Resources. The old way includes the menu bar at the top of the screen but that's not included anymore. Changing how Subject fetches the size is therefore a breaking change.

This PR adds a new flag to SubjectConfiguration. When set to true (false is default), the default Subject screen size is obtained from the context Resources and WindowManager is not accessed - meaning no StrictMode violation.

Currently, the flag is set up just like the other Subject properties. This doesn't seem necessary since it's only used in Subject initialisation. SubjectController doesn't really need it, but it inherits from SubjectConfigurationInterface. Anyway, it's Friday evening and this fix works.

@mscwilson mscwilson requested a review from matus-tomlein April 12, 2024 19:06
Copy link
Contributor

@matus-tomlein matus-tomlein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

@mscwilson mscwilson force-pushed the bug/windowmanager_context branch 2 times, most recently from 1d4d50b to 80c33aa Compare April 15, 2024 12:30
@mscwilson mscwilson force-pushed the bug/windowmanager_context branch from f6e49ea to 9ad9ef8 Compare April 17, 2024 13:02
@mscwilson mscwilson merged commit 2529e16 into release/6.0.3 Apr 17, 2024
2 of 3 checks passed
@mscwilson mscwilson deleted the bug/windowmanager_context branch April 17, 2024 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants