LHerskind / PokemonPositionFaker

A module for the xposed framework used for simulation walking in Pokemon GO
4 stars 1 forks source link

Fix boomerang bug #2

Open LHerskind opened 8 years ago

LHerskind commented 8 years ago

Fix the bug where the player sometimes boomerang back to true location.

Olaf3210 commented 8 years ago

It does not send you back to the true location, but to the location hardcoded in Faker.gotoPlace() (55.675989 12.568932), as if the coordinates are not retrieved successfully from the shared preferences. I worked around that bug by changing the hardcoded coordinates to invalid coordinates, checking the returned values match these invalid coordinates, and abort if this is the case. Something like that:

        mLatitude = Double.parseDouble(mSharedPreferences.getString("latitude", "1024.0"));
        mLongitude = Double.parseDouble(mSharedPreferences.getString("longtitude", "1024.0"));

        if(mLatitude == 1024.0 || mLongitude == 1024.0) return;

I'm not sure why the shared preferences fails to retrieve the coordinates from time to time, maybe it's a bug in xposed or a inter-process synchronization issue (i.e., the coordinates are read while they are being applied from LocationFaker.setMyLocation()).

LHerskind commented 8 years ago

Oh, forgot that i hardcoded the values, used them for testing. Thought about the same, maybe setting a lower refreshrate will help it.

Some times it boomerangs back to the true position, but i have only encountered this very few times

Olaf3210 commented 8 years ago

I've confirmed the issue comes from a race condition when a process writes the new preferences file while another read it. I've implemented a process mutex to avoid that, but it's a bit hacky and the proper way to avoid that is implementing an Android service. I'll probably send a PR for that later, if it's okay with you.