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

feat: Add Wear OS Interface for GPSTest #605

Merged
merged 17 commits into from
Jan 10, 2023
Merged

Conversation

adaext
Copy link
Contributor

@adaext adaext commented Oct 8, 2022

A Wear OS Interface Draft.

Closes #560

@CLAassistant
Copy link

CLAassistant commented Oct 8, 2022

CLA assistant check
All committers have signed the CLA.

gpswearos/build.gradle Outdated Show resolved Hide resolved
gpswearos/build.gradle Outdated Show resolved Hide resolved
build.gradle Outdated Show resolved Hide resolved
build.gradle Outdated Show resolved Hide resolved
gpswearos/build.gradle Outdated Show resolved Hide resolved
gpswearos/build.gradle Outdated Show resolved Hide resolved
@barbeau barbeau marked this pull request as draft October 11, 2022 14:21
gpswearos/build.gradle Outdated Show resolved Hide resolved
@adaext adaext marked this pull request as ready for review October 17, 2022 04:05
@adaext adaext marked this pull request as draft October 17, 2022 04:07
GPSTest/build.gradle Outdated Show resolved Hide resolved
wear/build.gradle Outdated Show resolved Hide resolved
library/build.gradle Outdated Show resolved Hide resolved
@barbeau
Copy link
Owner

barbeau commented Dec 1, 2022

In the latest version, looks like you were missing the Application name entry in the manifest. I added that and when launching you now see the dummy lat/lon values.

I also went ahead and added the Flows to the wear Activity. This should be very close to a working state in terms of listening to the GnssStatus and Location updates, although it needs some more debugging - I still don't see the status updates on the screen.

Here's a branch with the changes:
https://github.com/barbeau/gpstest/tree/wear-fix-application-manifest

...and the commit:
3d440f2

@adaext
Copy link
Contributor Author

adaext commented Dec 7, 2022

In the latest version, looks like you were missing the Application name entry in the manifest. I added that and when launching you now see the dummy lat/lon values.

I also went ahead and added the Flows to the wear Activity. This should be very close to a working state in terms of listening to the GnssStatus and Location updates, although it needs some more debugging - I still don't see the status updates on the screen.

Here's a branch with the changes: https://github.com/barbeau/gpstest/tree/wear-fix-application-manifest

...and the commit: 3d440f2

In the latest version, looks like you were missing the Application name entry in the manifest. I added that and when launching you now see the dummy lat/lon values.

I also went ahead and added the Flows to the wear Activity. This should be very close to a working state in terms of listening to the GnssStatus and Location updates, although it needs some more debugging - I still don't see the status updates on the screen.

Here's a branch with the changes: https://github.com/barbeau/gpstest/tree/wear-fix-application-manifest

...and the commit: 3d440f2

Thank you! It did work. The status doesn't update on the screen because the gnssStatuses is empty. It was created by this val gnssStatuses: List<SatelliteStatus> by signalInfoViewModel.filteredGnssStatuses.observeAsState(emptyList()). I've studied all the links you shared with me and searched from the internet but still don't know why it failed to observe the LiveData.

@adaext
Copy link
Contributor Author

adaext commented Dec 7, 2022

In the latest version, looks like you were missing the Application name entry in the manifest. I added that and when launching you now see the dummy lat/lon values.

I also went ahead and added the Flows to the wear Activity. This should be very close to a working state in terms of listening to the GnssStatus and Location updates, although it needs some more debugging - I still don't see the status updates on the screen.

Here's a branch with the changes: https://github.com/barbeau/gpstest/tree/wear-fix-application-manifest

...and the commit: 3d440f2
I guess it may be because the gnssStatuses list should be initialized by real GNSS data which the simulator couldn't provide. Could you please help me to test the latest commit on a real device? I don't have an electronic watch.

@barbeau
Copy link
Owner

barbeau commented Dec 9, 2022

I guess it may be because the gnssStatuses list should be initialized by real GNSS data which the simulator couldn't provide. Could you please help me to test the latest commit on a real device? I don't have an electronic watch.

@adaext I took a closer look, and there is actually an exception being thrown by the SharedLocationManager. I added a Log statement in the try/catch block:

        try {
            locationManager.requestLocationUpdates(
                LocationManager.GPS_PROVIDER,
                minTimeMillis(context, prefs),
                minDistance(context, prefs),
                callback,
                context.mainLooper
            )
        } catch (e: Exception) {
            Log.e(TAG, "Exception in location flow: $e")
            close(e) // in case of exception, close the Flow
        }

...and here's what is says:

Exception in location flow: java.lang.SecurityException: uid 10080 does not have android.permission.ACCESS_COARSE_LOCATION or android.permission.ACCESS_FINE_LOCATION.

So you just need to ask the user for location permissions prior to calling gpsStart() in the MainActivity. You should be able to reproduce this on the Wear emulator and still get location updates there. See the app MainActivity for code to ask for permissions, although you'll need to double-check that this is the same on Wear.

Also, could you add this type of Log statements in any existing try/catch block in all the Shared*Manager classes so we can easily see when a problem happens?

@barbeau barbeau marked this pull request as ready for review January 9, 2023 14:42
@barbeau barbeau changed the title Add Wear OS Interface for GPSTest feat: Add Wear OS Interface for GPSTest Jan 9, 2023
@barbeau barbeau merged commit 7f56a0e into barbeau:master Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Wear OS for smartwatch info
3 participants