Skip to content

Commit 0d611b7

Browse files
authored
Update to 0.55 (#853)
1 parent 0e97c8e commit 0d611b7

34 files changed

+1791
-1289
lines changed

library/src/main/java/com/pokegoapi/api/PokemonGo.java

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
import POGOProtos.Enums.TutorialStateOuterClass.TutorialState;
1919
import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo;
2020
import POGOProtos.Networking.Envelopes.SignatureOuterClass;
21-
import POGOProtos.Networking.Requests.Messages.CheckChallenge.CheckChallengeMessage;
21+
import POGOProtos.Networking.Requests.Messages.CheckChallengeMessageOuterClass.CheckChallengeMessage;
2222
import POGOProtos.Networking.Requests.Messages.DownloadItemTemplatesMessageOuterClass.DownloadItemTemplatesMessage;
2323
import POGOProtos.Networking.Requests.Messages.LevelUpRewardsMessageOuterClass.LevelUpRewardsMessage;
24-
import POGOProtos.Networking.Requests.Messages.VerifyChallenge.VerifyChallengeMessage;
24+
import POGOProtos.Networking.Requests.Messages.VerifyChallengeMessageOuterClass.VerifyChallengeMessage;
2525
import POGOProtos.Networking.Requests.RequestTypeOuterClass.RequestType;
2626
import POGOProtos.Networking.Responses.CheckChallengeResponseOuterClass.CheckChallengeResponse;
2727
import POGOProtos.Networking.Responses.DownloadRemoteConfigVersionResponseOuterClass.DownloadRemoteConfigVersionResponse;
@@ -148,6 +148,9 @@ public PokemonGo(OkHttpClient client, Time time, long seed) {
148148
client = client.newBuilder()
149149
.addNetworkInterceptor(new ClientInterceptor())
150150
.build();
151+
inventories = new Inventories(this);
152+
settings = new Settings(this);
153+
playerProfile = new PlayerProfile(this);
151154
requestHandler = new RequestHandler(this, client);
152155
map = new Map(this);
153156
longitude = Double.NaN;
@@ -195,6 +198,7 @@ public PokemonGo(OkHttpClient client) {
195198
* @throws LoginFailedException When login fails
196199
* @throws RemoteServerException When server fails
197200
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
201+
* @throws HashException if an exception occurs while performing a hash request
198202
*/
199203
public void login(CredentialProvider credentialProvider, HashProvider hashProvider)
200204
throws LoginFailedException, CaptchaActiveException, RemoteServerException, HashException {
@@ -208,10 +212,6 @@ public void login(CredentialProvider credentialProvider, HashProvider hashProvid
208212
this.hashProvider = hashProvider;
209213

210214
startTime = currentTimeMillis();
211-
inventories = new Inventories(this);
212-
settings = new Settings(this);
213-
playerProfile = new PlayerProfile(this);
214-
215215
initialize();
216216
}
217217

@@ -279,6 +279,10 @@ private void initialize() throws RemoteServerException, CaptchaActiveException,
279279
playerProfile.setupAvatar();
280280
}
281281

282+
if (!heartbeat.active()) {
283+
heartbeat.start();
284+
}
285+
282286
if (!tutorialStates.contains(TutorialState.POKEMON_CAPTURE)) {
283287
playerProfile.encounterTutorialComplete();
284288
}
@@ -301,6 +305,7 @@ private void initialize() throws RemoteServerException, CaptchaActiveException,
301305
* @throws LoginFailedException When login fails
302306
* @throws RemoteServerException When server fails
303307
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
308+
* @throws HashException if an exception occurs while performing a hash request
304309
*/
305310
private void fireRequestBlock(ServerRequest request, RequestType... exclude)
306311
throws RemoteServerException, CaptchaActiveException, LoginFailedException, HashException {
@@ -318,6 +323,7 @@ private void fireRequestBlock(ServerRequest request, RequestType... exclude)
318323
* @throws LoginFailedException When login fails
319324
* @throws RemoteServerException When server fails
320325
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
326+
* @throws HashException if an exception occurs while performing a hash request
321327
*/
322328
public void getAssetDigest() throws RemoteServerException, CaptchaActiveException, LoginFailedException,
323329
HashException {
@@ -346,14 +352,15 @@ private static long hash(String string) {
346352
/**
347353
* Fetches valid AuthInfo
348354
*
355+
* @param refresh if the AuthInfo object should be refreshed
349356
* @return AuthInfo object
350357
* @throws LoginFailedException when login fails
351358
* @throws RemoteServerException When server fails
352359
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
353360
*/
354-
public AuthInfo getAuthInfo()
361+
public AuthInfo getAuthInfo(boolean refresh)
355362
throws LoginFailedException, CaptchaActiveException, RemoteServerException {
356-
return credentialProvider.getAuthInfo();
363+
return credentialProvider.getAuthInfo(refresh);
357364
}
358365

359366
/**
@@ -380,9 +387,6 @@ public void setLocation(double latitude, double longitude, double altitude, doub
380387
setLongitude(longitude);
381388
setAltitude(altitude);
382389
setAccuracy(accuracy);
383-
if (!heartbeat.active() && !Double.isNaN(latitude) && !Double.isNaN(longitude)) {
384-
heartbeat.start();
385-
}
386390
}
387391

388392
public long currentTimeMillis() {
@@ -400,6 +404,10 @@ public void setLatitude(double value) {
400404
throw new IllegalArgumentException("latittude can not exceed +/- 90");
401405
}
402406
latitude = value;
407+
408+
if (heartbeat.active() && !Double.isNaN(latitude) && !Double.isNaN(longitude)) {
409+
heartbeat.beat();
410+
}
403411
}
404412

405413
/**
@@ -413,6 +421,10 @@ public void setLongitude(double value) {
413421
throw new IllegalArgumentException("longitude can not exceed +/- 180");
414422
}
415423
longitude = value;
424+
425+
if (heartbeat.active() && !Double.isNaN(latitude) && !Double.isNaN(longitude)) {
426+
heartbeat.beat();
427+
}
416428
}
417429

418430
/**
@@ -510,6 +522,7 @@ public void removeListener(Listener listener) {
510522
* Returns all listeners for the given type.
511523
*
512524
* @param listenerType the type of listeners to return
525+
* @param <T> the listener type
513526
* @return all listeners for the given type
514527
*/
515528
public <T extends Listener> List<T> getListeners(Class<T> listenerType) {
@@ -648,4 +661,12 @@ public void enqueueTask(Runnable task) {
648661
public int getVersion() {
649662
return hashProvider.getHashVersion();
650663
}
664+
665+
/**
666+
* Exits this API
667+
*/
668+
public void exit() {
669+
heartbeat.exit();
670+
requestHandler.exit();
671+
}
651672
}

library/src/main/java/com/pokegoapi/api/device/DeviceInfo.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@
1515

1616
package com.pokegoapi.api.device;
1717

18+
import POGOProtos.Networking.Envelopes.SignatureOuterClass;
1819
import com.pokegoapi.api.PokemonGo;
1920

2021
import java.util.Random;
2122
import java.util.UUID;
2223

23-
import POGOProtos.Networking.Envelopes.SignatureOuterClass;
24-
2524
/**
2625
* Created by fabianterhorst on 08.08.16.
2726
*/
@@ -197,7 +196,6 @@ public static DeviceInfo getDefault(PokemonGo api) {
197196

198197
/**
199198
* Sets AndroidBoardName
200-
* <p>
201199
* <pre>
202200
* {@code deviceInfo.setAndroidBoardName(Build.BOARD);}
203201
* </pre>
@@ -210,7 +208,6 @@ public void setAndroidBoardName(String androidBoardName) {
210208

211209
/**
212210
* Sets AndroidBootloader
213-
* <p>
214211
* <pre>
215212
* {@code deviceInfo.setAndroidBootloader(Build.BOOTLOADER);}
216213
* </pre>
@@ -223,7 +220,6 @@ public void setAndroidBootloader(String androidBootloader) {
223220

224221
/**
225222
* Sets DeviceBrand
226-
* <p>
227223
* <pre>
228224
* {@code deviceInfo.setDeviceBrand(Build.BRAND);}
229225
* </pre>
@@ -236,7 +232,6 @@ public void setDeviceBrand(String deviceBrand) {
236232

237233
/**
238234
* Sets DeviceId
239-
* <p>
240235
* <pre>
241236
* {@code deviceInfo.setDeviceId(UUID.randomUUID().toString());}
242237
* </pre>
@@ -249,7 +244,6 @@ public void setDeviceId(String deviceId) {
249244

250245
/**
251246
* Sets DeviceModel
252-
* <p>
253247
* <pre>
254248
* {@code deviceInfo.setDeviceModel(Build.MODEL);}
255249
* </pre>
@@ -262,7 +256,6 @@ public void setDeviceModel(String deviceModel) {
262256

263257
/**
264258
* Sets DeviceModelBoot
265-
* <p>
266259
* <pre>
267260
* {@code deviceInfo.setDeviceModelBoot("qcom");}
268261
* </pre>
@@ -275,7 +268,6 @@ public void setDeviceModelBoot(String deviceModelBoot) {
275268

276269
/**
277270
* Sets DeviceModelIdentifier
278-
* <p>
279271
* <pre>
280272
* {@code deviceInfo.setDeviceModelIdentifier(Build.PRODUCT);}
281273
* </pre>
@@ -288,7 +280,6 @@ public void setDeviceModelIdentifier(String deviceModelIdentifier) {
288280

289281
/**
290282
* Sets FirmwareBrand
291-
* <p>
292283
* <pre>
293284
* {@code deviceInfo.setFirmwareBrand(Build.PRODUCT);}
294285
* </pre>
@@ -301,21 +292,19 @@ public void setFirmwareBrand(String firmwareBrand) {
301292

302293
/**
303294
* Sets FirmwareFingerprint
304-
* <p>
305295
* <pre>
306296
* {@code deviceInfo.setFirmwareFingerprint(Build.FINGERPRINT);}
307297
* </pre>
308298
*
309299
* @param firmwareFingerprint FirmwareFingerprint,
310-
* for example: "google/angler/angler:7.0/NPD90G/3051502:user/release-keys"
300+
* for example: "google/angler/angler:7.0/NPD90G/3051502:user/release-keys"
311301
*/
312302
public void setFirmwareFingerprint(String firmwareFingerprint) {
313303
deviceInfoBuilder.setFirmwareFingerprint(firmwareFingerprint);
314304
}
315305

316306
/**
317307
* Sets FirmwareTags
318-
* <p>
319308
* <pre>
320309
* {@code deviceInfo.setFirmwareTags(Build.TAGS);}
321310
* </pre>
@@ -328,7 +317,6 @@ public void setFirmwareTags(String firmwareTags) {
328317

329318
/**
330319
* Sets FirmwareType
331-
* <p>
332320
* <pre>
333321
* {@code deviceInfo.setFirmwareType(Build.TYPE);}
334322
* </pre>
@@ -341,7 +329,6 @@ public void setFirmwareType(String firmwareType) {
341329

342330
/**
343331
* Sets HardwareManufacturer
344-
* <p>
345332
* <pre>
346333
* {@code deviceInfo.setHardwareManufacturer(Build.MANUFACTURER);}
347334
* </pre>
@@ -354,7 +341,6 @@ public void setHardwareManufacturer(String hardwareManufacturer) {
354341

355342
/**
356343
* Sets HardwareModel
357-
* <p>
358344
* <pre>
359345
* {@code deviceInfo.setHardwareModel(Build.HARDWARE);}
360346
* </pre>

0 commit comments

Comments
 (0)