Background
EndpointInfoFactory currently calls deviceUtils.getDeviceId() and
deviceUtils.getDeviceName() directly from its property initializers, so
the calls run as soon as Koin instantiates the factory.
The commonMain source set is copied into the CrossPaste mobile project.
On Android, DeviceUtils.getDeviceId() reads Settings.Secure.ANDROID_ID,
and the domestic (Chinese app store) flavor must not read hardware
identifiers before the user accepts the privacy policy.
Proposal
Convert deviceName and deviceId in EndpointInfoFactory to by lazy
so the values are computed on first access inside createEndpointInfo()
instead of at construction time.
Desktop impact
None observable.
EndpointInfoFactory is only consumed once the network server is
ready, and createEndpointInfo() is the only reader of these fields.
- Desktop
getDeviceId() does not touch hardware identifiers.
LazyThreadSafetyMode.SYNCHRONIZED (the default for by lazy)
preserves the once-only initialization guarantee that property
initializers gave us.
Background
EndpointInfoFactorycurrently callsdeviceUtils.getDeviceId()anddeviceUtils.getDeviceName()directly from its property initializers, sothe calls run as soon as Koin instantiates the factory.
The
commonMainsource set is copied into the CrossPaste mobile project.On Android,
DeviceUtils.getDeviceId()readsSettings.Secure.ANDROID_ID,and the domestic (Chinese app store) flavor must not read hardware
identifiers before the user accepts the privacy policy.
Proposal
Convert
deviceNameanddeviceIdinEndpointInfoFactorytoby lazyso the values are computed on first access inside
createEndpointInfo()instead of at construction time.
Desktop impact
None observable.
EndpointInfoFactoryis only consumed once the network server isready, and
createEndpointInfo()is the only reader of these fields.getDeviceId()does not touch hardware identifiers.LazyThreadSafetyMode.SYNCHRONIZED(the default forby lazy)preserves the once-only initialization guarantee that property
initializers gave us.