fng 4 years ago
commit
8f7c091c51
  1. 14
      .gitignore
  2. 7
      README.md
  3. 0
      assets/.gitkeep
  4. 0
      assets/.gitkeeper
  5. 1
      assets/main.js
  6. 169
      build.gradle
  7. 251
      config/quality/checkstyle.xml
  8. 23
      gradle.properties
  9. BIN
      libs/armeabi/libweexjsb.so
  10. BIN
      libs/armeabi/libweexjsc.so
  11. BIN
      libs/armeabi/libweexjss.so
  12. BIN
      libs/armeabi/libweexjst.so
  13. BIN
      libs/x86/libweexjsb.so
  14. BIN
      libs/x86/libweexjsc.so
  15. BIN
      libs/x86/libweexjss.so
  16. 19
      proguard-rules.pro
  17. 2
      publish.sh
  18. 37
      src/main/AndroidManifest.xml
  19. 50
      src/main/java/com/taobao/weex/ComponentObserver.java
  20. 41
      src/main/java/com/taobao/weex/IWXActivityStateListener.java
  21. 49
      src/main/java/com/taobao/weex/IWXRenderListener.java
  22. 66
      src/main/java/com/taobao/weex/IWXStatisticsListener.java
  23. 200
      src/main/java/com/taobao/weex/InitConfig.java
  24. 26
      src/main/java/com/taobao/weex/LayoutFinishListener.java
  25. 67
      src/main/java/com/taobao/weex/RenderContainer.java
  26. 341
      src/main/java/com/taobao/weex/WXEnvironment.java
  27. 52
      src/main/java/com/taobao/weex/WXGlobalEventModule.java
  28. 57
      src/main/java/com/taobao/weex/WXGlobalEventReceiver.java
  29. 87
      src/main/java/com/taobao/weex/WXRenderErrorCode.java
  30. 543
      src/main/java/com/taobao/weex/WXSDKEngine.java
  31. 1873
      src/main/java/com/taobao/weex/WXSDKInstance.java
  32. 471
      src/main/java/com/taobao/weex/WXSDKManager.java
  33. 92
      src/main/java/com/taobao/weex/adapter/DefaultUriAdapter.java
  34. 234
      src/main/java/com/taobao/weex/adapter/DefaultWXHttpAdapter.java
  35. 27
      src/main/java/com/taobao/weex/adapter/DrawableStrategy.java
  36. 27
      src/main/java/com/taobao/weex/adapter/ICrashInfoReporter.java
  37. 41
      src/main/java/com/taobao/weex/adapter/IDrawableLoader.java
  38. 31
      src/main/java/com/taobao/weex/adapter/ITracingAdapter.java
  39. 27
      src/main/java/com/taobao/weex/adapter/IWXAccessibilityRoleAdapter.java
  40. 41
      src/main/java/com/taobao/weex/adapter/IWXDebugAdapter.java
  41. 68
      src/main/java/com/taobao/weex/adapter/IWXHttpAdapter.java
  42. 32
      src/main/java/com/taobao/weex/adapter/IWXImgLoaderAdapter.java
  43. 32
      src/main/java/com/taobao/weex/adapter/IWXJSExceptionAdapter.java
  44. 50
      src/main/java/com/taobao/weex/adapter/IWXSoLoaderAdapter.java
  45. 20
      src/main/java/com/taobao/weex/adapter/IWXTypefaceAdapter.java
  46. 47
      src/main/java/com/taobao/weex/adapter/IWXUserTrackAdapter.java
  47. 79
      src/main/java/com/taobao/weex/adapter/URIAdapter.java
  48. 33
      src/main/java/com/taobao/weex/annotation/Component.java
  49. 39
      src/main/java/com/taobao/weex/annotation/JSMethod.java
  50. 31
      src/main/java/com/taobao/weex/appfram/clipboard/IWXClipboard.java
  51. 148
      src/main/java/com/taobao/weex/appfram/clipboard/WXClipboardModule.java
  52. 44
      src/main/java/com/taobao/weex/appfram/navigator/IActivityNavBarSetter.java
  53. 343
      src/main/java/com/taobao/weex/appfram/navigator/WXNavigatorModule.java
  54. 198
      src/main/java/com/taobao/weex/appfram/pickers/DatePickerImpl.java
  55. 328
      src/main/java/com/taobao/weex/appfram/pickers/WXPickersModule.java
  56. 329
      src/main/java/com/taobao/weex/appfram/storage/DefaultWXStorage.java
  57. 32
      src/main/java/com/taobao/weex/appfram/storage/IWXStorage.java
  58. 52
      src/main/java/com/taobao/weex/appfram/storage/IWXStorageAdapter.java
  59. 107
      src/main/java/com/taobao/weex/appfram/storage/StorageResultHandler.java
  60. 219
      src/main/java/com/taobao/weex/appfram/storage/WXSQLiteOpenHelper.java
  61. 180
      src/main/java/com/taobao/weex/appfram/storage/WXStorageModule.java
  62. 48
      src/main/java/com/taobao/weex/appfram/websocket/IWebSocketAdapter.java
  63. 27
      src/main/java/com/taobao/weex/appfram/websocket/IWebSocketAdapterFactory.java
  64. 51
      src/main/java/com/taobao/weex/appfram/websocket/WebSocketCloseCodes.java
  65. 188
      src/main/java/com/taobao/weex/appfram/websocket/WebSocketModule.java
  66. 46
      src/main/java/com/taobao/weex/bridge/EventResult.java
  67. 33
      src/main/java/com/taobao/weex/bridge/Invoker.java
  68. 39
      src/main/java/com/taobao/weex/bridge/JSCallback.java
  69. 28
      src/main/java/com/taobao/weex/bridge/JavascriptInvokable.java
  70. 66
      src/main/java/com/taobao/weex/bridge/MethodInvoker.java
  71. 32
      src/main/java/com/taobao/weex/bridge/ModuleFactory.java
  72. 95
      src/main/java/com/taobao/weex/bridge/NativeInvokeHelper.java
  73. 43
      src/main/java/com/taobao/weex/bridge/SimpleJSCallback.java
  74. 571
      src/main/java/com/taobao/weex/bridge/WXBridge.java
  75. 2290
      src/main/java/com/taobao/weex/bridge/WXBridgeManager.java
  76. 90
      src/main/java/com/taobao/weex/bridge/WXHashMap.java
  77. 65
      src/main/java/com/taobao/weex/bridge/WXJSObject.java
  78. 422
      src/main/java/com/taobao/weex/bridge/WXModuleManager.java
  79. 160
      src/main/java/com/taobao/weex/bridge/WXParams.java
  80. 96
      src/main/java/com/taobao/weex/bridge/WXServiceManager.java
  81. 45
      src/main/java/com/taobao/weex/bridge/WXTask.java
  82. 58
      src/main/java/com/taobao/weex/bridge/WXValidateProcessor.java
  83. 371
      src/main/java/com/taobao/weex/common/Constants.java
  84. 26
      src/main/java/com/taobao/weex/common/Destroyable.java
  85. 27
      src/main/java/com/taobao/weex/common/ICheckBindingScroller.java
  86. 109
      src/main/java/com/taobao/weex/common/IWXBridge.java
  87. 34
      src/main/java/com/taobao/weex/common/IWXDebugProxy.java
  88. 23
      src/main/java/com/taobao/weex/common/IWXObject.java
  89. 23
      src/main/java/com/taobao/weex/common/IWXTask.java
  90. 56
      src/main/java/com/taobao/weex/common/OnWXScrollListener.java
  91. 98
      src/main/java/com/taobao/weex/common/TypeModuleFactory.java
  92. 84
      src/main/java/com/taobao/weex/common/WXCompatModule.java
  93. 36
      src/main/java/com/taobao/weex/common/WXConfig.java
  94. 240
      src/main/java/com/taobao/weex/common/WXErrorCode.java
  95. 28
      src/main/java/com/taobao/weex/common/WXException.java
  96. 24
      src/main/java/com/taobao/weex/common/WXImageSharpen.java
  97. 64
      src/main/java/com/taobao/weex/common/WXImageStrategy.java
  98. 34
      src/main/java/com/taobao/weex/common/WXInstanceWrap.java
  99. 38
      src/main/java/com/taobao/weex/common/WXJSBridgeMsgType.java
  100. 36
      src/main/java/com/taobao/weex/common/WXJSEngineListener.java
  101. Some files were not shown because too many files have changed in this diff Show More

14
.gitignore vendored

@ -0,0 +1,14 @@
.gradle
.idea
build
captures
local.properties
target
bin
.classpath
.project
.settings
gen
*.iml
lint.xml
project.properties

7
README.md

@ -0,0 +1,7 @@
## Unit Test
Unit test code is under 'src/test'. You can run unit test use command:
```bash
./gradlew clean testDebugUnitTest jacocoTestReportDebug
```
This task will run all unit test and produce both unit test report and jacoco test coverage report in 'build/reports'.

0
assets/.gitkeep

0
assets/.gitkeeper

1
assets/main.js

File diff suppressed because one or more lines are too long

169
build.gradle

@ -0,0 +1,169 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.7.3'
classpath 'com.vanniktech:gradle-android-junit-jacoco-plugin:0.5.0'
}
}
plugins {
id "com.github.hierynomus.license" version "0.14.0"
}
apply plugin: 'com.android.library'
apply plugin: 'checkstyle'
apply plugin: 'com.getkeepsafe.dexcount'
ext.disableCov = project.hasProperty('disableCov') ? project.getProperty('disableCov') : 'false'
if(!disableCov.toBoolean()){
apply plugin: 'com.vanniktech.android.junit.jacoco'
junitJacoco {
excludes = ['com/taobao/weex/dom/flex/**','com/taobao/weex/ui/view/refresh/circlebar/**']
}
}
task checkstyle(type: Checkstyle) {
configFile file("${project.rootDir}/config/quality/checkstyle.xml") // Where my checkstyle config is...
// configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath // Where is my suppressions file for checkstyle is...
source 'src'
include '**/*.java'
exclude '**/gen/**'
exclude '**/test/**'
exclude '**/com/taobao/weex/dom/flex/**'
classpath = files()
}
checkstyle {
toolVersion = '6.9'
}
version = "0.18.0"
android {
compileSdkVersion COMPILE_SDK_VERSION as int
buildToolsVersion BUILD_TOOLS_VERSION
resourcePrefix "weex"
useLibrary 'org.apache.http.legacy'
copy {
from '../../pre-build'
into new File(projectDir,"assets")
include 'native-bundle-main.js'
rename('native-bundle-main.js','main.js')
}
def line
new File(projectDir,"assets/main.js").withReader { line = it.readLine() }
def m = line =~ /[A-Z\s]+\s+([0-9\.]+),\s+Build\s+[0-9]+/;
def jsfmVersion = m[0][1]
println jsfmVersion
if(project.hasProperty('asfRelease')){
//download so file if not exist, when compile in source release
download{
src 'https://git-wip-us.apache.org/repos/asf?p=incubator-weex.git;a=blob_plain;f=android/sdk/libs/armeabi/libweexjsc.so;hb=refs/heads/master'
dest "${projectDir}/libs/armeabi/libweexjsc.so"
overwrite false
}
download{
src 'https://git-wip-us.apache.org/repos/asf?p=incubator-weex.git;a=blob_plain;f=android/sdk/libs/x86/libweexjsc.so;hb=refs/heads/master'
dest "${projectDir}/libs/x86/libweexjsc.so"
overwrite false
}
}
def ARMEABI_Size = new File(projectDir,"libs/armeabi/libweexjsc.so").length();
def X86_Size = new File(projectDir,"libs/x86/libweexjsc.so").length();
println "ARMEABI_Size: "+ARMEABI_Size;
println "X86_Size:" + X86_Size;
defaultConfig {
buildConfigField "long", "ARMEABI_Size", "${ARMEABI_Size}"
buildConfigField "long", "X86_Size", "${X86_Size}"
buildConfigField "String", "buildJavascriptFrameworkVersion", "\"${jsfmVersion}\""
buildConfigField "String", "buildVersion", "\"${version}\""
minSdkVersion 14
targetSdkVersion TARGET_SDK_VERSION as int
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi","x86"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "ENABLE_TRACE", "false"
}
debug {
testCoverageEnabled true
buildConfigField "boolean", "ENABLE_TRACE", "true"
}
}
sourceSets {
main {
assets.srcDirs = ['assets']
jniLibs.srcDir(['libs'])
java {
srcDirs = ["src/main/java"];
}
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
compileOptions.encoding = "UTF-8"
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
testOptions {
unitTests.returnDefaultValues = true
unitTests.all {
maxHeapSize = "1024m"
jvmArgs += ['-XX:-UseSplitVerifier', '-noverify','-Xverify:none']/* fix VerifyError */
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
provided "com.android.support:recyclerview-v7:${PROJECT_SUPPORTLIBVERSION}"
provided "com.android.support:support-v4:${PROJECT_SUPPORTLIBVERSION}"
provided "com.android.support:appcompat-v7:${PROJECT_SUPPORTLIBVERSION}"
provided "com.alibaba:fastjson:1.1.46.android"
testCompile "com.alibaba:fastjson:1.1.46.android"
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-core:1.3'
testCompile 'org.javassist:javassist:3.20.0-GA'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.objenesis:objenesis:2.1'
testCompile 'org.powermock:powermock-core:1.6.4'
testCompile 'org.powermock:powermock-api-mockito:1.6.4'
testCompile 'org.powermock:powermock-module-junit4-common:1.6.4'
testCompile 'org.powermock:powermock-module-junit4:1.6.4'
testCompile 'org.powermock:powermock-module-junit4-legacy:1.6.4'
testCompile 'org.powermock:powermock-module-testng:1.6.4'
testCompile 'org.powermock:powermock-classloading-xstream:1.6.4'
testCompile "org.powermock:powermock-module-junit4-rule:1.6.4"
testCompile 'org.robolectric:robolectric:3.3.2'
testCompile "org.robolectric:shadows-httpclient:3.3.2"
testCompile 'org.json:json:20160212'
}
if(file('../license/LICENSE').exists()){
license {
header = file('../license/LICENSE')
excludes(["com/taobao/weex/dom/flex/*.java"])
}
preBuild.dependsOn licenseFormat
}

251
config/quality/checkstyle.xml

@ -0,0 +1,251 @@
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration that checks the Google coding conventions from Google Java Style
that can be found at https://google.github.io/styleguide/javaguide.html.
Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.sf.net (or in your downloaded distribution).
To completely disable a check, just comment it out or delete it from the file.
Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
-->
<module name = "Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java, properties, xml"/>
<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<!--<module name="Header">
<property name="headerFile" value="license/LICENSE"/>
<property name="ignoreLines" value="0,1,2,3,4,5,202"/>
<property name="fileExtensions" value="java"/>
</module>-->
<module name="TreeWalker">
<module name="OuterTypeFilename"/>
<module name="IllegalTokenText">
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
<property name="format" value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
<property name="message" value="Avoid using corresponding octal or Unicode escape."/>
</module>
<module name="AvoidEscapedUnicodeCharacters">
<property name="allowEscapesForControlCharacters" value="true"/>
<property name="allowByTailComment" value="true"/>
<property name="allowNonPrintableEscapes" value="true"/>
</module>
<module name="LineLength">
<property name="max" value="100"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>
<module name="AvoidStarImport"/>
<module name="OneTopLevelClass"/>
<module name="NoLineWrap"/>
<module name="EmptyBlock">
<property name="option" value="TEXT"/>
<property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
</module>
<module name="NeedBraces"/>
<module name="LeftCurly">
<property name="maxLineLength" value="100"/>
</module>
<module name="RightCurly"/>
<module name="RightCurly">
<property name="option" value="alone"/>
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
</module>
<module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyTypes" value="true"/>
<property name="allowEmptyLoops" value="true"/>
<message key="ws.notFollowed"
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
<message key="ws.notPreceded"
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
</module>
<module name="OneStatementPerLine"/>
<module name="MultipleVariableDeclarations"/>
<module name="ArrayTypeStyle"/>
<module name="MissingSwitchDefault"/>
<module name="FallThrough"/>
<module name="UpperEll"/>
<module name="ModifierOrder"/>
<module name="ConstantName">
</module>
<module name="EmptyLineSeparator">
<property name="allowNoEmptyLineBetweenFields" value="true"/>
</module>
<module name="SeparatorWrap">
<property name="tokens" value="DOT"/>
<property name="option" value="nl"/>
</module>
<module name="SeparatorWrap">
<property name="tokens" value="COMMA"/>
<property name="option" value="EOL"/>
</module>
<module name="PackageName">
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
<message key="name.invalidPattern"
value="Package name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="TypeName">
<message key="name.invalidPattern"
value="Type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="MemberName">
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
<message key="name.invalidPattern"
value="Member name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ParameterName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
<message key="name.invalidPattern"
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<!--<module name="CatchParameterName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
<message key="name.invalidPattern"
value="Catch parameter name ''{0}'' must match pattern ''{1}''."/>
</module>-->
<module name="LocalVariableName">
<property name="tokens" value="VARIABLE_DEF"/>
<property name="format" value="^[a-z0-9][a-zA-Z0-9]*$"/>
<property name="allowOneCharVarInForLoop" value="true"/>
<message key="name.invalidPattern"
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ClassTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Class type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="MethodTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Method type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="InterfaceTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Interface type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="NoFinalizer"/>
<module name="GenericWhitespace">
<message key="ws.followed"
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
<message key="ws.preceded"
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
<message key="ws.illegalFollow"
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
<message key="ws.notPreceded"
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
</module>
<module name="Indentation">
<property name="severity" value="ignore"/>
<property name="basicOffset" value="2"/>
<property name="braceAdjustment" value="0"/>
<property name="caseIndent" value="2"/>
<property name="throwsIndent" value="4"/>
<property name="lineWrappingIndentation" value="4"/>
<property name="arrayInitIndent" value="2"/>
</module>
<module name="AbbreviationAsWordInName">
<property name="ignoreFinal" value="false"/>
<property name="allowedAbbreviationLength" value="1"/>
</module>
<module name="OverloadMethodsDeclarationOrder"/>
<module name="VariableDeclarationUsageDistance"/>
<module name="CustomImportOrder">
<property name="specialImportsRegExp" value="com.google"/>
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="customImportOrderRules" value="STATIC###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
</module>
<module name="MethodParamPad"/>
<module name="OperatorWrap">
<property name="option" value="NL"/>
<property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
</module>
<module name="AnnotationLocation">
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
</module>
<module name="AnnotationLocation">
<property name="tokens" value="VARIABLE_DEF"/>
<property name="allowSamelineMultipleAnnotations" value="true"/>
</module>
<module name="NonEmptyAtclauseDescription"/>
<module name="JavadocTagContinuationIndentation"/>
<module name="SummaryJavadoc">
<property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
</module>
<module name="JavadocParagraph">
<property name="severity" value="ignore"/>
</module>
<module name="AtclauseOrder">
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
</module>
<!-- disable javadoc check -->
<module name="JavadocType">
<property name="severity" value="ignore"/>
</module>
<module name="JavadocMethod">
<property name="severity" value="ignore"/>
</module>
<module name="JavadocVariable">
<property name="severity" value="ignore"/>
</module>
<!--<module name="JavadocMethod">
<property name="severity" value="ignore"/>
<property name="scope" value="public"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="minLineCount" value="2"/>
<property name="allowedAnnotations" value="Override, Test"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
</module>-->
<module name="MethodName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
<message key="name.invalidPattern"
value="Method name ''{0}'' must match pattern ''{1}''."/>
</module>
<!--<module name="SingleLineJavadoc">
<property name="ignoreInlineTags" value="false"/>
</module>-->
<module name="EmptyCatchBlock">
<property name="exceptionVariableName" value="expected"/>
</module>
<!--<module name="CommentsIndentation"/>-->
</module>
</module>

23
gradle.properties

@ -0,0 +1,23 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.useDeprecatedNdk=true
org.gradle.daemon=false
org.gradle.parallel=false
org.gradle.jvmargs=-Xmx2048M

BIN
libs/armeabi/libweexjsb.so

Binary file not shown.

BIN
libs/armeabi/libweexjsc.so

Binary file not shown.

BIN
libs/armeabi/libweexjss.so

Binary file not shown.

BIN
libs/armeabi/libweexjst.so

Binary file not shown.

BIN
libs/x86/libweexjsb.so

Binary file not shown.

BIN
libs/x86/libweexjsc.so

Binary file not shown.

BIN
libs/x86/libweexjss.so

Binary file not shown.

19
proguard-rules.pro vendored

@ -0,0 +1,19 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/ouy/Library/AndroidStudio/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keep class com.taobao.weex.bridge.** { *; }
-dontwarn com.taobao.weex.bridge.**

2
publish.sh

@ -0,0 +1,2 @@
#!/usr/bin/env bash
./gradlew clean assemble publish

37
src/main/AndroidManifest.xml

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.taobao.weappplus_sdk"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21"/>
<application>
<receiver
android:name="com.taobao.weex.WXGlobalEventReceiver"
android:enabled="true"
android:exported="false">
</receiver>
</application>
</manifest>

50
src/main/java/com/taobao/weex/ComponentObserver.java

@ -0,0 +1,50 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
import android.view.View;
import com.taobao.weex.ui.component.WXComponent;
/**
* Created by sospartan on 14/06/2017.
*/
public interface ComponentObserver {
/**
* Called after component is create.
* Notice: View is not created at this moment.
* @param component
*/
void onCreate(WXComponent component);
/**
* Called before component destroy.
* @param component
*/
void onPreDestory(WXComponent component);
/**
* Called when component's view is created
* @param component
* @param view
*/
void onViewCreated(WXComponent component,View view);
}

41
src/main/java/com/taobao/weex/IWXActivityStateListener.java

@ -0,0 +1,41 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
/**
* Listener class for activity lifecycle
*/
@Deprecated
public interface IWXActivityStateListener {
void onActivityCreate();
void onActivityStart();
void onActivityPause();
void onActivityResume();
void onActivityStop();
void onActivityDestroy();
boolean onActivityBack();
}

49
src/main/java/com/taobao/weex/IWXRenderListener.java

@ -0,0 +1,49 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
import android.view.View;
public interface IWXRenderListener {
/**
* If {@link com.taobao.weex.common.WXRenderStrategy#APPEND_ASYNC} is applied, this method
* will be invoked when the rendering of first view is finish.
* If {@link com.taobao.weex.common.WXRenderStrategy#APPEND_ONCE} is applied, this method will
* be invoked when the rendering of the view tree is finished.
*/
void onViewCreated(WXSDKInstance instance, View view);
/**
* Called when the render view phase of weex has finished.
* It can be invoked at most once in the entire life of a {@link WXSDKInstance}
*/
void onRenderSuccess(WXSDKInstance instance, int width, int height);
/**
* Callback method, called when refresh is finished
*/
void onRefreshSuccess(WXSDKInstance instance, int width, int height);
/**
* Report exception occurred when weex instance is running. Exception <strong>may not</strong>
* cause user-noticeable failure of weex.
*/
void onException(WXSDKInstance instance, String errCode, String msg);
}

66
src/main/java/com/taobao/weex/IWXStatisticsListener.java

@ -0,0 +1,66 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
public interface IWXStatisticsListener {
/**
* Called when weex sdk engine begin to initialize.
*/
void onSDKEngineInitialize();
/**
* Called when begin to load js framework.
*/
void onJsFrameworkStart();
/**
* Called when finish loading js framework.
*/
void onJsFrameworkReady();
/**
* Called when the render view phase of first view reached.
*/
void onFirstView();
/**
* Called when the render view phase of first screen reached.
*/
void onFirstScreen();
/**
* Called when to start a http request.
*/
void onHttpStart();
/**
* Called when received a http response header data.
*/
void onHeadersReceived();
/**
* Called when to finish a http request.
*/
void onHttpFinish();
/**
* Called when an exception occured.
*/
void onException(String instanceid, String errCode, String msg);
}

200
src/main/java/com/taobao/weex/InitConfig.java

@ -0,0 +1,200 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
import com.taobao.weex.adapter.IDrawableLoader;
import com.taobao.weex.adapter.IWXDebugAdapter;
import com.taobao.weex.adapter.IWXHttpAdapter;
import com.taobao.weex.adapter.IWXImgLoaderAdapter;
import com.taobao.weex.adapter.IWXJSExceptionAdapter;
import com.taobao.weex.adapter.IWXSoLoaderAdapter;
import com.taobao.weex.adapter.IWXTypefaceAdapter;
import com.taobao.weex.adapter.IWXUserTrackAdapter;
import com.taobao.weex.adapter.URIAdapter;
import com.taobao.weex.appfram.storage.IWXStorageAdapter;
import com.taobao.weex.appfram.websocket.IWebSocketAdapterFactory;
/**
* Created by sospartan on 5/31/16.
*/
public class InitConfig {
private IWXHttpAdapter httpAdapter;
private IDrawableLoader drawableLoader;
private IWXImgLoaderAdapter imgAdapter;
private IWXUserTrackAdapter utAdapter;
private IWXDebugAdapter debugAdapter;
private IWXStorageAdapter storageAdapter;
private IWXSoLoaderAdapter soLoader;
private URIAdapter mURIAdapter;
private IWebSocketAdapterFactory webSocketAdapterFactory;
private IWXJSExceptionAdapter mJSExceptionAdapter;
private String framework;
//本木自定义adapter
private IWXTypefaceAdapter mTypefaceAdapter;
public IWXHttpAdapter getHttpAdapter() {
return httpAdapter;
}
public IWXImgLoaderAdapter getImgAdapter() {
return imgAdapter;
}
public IDrawableLoader getDrawableLoader() {
return drawableLoader;
}
public IWXUserTrackAdapter getUtAdapter() {
return utAdapter;
}
public IWXDebugAdapter getDebugAdapter() {
return debugAdapter;
}
public IWXSoLoaderAdapter getIWXSoLoaderAdapter() {
return soLoader;
}
public String getFramework() {
return framework;
}
public IWXStorageAdapter getStorageAdapter() {
return storageAdapter;
}
public URIAdapter getURIAdapter() {
return mURIAdapter;
}
public IWebSocketAdapterFactory getWebSocketAdapterFactory() {
return webSocketAdapterFactory;
}
public IWXJSExceptionAdapter getJSExceptionAdapter() {
return mJSExceptionAdapter;
}
public IWXTypefaceAdapter getTypefaceAdapter() {
return mTypefaceAdapter;
}
private InitConfig() {
}
public static class Builder {
IWXHttpAdapter httpAdapter;
IWXImgLoaderAdapter imgAdapter;
IDrawableLoader drawableLoader;
IWXUserTrackAdapter utAdapter;
IWXDebugAdapter debugAdapter;
IWXStorageAdapter storageAdapter;
IWXSoLoaderAdapter soLoader;
URIAdapter mURIAdapter;
IWXJSExceptionAdapter mJSExceptionAdapter;
String framework;
IWebSocketAdapterFactory webSocketAdapterFactory;
//本木自定义adapter
private IWXTypefaceAdapter typefaceAdapter;
public Builder() {
}
public Builder setHttpAdapter(IWXHttpAdapter httpAdapter) {
this.httpAdapter = httpAdapter;
return this;
}
public Builder setImgAdapter(IWXImgLoaderAdapter imgAdapter) {
this.imgAdapter = imgAdapter;
return this;
}
public Builder setDrawableLoader(IDrawableLoader drawableLoader) {
this.drawableLoader = drawableLoader;
return this;
}
public Builder setUtAdapter(IWXUserTrackAdapter utAdapter) {
this.utAdapter = utAdapter;
return this;
}
public Builder setDebugAdapter(IWXDebugAdapter debugAdapter) {
this.debugAdapter = debugAdapter;
return this;
}
public Builder setStorageAdapter(IWXStorageAdapter storageAdapter) {
this.storageAdapter = storageAdapter;
return this;
}
public Builder setURIAdapter(URIAdapter URIAdapter) {
mURIAdapter = URIAdapter;
return this;
}
public Builder setJSExceptionAdapter(IWXJSExceptionAdapter JSExceptionAdapter) {
mJSExceptionAdapter = JSExceptionAdapter;
return this;
}
public Builder setSoLoader(IWXSoLoaderAdapter loader) {
this.soLoader = loader;
return this;
}
public Builder setFramework(String framework) {
this.framework = framework;
return this;
}
public Builder setWebSocketAdapterFactory(IWebSocketAdapterFactory factory) {
this.webSocketAdapterFactory = factory;
return this;
}
public Builder setTypefaceAdapter(IWXTypefaceAdapter adapter) {
this.typefaceAdapter = adapter;
return this;
}
public InitConfig build() {
InitConfig config = new InitConfig();
config.httpAdapter = this.httpAdapter;
config.imgAdapter = this.imgAdapter;
config.drawableLoader = this.drawableLoader;
config.utAdapter = this.utAdapter;
config.debugAdapter = this.debugAdapter;
config.storageAdapter = this.storageAdapter;
config.soLoader = this.soLoader;
config.framework = this.framework;
config.mURIAdapter = this.mURIAdapter;
config.webSocketAdapterFactory = this.webSocketAdapterFactory;
config.mJSExceptionAdapter = this.mJSExceptionAdapter;
config.mTypefaceAdapter = this.typefaceAdapter;
return config;
}
}
}

26
src/main/java/com/taobao/weex/LayoutFinishListener.java

@ -0,0 +1,26 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
import android.support.annotation.NonNull;
public interface LayoutFinishListener {
void onLayoutFinish(@NonNull WXSDKInstance instance);
}

67
src/main/java/com/taobao/weex/RenderContainer.java

@ -0,0 +1,67 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import java.lang.ref.WeakReference;
/**
* Created by sospartan on 08/10/2016.
*/
public class RenderContainer extends FrameLayout {
private WeakReference<WXSDKInstance> mSDKInstance;
public RenderContainer(Context context) {
super(context);
}
public RenderContainer(Context context, AttributeSet attrs) {
super(context, attrs);
}
public RenderContainer(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public RenderContainer(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
public void setSDKInstance(WXSDKInstance instance) {
mSDKInstance = new WeakReference<>(instance);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
WXSDKInstance instance;
if (mSDKInstance != null && (instance = mSDKInstance.get()) != null) {
//re-render instance
instance.setSize(w, h);
}
}
}

341
src/main/java/com/taobao/weex/WXEnvironment.java

@ -0,0 +1,341 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.taobao.weex;
import android.app.Application;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Typeface;
import android.os.Environment;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.taobao.weappplus_sdk.BuildConfig;
import com.taobao.weex.common.WXConfig;
import com.taobao.weex.utils.FontDO;
import com.taobao.weex.common.WXErrorCode;
import com.taobao.weex.utils.LogLevel;
import com.taobao.weex.utils.TypefaceUtil;
import com.taobao.weex.utils.WXExceptionUtils;
import com.taobao.weex.utils.WXLogUtils;
import com.taobao.weex.utils.WXSoInstallMgrSdk;
import com.taobao.weex.utils.WXUtils;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
public class WXEnvironment {
public static final String OS = "android";
public static final String SYS_VERSION = android.os.Build.VERSION.RELEASE;
public static final String SYS_MODEL = android.os.Build.MODEL;
public static final String ENVIRONMENT = "environment";
public static final String WEEX_CURRENT_KEY = "wx_current_url";
/*********************
* Global config
***************************/
public static String JS_LIB_SDK_VERSION = BuildConfig.buildJavascriptFrameworkVersion;
public static String WXSDK_VERSION = BuildConfig.buildVersion;
public static Application sApplication;
public static final String DEV_Id = getDevId();
@Deprecated
public static int sDefaultWidth = 750;
public volatile static boolean JsFrameworkInit = false;
public static final String SETTING_EXCLUDE_X86SUPPORT = "env_exclude_x86";
public static boolean SETTING_FORCE_VERTICAL_SCREEN = false;
/**
* Debug model
*/
public static boolean sDebugMode = false;
public static boolean sForceEnableDevTool = false;
public static String sDebugWsUrl = "";
public static boolean sDebugServerConnectable = false;
public static boolean sRemoteDebugMode = false;
public static String sRemoteDebugProxyUrl = "";
public static boolean sDebugNetworkEventReporterEnable = false;//debugtool network switch
public static long sJSLibInitTime = 0;
public static long sSDKInitStart = 0;// init start timestamp
public static long sSDKInitInvokeTime = 0;//time cost to invoke init method
public static long sSDKInitExecuteTime = 0;//time cost to execute init job
/** from init to sdk-ready **/
public static long sSDKInitTime =0;
public static LogLevel sLogLevel = LogLevel.DEBUG;
private static boolean isApkDebug = true;
public static boolean isPerf = false;
private static boolean openDebugLog = false;
private static String sGlobalFontFamily;
private static Map<String, String> options = new HashMap<>();
static {
options.put(WXConfig.os, OS);
options.put(WXConfig.osName, OS);
}
/**
* dynamic
*/
public static boolean sDynamicMode = false;
public static String sDynamicUrl = "";
/**
* Fetch system information.
* @return map contains system information.
*/
public static Map<String, String> getConfig() {
Map<String, String> configs = new HashMap<>();
configs.put(WXConfig.os, OS);
configs.put(WXConfig.appVersion, getAppVersionName());
configs.put(WXConfig.cacheDir, getAppCacheFile());
configs.put(WXConfig.devId, DEV_Id);
configs.put(WXConfig.sysVersion, SYS_VERSION);
configs.put(WXConfig.sysModel, SYS_MODEL);
configs.put(WXConfig.weexVersion, String.valueOf(WXSDK_VERSION));
configs.put(WXConfig.logLevel,sLogLevel.getName());
try {
options.put(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.put(WXConfig.appName, sApplication.getPackageName());
}
return configs;
}
/**
* Get the version of the current app.
*/
private static String getAppVersionName() {
String versionName = "";
PackageManager manager;
PackageInfo info = null;
try {
manager = sApplication.getPackageManager();
info = manager.getPackageInfo(sApplication.getPackageName(), 0);
versionName = info.versionName;
} catch (Exception e) {
WXLogUtils.e("WXEnvironment getAppVersionName Exception: ", e);
}
return versionName;
}
/**
*
* @return string cache file
*/
private static String getAppCacheFile() {
String cache = "";
try {
cache = sApplication.getApplicationContext().getCacheDir().getPath();
} catch (Exception e) {
WXLogUtils.e("WXEnvironment getAppCacheFile Exception: ", e);
}
return cache;
}
public static Map<String, String> getCustomOptions() {
return options;
}
public static void addCustomOptions(String key, String value) {
options.put(key, value);
}
@Deprecated
/**
* Use {@link #isHardwareSupport()} if you want to see whether current hardware support Weex.
*/
public static boolean isSupport() {
boolean isInitialized = WXSDKEngine.isInitialized();
if(!isInitialized){
WXLogUtils.e("WXSDKEngine.isInitialized():" + isInitialized);
}
return isHardwareSupport() && isInitialized;
}
/**
* Tell whether Weex can run on current hardware.
* @return true if weex can run on current hardware, otherwise false.
* Weex has removed the restrictions on the tablet, please use {@link #isCPUSupport()}
*/
@Deprecated
public static boolean isHardwareSupport() {
if (WXEnvironment.isApkDebugable()) {
WXLogUtils.d("isTableDevice:" + WXUtils.isTabletDevice());
}
return isCPUSupport() && !WXUtils.isTabletDevice();
}
/**
* Determine whether Weex supports the current CPU architecture
* @return true when support
*/
public static boolean isCPUSupport(){
boolean excludeX86 = "true".equals(options.get(SETTING_EXCLUDE_X86SUPPORT));
boolean isX86AndExcluded = WXSoInstallMgrSdk.isX86() && excludeX86;
boolean isCPUSupport = WXSoInstallMgrSdk.isCPUSupport() && !isX86AndExcluded;
if (WXEnvironment.isApkDebugable()) {
WXLogUtils.d("WXEnvironment.sSupport:" + isCPUSupport
+ "isX86AndExclueded: "+ isX86AndExcluded);
}
return isCPUSupport;
}
public static boolean isApkDebugable() {
if (sApplication == null) {
return false;
}
if (isPerf) {
return false;
}
if (!isApkDebug) {
return false;
}
try {
ApplicationInfo info = sApplication.getApplicationInfo();
isApkDebug = (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
return isApkDebug;
} catch (Exception e) {
/**
* Don't call WXLogUtils.e here,will cause stackoverflow
*/
e.printStackTrace();
}
return false;
}
public static boolean isPerf() {
return isPerf;
}
private static String getDevId() {
return sApplication == null ? "" : ((TelephonyManager) sApplication
.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
}
public static Application getApplication() {
return sApplication;
}
public void initMetrics() {
if (sApplication == null) {
return;
}
}
public static String getDiskCacheDir(Context context) {
if (context == null) {
return null;
}
String cachePath = null;
try {
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
|| !Environment.isExternalStorageRemovable()) {
cachePath = context.getExternalCacheDir().getPath();
} else {
cachePath = context.getCacheDir().getPath();
}
} catch (Exception e) {
e.printStackTrace();
}
return cachePath;
}
public static String getFilesDir(Context context) {
if (context == null) {
return "";
}
File filesDir = context.getFilesDir();
String path = "";
if (filesDir != null) {
path = filesDir.getPath();
} else {
path = WXEnvironment.getApplication().getApplicationInfo().dataDir;
path += File.separator;
path += "files";
}
return path;
}
public static String getGlobalFontFamilyName() {
return sGlobalFontFamily;
}
public static void setGlobalFontFamily(String fontFamilyName, Typeface typeface) {
WXLogUtils.d("GlobalFontFamily", "Set global font family: " + fontFamilyName);
sGlobalFontFamily = fontFamilyName;
if (!TextUtils.isEmpty(fontFamilyName)) {
if (typeface == null) {
TypefaceUtil.removeFontDO(fontFamilyName);
} else {
FontDO nativeFontDO = new FontDO(fontFamilyName, typeface);
TypefaceUtil.putFontDO(nativeFontDO);