You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ky...@apache.org on 2019/01/17 11:28:23 UTC
[incubator-weex] branch master updated: * [Android] Fix problem of
ConcurrentModificaiton (#2043)
This is an automated email from the ASF dual-hosted git repository.
kyork pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
The following commit(s) were added to refs/heads/master by this push:
new 8ae9853 * [Android] Fix problem of ConcurrentModificaiton (#2043)
8ae9853 is described below
commit 8ae985386e8acf6f17445c66cf8d9b1259004f6d
Author: YorkShen <sh...@gmail.com>
AuthorDate: Thu Jan 17 19:28:17 2019 +0800
* [Android] Fix problem of ConcurrentModificaiton (#2043)
* [Android] Fix Problem of ConcurrentModificaion
* [Android] Change WXEnvironment.getCustomOptions().put() to WXEnvironment.addCustomOptions();
---
.../main/java/com/taobao/weex/WXEnvironment.java | 34 ++++++++++++----------
.../com/taobao/weex/bridge/WXBridgeManager.java | 2 +-
weex_core/Source/android/utils/params_utils.cpp | 2 +-
3 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java b/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java
index 4f8d78d..eb90d3a 100644
--- a/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java
+++ b/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java
@@ -27,8 +27,7 @@ import android.graphics.Typeface;
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;
@@ -37,21 +36,16 @@ import com.taobao.weex.utils.WXFileUtils;
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 {
@@ -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);
@@ -170,15 +164,15 @@ public class WXEnvironment {
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;
@@ -216,6 +210,12 @@ public class WXEnvironment {
}
+ /**
+ * 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;
}
@@ -224,6 +224,10 @@ public class WXEnvironment {
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.
@@ -261,7 +265,7 @@ public class WXEnvironment {
* @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()) {
diff --git a/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java b/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java
index c58b0ec..792c0e7 100644
--- a/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java
+++ b/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java
@@ -2363,7 +2363,7 @@ public class WXBridgeManager implements Callback, BactchExecutor {
}
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() {
diff --git a/weex_core/Source/android/utils/params_utils.cpp b/weex_core/Source/android/utils/params_utils.cpp
index 66c2979..64e5553 100644
--- a/weex_core/Source/android/utils/params_utils.cpp
+++ b/weex_core/Source/android/utils/params_utils.cpp
@@ -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(