Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-17946]: Update assetcrypt for modules. #6299

Merged
merged 2 commits into from
Nov 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class KrollAssetHelper
public interface AssetCrypt
{
String readAsset(String path);
void setIsProduction(boolean isProduction);
}

public static void setAssetCrypt(AssetCrypt assetCrypt)
Expand Down
4 changes: 1 addition & 3 deletions android/templates/build/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ public void onCreate()
postAppInfo();

<% if (encryptJS) { %>
KrollAssetHelper.AssetCrypt assetCrypt = new AssetCryptImpl();
assetCrypt.setIsProduction(DEPLOY_TYPE_PRODUCTION.equals(appInfo.getDeployType()));
KrollAssetHelper.setAssetCrypt(assetCrypt);
KrollAssetHelper.setAssetCrypt(new AssetCryptImpl());
<% } %>

V8Runtime runtime = new V8Runtime();
Expand Down
14 changes: 8 additions & 6 deletions android/templates/build/AssetCryptImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@
import java.lang.System;
import org.appcelerator.kroll.util.KrollAssetHelper;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiApplication;
import android.os.Debug;


public class AssetCryptImpl implements KrollAssetHelper.AssetCrypt
{
private boolean isProduction = false;

public void setIsProduction(boolean production)
{
isProduction = production;
}

private static class Range {
int offset;
Expand All @@ -34,6 +30,12 @@ public Range(int offset, int length) {

public String readAsset(String path)
{
TiApplication application = TiApplication.getInstance();
boolean isProduction = false;
if (application != null) {
isProduction = TiApplication.DEPLOY_TYPE_PRODUCTION.equals(application.getAppInfo().getDeployType());
}

if (isProduction && Debug.isDebuggerConnected()) {
Log.e("AssetCryptImpl", "Illegal State. Exit.");
System.exit(1);
Expand Down
14 changes: 14 additions & 0 deletions support/android/jspacker.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.lang.reflect.Method;
import java.lang.System;
import org.appcelerator.kroll.util.KrollAssetHelper;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiApplication;
import android.os.Debug;

public class AssetCryptImpl implements KrollAssetHelper.AssetCrypt
{
Expand All @@ -44,6 +47,17 @@

public String readAsset(String path)
{
TiApplication application = TiApplication.getInstance();
boolean isProduction = false;
if (application != null) {
isProduction = TiApplication.DEPLOY_TYPE_PRODUCTION.equals(application.getAppInfo().getDeployType());
}

if (isProduction && Debug.isDebuggerConnected()) {
Log.e("AssetCryptImpl", "Illegal State. Exit.");
System.exit(1);
}

Range range = assets.get(path);
if (range == null) {
return null;
Expand Down