Skip to content

Commit

Permalink
updates internal apksigner jar to 25.0.2
Browse files Browse the repository at this point in the history
updates version to 0.7.0
  • Loading branch information
patrickfav committed Dec 13, 2016
1 parent 69d5739 commit 252b476
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 23 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>at.favre.tools</groupId>
<artifactId>uber-apk-signer</artifactId>
<version>0.6.1</version>
<version>0.7.0</version>

<prerequisites>
<maven>3.1.0</maven>
Expand Down Expand Up @@ -104,7 +104,7 @@
<artifactId>apksigner</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/apksigner_25_0_0.jar</systemPath>
<systemPath>${project.basedir}/src/main/resources/lib/apksigner_25_0_2.jar</systemPath>
</dependency>
<!-- test -->
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/favre/tools/apksigner/SignTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ private static AndroidApkSignerVerify.Result verifySign(File targetApkFile, File
}
return result.verified ? result : null;
} catch (Exception e) {
throw new IllegalStateException("could not verifySign " + targetApkFile + ": " + e.getMessage(), e);
throw new IllegalStateException("could not verify " + targetApkFile + ": " + e.getMessage(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package at.favre.tools.apksigner.signing;

import com.android.apksig.ApkVerifier;
import com.android.apksigner.ApkSignerTool;

import java.io.File;
import java.lang.reflect.Method;
import java.security.MessageDigest;
import java.security.PublicKey;
import java.security.cert.X509Certificate;
Expand All @@ -30,27 +28,15 @@ public Result verify(File apk, Integer minSdkVersion, Integer maxSdkVersion, boo
List<String> warnings = new ArrayList<>();
List<String> errors = new ArrayList<>();

if (maxSdkVersion == null) {
maxSdkVersion = Integer.MAX_VALUE;
ApkVerifier.Builder builder = new ApkVerifier.Builder(apk);
if (minSdkVersion != null) {
builder.setMinCheckedPlatformVersion(minSdkVersion);
}

if (minSdkVersion == null) {
try {
Method method = ApkSignerTool.class.getDeclaredMethod("getMinSdkVersionFromAndroidManifest", File.class);
method.setAccessible(true);
minSdkVersion = (Integer) method.invoke(null, apk);
} catch (NoSuchMethodException e) {
throw new IllegalStateException("Could not get private method from apkSigner lib", e);
} catch (Exception e) {
throw new IllegalStateException("Failed to deduce Min API Level from APK\'s AndroidManifest.xml. Use --min-sdk-version to override.", e);
}
}

if (minSdkVersion > maxSdkVersion) {
throw new IllegalStateException("Min API Level (" + minSdkVersion + ") > max API Level (" + maxSdkVersion + ")");
if (maxSdkVersion != null) {
builder.setMaxCheckedPlatformVersion(maxSdkVersion);
}

ApkVerifier.Result apkVerifierResult = (new ApkVerifier.Builder(apk)).setCheckedPlatformVersions(minSdkVersion, maxSdkVersion).build().verify();
ApkVerifier.Result apkVerifierResult = builder.build().verify();
boolean verified = apkVerifierResult.isVerified();
Iterator iter;
if (verified) {
Expand Down
Binary file removed src/main/resources/lib/apksigner_25_0_0.jar
Binary file not shown.
Binary file added src/main/resources/lib/apksigner_25_0_2.jar
Binary file not shown.

0 comments on commit 252b476

Please sign in to comment.