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

TelemetryLocationEnabler Null Bug #156

Merged
merged 4 commits into from
Jun 4, 2018

Conversation

electrostat
Copy link
Contributor

Under certain circumstances, TelemetryLocationEnabler is null. Add in check to initialize, before being used.

- initialize telemetryLocationEnabler if it is null at this point
@electrostat electrostat self-assigned this May 25, 2018
Copy link
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

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

Noting here that this PR fixes #147

Other than 👇 looks good to me.

@@ -239,6 +239,10 @@ private void unregisterTelemetryReceiver() {

private void disableTelemetryLocationState() {
if (isLocationEnablerFromPreferences) {
if (telemetryLocationEnabler == null) {
telemetryLocationEnabler = new TelemetryLocationEnabler(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you extract a Lazy initialization method as suggested here #147 (comment)?

We could extract a Lazy initialization method and use it accordingly in both call sites (when enabling and disabling).

- extract out check logic into separate method
- include method within `enableTelemetryLocationState` to prevetn duplicate code
Copy link
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

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

Minor comment not blocking the PR.

@@ -253,6 +250,12 @@ private void checkApplicationContext() {
}
}

private void checkLocationEnabler() {
Copy link
Contributor

Choose a reason for hiding this comment

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

As we're creating a new instance of TelemetryLocationEnabler if not already created, what about calling this method createLocationEnabler instead?

- rename method to `createLocationEnabler`
@electrostat electrostat merged commit a682c43 into master Jun 4, 2018
@electrostat electrostat deleted the aa-enabler-initialization-issue branch June 4, 2018 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants