Skip to content

Commit

Permalink
Updated to remove separate method
Browse files Browse the repository at this point in the history
  • Loading branch information
nsingh-branch committed Oct 20, 2023
1 parent 6e68e0c commit b6621a1
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions Branch-SDK/src/main/java/io/branch/referral/DeviceInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ void updateRequestWithV1Params(ServerRequest serverRequest, JSONObject requestOb

requestObj.put(Defines.Jsonkey.APILevel.getKey(), SystemObserver.getAPILevel());

maybeAddSDFields(serverRequest, requestObj);

if (Branch.getPluginName() != null) {
requestObj.put(Defines.Jsonkey.PluginName.getKey(), Branch.getPluginName());
requestObj.put(Defines.Jsonkey.PluginVersion.getKey(), Branch.getPluginVersion());
Expand All @@ -111,6 +109,15 @@ void updateRequestWithV1Params(ServerRequest serverRequest, JSONObject requestOb
if ((!TextUtils.isEmpty(localIpAddr))) {
requestObj.put(Defines.Jsonkey.LocalIP.getKey(), localIpAddr);
}

if (serverRequest.isInitializationOrEventRequest()) {
requestObj.put(Defines.Jsonkey.CPUType.getKey(), SystemObserver.getCPUType());
requestObj.put(Defines.Jsonkey.DeviceBuildId.getKey(), SystemObserver.getDeviceBuildId());
requestObj.put(Defines.Jsonkey.Locale.getKey(), SystemObserver.getLocale());
requestObj.put(Defines.Jsonkey.ConnectionType.getKey(), SystemObserver.getConnectionType(context_));
requestObj.put(Defines.Jsonkey.DeviceCarrier.getKey(), SystemObserver.getCarrier(context_));
requestObj.put(Defines.Jsonkey.OSVersionAndroid.getKey(), SystemObserver.getOSVersion());
}
} catch (JSONException e) {
BranchLogger.d(e.getMessage());
}
Expand Down Expand Up @@ -170,8 +177,6 @@ void updateRequestWithV2Params(ServerRequest serverRequest, PrefHelper prefHelpe

userDataObj.put(Defines.Jsonkey.APILevel.getKey(), SystemObserver.getAPILevel());

maybeAddSDFields(serverRequest, userDataObj);

if (Branch.getPluginName() != null) {
userDataObj.put(Defines.Jsonkey.PluginName.getKey(), Branch.getPluginName());
userDataObj.put(Defines.Jsonkey.PluginVersion.getKey(), Branch.getPluginVersion());
Expand Down Expand Up @@ -217,22 +222,20 @@ void updateRequestWithV2Params(ServerRequest serverRequest, PrefHelper prefHelpe
((ServerRequestGetLATD) serverRequest).getAttributionWindow());
}

if (serverRequest.isInitializationOrEventRequest()) {
userDataObj.put(Defines.Jsonkey.CPUType.getKey(), SystemObserver.getCPUType());
userDataObj.put(Defines.Jsonkey.DeviceBuildId.getKey(), SystemObserver.getDeviceBuildId());
userDataObj.put(Defines.Jsonkey.Locale.getKey(), SystemObserver.getLocale());
userDataObj.put(Defines.Jsonkey.ConnectionType.getKey(), SystemObserver.getConnectionType(context_));
userDataObj.put(Defines.Jsonkey.DeviceCarrier.getKey(), SystemObserver.getCarrier(context_));
userDataObj.put(Defines.Jsonkey.OSVersionAndroid.getKey(), SystemObserver.getOSVersion());
}

} catch (JSONException e) {
BranchLogger.d(e.getMessage());
}
}

private void maybeAddSDFields(ServerRequest serverRequest, JSONObject requestObj) throws JSONException {
if (serverRequest.isInitializationOrEventRequest()) {
requestObj.put(Defines.Jsonkey.CPUType.getKey(), SystemObserver.getCPUType());
requestObj.put(Defines.Jsonkey.DeviceBuildId.getKey(), SystemObserver.getDeviceBuildId());
requestObj.put(Defines.Jsonkey.Locale.getKey(), SystemObserver.getLocale());
requestObj.put(Defines.Jsonkey.ConnectionType.getKey(), SystemObserver.getConnectionType(context_));
requestObj.put(Defines.Jsonkey.DeviceCarrier.getKey(), SystemObserver.getCarrier(context_));
requestObj.put(Defines.Jsonkey.OSVersionAndroid.getKey(), SystemObserver.getOSVersion());
}
}

/**
* get the package name for the this application
*
Expand Down

0 comments on commit b6621a1

Please sign in to comment.