GithubHelp home page GithubHelp logo

microg / applewifinlpbackend Goto Github PK

View Code? Open in Web Editor NEW
74.0 16.0 15.0 207 KB

UnifiedNlp Backend that uses Apple's service to resolve wifi locations. Location calculation is done onboard and wifi locations are cached to minimize data usage.

License: Apache License 2.0

Java 100.00%
unifiednlp microg android java android-app geolocation apple

applewifinlpbackend's Introduction

AppleWifiNlpBackend

UnifiedNlp backend that uses Apple's service to resolve wifi locations.

Location calculation is done onboard and wifi locations are cached to minimize data usage.

Used libraries

License

Copyright (C) 2013-2018 microG Project Team

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

The launcher icon (res/drawable-*/ic_launcher.png) is created using the Launcher Icon Generator from Android Asset Studio and thus licensed under CC BY 3.0.

applewifinlpbackend's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

applewifinlpbackend's Issues

locationCompatibleWithClass() too inclusive?

Because locationCompatibleWithClass() returns true if any AP currently in a class is close to the AP being checked, wifi APs spread out with spacing just under MAX_WIFI_RADIUS may result a set of APs that could be kilometers apart. Perhaps locationCompatibleWithClass() should only return true if the new location is within the desired radius of ALL the APs currently in the class rather than just one of them.

Not sure what combineClasses() is/was supposed to do but I suspect that if you create one class for every AP before actually doing the current work in divideInClasses that you would end up with one of the results being optimal. There would, of course, be many classes with duplicate members but selecting any one of the duplicates should not be an issue. Worst case with N APs would be N classes each with N members. I suspect that N is usually << 100, probably on the order of 10, so it should not be too big a memory or processing load.

Add caching configuration

It's not entirely clear for me as an user how the cache works. I keep seeing data usage even for places that should be completely cached by now. How long is location data cached for?

I propose that the caching duration be configurable. This way someone can
a) Figure out how long the cache duration is
b) Modify it to balance privacy and up-to-date-ness

:)

(btw, it is impressive how much dedication and polish is flowing into microg. Thank you for making this!)

Read phone state/identity permission gets added

The permission is added despite it not being defined in the manifest.

Over at F-Droid, a dev suspects that it gets added during build because a very old SDK is targeted. Seems kinda weird to me.

Could probably do without that permission (The 1.0.1 F-Droid build didn't have it and still worked)

BackendService NullPointerException

01-28 16:46:18.250 12257 28801 W AppleNlpBackendService: java.lang.NullPointerException
01-28 16:46:18.250 12257 28801 W AppleNlpBackendService:  at org.microg.nlp.backend.apple.BackendService$1.run(BackendService.java:57)
01-28 16:46:18.250 12257 28801 W AppleNlpBackendService:  at java.lang.Thread.run(Thread.java:841)
01-28 16:46:18.250 12257 28801 W dalvikvm: threadid=13: thread exiting with uncaught exception (group=0x4160ed58)
01-28 16:46:18.251 12257 28801 E AndroidRuntime: FATAL EXCEPTION: Thread-1751
01-28 16:46:18.251 12257 28801 E AndroidRuntime: Process: org.microg.nlp.backend.apple, PID: 12257
01-28 16:46:18.251 12257 28801 E AndroidRuntime: java.lang.NullPointerException
01-28 16:46:18.251 12257 28801 E AndroidRuntime:  at org.microg.nlp.backend.apple.BackendService$1.run(BackendService.java:79)
01-28 16:46:18.251 12257 28801 E AndroidRuntime:  at java.lang.Thread.run(Thread.java:841)

I'm not sure how to reproduce, i just leave it on for some time. by checking the code it looks like onWiFIChange comes before onOpen which is the only case leads to "database == NULL"

requires android.permission.ACCESS_COARSE_LOCATION

it seems missing
02-04 02:17:55.281 1791 1841 W ActivityManager: Permission Denial: Accessing service ComponentInfo{org.microg.nlp.backend.apple/org.microg.nlp.backend.apple.BackendService} from pid=24299, uid=10123 requires android.permission.ACCESS_COARSE_LOCATION

android 6.0

Apple Wifi Backend Crashes

Crash happens right after enabling the backend.
microG Services Core 0.2.4-107-g0596d2c
Apple UnifiedNlp Backend 1.2.2

Here's the logcat relevant part:

D/dalvikvm( 2449): GC_CONCURRENT freed 1609K, 51% free 6439K/13063K, paused 6ms+18ms
D/NlpLocBackendHelper( 2580): Binding to: Intent { act=org.microg.nlp.LOCATION_BACKEND pkg=org.microg.nlp.backend.apple cmp=org.microg.nlp.backend.apple/.BackendService }
W/InputManagerService( 2326): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4114a688
D/NlpLocBackendHelper( 2580): Bound to: ComponentInfo{org.microg.nlp.backend.apple/org.microg.nlp.backend.apple.BackendService}
D/AppleNlpBackendService(13761): onOpen
I/libblt_hw( 1962): Library closed (handle = 0, fd = 26)
D/AppleNlpBackendService(13761): Found 4 wifis, of whom 2 with location and 0 unknown.
D/AppleNlpCalculator(13761): Build classes of size: 2
D/AppleNlpCalculator(13761): is dual class and verified.
D/AppleNlpCalculator(13761): Using with weight=1.000000 mac=14:cc:20:6d:df:96 sig=-80 acc=27.000000 lat=32.640476 lon=51.682774
D/AppleNlpCalculator(13761): Using with weight=4.000000 mac=90:f6:52:7d:0b:2c sig=-58 acc=24.000000 lat=32.640461 lon=51.682556
D/AndroidRuntime(13761): Shutting down VM
W/dalvikvm(13761): threadid=1: thread exiting with uncaught exception (group=0x40a371f8)
E/AndroidRuntime(13761): FATAL EXCEPTION: main
E/AndroidRuntime(13761): java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.wifi.SCAN_RESULTS flg=0x10000010 } in org.microg.nlp.api.WiFiBackendHelper$1@40d08108
E/AndroidRuntime(13761): 	at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:737)
E/AndroidRuntime(13761): 	at android.os.Handler.handleCallback(Handler.java:605)
E/AndroidRuntime(13761): 	at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(13761): 	at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(13761): 	at android.app.ActivityThread.main(ActivityThread.java:4575)
E/AndroidRuntime(13761): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(13761): 	at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(13761): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
E/AndroidRuntime(13761): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
E/AndroidRuntime(13761): 	at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
E/AndroidRuntime(13761): 	at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(13761): Caused by: java.lang.SecurityException: Requires INSTALL_LOCATION_PROVIDER permission
E/AndroidRuntime(13761): 	at android.os.Parcel.readException(Parcel.java:1327)
E/AndroidRuntime(13761): 	at android.os.Parcel.readException(Parcel.java:1281)
E/AndroidRuntime(13761): 	at org.microg.nlp.api.LocationCallback$Stub$Proxy.report(LocationCallback.java:91)
E/AndroidRuntime(13761): 	at org.microg.nlp.api.LocationBackendService.report(LocationBackendService.java:53)
E/AndroidRuntime(13761): 	at org.microg.nlp.backend.apple.BackendService.onWiFisChanged(BackendService.java:158)
E/AndroidRuntime(13761): 	at org.microg.nlp.api.WiFiBackendHelper.onWiFisChanged(WiFiBackendHelper.java:117)
E/AndroidRuntime(13761): 	at org.microg.nlp.api.WiFiBackendHelper.access$000(WiFiBackendHelper.java:41)
E/AndroidRuntime(13761): 	at org.microg.nlp.api.WiFiBackendHelper$1.onReceive(WiFiBackendHelper.java:51)
E/AndroidRuntime(13761): 	at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:728)
E/AndroidRuntime(13761): 	... 10 more
I/libblt_hw( 1962): Library opened (handle = 0, fd = 26)
I/AMIL    (13797): Amil1_01Init : Creating AMIL thread
+++ LOG: malformed log message
I/Process (13761): Sending signal. PID: 13761 SIG: 9
I/ActivityManager( 2326): Process org.microg.nlp.backend.apple (pid 13761) has died.
W/ActivityManager( 2326): Scheduling restart of crashed service org.microg.nlp.backend.apple/.BackendService in 5000ms
D/NlpLocBackendHelper( 2580): Unbound from: ComponentInfo{org.microg.nlp.backend.apple/org.microg.nlp.backend.apple.BackendService}
W/InputManagerService( 2326): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40edc450
I/libblt_hw( 1962): Library closed (handle = 0, fd = 26)
D/NlpLocBackendHelper( 2580): Not (yet) bound.
I/AMIL    (13804): Amil1_01Init : Creating AMIL thread
D/NlpLocBackendHelper( 2580): Not (yet) bound.
I/ActivityManager( 2326): Start proc org.microg.nlp.backend.apple for service org.microg.nlp.backend.apple/.BackendService: pid=13809 uid=10095 gids={3003, 1015}
I/dalvikvm(13809): Could not find method org.microg.nlp.api.HelperLocationBackendService.checkSelfPermission, referenced from method org.microg.nlp.api.HelperLocationBackendService.getInitIntent
W/dalvikvm(13809): VFY: unable to resolve virtual method 1841: Lorg/microg/nlp/api/HelperLocationBackendService;.checkSelfPermission (Ljava/lang/String;)I
D/dalvikvm(13809): VFY: replacing opcode 0x6e at 0x0039
I/dalvikvm(13809): Could not find method android.net.wifi.WifiManager.isScanAlwaysAvailable, referenced from method org.microg.nlp.api.WiFiBackendHelper.isScanAlwaysAvailable
W/dalvikvm(13809): VFY: unable to resolve virtual method 235: Landroid/net/wifi/WifiManager;.isScanAlwaysAvailable ()Z
D/dalvikvm(13809): VFY: replacing opcode 0x6e at 0x0008
D/NlpLocBackendHelper( 2580): Bound to: ComponentInfo{org.microg.nlp.backend.apple/org.microg.nlp.backend.apple.BackendService}
D/AppleNlpBackendService(13809): onOpen

[<package-id>] <title>

Affected app
Name: [e.g. WhatsApp]
Package id: [e.g. com.whatsapp]

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

System
Android Version: [e.g. 10]
Custom ROM: [e.g. LineageOS 17.1]

microG
microG Core version: [e.g. 0.2.13.203915]
microG Self-Check results: [e.g. All ticked]

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.