Skip to content

Commit

Permalink
合并master代码
Browse files Browse the repository at this point in the history
  • Loading branch information
zhayu.ll committed Nov 27, 2018
2 parents 63a16a1 + 0e1259e commit 1920b32
Show file tree
Hide file tree
Showing 458 changed files with 58,053 additions and 20,065 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/.idea/libraries
!.idea/codeStyleSettings.xml
.DS_Store
/build/
#/build
/captures
.vscode/

Expand Down
1 change: 0 additions & 1 deletion atlas-aapt/prebuilts/clang/darwin-x86/host/3.6
Submodule 3.6 deleted from 606e79
29 changes: 16 additions & 13 deletions atlas-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'


def mini = getEnvValue("mini", 'false')
def commitTag = getEnvValue("commitTag", 'false')

Expand All @@ -11,9 +10,11 @@ buildscript {
repositories {
mavenCentral()
jcenter()
google()
}

dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath "com.taobao.android:atlasplugin:3.0.1-rc55"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath "com.github.dcendents:android-maven-gradle-plugin:1.4.1"
}
Expand All @@ -24,10 +25,12 @@ repositories {

}


group = 'com.taobao.android'
description = """atlas_core"""
String postFix = mini=='true' ? "-mini" : "";
version "5.1.0.0${postFix}"

version "5.1.0.8-RC1"

String getEnvValue(key, defValue) {
def val = System.getProperty(key);
Expand Down Expand Up @@ -126,7 +129,7 @@ project.gradle.buildFinished{

android {
compileSdkVersion 23
buildToolsVersion '25.0.1'
buildToolsVersion '26.0.2'
lintOptions {
abortOnError false
}
Expand Down Expand Up @@ -198,16 +201,16 @@ install {
}
}

task sourcesJar(type: Jar) {
from('src/main/java') {
include '**'
}
classifier = 'sources'
}
//task sourcesJar(type: Jar) {
// from('src/main/java') {
// include '**'
// }
// classifier = 'sources'
//}

artifacts {
archives sourcesJar
}
//artifacts {
// archives sourcesJar
//}

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
Expand Down
2 changes: 1 addition & 1 deletion atlas-core/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Binary file modified atlas-core/libs/armeabi-v7a/libdalvikpatch.so
Binary file not shown.
Binary file modified atlas-core/libs/armeabi/libdalvikpatch.so
Binary file not shown.
Binary file modified atlas-core/libs/mips/libdalvikpatch.so
Binary file not shown.
Binary file modified atlas-core/libs/x86/libdalvikpatch.so
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@
import android.view.ViewGroup;
import android.view.ViewParent;
import org.osgi.framework.Bundle;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.io.File;

import static android.taobao.atlas.runtime.DelegateResources.getGetCookieName;

/**
* Utility class to create {@link ViewDataBinding} from layouts.
*/
public class AtlasDataBindingUtil {
private static HashMap<String, Object> sMappers = new HashMap();
private static final HashMap<String, Object> sMappers = new HashMap();
private static DataBindingComponent sDefaultComponent = null;

/**
Expand Down Expand Up @@ -364,7 +367,8 @@ private static Object getDataBinderMapper(Application application, Resources res
{
String className = null;
String bundleLocation = null;
String assetsPath = (String)AssetManager.class.getMethod("getCookieName", new Class[] { Integer.TYPE }).invoke(resource.getAssets(), new Object[] { Integer.valueOf(cookie) });
AssetManager assets = resource.getAssets();
String assetsPath = getGetCookieName(assets, cookie);
if (assetsPath.endsWith(".zip"))
{
bundleLocation = substringBetween(assetsPath,"/storage/","/");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package android.support.multidex;

import android.util.Log;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
* Created by jingchaoqinjc on 18/3/4.
*/

public class DexElementsMaker implements IDexElementsMaker {

private static final String TAG = "DexElementsMaker";

final ArrayList<File> files;
final IDexElementsMethodInvoker invoker;

DexElementsMaker(ArrayList<File> files, IDexElementsMethodInvoker invoker) {
this.files = files;
this.invoker = invoker;
}

@Override
public Object[] make() throws IllegalAccessException, InvocationTargetException,
NoSuchMethodException {

if (files.size() <= 1) {
return invoker.invoke(files);
}

//通过算法,将文件分解成大小相似的文件集,使得每个文件集在加载的时候时间相似
ArrayList<ArrayList<File>> filesList = makeFilesList();

int size = filesList.size();
FutureTask<Object[]>[] futureTasks = new FutureTask[size];
for (int i = 0; i < size; i++) {
futureTasks[i] = new FutureTask<Object[]>(new DexElementsCallable(i, filesList.get(i), invoker));
}

//其他任务在子线程里完成,加速加载
for (int i = 1; i < size; i++) {
new Thread(futureTasks[i]).start();
}
//一个任务在主线程完成,充分利用主线程资源
futureTasks[0].run();

ArrayList<Object[]> objectsList = new ArrayList<Object[]>();
int objectsTotalLength = 0;

try {
for (int i = 0; i < size; i++) {
Object[] objects = futureTasks[i].get();
if (objects == null) throw new RuntimeException("Illegal Action");

objectsTotalLength += objects.length;
objectsList.add(objects);
}

Object[] objects = new Object[objectsTotalLength];

int offset = 0;
for (Object[] subObjects : objectsList) {
if (subObjects != null) {
System.arraycopy(subObjects, 0, objects, offset, subObjects.length);
offset += subObjects.length;
}
}

return objects;
} catch (Exception e) {

}

return invoker.invoke(files);
}

private long getMaxFileLength() {
long max = 0;
for (File file : files) {
if (file != null) {
long length = file.length();
max = length > max ? length : max;
}
}
return max;
}

private ArrayList<ArrayList<File>> makeFilesList() {
ArrayList<ArrayList<File>> filesList = new ArrayList<ArrayList<File>>();

long maxFileLength = getMaxFileLength();
long subTotalLength = 0;
ArrayList<File> subFiles = new ArrayList<File>();
filesList.add(subFiles);

for (File file : files) {
if (file != null) {
long subLength = file.length();
if (subLength + subTotalLength > maxFileLength) {
subTotalLength = 0;
subFiles = new ArrayList<File>();
filesList.add(subFiles);
}

subFiles.add(file);
subTotalLength += subLength;
}
}

return filesList;
}

private static class DexElementsCallable implements Callable<Object[]> {
final int id;
final ArrayList<File> files;
final IDexElementsMethodInvoker invoker;

private DexElementsCallable(int id, ArrayList<File> files, IDexElementsMethodInvoker invoker) {
this.id = id;
this.files = files;
this.invoker = invoker;
}

@Override
public Object[] call() throws Exception {
try {
long startTime = System.currentTimeMillis();
Object[] objects = invoker.invoke(files);
long endTime = System.currentTimeMillis();
Log.i(TAG, "cost " + id + " time:" + (endTime - startTime));
return objects;
} catch (Exception e) {

}
return null;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package android.support.multidex;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;

/**
* Created by jingchaoqinjc on 18/3/4.
*/

public class DexElementsMethodInvokerV14 implements IDexElementsMethodInvoker {

final Object dexPathList;
final File optimizedDirectory;
final Method makeDexElements;

public DexElementsMethodInvokerV14(Object dexPathList, File optimizedDirectory, Method makeDexElements) {
this.dexPathList = dexPathList;
this.optimizedDirectory = optimizedDirectory;
this.makeDexElements = makeDexElements;
}

@Override
public Object[] invoke(ArrayList<File> files) throws InvocationTargetException, IllegalAccessException {
return (Object[]) makeDexElements.invoke(dexPathList, files, optimizedDirectory);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package android.support.multidex;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;

/**
* Created by jingchaoqinjc on 18/3/4.
*/

public class DexElementsMethodInvokerV19 implements IDexElementsMethodInvoker {

final Object dexPathList;
final File optimizedDirectory;
final ArrayList<IOException> suppressedExceptions;
final Method makeDexElements;

public DexElementsMethodInvokerV19(Object dexPathList, File optimizedDirectory, ArrayList<IOException> suppressedExceptions, Method makeDexElements) {
this.dexPathList = dexPathList;
this.optimizedDirectory = optimizedDirectory;
this.suppressedExceptions = suppressedExceptions;
this.makeDexElements = makeDexElements;
}

@Override
public Object[] invoke(ArrayList<File> files) throws InvocationTargetException, IllegalAccessException {
return (Object[]) makeDexElements.invoke(dexPathList, files, optimizedDirectory, suppressedExceptions);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package android.support.multidex;

import java.lang.reflect.InvocationTargetException;

/**
* Created by jingchaoqinjc on 18/3/4.
*/

public interface IDexElementsMaker {

Object[] make() throws IllegalAccessException, InvocationTargetException,
NoSuchMethodException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package android.support.multidex;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;

/**
* Created by jingchaoqinjc on 18/3/4.
*/

public interface IDexElementsMethodInvoker {

public Object[] invoke(ArrayList<File> files) throws InvocationTargetException, IllegalAccessException;

}
Loading

0 comments on commit 1920b32

Please sign in to comment.