Skip to content

Commit

Permalink
[customdiff] fix npe
Browse files Browse the repository at this point in the history
  • Loading branch information
Nalecy committed Oct 31, 2022
1 parent 630f8d1 commit 357dfe8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ public class TinkerPatchExtension {
*/
String customPath

/**
* customDiffPathArgs
* default: null
*/
String customDiffPathArgs

public TinkerPatchExtension() {
oldApk = ""
outputFolder = ""
Expand All @@ -112,6 +118,7 @@ public class TinkerPatchExtension {
useSign = true
tinkerEnable = true
customPath = null
customDiffPathArgs = null
}

void checkParameter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public class TinkerPatchSchemaTask extends DefaultTask {
.setIgnoreWarning(configuration.ignoreWarning)
.setAllowLoaderInAnyDex(configuration.allowLoaderInAnyDex)
.setCustomDiffPath(configuration.customPath)
.setCustomDiffPathArgs(configuration.customDiffPathArgs)
.setRemoveLoaderForAllDex(configuration.removeLoaderForAllDex)
.setDexFilePattern(new ArrayList<String>(configuration.dex.pattern))
.setIsProtectedApp(configuration.buildConfig.isProtectedApp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ public Configuration(InputParam param) throws IOException, TinkerPatchException

mUseSignAPk = param.useSign;
mCustomDiffPath = param.customDiffPath;
mCustomDiffPathArgs = param.customDiffPathArgs;
setSignData(param.signFile, param.keypass, param.storealias, param.storepass);

FileOperation.cleanDir(new File(mOutFolder));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class InputParam {
public final String storealias;
public final String storepass;
public final String customDiffPath;
public final String customDiffPathArgs;
public final boolean ignoreWarning;
public final boolean allowLoaderInAnyDex;
public final boolean removeLoaderForAllDex;
Expand Down Expand Up @@ -98,6 +99,7 @@ private InputParam(
String storealias,
String storepass,
String customDiffPath,
String customDiffPathArgs,
boolean ignoreWarning,
boolean allowLoaderInAnyDex,
boolean removeLoaderForAllDex,
Expand Down Expand Up @@ -130,6 +132,7 @@ private InputParam(
this.storealias = storealias;
this.storepass = storepass;
this.customDiffPath = customDiffPath;
this.customDiffPathArgs = customDiffPathArgs;
this.ignoreWarning = ignoreWarning;
this.allowLoaderInAnyDex = allowLoaderInAnyDex;
this.removeLoaderForAllDex = removeLoaderForAllDex;
Expand Down Expand Up @@ -168,6 +171,7 @@ public static class Builder {
private String storealias;
private String storepass;
private String customDiffPath;
private String customDiffPathArgs;
private boolean ignoreWarning;
private boolean allowLoaderInAnyDex;
private boolean removeLoaderForAllDex;
Expand Down Expand Up @@ -311,6 +315,11 @@ public Builder setCustomDiffPath(String path) {
return this;
}

public Builder setCustomDiffPathArgs(String args) {
this.customDiffPathArgs = args;
return this;
}

public Builder setRemoveLoaderForAllDex(boolean removeLoaderForAllDex){
this.removeLoaderForAllDex = removeLoaderForAllDex;
return this;
Expand Down Expand Up @@ -376,6 +385,7 @@ public InputParam create() {
storealias,
storepass,
customDiffPath,
customDiffPathArgs,
ignoreWarning,
allowLoaderInAnyDex,
removeLoaderForAllDex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class CustomDiff {

public static boolean checkHasCustomDiff(Configuration config) {
return config.mCustomDiffPath != null && !config.mCustomDiffPath.trim().isEmpty();
return config.mCustomDiffPath != null && !config.mCustomDiffPath.trim().isEmpty() && config.mCustomDiffPathArgs != null && !config.mCustomDiffPathArgs.isEmpty();
}

public static void diffFile(String mCustomDiffPath,String mCustomDiffPathArgs, File oldFile, File newFile, File diffFile) throws IOException {
Expand Down

0 comments on commit 357dfe8

Please sign in to comment.