Skip to content

Commit 8ff5cbd

Browse files
Refactoring. Merging "CrashImpl" classes and "Device" classes. (#34)
* Merging "CrashImpl" and "CrashImplCore". Solving some test issues due to updating JSON version. * Removing unused calls related to activities. * Merging "Device" with "DeviceCore"
1 parent 1517ff8 commit 8ff5cbd

27 files changed

+675
-882
lines changed

.idea/modules/app-java/countly-sdk-java.app-java.main.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules/app-java/countly-sdk-java.app-java.test.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules/sdk-java/countly-sdk-java.sdk-java.main.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules/sdk-java/countly-sdk-java.sdk-java.test.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app-java/src/main/java/ly/count/java/demo/BackendModePerformanceTests.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import ly.count.sdk.java.Config;
44
import ly.count.sdk.java.Countly;
5-
import ly.count.sdk.java.internal.DeviceCore;
5+
import ly.count.sdk.java.internal.Device;
66

77
import java.io.File;
88
import java.util.HashMap;
@@ -33,9 +33,9 @@ private static void initSDK(int eventQueueSize, int requestQueueSize) {
3333
static void performLargeRequestQueueSizeTest() {
3434
System.out.println("===== Test Started: 'Large request queue size' =====");
3535
int requestQSize = 1000000;
36-
System.out.printf("Before SDK Initialization: Total Memory = %dMb, Available RAM = %dMb %n", DeviceCore.dev.getRAMTotal(), DeviceCore.dev.getRAMAvailable());
36+
System.out.printf("Before SDK Initialization: Total Memory = %dMb, Available RAM = %dMb %n", Device.dev.getRAMTotal(), Device.dev.getRAMAvailable());
3737
initSDK(1, requestQSize);
38-
System.out.printf("After SDK Initialization: Total Memory = %d Mb, Available RAM= %d Mb %n", DeviceCore.dev.getRAMTotal(), DeviceCore.dev.getRAMAvailable());
38+
System.out.printf("After SDK Initialization: Total Memory = %d Mb, Available RAM= %d Mb %n", Device.dev.getRAMTotal(), Device.dev.getRAMAvailable());
3939

4040
int batchSize = requestQSize / 25;
4141

@@ -106,7 +106,7 @@ static void performLargeRequestQueueSizeTest() {
106106
Countly.backendMode().sessionBegin(DEVICE_ID, metrics, location, null);
107107
}
108108

109-
System.out.printf("After adding %d request: Total Memory = %d Mb, Available RAM= %d Mb %n", requestQSize, DeviceCore.dev.getRAMTotal(), DeviceCore.dev.getRAMAvailable());
109+
System.out.printf("After adding %d request: Total Memory = %d Mb, Available RAM= %d Mb %n", requestQSize, Device.dev.getRAMTotal(), Device.dev.getRAMAvailable());
110110

111111
Countly.stop(false);
112112
System.out.println("=====SDK Stop=====");
@@ -115,9 +115,9 @@ static void performLargeRequestQueueSizeTest() {
115115
static void performLargeEventQueueTest() {
116116
int noOfEvents = 100000;
117117
System.out.println("===== Test Start: 'Large Event queues against multiple devices ids' =====");
118-
System.out.printf("Before SDK Initialization: Total Memory = %dMb, Available RAM = %dMb %n", DeviceCore.dev.getRAMTotal(), DeviceCore.dev.getRAMAvailable());
118+
System.out.printf("Before SDK Initialization: Total Memory = %dMb, Available RAM = %dMb %n", Device.dev.getRAMTotal(), Device.dev.getRAMAvailable());
119119
initSDK(noOfEvents, 1000);
120-
System.out.printf("After SDK Initialization: Total Memory = %d Mb, Available RAM= %d Mb %n", DeviceCore.dev.getRAMTotal(), DeviceCore.dev.getRAMAvailable());
120+
System.out.printf("After SDK Initialization: Total Memory = %d Mb, Available RAM= %d Mb %n", Device.dev.getRAMTotal(), Device.dev.getRAMAvailable());
121121

122122
int noOfDevices = 10;
123123
for (int d = 0; d <= noOfDevices; ++d) {
@@ -132,7 +132,7 @@ static void performLargeEventQueueTest() {
132132
Countly.backendMode().recordEvent("device-id-" + d, "Event Key " + i, 1, 0.1, 5.0, segment, null);
133133
}
134134
}
135-
System.out.printf("After adding %d events into event queue: Total Memory = %d Mb, Available RAM= %d Mb %n", noOfEvents * noOfDevices, DeviceCore.dev.getRAMTotal(), DeviceCore.dev.getRAMAvailable());
135+
System.out.printf("After adding %d events into event queue: Total Memory = %d Mb, Available RAM= %d Mb %n", noOfEvents * noOfDevices, Device.dev.getRAMTotal(), Device.dev.getRAMAvailable());
136136

137137
Countly.stop(false);
138138
System.out.println("=====SDK Stop=====");
@@ -141,9 +141,9 @@ static void performLargeEventQueueTest() {
141141
static void recordBulkDataAndSendToServer() throws InterruptedException {
142142

143143
System.out.println("===== Test Start: 'Record bulk data to server' =====");
144-
System.out.printf("Before SDK Initialization: Total Memory = %dMb, Available RAM = %dMb %n", DeviceCore.dev.getRAMTotal(), DeviceCore.dev.getRAMAvailable());
144+
System.out.printf("Before SDK Initialization: Total Memory = %dMb, Available RAM = %dMb %n", Device.dev.getRAMTotal(), Device.dev.getRAMAvailable());
145145
initSDK(100, 1000);
146-
System.out.printf("After SDK Initialization: Total Memory = %d Mb, Available RAM= %d Mb %n", DeviceCore.dev.getRAMTotal(), DeviceCore.dev.getRAMAvailable());
146+
System.out.printf("After SDK Initialization: Total Memory = %d Mb, Available RAM= %d Mb %n", Device.dev.getRAMTotal(), Device.dev.getRAMAvailable());
147147
int countOfRequest = 10;
148148
int remaining = countOfRequest;
149149
int secondsToSleep = 5;
@@ -166,7 +166,7 @@ static void recordBulkDataAndSendToServer() throws InterruptedException {
166166
} while (remaining != 0 || Countly.backendMode().getQueueSize() != 0);
167167

168168

169-
System.out.printf("After successfully sending %d requests to server: Total Memory = %d Mb, Available RAM= %d Mb %n", countOfRequest, DeviceCore.dev.getRAMTotal(), DeviceCore.dev.getRAMAvailable());
169+
System.out.printf("After successfully sending %d requests to server: Total Memory = %d Mb, Available RAM= %d Mb %n", countOfRequest, Device.dev.getRAMTotal(), Device.dev.getRAMAvailable());
170170

171171
Countly.stop(false);
172172
System.out.println("=====SDK Stop=====");

sdk-java/src/main/java/ly/count/sdk/java/Config.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,8 @@ public Config(String serverURL, String serverAppKey) {
596596
* Whether to allow fallback from unavailable device id strategy to Countly OpenUDID derivative.
597597
*
598598
* @param deviceIdFallbackAllowed true if fallback is allowed
599-
* @deprecated this will do nothing
600599
* @return {@code this} instance for method chaining
600+
* @deprecated this will do nothing
601601
*/
602602
public Config setDeviceIdFallbackAllowed(boolean deviceIdFallbackAllowed) {
603603
return this;
@@ -917,8 +917,8 @@ public Config setSessionCooldownPeriod(int sessionCooldownPeriod) {
917917
* Change name of SDK used in HTTP requests
918918
*
919919
* @param sdkName new name of SDK
920-
* @deprecated Calling this function will do nothing
921920
* @return {@code this} instance for method chaining
921+
* @deprecated Calling this function will do nothing
922922
*/
923923
public Config setSdkName(String sdkName) {
924924
return this;
@@ -928,8 +928,8 @@ public Config setSdkName(String sdkName) {
928928
* Change version of SDK used in HTTP requests
929929
*
930930
* @param sdkVersion new version of SDK
931-
* @deprecated Calling this function will do nothing
932931
* @return {@code this} instance for method chaining
932+
* @deprecated Calling this function will do nothing
933933
*/
934934
public Config setSdkVersion(String sdkVersion) {
935935
return this;
@@ -1102,17 +1102,18 @@ public Config addCertificatePin(String pemEncodedCertificate) {
11021102
* To disable ANR reporting, use {@link #disableANRCrashReporting()}.
11031103
*
11041104
* @param periodInSeconds how much time the SDK waits between individual ANR checks
1105-
* @deprecated will do nothing
11061105
* @return {@code this} instance for method chaining
1106+
* @deprecated will do nothing
11071107
*/
11081108
public Config setCrashReportingANRCheckingPeriod(int periodInSeconds) {
11091109
return this;
11101110
}
11111111

11121112
/**
11131113
* Disable ANR detection and thus reporting to Countly server.
1114-
* @deprecated will do nothing
1114+
*
11151115
* @return {@code this} instance for method chaining
1116+
* @deprecated will do nothing
11161117
*/
11171118
public Config disableANRCrashReporting() {
11181119
return this;
@@ -1139,8 +1140,8 @@ public Config setCrashProcessorClass(Class<? extends CrashProcessor> crashProces
11391140
*
11401141
* @param feature feature index to override
11411142
* @param cls {@link Class} to use instead of Countly SDK standard class
1142-
* @deprecated this will do nothing
11431143
* @return {@code this} instance for method chaining
1144+
* @deprecated this will do nothing
11441145
*/
11451146
protected Config overrideModule(Integer feature, Class<? extends Module> cls) {
11461147
return this;
@@ -1296,8 +1297,9 @@ public int getDeviceIdStrategy() {
12961297

12971298
/**
12981299
* Whether to allow fallback from unavailable device id strategy to any other available.
1299-
* @deprecated this will always return "true"
1300+
*
13001301
* @return true if fallback is allowed
1302+
* @deprecated this will always return "true"
13011303
*/
13021304
public boolean isDeviceIdFallbackAllowed() {
13031305
return deviceIdFallbackAllowed;
@@ -1341,17 +1343,19 @@ public String getParameterTamperingProtectionSalt() {
13411343

13421344
/**
13431345
* Getter for {@link #sdkName}
1344-
* @deprecated this will be removed
1346+
*
13451347
* @return {@link #sdkName} value
1348+
* @deprecated this will be removed
13461349
*/
13471350
public String getSdkName() {
13481351
return sdkName;
13491352
}
13501353

13511354
/**
13521355
* Getter for {@link #sdkVersion}
1353-
* @deprecated this will be removed
1356+
*
13541357
* @return {@link #sdkVersion} value
1358+
* @deprecated this will be removed
13551359
*/
13561360
public String getSdkVersion() {
13571361
return sdkVersion;
@@ -1503,8 +1507,9 @@ public Set<String> getCertificatePins() {
15031507

15041508
/**
15051509
* Getter for {@link #crashReportingANRCheckingPeriod}
1506-
* @Deprecated will always return "5"
1510+
*
15071511
* @return {@link #crashReportingANRCheckingPeriod} value
1512+
* @Deprecated will always return "5"
15081513
*/
15091514
public int getCrashReportingANRCheckingPeriod() {
15101515
return 5;
@@ -1521,8 +1526,9 @@ public String getCrashProcessorClass() {
15211526

15221527
/**
15231528
* Getter for {@link #moduleOverrides}
1524-
* @deprecated this always return "null"
1529+
*
15251530
* @return {@link #moduleOverrides} value for {@code Feature} specified
1531+
* @deprecated this always return "null"
15261532
*/
15271533
public Class<? extends Module> getModuleOverride(int feature) {
15281534
return null;

sdk-java/src/main/java/ly/count/sdk/java/User.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package ly.count.sdk.java;
22

3+
import ly.count.sdk.java.internal.Device;
4+
35
import java.util.Map;
46
import java.util.Set;
57

@@ -107,7 +109,7 @@ public static Gender fromString(String v) {
107109

108110
/**
109111
* Current user locale in "lang_COUNTRY", like en_US or de_DE if default device locale is overridden.
110-
* If not set, Countly will use {@link ly.count.sdk.java.internal.DeviceCore#getLocale()}.
112+
* If not set, Countly will use {@link Device#getLocale()}.
111113
*
112114
* @return current user locale
113115
*/

0 commit comments

Comments
 (0)