-
Notifications
You must be signed in to change notification settings - Fork 23
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
Update to Android 10 #131
Comments
It is highly unlikely that I'll be maintaining this project going forward. Would you like to take it over? I am not sure how that is done on GitHub but I am sure we could figure it out. |
You can transfer ownership of a repository. |
Thank you for the honor but I doubt I am worthy. I have only just started to play with Android app development and this is the second app I even managed to compile. I don't really have the capacity to manage such a project on my own. But I will keep tinkering for a while and try to get it working properly on Android 10. Note that you can archive this project any time if you wish. If you do than I will detach my fork and rename it so it is no longer connected to your "org.fitchfamily" domain. Maybe you could donate this project to microg if they want it, then multiple people can work on it. They already have 4 backends and then I can just offer my contribution there. This would be the best solution I think. |
@ploink I would like to test your updated build, but I cannot see any new releases in https://github.com/ploink/Local-GSM-Backend/releases Thank you in advance |
@baldrianbandit Sorry about that. I just uploaded a new release. This one should work. |
@ploink I'm testing v1.4.23-ploink right now. It works awesomely fine once set up following your instructions. Great work ! :D |
Unfortunately, my attempts did not lead to a working network location, yet. I Thereby which show up repeatedly while Osmand is active. It does not receive a network location. |
@baldrianbandit I am not sure about the other lines, but you may want to look for "ProviderRequest[ON interval...." lines and "using autoUpdate=true autoTime=". I have added a debug apk to the releases. This one should give you a lot more info if you filter/search logcat for "gsmloc". You can simply install it as an update over the release version. Disable, then re-enable the backend in microg's "configure location backends" to get it going. You could use my app https://github.com/ploink/Hellocation for testing if you like. |
Thanks a lot. 1.4.23-debug is much more chatty. Also, Hellocation is very appreciated - it's good to clearly differentiate between gps and network location. But, in the end, Hellocation does not get any network location updates using 1.4.23-debug as a provider. Here is what gsmloc logs on my LineageOS 17.1 device:
|
Looks like you have been bitten by the 0-prefix MNC bug in Android 9 and possibly 10. I can fix that but it will take some time. Gsm-backend uses UnifiedNlpApi but has its own code for fetching cell info. |
Yeah, but isn't the 0-prefix MNC bug is related to IchnaeaBackend, only? @domkrm even published a fixed build (see below in the linked issue). But I prefer a network location service that doesn't query my location info at any online database. The point is, reverting back to LocalGSMBackend 1.4.22 makes my network location work again. But I cannot find any hint in logcat that shows me why it isn't working when using 1.4.23-ploink. You are right, the MNC=-1 looks suspicious. But why should 1.4.22 not suffer from the same behaviour? (Although I cannot see, because it's less chatty than your build) |
It is a bug in Android. The Android getCellIdentity() method returns "mMcc=null" so the value is simply not available. It would affect all apps that try this. What domkrm's fix does, it calls getNetworkOperator() when getCellIdentity() does not return a valid MNC. I am not sure though how that deals with multi-sim situations. If the old v1.4.22 does give the MNC, then that is interesting. It uses the now deprecated getCellLocation() and getNeighboringCellInfo(). These may not have the MNC bug. Problem is, they are no longer available when compiling for Android 10. I would have to look into it further and see what is the best way to work around the bug and still support multi-sim properly. |
@baldrianbandit You may try v1.4.24-ploink. It includes the workaround. |
Wow @ploink. Hellocation instantly get's a location fix via network using 1.4.24-ploink. Thanks a lot.
Is that part of the workaround -- do you assign a fixed MNC? |
I am glad it works. If you look at TelephonyHelper.java there is this bit of code: if (mcc <= 0) continue;
// Uncomment to simulate 0-prefix MNC bug
//if (DEBUG) mnc = -1;
Log.i(TAG, "CellInfo: " + tech + " MCC=" + mcc + " MNC="
+ mnc + " CID=" + cid + " LAC=" + lac + " dBm=" + Math.round(dBm));
if (cid == CellInfo.UNAVAILABLE || lac == CellInfo.UNAVAILABLE
|| mcc < 200 || mcc == 999) continue;
// Workaround for 0-prefix MNC bug
if (mnc < 0 && inputCellInfo.isRegistered()) {
mnc = toInteger(tm.getNetworkOperator().substring(3));
Log.w(TAG, "Fixed MNC=" + mnc);
} In plain english: If MCC, CID & LAC are good and MNC is missing, then use your currently registered network operator MNC code. The fix is not perfect. You only use data from the registered cell so you never get an average of multiple cell tower locations. This is because you cannot be certain the non-registered cells have the same MNC. But this is not much of a problem as most phones rarely get that info for non-registered cell towers. EDIT: According to This answer, you only get neighboring(non-registered) cell info when you are on GSM. I just tried forcing my phone to GSM and indeed, I now pick up 6 cell towers in my area with valid mcc/mnc/lac/cid and get a much more accurate location. It gets more complicated when you use multiple SIM cards and are registered to more than one cell tower at the same time and they are from different providers. Then you may get the wrong MNC code. |
My network based location when using gsmloc has always been a little blurred, as if the service knew the current cell, only. I find that okay since it becomes accurate as soon as I get an additional GPS fix. As you mentioned the now deprecated getNeighboringCellInfo() - I think it never worked on my device, thus it also seems to suffer from the 0-prefix bug. In TelephonyHelper the MNC is assign by
If I had a MNC of '02' (str), it would become '2' (int) and thus, it would match my MNC in a db query no more. Do you think the root of the whole issue is Android handling MNCs as integers (or having 0-prefixed numbers at all)? |
The database is in integers. With your phone/rom "id.getMncString()" always returns null.Theoretically MNC 02 could be different from 002, but that confusion is avoided when assigning MNC's. I forgot where I read that, but for example this list also uses integers. |
Sorry for being so ignorant, but having dectected that the local cell based location on LOS 17.1 with microg didn't work, I came acoss this thread .. |
@Chris56
Correct, but also in microG setting:
You do not need to disable battery optimization for GSM Location service. It should run just fine with a recent MicroG version. |
I am using (or try to use) this with LOS17.1 and microG. Downloaded from FDroid (1.4.23). The hellocation app does only show No last known locatipon (for any type). May I ask what is difference between passive and network? After once a GPS position is found, it repeats that also in LastKnow when selecting "passive". Is this the expected behaviour? The appleWifi Backend on the other hand returns just one! passive position after some seconds (although interval is set to 0". |
@starbrights API 29 = Android 10.
|
I have handed off this project to @Devee. The new official repository for this work is a now at https://gitlab.com/deveee/Local-GSM-Backend. The current f-droid version of this seems to be built based on the version at the new maintainer's repository so if you are using that version there should be no issue with the apk signature. If this is still an issue, please open it on the new repository with the new maintainer. |
I can confirm the 1.4.25-ploink works! While I think latest FDroid vesion not. For me it is hard to see is it microG, backend, app, OS or my stupidness that it fails. Lot of things can fail and I'm not an expert. Imho it would be good to bring back the energy saving location service as in Android 9. At least as an option in LOS. |
@starbrights I have to fix one crash that happens on old android version after updating the project to android 10 and then I think that it can be updated on fdroid. |
Thank you and of course @ploink for all that. |
@starbrights wrote:
Copying my reply to: microg/GmsCore#1196 about this here to keep everyone in the loop: I'm seeing similar network location timing issues on a lineage-17.1 + latest micro-G config. I've run several tests and the amount of time between updates (and the amount of time when only a "stale" location is available) seems to depend on which Nlp providers are used:
If you have no objection against using the Apple Wifi webAPIs (and thus sending some data to Apple) then using the Apple Wifi NLP provider from F-Droid is a good workaround for the timings issues. At least this seems to work well for me. |
A quick update on this, I just retried this on a fresh install and for the apple backend to work properly I also need to disable the "throttle wifi scanning" option under developer options and then disable + re-enable the apple wifi backend in the microg location settings. Without this the apple backend was behaving quite similar to the mozilla NLP (IchnaeaNlpBackend) version 1.3.3 case, where Networklocation works with 5 seconds ok + 10 seconds stale data. Unfortunately disabling "throttle wifi scanning" does not help for the 1.3.3 mozilla NLP backend. |
I recently upgraded to Android 10 and GSMbackend does not work reliably. When I disable/enable the backend it may work briefly and then stop again.
Part of it may be related to this issue with microg but I think there is more to it. Even with android 9, two of my apps that only use coarse location rarely get a location while Osmand does most of the time.
So I forked the project and tried to update it. At first it would not build with Android studio 3.5.3, but I managed to fix that by updating gradle and some dependencies. I managed to get it up to SDK28 (Android 9). Then I converted to AndroidX (which is required for SDK29). The problem with SDK29 (Android 10) is that method getNeighboringCellInfo() is deprecated and no longer available. Even when I target SDK28, the method does not return any data on the device. Code changes are needed to fix that.
I published two apk's from the updated source if anyone wants to try. For me the debug version actually works much better on A10, about the same as it did on A9. It would be interesting to figure out why.
Any comments appreciated.
The text was updated successfully, but these errors were encountered: