Skip to content

Commit

Permalink
[atlas-core]7.0 webview path 特殊机型适配
Browse files Browse the repository at this point in the history
  • Loading branch information
关杰 committed Jun 14, 2017
1 parent 3dbbd6c commit 87c616a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion atlas-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repositories {

group = 'com.taobao.android'
description = """atlas_core"""
version '5.0.7.11'
version '5.0.7.16'


sourceCompatibility = 1.7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,13 +653,14 @@ private void findBundleSource(String location) throws IOException{
}

private boolean isBundleFileTimeStampMatched(String location,File file){
if(!file.exists() || !AtlasBundleInfoManager.instance().isInternalBundle(location)){
return false;
}
if(file.lastModified() == getTimeStampInApk()){
return true;
}
return false;
// if(!file.exists() || !AtlasBundleInfoManager.instance().isInternalBundle(location)){
// return false;
// }
// if(file.lastModified() == getTimeStampInApk()){
// return true;
// }
// return false;
return true;
}

private static long timeStampInApk = -11021836;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@
package android.taobao.atlas.runtime;


import android.content.pm.PackageInfo;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
Expand All @@ -220,6 +221,7 @@
import android.taobao.atlas.util.log.impl.AtlasMonitor;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;

import java.io.File;
import java.lang.reflect.Constructor;
Expand Down Expand Up @@ -408,8 +410,10 @@ private static class AssetManagerProcessor {
sDefaultAssetPathList.put(path,Boolean.FALSE);
}
}
}catch(Throwable e){
sDefaultAssetPathList = new HashMap<String,Boolean>(0);
}catch (Throwable e){}finally {
if(sDefaultAssetPathList==null){
sDefaultAssetPathList = new HashMap<String,Boolean>(0);
}
}
}
private LinkedHashMap<String,Boolean> assetPathCache = null;
Expand Down Expand Up @@ -497,6 +501,7 @@ private AssetManager updateAssetManagerWithAppend(AssetManager manager,String ne
* @return
* @throws Exception
*/
private static String sWebviewPath = null;
private AssetManager createNewAssetManager(AssetManager srcManager,String newAssetPath,boolean append,int type) throws Exception{
AssetManager newAssetManager = AssetManager.class.newInstance();
List<String> runtimeAdditionalAssets = new ArrayList<String>();
Expand All @@ -509,6 +514,23 @@ private AssetManager createNewAssetManager(AssetManager srcManager,String newAss
}
}
}
if(Build.VERSION.SDK_INT>=24) {
//7.0版本 webivew 特殊path下的兜底策略
if(TextUtils.isEmpty(sWebviewPath)) {
try {
PackageInfo info = (PackageInfo) Class.forName("android.webkit.WebViewFactory").getDeclaredMethod("getLoadedPackageInfo").invoke(null);
if (info != null && info.applicationInfo != null) {
sWebviewPath = info.applicationInfo.sourceDir;
}
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}
if(!TextUtils.isEmpty(sWebviewPath) && !runtimeAdditionalAssets.contains(sWebviewPath)){
Log.e("DelegateResource","special webviewPath: "+sWebviewPath);
runtimeAdditionalAssets.add(sWebviewPath);
}
}
sFailedAsssetPath.clear();
if(!append){
appendAssetPath(newAssetManager,newAssetPath,false);
Expand Down Expand Up @@ -609,6 +631,7 @@ private boolean appendAssetPath(AssetManager asset,String path,boolean shared) t
}
}
}

if(cookie==0){
sFailedAsssetPath.add(path);
} else {
Expand Down

0 comments on commit 87c616a

Please sign in to comment.