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.
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
, inSubject.setDefaultScreenResolution()
, because it uses a deprecated method, viaWindowManager
, 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 thecontext.resources
. We already use the context Resources to get the screen resolution for the mobile/platform context entity.Unfortunately,
WindowManager
gives a different answer fromDisplayManager
/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 andWindowManager
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 fromSubjectConfigurationInterface
. Anyway, it's Friday evening and this fix works.