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

Android concurrent map #3

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
import android.os.Environment;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;

import com.taobao.weex.BuildConfig;
import com.taobao.weex.common.WXConfig;
import com.taobao.weex.utils.FontDO;
import com.taobao.weex.utils.LogLevel;
Expand All @@ -37,21 +36,16 @@
import com.taobao.weex.utils.WXLogUtils;
import com.taobao.weex.utils.WXSoInstallMgrSdk;
import com.taobao.weex.utils.WXUtils;

import org.w3c.dom.Text;

import dalvik.system.PathClassLoader;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

import dalvik.system.PathClassLoader;
import java.util.concurrent.ConcurrentHashMap;

public class WXEnvironment {

Expand Down Expand Up @@ -135,7 +129,7 @@ public class WXEnvironment {
private static String LIB_LD_PATH = null;


private static Map<String, String> options = new HashMap<>();
private static Map<String, String> options = new ConcurrentHashMap<>();
static {
options.put(WXConfig.os, OS);
options.put(WXConfig.osName, OS);
Expand Down Expand Up @@ -170,15 +164,15 @@ public static Map<String, String> getConfig() {

try {
if (isApkDebugable()) {
options.put(WXConfig.debugMode, "true");
addCustomOptions(WXConfig.debugMode, "true");
}
options.put(WXConfig.scale, Float.toString(sApplication.getResources().getDisplayMetrics().density));
addCustomOptions(WXConfig.scale, Float.toString(sApplication.getResources().getDisplayMetrics().density));
}catch (NullPointerException e){
//There is little chance of NullPointerException as sApplication may be null.
WXLogUtils.e("WXEnvironment scale Exception: ", e);
}
configs.putAll(options);
if(configs!=null&&configs.get(WXConfig.appName)==null && sApplication!=null){
configs.putAll(getCustomOptions());
if(configs.get(WXConfig.appName)==null && sApplication!=null){
configs.put(WXConfig.appName, sApplication.getPackageName());
}
return configs;
Expand Down Expand Up @@ -216,6 +210,12 @@ private static String getAppCacheFile() {
}


/**
* Use {@link #addCustomOptions(String, String)} to add custom options.
* Use {@link #getCustomOptions(String)} to get custom options
* @return
*/
@Deprecated
public static Map<String, String> getCustomOptions() {
return options;
}
Expand All @@ -224,6 +224,10 @@ public static void addCustomOptions(String key, String value) {
options.put(key, value);
}

public static String getCustomOptions(String key){
return options.get(key);
}

@Deprecated
/**
* Use {@link #isHardwareSupport()} if you want to see whether current hardware support Weex.
Expand Down Expand Up @@ -261,7 +265,7 @@ public static boolean isHardwareSupport() {
* @return true when support
*/
public static boolean isCPUSupport(){
boolean excludeX86 = "true".equals(options.get(SETTING_EXCLUDE_X86SUPPORT));
boolean excludeX86 = "true".equals(getCustomOptions().get(SETTING_EXCLUDE_X86SUPPORT));
boolean isX86AndExcluded = WXSoInstallMgrSdk.isX86() && excludeX86;
boolean isCPUSupport = WXSoInstallMgrSdk.isCPUSupport() && !isX86AndExcluded;
if (WXEnvironment.isApkDebugable()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2363,7 +2363,7 @@ public static void updateGlobalConfig(String config) {
}
if(!TextUtils.equals(config, globalConfig)){
globalConfig = config;
WXEnvironment.getCustomOptions().put(GLOBAL_CONFIG_KEY, globalConfig);
WXEnvironment.addCustomOptions(GLOBAL_CONFIG_KEY, globalConfig);
Runnable runnable = new Runnable() {
@Override
public void run() {
Expand Down
2 changes: 1 addition & 1 deletion weex_core/Source/android/utils/params_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ std::vector<INIT_FRAMEWORK_PARAMS*> initFromParam(
return initFrameworkParams;
}

jclass jmapclass = env->FindClass("java/util/HashMap");
jclass jmapclass = env->FindClass("java/util/Map");
jmethodID jkeysetmid =
env->GetMethodID(jmapclass, "keySet", "()Ljava/util/Set;");
jmethodID jgetmid = env->GetMethodID(
Expand Down