igoticecream / Snorlax

Xposed module (Android) to check pokemons stats
Other
62 stars 22 forks source link

Enhancement: broadcast responses #13

Closed krosk closed 7 years ago

krosk commented 7 years ago

Hello,

I implemented a prototype module for Snorlax, to act as a "Mitm broadcaster". The module translates get map objects responses into an intent with extra data (in JSON format), and my own app capture the intent and track my spawn encounters.

Why did not I do my spawn diary directly as a module for Snorlax? An xposed module is cumbersome to develop and test (forced reboot everytime it is updated...). An app that captures intent is much faster to develop and easier to test. I actually develop and compile my app on the go, something I can't do when I dabble with Snorlax source code.

I have very limited android experience, but if this broadcast thing is generalized to other responses, I believe Snorlax has the potential to become a platform over which other app developpers can plug in through Intent broadcast.

Any thoughts on this?

taririk commented 7 years ago

I think this is a very good approach. Given Snorlax is already very well structured and modularized. It could instead be used as a dedicated data provider to other modules outside of xposed. Would you mind sharing your code?

igoticecream commented 7 years ago

You mean like broadcasting every response and request?

krosk commented 7 years ago

For starters, broadcasting a few response (and maybe requests if they have interesting data) would be more than enough. GetMapObjects and GetInventory come to mind.

The broadcasting will ensure that the data is accessed as read only. Snorlax could also enable or disable which response gets broadcasted on its user interface.

I will upload a snippet of code soon

MaT-PT commented 7 years ago

GetPlayer would be useful too.

igoticecream commented 7 years ago

Sounds nice... I'd like to take a look on that snippet @krosk

krosk commented 7 years ago

Have a look there for the in-Snorlax part: https://github.com/krosk/Snorlax/commit/3340796b95d41f624723fde2f5e20ee7a37504c6 https://github.com/krosk/Snorlax/commit/de6c0d54e980998d84d076226809384362941f86

Disclaimer: code totally not cleaned for sharing, please improve upon it

Out of Snorlax, I implement a BroadcastReceiver that listens to the intent "com.icecream.snorlax.BROADCAST_GETMAPOBJECTS" and do my thing on the Intent data, each time it is broadcasted (that is, directly when I receive a response).

igoticecream commented 7 years ago

Ok ok I like the idea! Currently Im working with a feature that works with gson and auto-value-gson to persist some data on external storage... For code consistency I'm going to drop json objects and json arrays for the libraries mentioned

igoticecream commented 7 years ago

Make a pull request to dev branch 💃

krosk commented 7 years ago

Sure, feel free to change to whatever library is best. I made the pull request to dev branch.

igoticecream commented 7 years ago

For map objects, I do the following output:

{
   "wild":[
      {
         "encounter_id":-967454372306407651,
         "pokedex":16,
         "time_till_hidden_ms":342782,
         "last_modified_timestamp_ms":1476463374878,
         "latitude":10.464603324116037,
         "longitude":-66.97483351084206,
         "spawnpoint_id":"8c2a5f8b4cf",
         "s2_cell_id":-8346753907698958336
      },
      {
         "encounter_id":6355789224367253853,
         "pokedex":13,
         "time_till_hidden_ms":88790,
         "last_modified_timestamp_ms":1476463374878,
         "latitude":10.46444625169523,
         "longitude":-66.97492658741469,
         "spawnpoint_id":"8c2a5f8b4b5",
         "s2_cell_id":-8346753907698958336
      },
      {
         "encounter_id":-629473294973047011,
         "pokedex":16,
         "time_till_hidden_ms":1005374945,
         "last_modified_timestamp_ms":1476463374878,
         "latitude":10.464753331328524,
         "longitude":-66.97464735772928,
         "spawnpoint_id":"8c2a5f8b4df",
         "s2_cell_id":-8346753907698958336
      }
   ],
   "map":[
      {
         "encounter_id":-967454372306407651,
         "pokedex":16,
         "expiration_timestamp_ms":1476463717660,
         "latitude":10.464603324116037,
         "longitude":-66.97483351084206,
         "spawnpoint_id":"8c2a5f8b4cf",
         "s2_cell_id":-8346753907698958336
      },
      {
         "encounter_id":6355789224367253853,
         "pokedex":13,
         "expiration_timestamp_ms":1476463463668,
         "latitude":10.46444625169523,
         "longitude":-66.97492658741469,
         "spawnpoint_id":"8c2a5f8b4b5",
         "s2_cell_id":-8346753907698958336
      },
      {
         "encounter_id":-629473294973047011,
         "pokedex":16,
         "expiration_timestamp_ms":-1,
         "latitude":10.464753331328524,
         "longitude":-66.97464735772928,
         "spawnpoint_id":"8c2a5f8b4df",
         "s2_cell_id":-8346753907698958336
      }
   ],
   "nearby":[
      {
         "encounter_id":-967454372306407651,
         "pokedex":16,
         "distance_in_meters":0.0,
         "fort_id":"",
         "s2_cell_id":-8346753907698958336
      },
      {
         "encounter_id":1907947272857238701,
         "pokedex":29,
         "distance_in_meters":0.0,
         "fort_id":"",
         "s2_cell_id":-8346753907698958336
      },
      {
         "encounter_id":6355789224367253853,
         "pokedex":13,
         "distance_in_meters":0.0,
         "fort_id":"",
         "s2_cell_id":-8346753907698958336
      },
      {
         "encounter_id":-629473294973047011,
         "pokedex":16,
         "distance_in_meters":0.0,
         "fort_id":"",
         "s2_cell_id":-8346753907698958336
      },
      {
         "encounter_id":2017617235307389421,
         "pokedex":35,
         "distance_in_meters":0.0,
         "fort_id":"",
         "s2_cell_id":-8346753907698958336
      }
   ],
   "disk":[

   ]
}

Data is coming from:

mapCell.getWildPokemonsList();
mapCell.getCatchablePokemonsList();
mapCell.getNearbyPokemonsList();
mapCell.getFortsList(); (Has lure info)

Is that ok?

igoticecream commented 7 years ago

Feature implemented, live on dev branch... last commit 7f07e18756fcd545679fc7ccb9f2419c6ef26670

krosk commented 7 years ago

Yes it is. Later you may consider putting the Pokémon data too (IV moves et etc) from wild pokemons, they are all interesting data

On Oct 14, 2016 18:46, "Pedro Diaz" notifications@github.com wrote:

For map objects, I do the following output:

{ "wild":[ { "encounter_id":-967454372306407651, "pokedex":16, "time_till_hidden_ms":342782, "last_modified_timestamp_ms":1476463374878, "latitude":10.464603324116037, "longitude":-66.97483351084206, "spawnpoint_id":"8c2a5f8b4cf", "s2_cell_id":-8346753907698958336 }, { "encounter_id":6355789224367253853, "pokedex":13, "time_till_hidden_ms":88790, "last_modified_timestamp_ms":1476463374878, "latitude":10.46444625169523, "longitude":-66.97492658741469, "spawnpoint_id":"8c2a5f8b4b5", "s2_cell_id":-8346753907698958336 }, { "encounter_id":-629473294973047011, "pokedex":16, "time_till_hidden_ms":1005374945, "last_modified_timestamp_ms":1476463374878, "latitude":10.464753331328524, "longitude":-66.97464735772928, "spawnpoint_id":"8c2a5f8b4df", "s2_cell_id":-8346753907698958336 } ], "map":[ { "encounter_id":-967454372306407651, "pokedex":16, "expiration_timestamp_ms":1476463717660, "latitude":10.464603324116037, "longitude":-66.97483351084206, "spawnpoint_id":"8c2a5f8b4cf", "s2_cell_id":-8346753907698958336 }, { "encounter_id":6355789224367253853, "pokedex":13, "expiration_timestamp_ms":1476463463668, "latitude":10.46444625169523, "longitude":-66.97492658741469, "spawnpoint_id":"8c2a5f8b4b5", "s2_cell_id":-8346753907698958336 }, { "encounter_id":-629473294973047011, "pokedex":16, "expiration_timestamp_ms":-1, "latitude":10.464753331328524, "longitude":-66.97464735772928, "spawnpoint_id":"8c2a5f8b4df", "s2_cell_id":-8346753907698958336 } ], "nearby":[ { "encounter_id":-967454372306407651, "pokedex":16, "distance_in_meters":0.0, "fort_id":"", "s2_cell_id":-8346753907698958336 }, { "encounter_id":1907947272857238701, "pokedex":29, "distance_in_meters":0.0, "fort_id":"", "s2_cell_id":-8346753907698958336 }, { "encounter_id":6355789224367253853, "pokedex":13, "distance_in_meters":0.0, "fort_id":"", "s2_cell_id":-8346753907698958336 }, { "encounter_id":-629473294973047011, "pokedex":16, "distance_in_meters":0.0, "fort_id":"", "s2_cell_id":-8346753907698958336 }, { "encounter_id":2017617235307389421, "pokedex":35, "distance_in_meters":0.0, "fort_id":"", "s2_cell_id":-8346753907698958336 } ], "disk":[

] }

Data is coming from:

mapCell.getWildPokemonsList(); mapCell.getCatchablePokemonsList(); mapCell.getNearbyPokemonsList(); mapCell.getFortsList(); (Has lure info)

Is that ok?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/igoticecream/Snorlax/issues/13#issuecomment-253855959, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFfHJaqoC7ZXwhWK955MW7cdZW__00Pks5qz7H2gaJpZM4KTx5- .

igoticecream commented 7 years ago

Yea i saw that data while developing... I need to write a wiki page how this works and describe the json... later this week.

igoticecream commented 7 years ago

I guess PokemonData is empty?

87 10948-12052/? I/Xposed: # POGOProtos.Map.Pokemon.WildPokemonOuterClass$WildPokemon@8c75375f
                                           encounter_id: 6384545302645539549
                                           last_modified_timestamp_ms: 1476476848898
                                           latitude: 10.464471799054811
                                           longitude: -66.9741819751367
                                           pokemon_data {
                                             captured_cell_id: 0
                                             creation_time_ms: 0
                                             id: 0
                                             pokemon_id: ODDISH
                                             pokemon_id_value: 43
                                           }
                                           spawn_point_id: "8c2a5f8b45f"
                                           time_till_hidden_ms: 991900925
10-14 16:27:30.597 10948-12052/? I/Xposed: # POGOProtos.Map.Pokemon.WildPokemonOuterClass$WildPokemon@222b7c0d
                                           encounter_id: -1970438569539709811
                                           last_modified_timestamp_ms: 1476476848898
                                           latitude: 10.464903338332592
                                           longitude: -66.97446120465979
                                           pokemon_data {
                                             captured_cell_id: 0
                                             creation_time_ms: 0
                                             id: 0
                                             pokemon_id: PIDGEY
                                             pokemon_id_value: 16
                                           }
                                           spawn_point_id: "8c2a5f8b51b"
                                           time_till_hidden_ms: 243498
10-14 16:27:30.607 10948-12052/? I/Xposed: # POGOProtos.Map.Pokemon.WildPokemonOuterClass$WildPokemon@d1765ef8
                                           encounter_id: -7314530930160370019
                                           last_modified_timestamp_ms: 1476476848898
                                           latitude: 10.464793007606314
                                           longitude: -66.97408889865065
                                           pokemon_data {
                                             captured_cell_id: 0
                                             creation_time_ms: 0
                                             id: 0
                                             pokemon_id: EEVEE
                                             pokemon_id_value: 133
                                           }
                                           spawn_point_id: "8c2a5f8b5ad"
                                           time_till_hidden_ms: 48562
10-14 16:27:30.623 10948-12052/? I/Xposed: # POGOProtos.Map.Pokemon.WildPokemonOuterClass$WildPokemon@c5f37dbc
                                           encounter_id: 7195631391279886685
                                           last_modified_timestamp_ms: 1476476848898
                                           latitude: 10.46497127620056
                                           longitude: -66.97427505163357
                                           pokemon_data {
                                             captured_cell_id: 0
                                             creation_time_ms: 0
                                             id: 0
                                             pokemon_id: PARAS
                                             pokemon_id_value: 46
                                           }
                                           spawn_point_id: "8c2a5f8b509"
                                           time_till_hidden_ms: 323010
10-14 16:27:30.633 10948-12052/? I/Xposed: # POGOProtos.Map.Pokemon.WildPokemonOuterClass$WildPokemon@8ec4b71
                                           encounter_id: 100303499573695229
                                           last_modified_timestamp_ms: 1476476848898
                                           latitude: 10.465231614627145
                                           longitude: -66.97446120465979
                                           pokemon_data {
                                             captured_cell_id: 0
                                             creation_time_ms: 0
                                             id: 0
                                             pokemon_id: ZUBAT
                                             pokemon_id_value: 41
                                           }
                                           spawn_point_id: "8c2a5f8b56f"
                                           time_till_hidden_ms: 816730
10-14 16:27:30.640 10948-12052/? I/Xposed: # POGOProtos.Map.Pokemon.WildPokemonOuterClass$WildPokemon@dc7ce47
                                           encounter_id: -1043922175575498419
                                           last_modified_timestamp_ms: 1476476848898
                                           latitude: 10.464924534602977
                                           longitude: -66.97474043428026
                                           pokemon_data {
                                             captured_cell_id: 0
                                             creation_time_ms: 0
                                             id: 0
                                             pokemon_id: PIDGEY
                                             pokemon_id_value: 16
                                           }
                                           spawn_point_id: "8c2a5f8b525"
                                           time_till_hidden_ms: 268402
krosk commented 7 years ago

I never tried. I assumed since there is the pokemon data object in the protobuf, it should have contained valid data, Seems like maybe they did not include data?

igoticecream commented 7 years ago

Yea it's empty... sounds logic anyways.

Maybe it's time to broadcast player and inventory