Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Commit

Permalink
Using native-interface preference in the update process.
Browse files Browse the repository at this point in the history
  • Loading branch information
nikDemyankov committed Mar 4, 2016
1 parent 9d13f5a commit fbf9d25
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ private void fetchUpdate(CallbackContext jsCallback) {
return;
}

ChcpError error = UpdatesLoader.downloadUpdate(cordova.getActivity(), chcpXmlConfig.getConfigUrl(), pluginInternalPrefs.getCurrentReleaseVersionName());
final PluginFilesStructure currentReleaseFS = new PluginFilesStructure(cordova.getActivity(), pluginInternalPrefs.getCurrentReleaseVersionName());
final ChcpError error = UpdatesLoader.downloadUpdate(chcpXmlConfig.getConfigUrl(), currentReleaseFS, chcpXmlConfig.getNativeInterfaceVersion());
if (error != ChcpError.NONE) {
if (jsCallback != null) {
PluginResult errorResult = PluginResultHelper.createPluginResult(UpdateDownloadErrorEvent.EVENT_NAME, null, error);
Expand Down Expand Up @@ -641,7 +642,7 @@ public void onEvent(NothingToUpdateEvent event) {
@SuppressWarnings("unused")
@Subscribe
public void onEvent(BeforeInstallEvent event) {
Log.d("CHCP", "Before install");
Log.d("CHCP", "Dispatching Before install event");

PluginResult jsResult = PluginResultHelper.pluginResultFromEvent(event);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.nordnetab.chcp.main.updater;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;

Expand All @@ -23,7 +22,6 @@
import com.nordnetab.chcp.main.storage.IObjectFileStorage;
import com.nordnetab.chcp.main.utils.FilesUtility;
import com.nordnetab.chcp.main.utils.URLUtility;
import com.nordnetab.chcp.main.utils.VersionHelper;

import java.io.IOException;
import java.util.List;
Expand All @@ -39,7 +37,7 @@
class UpdateLoaderWorker implements WorkerTask {

private final String applicationConfigUrl;
private final int appBuildVersion;
private final int appNativeVersion;
private final PluginFilesStructure filesStructure;

private IObjectFileStorage<ApplicationConfig> appConfigStorage;
Expand All @@ -53,14 +51,14 @@ class UpdateLoaderWorker implements WorkerTask {
/**
* Constructor.
*
* @param context application context
* @param configUrl application config url
* @param currentVersion current version of the content
* @param configUrl application config url
* @param currentReleaseFileStructure files structure of the current release
* @param currentNativeVersion current native version of the
*/
public UpdateLoaderWorker(Context context, final String configUrl, final String currentVersion) {
filesStructure = new PluginFilesStructure(context, currentVersion);
public UpdateLoaderWorker(final String configUrl, final PluginFilesStructure currentReleaseFileStructure, final int currentNativeVersion) {
filesStructure = currentReleaseFileStructure;
applicationConfigUrl = configUrl;
appBuildVersion = VersionHelper.applicationVersionCode(context);
appNativeVersion = currentNativeVersion;
}

@Override
Expand All @@ -85,7 +83,7 @@ public void run() {
}

// check if current native version supports new content
if (newAppConfig.getContentConfig().getMinimumNativeVersion() > appBuildVersion) {
if (newAppConfig.getContentConfig().getMinimumNativeVersion() > appNativeVersion) {
setErrorResult(ChcpError.APPLICATION_BUILD_VERSION_TOO_LOW, newAppConfig);
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.nordnetab.chcp.main.updater;

import android.content.Context;

import com.nordnetab.chcp.main.model.ChcpError;
import com.nordnetab.chcp.main.model.PluginFilesStructure;

import de.greenrobot.event.EventBus;

Expand Down Expand Up @@ -30,12 +29,12 @@ public static boolean isExecuting() {
* Request update download.
* Download performed in background. Events are dispatched to notify us about the result.
*
* @param context application context
* @param configURL url from which we should download application config
* @param currentVersion current version of the content
* @param configURL url from which we should download application config
* @param currentReleaseFileStructure files structure of the current release
* @param currentNativeVersion current native interface version
* @return <code>ChcpError.NONE</code> if download has started; otherwise - error details
*/
public static ChcpError downloadUpdate(final Context context, final String configURL, final String currentVersion) {
public static ChcpError downloadUpdate(final String configURL, final PluginFilesStructure currentReleaseFileStructure, final int currentNativeVersion) {
// if download already in progress - exit
if (isExecuting) {
return ChcpError.DOWNLOAD_ALREADY_IN_PROGRESS;
Expand All @@ -48,7 +47,7 @@ public static ChcpError downloadUpdate(final Context context, final String confi

isExecuting = true;

UpdateLoaderWorker task = new UpdateLoaderWorker(context, configURL, currentVersion);
final UpdateLoaderWorker task = new UpdateLoaderWorker(configURL, currentReleaseFileStructure, currentNativeVersion);
executeTask(task);

return ChcpError.NONE;
Expand Down

0 comments on commit fbf9d25

Please sign in to comment.