/** * Sets the value of the {@code Created-By} field in JAR signature files. * * <p><em>Note:</em> This method may only be invoked when this builder is not initialized * with an {@link ApkSignerEngine}. * * @throws IllegalStateException if this builder was initialized with an * {@link ApkSignerEngine} */ public Builder setCreatedBy(String createdBy) { checkInitializedWithoutEngine(); if (createdBy == null) { throw new NullPointerException(); } mCreatedBy = createdBy; return this; }
/** * Sets whether the APK should be signed using APK Signature Scheme v2 (aka v2 signature * scheme). * * <p>By default, whether APK is signed using APK Signature Scheme v2 is determined by * {@code ApkSigner} based on the platform versions supported by the APK or specified using * {@link #setMinSdkVersion(int)}. * * <p><em>Note:</em> This method may only be invoked when this builder is not initialized * with an {@link ApkSignerEngine}. * * @param enabled {@code true} to require the APK to be signed using APK Signature Scheme * v2, {@code false} to require the APK to not be signed using APK Signature Scheme * v2. * * @throws IllegalStateException if this builder was initialized with an * {@link ApkSignerEngine} * * @see <a href="https://source.android.com/security/apksigning/v2.html">APK Signature Scheme v2</a> */ public Builder setV2SigningEnabled(boolean enabled) { checkInitializedWithoutEngine(); mV2SigningEnabled = enabled; return this; }
/** * Sets whether the APK should be signed using JAR signing (aka v1 signature scheme). * * <p>By default, whether APK is signed using JAR signing is determined by * {@code ApkSigner}, based on the platform versions supported by the APK or specified using * {@link #setMinSdkVersion(int)}. Disabling JAR signing will result in APK signatures which * don't verify on Android Marshmallow (Android 6.0, API Level 23) and lower. * * <p><em>Note:</em> This method may only be invoked when this builder is not initialized * with an {@link ApkSignerEngine}. * * @param enabled {@code true} to require the APK to be signed using JAR signing, * {@code false} to require the APK to not be signed using JAR signing. * * @throws IllegalStateException if this builder was initialized with an * {@link ApkSignerEngine} * * @see <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Signed_JAR_File">JAR signing</a> */ public Builder setV1SigningEnabled(boolean enabled) { checkInitializedWithoutEngine(); mV1SigningEnabled = enabled; return this; }
/** * Sets the minimum Android platform version (API Level) on which APK signatures produced * by the signer being built must verify. This method is useful for overriding the default * behavior where the minimum API Level is obtained from the {@code android:minSdkVersion} * attribute of the APK's {@code AndroidManifest.xml}. * * <p><em>Note:</em> This method may result in APK signatures which don't verify on some * Android platform versions supported by the APK. * * <p><em>Note:</em> This method may only be invoked when this builder is not initialized * with an {@link ApkSignerEngine}. * * @throws IllegalStateException if this builder was initialized with an * {@link ApkSignerEngine} */ public Builder setMinSdkVersion(int minSdkVersion) { checkInitializedWithoutEngine(); mMinSdkVersion = minSdkVersion; return this; }
/** * Sets whether signatures produced by signers other than the ones configured in this engine * should be copied from the input APK to the output APK. * * <p>By default, signatures of other signers are omitted from the output APK. * * <p><em>Note:</em> This method may only be invoked when this builder is not initialized * with an {@link ApkSignerEngine}. * * @throws IllegalStateException if this builder was initialized with an * {@link ApkSignerEngine} */ public Builder setOtherSignersSignaturesPreserved(boolean preserved) { checkInitializedWithoutEngine(); mOtherSignersSignaturesPreserved = preserved; return this; }