igoticecream / Snorlax

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

added HatchNotification originally made by MaT-PT #7

Closed pperle closed 8 years ago

pperle commented 8 years ago

I need someone to test this. I'm going for a walk now but I still need ~3.5km...

pperle commented 8 years ago

dang it.. I only compiled as debug.... now build is falining because of ProGuard.. I guess

Warning: there were 6 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning: there were 1 unresolved references to program class members.
         Your input classes appear to be inconsistent.
         You may need to recompile the code.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)

I think the problem is my lamda...

.subscribe(pair -> {
            switch (pair.first) {
                case GET_HATCHED_EGGS:
                    onHatch(pair.second);
                    break;
                case GET_INVENTORY:
                    onInventoryUpdate(pair.second);
                    break;
                default:
                    break;
            }
        }
        , Log::e);
igoticecream commented 8 years ago

Weird... have you found the error?

pperle commented 8 years ago

oh... maybe I should have searched for lintOptions

sorry

igoticecream commented 8 years ago

Travis is building... i hope it passes.

How went the feature, does it work? i gotta walk 4km to test -_-

igoticecream commented 8 years ago

Btw, seems like the feature is not active. Missing @Inject on Hatch constructor and is not being call on Snorlax class. Also, HatchNotification's show() is not being called

pperle commented 8 years ago

yes.. I just went for a walk and it didnt work.. next one is 600m...

nope.. I didn't see any notification :(

igoticecream commented 8 years ago

I'm going to hide the hatch feature since it's deactivate from de GUI since i need to release v1.2.0 which fixes detection of mocking location

pperle commented 8 years ago

Ok so the problem is GET_INVENTORY in no longer a used RequestType...

The only RequestType I found that are still valid are:

GET_PLAYER
DOWNLOAD_REMOTE_CONFIG_VERSION
CHECK_CHALLENGE
GET_HATCHED_EGGS
GET_ASSET_DIGEST
LEVEL_UP_REWARDS
GET_MAP_OBJECTS
GET_GYM_DETAILS
RECYCLE_INVENTORY_ITEM
RELEASE_POKEMON
ENCOUNTER
CATCH_POKEMON

I don't know where the inventory data is...

igoticecream commented 8 years ago

I'm getting the following output:

09-27 17:14:55.240 8913-10115/? I/Xposed: Found envelope
09-27 17:14:55.241 8913-10115/? I/Xposed:   + GET_PLAYER
09-27 17:14:55.487 8913-10114/? I/Xposed: Found envelope
09-27 17:14:55.487 8913-10114/? I/Xposed:   + GET_PLAYER
09-27 17:14:55.488 8913-10114/? I/Xposed: Found envelope
09-27 17:14:55.488 8913-10114/? I/Xposed:   + GET_PLAYER
09-27 17:14:56.591 8913-10115/? I/Xposed: Found envelope
09-27 17:14:56.592 8913-10115/? I/Xposed:   + DOWNLOAD_REMOTE_CONFIG_VERSION
09-27 17:14:56.592 8913-10115/? I/Xposed:   + CHECK_CHALLENGE
09-27 17:14:56.592 8913-10115/? I/Xposed:   + GET_HATCHED_EGGS
09-27 17:14:56.592 8913-10115/? I/Xposed:   + GET_INVENTORY
09-27 17:14:56.592 8913-10115/? I/Xposed:   + CHECK_AWARDED_BADGES
09-27 17:14:56.592 8913-10115/? I/Xposed:   + DOWNLOAD_SETTINGS
09-27 17:14:57.001 8913-10114/? I/Xposed: Found envelope
09-27 17:14:57.001 8913-10114/? I/Xposed:   + GET_ASSET_DIGEST
09-27 17:14:57.001 8913-10114/? I/Xposed:   + CHECK_CHALLENGE
09-27 17:14:57.001 8913-10114/? I/Xposed:   + GET_HATCHED_EGGS
09-27 17:14:57.001 8913-10114/? I/Xposed:   + GET_INVENTORY
09-27 17:14:57.001 8913-10114/? I/Xposed:   + CHECK_AWARDED_BADGES
09-27 17:14:57.001 8913-10114/? I/Xposed:   + DOWNLOAD_SETTINGS
09-27 17:14:59.550 8913-10115/? I/Xposed: Found envelope
09-27 17:14:59.550 8913-10115/? I/Xposed:   + LEVEL_UP_REWARDS
09-27 17:14:59.550 8913-10115/? I/Xposed:   + CHECK_CHALLENGE
09-27 17:14:59.550 8913-10115/? I/Xposed:   + GET_HATCHED_EGGS
09-27 17:14:59.550 8913-10115/? I/Xposed:   + GET_INVENTORY
09-27 17:14:59.550 8913-10115/? I/Xposed:   + CHECK_AWARDED_BADGES
09-27 17:14:59.550 8913-10115/? I/Xposed:   + DOWNLOAD_SETTINGS
09-27 17:14:59.550 8913-10115/? I/Xposed:   + GET_BUDDY_WALKED
09-27 17:15:00.084 8913-10114/? I/Xposed: Found envelope
09-27 17:15:00.084 8913-10114/? I/Xposed:   + GET_ASSET_DIGEST
09-27 17:15:00.086 8913-10114/? I/Xposed:   + CHECK_CHALLENGE
09-27 17:15:00.086 8913-10114/? I/Xposed:   + GET_HATCHED_EGGS
09-27 17:15:00.086 8913-10114/? I/Xposed:   + GET_INVENTORY
09-27 17:15:00.086 8913-10114/? I/Xposed:   + CHECK_AWARDED_BADGES
09-27 17:15:00.086 8913-10114/? I/Xposed:   + DOWNLOAD_SETTINGS
09-27 17:15:00.086 8913-10114/? I/Xposed:   + GET_BUDDY_WALKED

With this code

mMitmRelay
            .getObservable()
            .doOnNext(envelope -> Log.d("Found envelope"))
            .flatMap(envelope -> {
                List<Request> requests = envelope.getRequest().getRequestsList();

                List<RequestType> types = new ArrayList<>();
                for (int i = 0; i < requests.size(); i++) {
                    RequestTypeOuterClass.RequestType type = requests.get(i).getRequestType();

                    types.add(type);
                }
                return Observable.from(types);
            })
            .subscribe(type -> Log.d("  + %s", type.toString()));
pperle commented 8 years ago

I logged the RequestTypes inside of the subscribe method of Hatch (inside the for loop) because thats where the checking for RequestType is

mSubscription = mMitmRelay
        .getObservable()
        .compose(mPreferences.isEnabled())
        .flatMap(envelope -> {
            List<RequestOuterClass.Request> requests = envelope.getRequest().getRequestsList();

            for (int i = 0; i < requests.size(); i++) {
                RequestTypeOuterClass.RequestType type = requests.get(i).getRequestType();

                Log.d("RequestType = " + type);

                switch (type) {
                    case GET_HATCHED_EGGS:
                    case GET_INVENTORY:
                        return Observable.just(new Pair<>(type, envelope.getResponse().getReturns(i)));
                    default:
                        break;
                }

            }
            return Observable.empty();
        })
        .subscribe(pair -> {
                    switch (pair.first) {
                        case GET_HATCHED_EGGS:
                            onHatch(pair.second);
                            break;
                        case GET_INVENTORY:
                            onInventoryUpdate(pair.second);
                            break;
                        default:
                            break;
                    }
                }
                , Log::e);
igoticecream commented 8 years ago

I think the "default break" break's the loop and is causing the bug... try removing that and test

pperle commented 8 years ago

Sadly no, the break only ends the switch. I have to check tomorrow... Restarting my phone takes ages...