diff --git a/Branch-SDK/src/main/java/io/branch/referral/ServerRequest.java b/Branch-SDK/src/main/java/io/branch/referral/ServerRequest.java index d3c256504..d27a5c8d2 100644 --- a/Branch-SDK/src/main/java/io/branch/referral/ServerRequest.java +++ b/Branch-SDK/src/main/java/io/branch/referral/ServerRequest.java @@ -139,16 +139,7 @@ protected ServerRequest(Defines.RequestPath requestPath, JSONObject post, Contex public boolean shouldRetryOnFail() { return false; } - - /** - * Specifies whether this request should be persisted to memory in order to re send in the next session - * - * @return {@code true} by default. Should be override for request that need not to be persisted - */ - boolean isPersistable() { - return true; - } - + /** * Specifies whether this request should add the limit app tracking value * @@ -348,7 +339,8 @@ public JSONObject toJSON() { } return json; } - + + // TODO: Replace with in-memory only ServerRequest objects. /** *

Converts a {@link JSONObject} object containing keys stored as key-value pairs into * a {@link ServerRequest}.

@@ -388,13 +380,14 @@ public static ServerRequest fromJSON(JSONObject json, Context context) { } catch (JSONException e) { BranchLogger.w("Caught JSONException " + e.getMessage()); } - + if (!TextUtils.isEmpty(requestPath)) { return getExtendedServerRequest(requestPath, post, context, initiatedByClient); } return null; } - + + // TODO: Replace with in-memory only ServerRequest objects. /** *

Factory method for creating the specific server requests objects. Creates requests according * to the request path.

@@ -406,7 +399,7 @@ public static ServerRequest fromJSON(JSONObject json, Context context) { */ private static ServerRequest getExtendedServerRequest(String requestPath, JSONObject post, Context context, boolean initiatedByClient) { ServerRequest extendedReq = null; - + if (requestPath.equalsIgnoreCase(Defines.RequestPath.GetURL.getPath())) { extendedReq = new ServerRequestCreateUrl(Defines.RequestPath.GetURL, post, context); } else if (requestPath.equalsIgnoreCase(Defines.RequestPath.RegisterInstall.getPath())) { @@ -414,10 +407,9 @@ private static ServerRequest getExtendedServerRequest(String requestPath, JSONOb } else if (requestPath.equalsIgnoreCase(Defines.RequestPath.RegisterOpen.getPath())) { extendedReq = new ServerRequestRegisterOpen(Defines.RequestPath.RegisterOpen, post, context, initiatedByClient); } - return extendedReq; } - + /** * Updates the google ads parameters. This should be called only from a background thread since it involves GADS method invocation using reflection * Ensure that when there is a valid GAID/AID, remove the SSAID if it's being used diff --git a/Branch-SDK/src/main/java/io/branch/referral/ServerRequestCreateUrl.java b/Branch-SDK/src/main/java/io/branch/referral/ServerRequestCreateUrl.java index 3b70fe021..f57859a15 100644 --- a/Branch-SDK/src/main/java/io/branch/referral/ServerRequestCreateUrl.java +++ b/Branch-SDK/src/main/java/io/branch/referral/ServerRequestCreateUrl.java @@ -257,11 +257,6 @@ private String generateLongUrlWithParams(String baseUrl) { return longUrl; } - @Override - boolean isPersistable() { - return false; // No need to retrieve create url request from previous session - } - @Override protected boolean prepareExecuteWithoutTracking() { // SDK-271 -- Allow creation of short links when tracking is disabled. diff --git a/Branch-SDK/src/main/java/io/branch/referral/ServerRequestQueue.java b/Branch-SDK/src/main/java/io/branch/referral/ServerRequestQueue.java index 3dde498ad..80041b6b6 100644 --- a/Branch-SDK/src/main/java/io/branch/referral/ServerRequestQueue.java +++ b/Branch-SDK/src/main/java/io/branch/referral/ServerRequestQueue.java @@ -83,50 +83,7 @@ static void shutDown() { private ServerRequestQueue(Context c) { sharedPref = c.getSharedPreferences("BNC_Server_Request_Queue", Context.MODE_PRIVATE); editor = sharedPref.edit(); - queue = retrieve(c); - } - - private void persist() { - try { - JSONArray jsonArr = new JSONArray(); - synchronized (reqQueueLockObject) { - for (ServerRequest aQueue : queue) { - if (aQueue.isPersistable()) { - JSONObject json = aQueue.toJSON(); - if (json != null) { - jsonArr.put(json); - } - } - } - } - - editor.putString(PREF_KEY, jsonArr.toString()).apply(); - } catch (Exception ex) { - String msg = ex.getMessage(); - BranchLogger.e("Failed to persist queue" + (msg == null ? "" : msg)); - } - } - - private List retrieve(Context context) { - String jsonStr = sharedPref.getString(PREF_KEY, null); - List result = Collections.synchronizedList(new LinkedList()); - synchronized (reqQueueLockObject) { - if (jsonStr != null) { - try { - JSONArray jsonArr = new JSONArray(jsonStr); - for (int i = 0, size = Math.min(jsonArr.length(), MAX_ITEMS); i < size; i++) { - JSONObject json = jsonArr.getJSONObject(i); - ServerRequest req = ServerRequest.fromJSON(json, context); - if (req != null) { - result.add(req); - } - } - } catch (JSONException e) { - BranchLogger.w("Caught JSONException " + e.getMessage()); - } - } - } - return result; + queue = Collections.synchronizedList(new LinkedList()); } /** @@ -154,7 +111,6 @@ void enqueue(ServerRequest request) { if (getSize() >= MAX_ITEMS) { queue.remove(1); } - persist(); } } } @@ -228,7 +184,6 @@ void insert(ServerRequest request, int index) { index = queue.size(); } queue.add(index, request); - persist(); } catch (IndexOutOfBoundsException e) { BranchLogger.e("Caught IndexOutOfBoundsException " + e.getMessage()); } @@ -250,7 +205,6 @@ public ServerRequest removeAt(int index) { synchronized (reqQueueLockObject) { try { req = queue.remove(index); - persist(); } catch (IndexOutOfBoundsException e) { BranchLogger.e("Caught IndexOutOfBoundsException " + e.getMessage()); } @@ -270,7 +224,6 @@ public boolean remove(ServerRequest request) { synchronized (reqQueueLockObject) { try { isRemoved = queue.remove(request); - persist(); } catch (UnsupportedOperationException e) { BranchLogger.e("Caught UnsupportedOperationException " + e.getMessage()); } @@ -285,7 +238,6 @@ void clear() { synchronized (reqQueueLockObject) { try { queue.clear(); - persist(); } catch (UnsupportedOperationException e) { BranchLogger.e("Caught UnsupportedOperationException " + e.getMessage()); } diff --git a/build.gradle.kts b/build.gradle.kts index 07c3224a0..55f707167 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,8 @@ import org.gradle.api.tasks.testing.logging.* plugins { - id("com.android.library") version "8.1.2" apply false - id("com.android.application") version "8.1.2" apply false + id("com.android.library") version "8.3.2" apply false + id("com.android.application") version "8.3.2" apply false id("org.jetbrains.kotlin.android") version "1.6.21" apply false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 70880f24e..d84ea14c9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ #Sun Apr 07 13:06:19 PDT 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists