freshollie / UsbGps4Droid

USB GPS Provider for android :artificial_satellite:. A maintained fork of hvb/USBGps4Droid
GNU General Public License v3.0
82 stars 34 forks source link

Could NOT work on HUAWEI matepad (HarmonyOS) #43

Closed bilibili12433014 closed 2 months ago

bilibili12433014 commented 2 months ago

Device: matepad 11.5S 8G+256G OS Version: HarmonyOS 4.2.0.126

Detail: SoftWare(UsbGps) successfully reads GPS data from my U-blox, but my navigation softwares could NOT read GPS information.

freshollie commented 2 months ago

Did you do this? https://developer.huawei.com/consumer/en/doc/HMSCore-Guides/location-develop-steps-0000001050746143#section5825644497

freshollie commented 2 months ago

To use the mock location function, go to Settings > System & updates > Developer options > Select mock location app and select the desired app. (If Developer options is unavailable, go to Settings > About phone and tap Build number for seven consecutive times. Then, Developer options will be displayed on System & updates.)

This app required mock location so if you've not selected the app then the location will not be updated

bilibili12433014 commented 2 months ago

I do have set mock app, but it did not work!

bilibili12433014 commented 2 months ago

I found difference between your code and the code in the link. Is this a possible cause of this bug? your code:

<uses-permission
        android:name="android.permission.ACCESS_MOCK_LOCATION"
        tools:ignore="MockLocation" />

code in the link:

<uses-permission
    android:name="android.permission.ACCESS_MOCK_LOCATION"
    tools:ignore="MockLocation,ProtectedPermissions" />
freshollie commented 2 months ago

Yes it could be. Are you able to recompile the app yourself and test?

bilibili12433014 commented 2 months ago

let me have a try

bilibili12433014 commented 2 months ago

This may be the problem: 图片

After I added ,ProtectedPermissions , no error appeared. But I could not compile, could you help build a release?

freshollie commented 2 months ago

I think this repo is on API level 23 so should be ok. Why can't you compile? I've not got the repo set up on any of my current machines

freshollie commented 2 months ago

Btw, if you are able to select the app in mock location this is not likely to be the issue. I'm not sure if there is a specific reason for mock location not working on that OS, it would require some local debugging from you

bilibili12433014 commented 2 months ago

Now, I successfully sync your app and compile it. However, I could not install app to my matepad, because Android Studio could not recognize it. As Android Studio could recognize my phones, install app and run app (one is also HarmonyOS but 4.0.0, one is Xiaomi HyperOS), i think, this may be a HarmonyOS bug about USB DEBUG and may affect GPS MOCK. I am trying to communicate with HUAWEI's engineer, if I get any futher information, I will make a new comment.

bilibili12433014 commented 2 months ago

By searching Internet, there is a bug about USB DEBUG: "file" mode must be selected, if "charge" mode is selected, USB DEBUG will not work; but I still could not find the reason why GPS MOCK could not work.

freshollie commented 2 months ago

I'm not sure. Have you tired another app with GPS mock? Is the GPS location being displayed in the app?

bilibili12433014 commented 2 months ago

After test, I have confirmed that your application runs correctly and there are no bugs. The reason the mock location is not working is that my navigation software obtains location data directly from the satellite, not from the operating system. I wrote a demo to obtain location data and tested it, and the mock location feature does indeed work. Other mock applications and navigation softwares are tested, they do work.

freshollie commented 2 months ago

Ok, thanks for letting me know :)