Skip to content

Commit 04dab56

Browse files
authored
Remove unnecessary code (#473)
1 parent c9e97f9 commit 04dab56

File tree

4 files changed

+22
-64
lines changed

4 files changed

+22
-64
lines changed

AndroidSDKCore/src/main/java/com/leanplum/Leanplum.java

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,6 @@ public static void setSocketConnectionSettings(String hostName, int port) {
162162
Constants.SOCKET_PORT = port;
163163
}
164164

165-
/**
166-
* Optional. By default, Leanplum will hash file variables to determine if they're modified and
167-
* need to be uploaded to the server. Use this method to override this setting.
168-
*
169-
* @param enabled Setting this to false will reduce startup latency in development mode, but it's
170-
* possible that Leanplum will always have the most up-to-date versions of your resources.
171-
* (Default: true)
172-
*/
173-
public static void setFileHashingEnabledInDevelopmentMode(boolean enabled) {
174-
Constants.hashFilesToDetermineModifications = enabled;
175-
}
176-
177165
/**
178166
* Optional. Whether to enable file uploading in development mode.
179167
*
@@ -225,15 +213,6 @@ public static void setNetworkTimeout(int seconds, int downloadSeconds) {
225213
Constants.NETWORK_TIMEOUT_SECONDS_FOR_DOWNLOADS = downloadSeconds;
226214
}
227215

228-
/**
229-
* Advanced: Whether new variables can be downloaded mid-session. By default, this is disabled.
230-
* Currently, if this is enabled, new variables can only be downloaded if a push notification is
231-
* sent while the app is running, and the notification's metadata hasn't be downloaded yet.
232-
*/
233-
public static void setCanDownloadContentMidSessionInProductionMode(boolean value) {
234-
Constants.canDownloadContentMidSessionInProduction = value;
235-
}
236-
237216
/**
238217
* Must call either this or {@link Leanplum#setAppIdForProductionMode} before issuing any calls to
239218
* the API, including start.
@@ -824,7 +803,7 @@ private static void handleStartResponse(final JSONObject response) {
824803
APIConfig.getInstance().setToken(token);
825804
APIConfig.getInstance().saveToken();
826805

827-
applyContentInResponse(response, true);
806+
applyContentInResponse(response);
828807

829808
VarCache.saveUserAttributes();
830809

@@ -947,9 +926,8 @@ public void run() {
947926
* Applies the variables, messages, or update rules in a start or getVars response.
948927
*
949928
* @param response The response containing content.
950-
* @param alwaysApply Always apply the content regardless of whether the content changed.
951929
*/
952-
private static void applyContentInResponse(JSONObject response, boolean alwaysApply) {
930+
private static void applyContentInResponse(JSONObject response) {
953931
Map<String, Object> values = JsonConverter.mapFromJsonOrDefault(
954932
response.optJSONObject(Constants.Keys.VARS));
955933
Map<String, Object> messages = JsonConverter.mapFromJsonOrDefault(
@@ -966,22 +944,15 @@ private static void applyContentInResponse(JSONObject response, boolean alwaysAp
966944
String varsJson = (varsJsonObj != null) ? varsJsonObj.toString() : null;
967945
String varsSignature = response.optString(Constants.Keys.VARS_SIGNATURE);
968946

969-
if (alwaysApply
970-
|| !values.equals(VarCache.getDiffs())
971-
|| !messages.equals(VarCache.getMessageDiffs())
972-
|| !variants.equals(VarCache.variants())
973-
|| !localCaps.equals(VarCache.localCaps())
974-
|| !regions.equals(VarCache.regions())) {
975-
VarCache.applyVariableDiffs(
976-
values,
977-
messages,
978-
regions,
979-
variants,
980-
localCaps,
981-
variantDebugInfo,
982-
varsJson,
983-
varsSignature);
984-
}
947+
VarCache.applyVariableDiffs(
948+
values,
949+
messages,
950+
regions,
951+
variants,
952+
localCaps,
953+
variantDebugInfo,
954+
varsJson,
955+
varsSignature);
985956
}
986957

987958
/**
@@ -2079,7 +2050,7 @@ public void response(JSONObject response) {
20792050
if (response == null) {
20802051
Log.e("No response received from the server. Please contact us to investigate.");
20812052
} else {
2082-
applyContentInResponse(response, false);
2053+
applyContentInResponse(response);
20832054
if (response.optBoolean(Constants.Keys.SYNC_INBOX, false)) {
20842055
LeanplumInbox.getInstance().downloadMessages();
20852056
} else {

AndroidSDKCore/src/main/java/com/leanplum/internal/Constants.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,11 @@ public class Constants {
5454
static final int MAX_USER_ID_LENGTH = 400;
5555

5656
public static String defaultDeviceId = null;
57-
public static boolean hashFilesToDetermineModifications = true;
5857
public static boolean isDevelopmentModeEnabled = false;
5958
public static boolean loggingEnabled = false;
6059
public static boolean isTestMode = false;
6160
public static boolean enableVerboseLoggingInDevelopmentMode = false;
6261
public static boolean enableFileUploadingInDevelopmentMode = true;
63-
public static boolean canDownloadContentMidSessionInProduction = false;
6462
static boolean isInPermanentFailureState = false;
6563

6664
public static boolean isNoop() {

AndroidSDKCore/src/main/java/com/leanplum/internal/VarCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public static void registerFile(
181181
Map<String, Object> variationAttributes = new HashMap<>();
182182
Map<String, Object> attributes = new HashMap<>();
183183

184-
if (Constants.hashFilesToDetermineModifications && Util.isSimulator()) {
184+
if (Util.isSimulator()) {
185185
HashResults result = FileManager.fileMD5HashCreateWithPath(defaultStream.openStream());
186186
if (result != null) {
187187
attributes.put(Constants.Keys.HASH, result.hash);

AndroidSDKPush/src/main/java/com/leanplum/LeanplumPushService.java

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -199,26 +199,15 @@ public void response(JSONObject response) {
199199
String varsJson = (varsJsonObj != null) ? varsJsonObj.toString() : null;
200200
String varsSignature = response.optString(Constants.Keys.VARS_SIGNATURE);
201201

202-
if (!Constants.canDownloadContentMidSessionInProduction ||
203-
VarCache.getDiffs().equals(values)) {
204-
values = null;
205-
varsJson = null;
206-
varsSignature = null;
207-
}
208-
if (VarCache.getMessageDiffs().equals(messages)) {
209-
messages = null;
210-
}
211-
if (values != null || messages != null) {
212-
VarCache.applyVariableDiffs(
213-
values,
214-
messages,
215-
regions,
216-
variants,
217-
localCaps,
218-
null,
219-
varsJson,
220-
varsSignature);
221-
}
202+
VarCache.applyVariableDiffs(
203+
values,
204+
messages,
205+
regions,
206+
variants,
207+
localCaps,
208+
null,
209+
varsJson,
210+
varsSignature);
222211
}
223212
onComplete.variablesChanged();
224213
} catch (Throwable t) {

0 commit comments

Comments
 (0)