Skip to content

Commit

Permalink
Refactoring. Merging "CrashImpl" classes and "Device" classes. (#34)
Browse files Browse the repository at this point in the history
* Merging "CrashImpl" and "CrashImplCore". Solving some test issues due to updating JSON version.

* Removing unused calls related to activities.

* Merging "Device" with "DeviceCore"
  • Loading branch information
ArtursKadikis authored Mar 6, 2023
1 parent 1517ff8 commit 8ff5cbd
Show file tree
Hide file tree
Showing 27 changed files with 675 additions and 882 deletions.
2 changes: 1 addition & 1 deletion .idea/modules/app-java/countly-sdk-java.app-java.main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules/app-java/countly-sdk-java.app-java.test.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules/sdk-java/countly-sdk-java.sdk-java.main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules/sdk-java/countly-sdk-java.sdk-java.test.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ly.count.sdk.java.Config;
import ly.count.sdk.java.Countly;
import ly.count.sdk.java.internal.DeviceCore;
import ly.count.sdk.java.internal.Device;

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

int batchSize = requestQSize / 25;

Expand Down Expand Up @@ -106,7 +106,7 @@ static void performLargeRequestQueueSizeTest() {
Countly.backendMode().sessionBegin(DEVICE_ID, metrics, location, null);
}

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

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

int noOfDevices = 10;
for (int d = 0; d <= noOfDevices; ++d) {
Expand All @@ -132,7 +132,7 @@ static void performLargeEventQueueTest() {
Countly.backendMode().recordEvent("device-id-" + d, "Event Key " + i, 1, 0.1, 5.0, segment, null);
}
}
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());
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());

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

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


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());
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());

Countly.stop(false);
System.out.println("=====SDK Stop=====");
Expand Down
28 changes: 17 additions & 11 deletions sdk-java/src/main/java/ly/count/sdk/java/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,8 @@ public Config(String serverURL, String serverAppKey) {
* Whether to allow fallback from unavailable device id strategy to Countly OpenUDID derivative.
*
* @param deviceIdFallbackAllowed true if fallback is allowed
* @deprecated this will do nothing
* @return {@code this} instance for method chaining
* @deprecated this will do nothing
*/
public Config setDeviceIdFallbackAllowed(boolean deviceIdFallbackAllowed) {
return this;
Expand Down Expand Up @@ -917,8 +917,8 @@ public Config setSessionCooldownPeriod(int sessionCooldownPeriod) {
* Change name of SDK used in HTTP requests
*
* @param sdkName new name of SDK
* @deprecated Calling this function will do nothing
* @return {@code this} instance for method chaining
* @deprecated Calling this function will do nothing
*/
public Config setSdkName(String sdkName) {
return this;
Expand All @@ -928,8 +928,8 @@ public Config setSdkName(String sdkName) {
* Change version of SDK used in HTTP requests
*
* @param sdkVersion new version of SDK
* @deprecated Calling this function will do nothing
* @return {@code this} instance for method chaining
* @deprecated Calling this function will do nothing
*/
public Config setSdkVersion(String sdkVersion) {
return this;
Expand Down Expand Up @@ -1102,17 +1102,18 @@ public Config addCertificatePin(String pemEncodedCertificate) {
* To disable ANR reporting, use {@link #disableANRCrashReporting()}.
*
* @param periodInSeconds how much time the SDK waits between individual ANR checks
* @deprecated will do nothing
* @return {@code this} instance for method chaining
* @deprecated will do nothing
*/
public Config setCrashReportingANRCheckingPeriod(int periodInSeconds) {
return this;
}

/**
* Disable ANR detection and thus reporting to Countly server.
* @deprecated will do nothing
*
* @return {@code this} instance for method chaining
* @deprecated will do nothing
*/
public Config disableANRCrashReporting() {
return this;
Expand All @@ -1139,8 +1140,8 @@ public Config setCrashProcessorClass(Class<? extends CrashProcessor> crashProces
*
* @param feature feature index to override
* @param cls {@link Class} to use instead of Countly SDK standard class
* @deprecated this will do nothing
* @return {@code this} instance for method chaining
* @deprecated this will do nothing
*/
protected Config overrideModule(Integer feature, Class<? extends Module> cls) {
return this;
Expand Down Expand Up @@ -1296,8 +1297,9 @@ public int getDeviceIdStrategy() {

/**
* Whether to allow fallback from unavailable device id strategy to any other available.
* @deprecated this will always return "true"
*
* @return true if fallback is allowed
* @deprecated this will always return "true"
*/
public boolean isDeviceIdFallbackAllowed() {
return deviceIdFallbackAllowed;
Expand Down Expand Up @@ -1341,17 +1343,19 @@ public String getParameterTamperingProtectionSalt() {

/**
* Getter for {@link #sdkName}
* @deprecated this will be removed
*
* @return {@link #sdkName} value
* @deprecated this will be removed
*/
public String getSdkName() {
return sdkName;
}

/**
* Getter for {@link #sdkVersion}
* @deprecated this will be removed
*
* @return {@link #sdkVersion} value
* @deprecated this will be removed
*/
public String getSdkVersion() {
return sdkVersion;
Expand Down Expand Up @@ -1503,8 +1507,9 @@ public Set<String> getCertificatePins() {

/**
* Getter for {@link #crashReportingANRCheckingPeriod}
* @Deprecated will always return "5"
*
* @return {@link #crashReportingANRCheckingPeriod} value
* @Deprecated will always return "5"
*/
public int getCrashReportingANRCheckingPeriod() {
return 5;
Expand All @@ -1521,8 +1526,9 @@ public String getCrashProcessorClass() {

/**
* Getter for {@link #moduleOverrides}
* @deprecated this always return "null"
*
* @return {@link #moduleOverrides} value for {@code Feature} specified
* @deprecated this always return "null"
*/
public Class<? extends Module> getModuleOverride(int feature) {
return null;
Expand Down
4 changes: 3 additions & 1 deletion sdk-java/src/main/java/ly/count/sdk/java/User.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ly.count.sdk.java;

import ly.count.sdk.java.internal.Device;

import java.util.Map;
import java.util.Set;

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

/**
* Current user locale in "lang_COUNTRY", like en_US or de_DE if default device locale is overridden.
* If not set, Countly will use {@link ly.count.sdk.java.internal.DeviceCore#getLocale()}.
* If not set, Countly will use {@link Device#getLocale()}.
*
* @return current user locale
*/
Expand Down
Loading

0 comments on commit 8ff5cbd

Please sign in to comment.