Skip to content

Commit 84604ec

Browse files
committed
Comment, naming, and spacing clean up
1 parent 77f072a commit 84604ec

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/OSUtils.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private static boolean hasHMSAvailabilityLibrary() {
156156
try {
157157
// noinspection ConstantConditions
158158
return com.huawei.hms.api.HuaweiApiAvailability.class != null;
159-
} catch (Throwable e) {
159+
} catch (Exception e) {
160160
return false;
161161
}
162162
}
@@ -165,7 +165,7 @@ private static boolean hasHMSPushKitLibrary() {
165165
try {
166166
// noinspection ConstantConditions
167167
return com.huawei.hms.aaid.HmsInstanceId.class != null;
168-
} catch (Throwable e) {
168+
} catch (Exception e) {
169169
return false;
170170
}
171171
}
@@ -174,7 +174,7 @@ private static boolean hasHMSAGConnectLibrary() {
174174
try {
175175
// noinspection ConstantConditions
176176
return com.huawei.agconnect.config.AGConnectServicesConfig.class != null;
177-
} catch (Throwable e) {
177+
} catch (Exception e) {
178178
return false;
179179
}
180180
}
@@ -344,7 +344,6 @@ int getDeviceType() {
344344
// Start - Fallback logic
345345
// Libraries in the app (Google:FCM, HMS:PushKit) + Device may not have a valid combo
346346
// Example: App with only the FCM library in it and a Huawei device with only HMS Core
347-
348347
if (isGMSInstalledAndEnabled())
349348
return UserState.DEVICE_TYPE_ANDROID;
350349

OneSignalSDK/onesignal/src/main/java/com/onesignal/PushRegistratorHMS.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void run() {
5353
}
5454

5555
private synchronized void getHMSTokenTask(@NonNull Context context, @NonNull RegisteredHandler callback) throws ApiException {
56-
// If here is required to prevent AGConnectServicesConfig or HmsInstanceId used below
56+
// Check required to prevent AGConnectServicesConfig or HmsInstanceId used below
5757
// from throwing a ClassNotFoundException
5858
if (!OSUtils.hasAllHMSLibrariesForPushKit()) {
5959
callback.complete(null, UserState.PUSH_STATUS_MISSING_HMS_PUSHKIT_LIBRARY);

OneSignalSDK/unittest/src/test/java/com/onesignal/ShadowOSUtils.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ public boolean supportsADM() {
2121
boolean hasFCMLibrary() {
2222
return hasFCMLibrary;
2323
}
24+
2425
public static boolean hasGCMLibrary;
2526
public static boolean hasGCMLibrary() {
2627
return hasGCMLibrary;
2728
}
29+
2830
public static boolean isGMSInstalledAndEnabled;
2931
public static boolean isGMSInstalledAndEnabled() {
3032
return isGMSInstalledAndEnabled;
@@ -35,10 +37,12 @@ public static boolean isGMSInstalledAndEnabled() {
3537
public static boolean hasHMSAvailability() {
3638
return hasHMSAvailability;
3739
}
40+
3841
public static boolean hasHMSPushKitLibrary;
3942
public static boolean hasHMSPushKitLibrary() {
4043
return hasHMSPushKitLibrary;
4144
}
45+
4246
public static boolean hasHMSAGConnectLibrary;
4347
public static boolean hasHMSAGConnectLibrary() {
4448
return hasHMSAGConnectLibrary;
@@ -48,20 +52,21 @@ public static boolean hasHMSAGConnectLibrary() {
4852
public static boolean isHMSCoreInstalledAndEnabled() {
4953
return isHMSCoreInstalledAndEnabled;
5054
}
55+
5156
public static boolean isHMSCoreInstalledAndEnabledFallback() {
5257
return isHMSCoreInstalledAndEnabled;
5358
}
5459

55-
public static void hasAllRecommendHMSLibraries(boolean value) {
60+
public static void hasAllRecommendedHMSLibraries(boolean value) {
5661
// required
5762
hasHMSPushKitLibrary = value;
5863
hasHMSAGConnectLibrary = value;
59-
// recommend
64+
// recommended
6065
hasHMSAvailability = value;
6166
}
6267

6368
public static void supportsHMS(boolean value) {
64-
hasAllRecommendHMSLibraries(value);
69+
hasAllRecommendedHMSLibraries(value);
6570
isHMSCoreInstalledAndEnabled = true;
6671
}
6772

OneSignalSDK/unittest/src/test/java/com/test/onesignal/DeviceTypeTestsRunner.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void GCMAndGMSEnabled_isAndroid() {
8383
@Test
8484
public void supportedHMS_isHuawei() {
8585
ShadowOSUtils.isHMSCoreInstalledAndEnabled = true;
86-
ShadowOSUtils.hasAllRecommendHMSLibraries(true);
86+
ShadowOSUtils.hasAllRecommendedHMSLibraries(true);
8787

8888
assertEquals(DEVICE_TYPE_HUAWEI, getDeviceType());
8989
}
@@ -94,7 +94,7 @@ public void supportsFCMAndHMS_PreferAndroid() {
9494
ShadowOSUtils.hasFCMLibrary = true;
9595

9696
ShadowOSUtils.isHMSCoreInstalledAndEnabled = true;
97-
ShadowOSUtils.hasAllRecommendHMSLibraries(true);
97+
ShadowOSUtils.hasAllRecommendedHMSLibraries(true);
9898

9999
// Prefer Google Services over Huawei if both available
100100
assertEquals(DEVICE_TYPE_ANDROID, getDeviceType());
@@ -106,7 +106,7 @@ public void hasFCMButNoGMSOnDeviceAndHasHMS_isHuawei() {
106106
ShadowOSUtils.hasFCMLibrary = true;
107107

108108
ShadowOSUtils.isHMSCoreInstalledAndEnabled = true;
109-
ShadowOSUtils.hasAllRecommendHMSLibraries(true);
109+
ShadowOSUtils.hasAllRecommendedHMSLibraries(true);
110110

111111
// Use HMS since device does not have the "Google Play services" app or it is disabled
112112
assertEquals(DEVICE_TYPE_HUAWEI, getDeviceType());

0 commit comments

Comments
 (0)