Skip to content

Commit 0e97c8e

Browse files
RebliNk17Gegy
authored andcommitted
Better support for the hash service problems. (#854)
* Added better support for the hash service Throw exceptions when error accor. also you can get the headers that the hash service is sending. * Added better support for the hash service Throw exceptions when error accor. also you can get the headers that the hash service is sending. * add buddy check to pokemon poke.isBuddy() to check if that pokemon is your buddy. easier than before 💭 * Fixed style * fix check style
1 parent 0350911 commit 0e97c8e

File tree

88 files changed

+9611
-8709
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+9611
-8709
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,4 @@ fabric.properties
158158
.LSOverride
159159

160160

161+
*.iml

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

+14-7
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import com.pokegoapi.exceptions.CaptchaActiveException;
4646
import com.pokegoapi.exceptions.LoginFailedException;
4747
import com.pokegoapi.exceptions.RemoteServerException;
48+
import com.pokegoapi.exceptions.hash.HashException;
4849
import com.pokegoapi.main.AsyncServerRequest;
4950
import com.pokegoapi.main.CommonRequests;
5051
import com.pokegoapi.main.Heartbeat;
@@ -56,8 +57,8 @@
5657
import com.pokegoapi.util.SystemTimeImpl;
5758
import com.pokegoapi.util.Time;
5859
import com.pokegoapi.util.hash.HashProvider;
59-
import lombok.Getter;
6060
import lombok.Setter;
61+
import lombok.Getter;
6162
import okhttp3.OkHttpClient;
6263

6364
import java.io.IOException;
@@ -196,7 +197,7 @@ public PokemonGo(OkHttpClient client) {
196197
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
197198
*/
198199
public void login(CredentialProvider credentialProvider, HashProvider hashProvider)
199-
throws LoginFailedException, CaptchaActiveException, RemoteServerException {
200+
throws LoginFailedException, CaptchaActiveException, RemoteServerException, HashException {
200201
this.loggingIn = true;
201202
if (credentialProvider == null) {
202203
throw new NullPointerException("Credential Provider can not be null!");
@@ -214,7 +215,8 @@ public void login(CredentialProvider credentialProvider, HashProvider hashProvid
214215
initialize();
215216
}
216217

217-
private void initialize() throws RemoteServerException, CaptchaActiveException, LoginFailedException {
218+
private void initialize() throws RemoteServerException, CaptchaActiveException, LoginFailedException,
219+
HashException {
218220
playerProfile.updateProfile();
219221

220222
ServerRequest downloadConfigRequest = new ServerRequest(RequestType.DOWNLOAD_REMOTE_CONFIG_VERSION,
@@ -301,7 +303,7 @@ private void initialize() throws RemoteServerException, CaptchaActiveException,
301303
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
302304
*/
303305
private void fireRequestBlock(ServerRequest request, RequestType... exclude)
304-
throws RemoteServerException, CaptchaActiveException, LoginFailedException {
306+
throws RemoteServerException, CaptchaActiveException, LoginFailedException, HashException {
305307
getRequestHandler().sendServerRequests(request.withCommons().exclude(exclude));
306308
try {
307309
awaitChallenge();
@@ -317,7 +319,8 @@ private void fireRequestBlock(ServerRequest request, RequestType... exclude)
317319
* @throws RemoteServerException When server fails
318320
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
319321
*/
320-
public void getAssetDigest() throws RemoteServerException, CaptchaActiveException, LoginFailedException {
322+
public void getAssetDigest() throws RemoteServerException, CaptchaActiveException, LoginFailedException,
323+
HashException {
321324
fireRequestBlock(new ServerRequest(RequestType.GET_ASSET_DIGEST,
322325
CommonRequests.getGetAssetDigestMessageRequest(this)).exclude(RequestType.GET_BUDDY_WALKED));
323326
}
@@ -564,9 +567,11 @@ public boolean hasChallenge() {
564567
* @throws RemoteServerException when server fails
565568
* @throws InvalidProtocolBufferException when the client receives an invalid message from the server
566569
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
570+
* @throws HashException if there is a problem with the Hash key / Service
567571
*/
568572
public boolean verifyChallenge(String token)
569-
throws RemoteServerException, CaptchaActiveException, LoginFailedException, InvalidProtocolBufferException {
573+
throws RemoteServerException, CaptchaActiveException, LoginFailedException,
574+
InvalidProtocolBufferException, HashException {
570575
hasChallenge = false;
571576
VerifyChallengeMessage message = VerifyChallengeMessage.newBuilder().setToken(token).build();
572577
AsyncServerRequest request = new AsyncServerRequest(RequestType.VERIFY_CHALLENGE, message);
@@ -590,9 +595,11 @@ public boolean verifyChallenge(String token)
590595
* @throws RemoteServerException when server fails
591596
* @throws InvalidProtocolBufferException when the client receives an invalid message from the server
592597
* @throws CaptchaActiveException if a captcha is active and the message can't be sent
598+
* @throws HashException if there is a problem with the Hash key / Service
593599
*/
594600
public String checkChallenge()
595-
throws RemoteServerException, CaptchaActiveException, LoginFailedException, InvalidProtocolBufferException {
601+
throws RemoteServerException, CaptchaActiveException, LoginFailedException,
602+
InvalidProtocolBufferException, HashException {
596603
CheckChallengeMessage message = CheckChallengeMessage.newBuilder().build();
597604
AsyncServerRequest request = new AsyncServerRequest(RequestType.CHECK_CHALLENGE, message);
598605
ByteString responseData =

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

+14-14
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public static DeviceInfo getDefault(PokemonGo api) {
197197

198198
/**
199199
* Sets AndroidBoardName
200-
*
200+
* <p>
201201
* <pre>
202202
* {@code deviceInfo.setAndroidBoardName(Build.BOARD);}
203203
* </pre>
@@ -210,7 +210,7 @@ public void setAndroidBoardName(String androidBoardName) {
210210

211211
/**
212212
* Sets AndroidBootloader
213-
*
213+
* <p>
214214
* <pre>
215215
* {@code deviceInfo.setAndroidBootloader(Build.BOOTLOADER);}
216216
* </pre>
@@ -223,7 +223,7 @@ public void setAndroidBootloader(String androidBootloader) {
223223

224224
/**
225225
* Sets DeviceBrand
226-
*
226+
* <p>
227227
* <pre>
228228
* {@code deviceInfo.setDeviceBrand(Build.BRAND);}
229229
* </pre>
@@ -236,7 +236,7 @@ public void setDeviceBrand(String deviceBrand) {
236236

237237
/**
238238
* Sets DeviceId
239-
*
239+
* <p>
240240
* <pre>
241241
* {@code deviceInfo.setDeviceId(UUID.randomUUID().toString());}
242242
* </pre>
@@ -249,7 +249,7 @@ public void setDeviceId(String deviceId) {
249249

250250
/**
251251
* Sets DeviceModel
252-
*
252+
* <p>
253253
* <pre>
254254
* {@code deviceInfo.setDeviceModel(Build.MODEL);}
255255
* </pre>
@@ -262,7 +262,7 @@ public void setDeviceModel(String deviceModel) {
262262

263263
/**
264264
* Sets DeviceModelBoot
265-
*
265+
* <p>
266266
* <pre>
267267
* {@code deviceInfo.setDeviceModelBoot("qcom");}
268268
* </pre>
@@ -275,7 +275,7 @@ public void setDeviceModelBoot(String deviceModelBoot) {
275275

276276
/**
277277
* Sets DeviceModelIdentifier
278-
*
278+
* <p>
279279
* <pre>
280280
* {@code deviceInfo.setDeviceModelIdentifier(Build.PRODUCT);}
281281
* </pre>
@@ -288,7 +288,7 @@ public void setDeviceModelIdentifier(String deviceModelIdentifier) {
288288

289289
/**
290290
* Sets FirmwareBrand
291-
*
291+
* <p>
292292
* <pre>
293293
* {@code deviceInfo.setFirmwareBrand(Build.PRODUCT);}
294294
* </pre>
@@ -301,21 +301,21 @@ public void setFirmwareBrand(String firmwareBrand) {
301301

302302
/**
303303
* Sets FirmwareFingerprint
304-
*
304+
* <p>
305305
* <pre>
306306
* {@code deviceInfo.setFirmwareFingerprint(Build.FINGERPRINT);}
307307
* </pre>
308308
*
309309
* @param firmwareFingerprint FirmwareFingerprint,
310-
* for example: "google/angler/angler:7.0/NPD90G/3051502:user/release-keys"
310+
* for example: "google/angler/angler:7.0/NPD90G/3051502:user/release-keys"
311311
*/
312312
public void setFirmwareFingerprint(String firmwareFingerprint) {
313313
deviceInfoBuilder.setFirmwareFingerprint(firmwareFingerprint);
314314
}
315315

316316
/**
317317
* Sets FirmwareTags
318-
*
318+
* <p>
319319
* <pre>
320320
* {@code deviceInfo.setFirmwareTags(Build.TAGS);}
321321
* </pre>
@@ -328,7 +328,7 @@ public void setFirmwareTags(String firmwareTags) {
328328

329329
/**
330330
* Sets FirmwareType
331-
*
331+
* <p>
332332
* <pre>
333333
* {@code deviceInfo.setFirmwareType(Build.TYPE);}
334334
* </pre>
@@ -341,7 +341,7 @@ public void setFirmwareType(String firmwareType) {
341341

342342
/**
343343
* Sets HardwareManufacturer
344-
*
344+
* <p>
345345
* <pre>
346346
* {@code deviceInfo.setHardwareManufacturer(Build.MANUFACTURER);}
347347
* </pre>
@@ -354,7 +354,7 @@ public void setHardwareManufacturer(String hardwareManufacturer) {
354354

355355
/**
356356
* Sets HardwareModel
357-
*
357+
* <p>
358358
* <pre>
359359
* {@code deviceInfo.setHardwareModel(Build.HARDWARE);}
360360
* </pre>

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

+11-11
Original file line numberDiff line numberDiff line change
@@ -42,71 +42,71 @@ public interface DeviceInfos {
4242
String getDeviceBrand();
4343

4444
/**
45-
* adb.exe shell settings get secure android_id
46-
* UUID.randomUUID().toString();
45+
* adb.exe shell settings get secure android_id
46+
* UUID.randomUUID().toString();
4747
*
4848
* @return device id, for example: "****************"
4949
*/
5050
String getDeviceId();
5151

5252
/**
53-
* adb.exe shell getprop ro.product.model
53+
* adb.exe shell getprop ro.product.model
5454
*
5555
* @return device model, for example: "Nexus 6P"
5656
*/
5757
String getDeviceModel();
5858

5959
/**
60-
* adb.exe shell getprop ro.product.name
60+
* adb.exe shell getprop ro.product.name
6161
*
6262
* @return device model identifier, for example: "angler"
6363
*/
6464
String getDeviceModelIdentifier();
6565

6666
/**
67-
* Always qcom
67+
* Always qcom
6868
*
6969
* @return device boot model, for example: "qcom"
7070
*/
7171
String getDeviceModelBoot();
7272

7373
/**
74-
* adb.exe shell getprop ro.product.manufacturer
74+
* adb.exe shell getprop ro.product.manufacturer
7575
*
7676
* @return hardware manufacturer, for example: "Huawei"
7777
*/
7878
String getHardwareManufacturer();
7979

8080
/**
81-
* adb.exe shell getprop ro.product.model
81+
* adb.exe shell getprop ro.product.model
8282
*
8383
* @return hardware model, for example: "Nexus 6P"
8484
*/
8585
String getHardwareModel();
8686

8787
/**
88-
* adb.exe shell getprop ro.product.name
88+
* adb.exe shell getprop ro.product.name
8989
*
9090
* @return firmware brand, for example: "angler"
9191
*/
9292
String getFirmwareBrand();
9393

9494
/**
95-
* adb.exe shell getprop ro.build.tags
95+
* adb.exe shell getprop ro.build.tags
9696
*
9797
* @return firmware tags, for example: "release-keys"
9898
*/
9999
String getFirmwareTags();
100100

101101
/**
102-
* adb.exe shell getprop ro.build.type
102+
* adb.exe shell getprop ro.build.type
103103
*
104104
* @return firmware type, for example: "user"
105105
*/
106106
String getFirmwareType();
107107

108108
/**
109-
* adb.exe shell getprop ro.build.fingerprint
109+
* adb.exe shell getprop ro.build.fingerprint
110110
*
111111
* @return firmware fingerprint, for example: "google/angler/angler:7.0/NPD90G/3051502:user/release-keys"
112112
*/

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public LocationFixes() {
3333
* @return the default device info for the given api
3434
*/
3535
public static LocationFixes getDefault(PokemonGo api, RequestEnvelopeOuterClass.RequestEnvelope.Builder builder,
36-
long currentTime, Random random) {
36+
long currentTime, Random random) {
3737
int pn = random.nextInt(100);
3838
int providerCount;
3939
int[] negativeSnapshotProviders = new int[0];

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

-14
Original file line numberDiff line numberDiff line change
@@ -21,85 +21,71 @@
2121

2222
public interface SensorInfos {
2323
/**
24-
*
2524
* @return timestamp snapshot in ms since start
2625
*/
2726
long getTimestampSnapshot();
2827

2928
/**
30-
*
3129
* @return accelerometer axes, always 3
3230
*/
3331
long getAccelerometerAxes();
3432

3533
/**
36-
*
3734
* @return accel normalized x
3835
*/
3936
double getAccelNormalizedX();
4037

4138
/**
42-
*
4339
* @return accel normalized y
4440
*/
4541
double getAccelNormalizedY();
4642

4743
/**
48-
*
4944
* @return accel normalized z
5045
*/
5146
double getAccelNormalizedZ();
5247

5348
/**
54-
*
5549
* @return accel raw x
5650
*/
5751
double getAccelRawX();
5852

5953
/**
60-
*
6154
* @return accel raw y
6255
*/
6356
double getAccelRawY();
6457

6558
/**
66-
*
6759
* @return accel raw z
6860
*/
6961
double getAccelRawZ();
7062

7163
/**
72-
*
7364
* @return angel normalized x
7465
*/
7566
double getAngleNormalizedX();
7667

7768
/**
78-
*
7969
* @return angel normalized y
8070
*/
8171
double getAngleNormalizedY();
8272

8373
/**
84-
*
8574
* @return angel normalized z
8675
*/
8776
double getAngleNormalizedZ();
8877

8978
/**
90-
*
9179
* @return gyroscope raw x
9280
*/
9381
double getGyroscopeRawX();
9482

9583
/**
96-
*
9784
* @return gyroscope raw y
9885
*/
9986
double getGyroscopeRawY();
10087

10188
/**
102-
*
10389
* @return gyroscope raw z
10490
*/
10591
double getGyroscopeRawZ();

0 commit comments

Comments
 (0)