Skip to content

Commit

Permalink
【atlas-core】删掉installListener
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongcang committed Nov 16, 2017
1 parent 0af8b09 commit 3ebfa2d
Showing 1 changed file with 15 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
package android.taobao.atlas.patch;

import android.content.Context;
import android.content.pm.PackageManager;
import android.taobao.atlas.framework.Atlas;
import android.taobao.atlas.framework.BundleImpl;
import android.taobao.atlas.framework.Framework;
import android.taobao.atlas.runtime.RuntimeVariables;
import android.taobao.atlas.util.AtlasFileLock;
import android.taobao.atlas.util.BundleLock;
import android.taobao.atlas.util.IOUtil;
import android.taobao.atlas.util.StringUtils;
import android.text.TextUtils;
import android.util.Pair;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
Expand All @@ -32,7 +17,22 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import android.content.Context;
import android.content.pm.PackageManager;
import android.taobao.atlas.framework.Atlas;
import android.taobao.atlas.framework.BundleImpl;
import android.taobao.atlas.framework.Framework;
import android.taobao.atlas.runtime.RuntimeVariables;
import android.taobao.atlas.util.AtlasFileLock;
import android.taobao.atlas.util.BundleLock;
import android.taobao.atlas.util.IOUtil;
import android.taobao.atlas.util.StringUtils;
import android.text.TextUtils;
import android.util.Pair;
import dalvik.system.DexFile;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;

/**
* Created by guanjie on 2017/11/6.
Expand All @@ -48,7 +48,6 @@ public class AtlasHotPatchManager implements BundleListener{
private ConcurrentHashMap<String,Long> hotpatchBundles = new ConcurrentHashMap<>();
private HashMap<String,String> activePatchs = new HashMap<>();
private OnPatchActivatedListener mPatchListener;
private IPatchInstallListener mInstallListener;

public static synchronized AtlasHotPatchManager getInstance(){
return sPatchManager;
Expand All @@ -57,10 +56,6 @@ public static synchronized AtlasHotPatchManager getInstance(){
public interface OnPatchActivatedListener{
void onPatchActivated(String bundleName,String location,long patchVersion);
}
public interface IPatchInstallListener{
void install(boolean success,String bundleName,long patchVersion);
}


private AtlasHotPatchManager(){
try {
Expand Down Expand Up @@ -122,19 +117,13 @@ public void installHotFixPatch(String targetVersion, HashMap<String,Pair<Long,In
File hotFixFile = new File(patchBundleDir, entry.getValue().first+HOTFIX_NAME_POSTFIX);
installDex(entry.getValue().second, hotFixFile);
hotpatchBundles.put(entry.getKey(),Long.valueOf(entry.getValue().first));
if (null != mInstallListener){
mInstallListener.install(true,entry.getKey(),entry.getValue().first);
}
BundleImpl bundle = (BundleImpl) Atlas.getInstance().getBundle(entry.getKey());
if(bundle!=null){
Patch p = new Patch(hotFixFile,bundle.getClassLoader());
activePatch(entry.getKey(),p);
}
}catch(Exception e){
e.printStackTrace();
if (null != mInstallListener){
mInstallListener.install(false,entry.getKey(),entry.getValue().first);
}
}finally{
BundleLock.WriteUnLock(lockKey);
}
Expand All @@ -154,10 +143,6 @@ public void setPatchListener(OnPatchActivatedListener listener){
mPatchListener = listener;
}

public void setPatchInstallListener(IPatchInstallListener listener){
mInstallListener = listener;
}

public void storePatchInfo() throws IOException{
if(!meta.exists()){
meta.getParentFile().mkdirs();
Expand Down

0 comments on commit 3ebfa2d

Please sign in to comment.