@@ -86,3 +86,20 @@ dependencies {
               | 
            ||
| 86 | 86 | 
                     compile files('libs/jcc-bate-0.7.3.jar')
               | 
            
| 87 | 87 | 
                compile 'com.umeng.analytics:analytics:latest.integration'  | 
            
| 88 | 88 | 
                }  | 
            
| 89 | 
                +buildscript {
               | 
            |
| 90 | 
                +    repositories {
               | 
            |
| 91 | 
                + jcenter()  | 
            |
| 92 | 
                +        maven {
               | 
            |
| 93 | 
                +            url uri('..\\repo')
               | 
            |
| 94 | 
                + }  | 
            |
| 95 | 
                + }  | 
            |
| 96 | 
                +    dependencies {
               | 
            |
| 97 | 
                + //group:module:version  | 
            |
| 98 | 
                + classpath 'com.android.plugin.hotpatch:hotpatch:1.0.0'  | 
            |
| 99 | 
                + }  | 
            |
| 100 | 
                +}  | 
            |
| 101 | 
                +apply plugin: 'plugin.hotpatch'  | 
            |
| 102 | 
                +  | 
            |
| 103 | 
                +hotpatch{
               | 
            |
| 104 | 
                + includePackageDir='ai\\pai\\lensman'  | 
            |
| 105 | 
                +}  | 
            
                @@ -94,4 +94,12 @@ public static final int *;  | 
            ||
| 94 | 94 | 
                 -keep class com.tencent.mm.sdk.modelmsg.** implements com.tencent.mm.sdk.modelmsg.WXMediaMessage$IMediaObject {*;}
               | 
            
| 95 | 95 | 
                 -keep class com.tencent.mm.sdk.** {
               | 
            
| 96 | 96 | 
                *;  | 
            
| 97 | 
                -}  | 
            |
| 97 | 
                +}  | 
            |
| 98 | 
                +-keepclassmembers class *{
               | 
            |
| 99 | 
                + public static com.android.hotpatch.framework.ChangeQuickRedirect changeQuickRedirect;  | 
            |
| 100 | 
                +}  | 
            |
| 101 | 
                +-keepclassmembers class * {
               | 
            |
| 102 | 
                + public java.lang.Object accessSuper(java.lang.Object,int,java.lang.Object[]);  | 
            |
| 103 | 
                +}  | 
            |
| 104 | 
                +-keep class com.android.hotpatch.**{*;}
               | 
            |
| 105 | 
                +-keep class ai.pai.lensman.patch.**{*;}
               | 
            
                @@ -11,7 +11,11 @@ import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;  | 
            ||
| 11 | 11 | 
                import com.nostra13.universalimageloader.core.assist.QueueProcessingType;  | 
            
| 12 | 12 | 
                import com.nostra13.universalimageloader.utils.StorageUtils;  | 
            
| 13 | 13 | 
                 | 
            
| 14 | 
                +import java.io.File;  | 
            |
| 15 | 
                +  | 
            |
| 14 | 16 | 
                import ai.pai.lensman.utils.Constants;  | 
            
| 17 | 
                +import ai.pai.lensman.utils.PatchManager;  | 
            |
| 18 | 
                +import ai.pai.lensman.utils.UrlContainer;  | 
            |
| 15 | 19 | 
                 | 
            
| 16 | 20 | 
                 public class App extends Application {
               | 
            
| 17 | 21 | 
                 | 
            
                @@ -26,6 +30,8 @@ public class App extends Application {
               | 
            ||
| 26 | 30 | 
                super.onCreate();  | 
            
| 27 | 31 | 
                initImageLoader();  | 
            
| 28 | 32 | 
                mInstance = this.getApplicationContext();  | 
            
| 33 | 
                + new PatchManager().patch(this, UrlContainer.PATCH_CONFIG_URL,Constants.APP_PATCH_DIR+ File.separator+"patch-"+BuildConfig.VERSION_NAME+".dex","ai.pai.lensman.patch.PatchesInfoImpl");  | 
            |
| 34 | 
                +  | 
            |
| 29 | 35 | 
                }  | 
            
| 30 | 36 | 
                 | 
            
| 31 | 37 | 
                 | 
            
                @@ -79,6 +79,15 @@ public class Preferences {
               | 
            ||
| 79 | 79 | 
                         mPrefs.edit().putString("currentSession",currentSession).commit();
               | 
            
| 80 | 80 | 
                }  | 
            
| 81 | 81 | 
                 | 
            
| 82 | 
                +  | 
            |
| 83 | 
                +    public void setPatchUrl(String patchUrl){
               | 
            |
| 84 | 
                +        mPrefs.edit().putString("patchUrl",patchUrl).commit();
               | 
            |
| 85 | 
                + }  | 
            |
| 86 | 
                +  | 
            |
| 87 | 
                +    public String getPatchUrl(){
               | 
            |
| 88 | 
                +        return mPrefs.getString("patchUrl",NullStr);
               | 
            |
| 89 | 
                + }  | 
            |
| 90 | 
                +  | 
            |
| 82 | 91 | 
                     public void clearPrefs(){
               | 
            
| 83 | 92 | 
                mPrefs.edit().clear().commit();  | 
            
| 84 | 93 | 
                }  | 
            
                @@ -12,5 +12,6 @@ public class Constants {
               | 
            ||
| 12 | 12 | 
                public static final String ORIGIN_DIR_NAME = "origin";  | 
            
| 13 | 13 | 
                public static final String THUMBNAIL_DIR_NAME = "thumbnail";  | 
            
| 14 | 14 | 
                public static final String TMP_DIR_NAME = "tmp";  | 
            
| 15 | 
                + public static final String APP_PATCH_DIR = APP_ROOT_DIR+"/patch";  | 
            |
| 15 | 16 | 
                 | 
            
| 16 | 17 | 
                }  | 
            
                @@ -0,0 +1,62 @@  | 
            ||
| 1 | 
                +package ai.pai.lensman.utils;  | 
            |
| 2 | 
                +  | 
            |
| 3 | 
                +  | 
            |
| 4 | 
                +import com.android.common.http.HttpUtils;  | 
            |
| 5 | 
                +import com.android.hotpatch.utils.IPatchManager;  | 
            |
| 6 | 
                +  | 
            |
| 7 | 
                +import org.json.JSONObject;  | 
            |
| 8 | 
                +  | 
            |
| 9 | 
                +import java.io.File;  | 
            |
| 10 | 
                +import java.util.HashMap;  | 
            |
| 11 | 
                +  | 
            |
| 12 | 
                +import ai.pai.lensman.BuildConfig;  | 
            |
| 13 | 
                +import ai.pai.lensman.db.Preferences;  | 
            |
| 14 | 
                +  | 
            |
| 15 | 
                +public class PatchManager extends IPatchManager{
               | 
            |
| 16 | 
                +  | 
            |
| 17 | 
                + private String patchUrl;  | 
            |
| 18 | 
                +  | 
            |
| 19 | 
                +    public PatchManager(){
               | 
            |
| 20 | 
                + new File(Constants.APP_PATCH_DIR).mkdirs();  | 
            |
| 21 | 
                + }  | 
            |
| 22 | 
                +  | 
            |
| 23 | 
                + @Override  | 
            |
| 24 | 
                +    protected String getPatchFileDownloadUrl(String patchConfigUrl) {
               | 
            |
| 25 | 
                +        if(patchConfigUrl.contains("?")){
               | 
            |
| 26 | 
                + patchConfigUrl+="&platform=android";  | 
            |
| 27 | 
                +        }else{
               | 
            |
| 28 | 
                + patchConfigUrl+="?platform=android";  | 
            |
| 29 | 
                + }  | 
            |
| 30 | 
                + patchConfigUrl+="&version="+ BuildConfig.VERSION_NAME;  | 
            |
| 31 | 
                + patchConfigUrl+="&channel="+"guanwang";  | 
            |
| 32 | 
                + HashMap<String,String> httpParams = new HashMap<>();  | 
            |
| 33 | 
                +        httpParams.put("src","1");
               | 
            |
| 34 | 
                + String jsonStr = HttpUtils.doHttpPost(patchConfigUrl,httpParams);  | 
            |
| 35 | 
                +        try{
               | 
            |
| 36 | 
                + JSONObject response = new JSONObject(jsonStr);  | 
            |
| 37 | 
                +            JSONObject data = response.getJSONObject("data");
               | 
            |
| 38 | 
                +            patchUrl = data.getString("patch_url");
               | 
            |
| 39 | 
                + return patchUrl;  | 
            |
| 40 | 
                +        }catch (Exception e){
               | 
            |
| 41 | 
                + e.printStackTrace();  | 
            |
| 42 | 
                + }  | 
            |
| 43 | 
                + return null;  | 
            |
| 44 | 
                + }  | 
            |
| 45 | 
                +  | 
            |
| 46 | 
                + @Override  | 
            |
| 47 | 
                +    protected boolean isNewPatchFound() {
               | 
            |
| 48 | 
                +        if(!Preferences.getInstance().getPatchUrl().equals(patchUrl)){
               | 
            |
| 49 | 
                + new File(patchSavePath).delete();  | 
            |
| 50 | 
                + return true;  | 
            |
| 51 | 
                + }  | 
            |
| 52 | 
                +        if(!new File(patchSavePath).exists()){
               | 
            |
| 53 | 
                + return true;  | 
            |
| 54 | 
                + }  | 
            |
| 55 | 
                + return false;  | 
            |
| 56 | 
                + }  | 
            |
| 57 | 
                +  | 
            |
| 58 | 
                + @Override  | 
            |
| 59 | 
                +    protected void afterPatchSuccess() {
               | 
            |
| 60 | 
                + Preferences.getInstance().setPatchUrl(patchUrl);  | 
            |
| 61 | 
                + }  | 
            |
| 62 | 
                +}  | 
            
                @@ -67,5 +67,5 @@ public class UrlContainer {
               | 
            ||
| 67 | 67 | 
                 | 
            
| 68 | 68 | 
                public static final String PLATFORM_PRICE_RULES_PAGE_URL = "http://pai.ai/page/price";  | 
            
| 69 | 69 | 
                 | 
            
| 70 | 
                -  | 
            |
| 70 | 
                + public static final String PATCH_CONFIG_URL = HOST_URL+"op/patch";  | 
            |
| 71 | 71 | 
                }  | 
            
                @@ -0,0 +1 @@  | 
            ||
| 1 | 
                +04cbb405b312665f00431c8336b47edc  | 
            
                @@ -0,0 +1 @@  | 
            ||
| 1 | 
                +b621d002b8c17885daff42fd81164384aba7a7fc  | 
            
                @@ -0,0 +1,22 @@  | 
            ||
| 1 | 
                +<?xml version="1.0" encoding="UTF-8"?>  | 
            |
| 2 | 
                +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"  | 
            |
| 3 | 
                + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  | 
            |
| 4 | 
                + <modelVersion>4.0.0</modelVersion>  | 
            |
| 5 | 
                + <groupId>com.android.plugin.hotpatch</groupId>  | 
            |
| 6 | 
                + <artifactId>hotpatch</artifactId>  | 
            |
| 7 | 
                + <version>1.0.0</version>  | 
            |
| 8 | 
                + <dependencies>  | 
            |
| 9 | 
                + <dependency>  | 
            |
| 10 | 
                + <groupId>com.android.tools.build</groupId>  | 
            |
| 11 | 
                + <artifactId>gradle</artifactId>  | 
            |
| 12 | 
                + <version>2.2.3</version>  | 
            |
| 13 | 
                + <scope>compile</scope>  | 
            |
| 14 | 
                + </dependency>  | 
            |
| 15 | 
                + <dependency>  | 
            |
| 16 | 
                + <groupId>org.javassist</groupId>  | 
            |
| 17 | 
                + <artifactId>javassist</artifactId>  | 
            |
| 18 | 
                + <version>3.22.0-CR1</version>  | 
            |
| 19 | 
                + <scope>compile</scope>  | 
            |
| 20 | 
                + </dependency>  | 
            |
| 21 | 
                + </dependencies>  | 
            |
| 22 | 
                +</project>  | 
            
                @@ -0,0 +1 @@  | 
            ||
| 1 | 
                +640d4ea0944d59a7d903ec7f0bfeee75  | 
            
                @@ -0,0 +1 @@  | 
            ||
| 1 | 
                +cfddca111bee94e07609aa18512e0fcf2a3f856c  | 
            
                @@ -0,0 +1,12 @@  | 
            ||
| 1 | 
                +<?xml version="1.0" encoding="UTF-8"?>  | 
            |
| 2 | 
                +<metadata>  | 
            |
| 3 | 
                + <groupId>com.android.plugin.hotpatch</groupId>  | 
            |
| 4 | 
                + <artifactId>hotpatch</artifactId>  | 
            |
| 5 | 
                + <versioning>  | 
            |
| 6 | 
                + <release>1.0.0</release>  | 
            |
| 7 | 
                + <versions>  | 
            |
| 8 | 
                + <version>1.0.0</version>  | 
            |
| 9 | 
                + </versions>  | 
            |
| 10 | 
                + <lastUpdated>20170303105421</lastUpdated>  | 
            |
| 11 | 
                + </versioning>  | 
            |
| 12 | 
                +</metadata>  | 
            
                @@ -0,0 +1 @@  | 
            ||
| 1 | 
                +89037efcccecda6a668c32743755b699  | 
            
                @@ -0,0 +1 @@  | 
            ||
| 1 | 
                +93d08fd1b04f250f96c8acf7390f14028d49ec06  |