public class PackagingUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static com.google.common.collect.ImmutableSet<java.lang.String> |
DEFAULT_DONT_COMPRESS_EXTENSIONS
Set of file formats which are already compressed, or don't compress well, same as the one
used by aapt.
|
static com.google.common.collect.ImmutableList<java.lang.String> |
SIGNING_EXTENSIONS
List of file extensions that are used for jar signing.
|
| Constructor and Description |
|---|
PackagingUtils() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkFileForApkPackaging(java.lang.String filePath,
boolean allowClassFiles)
Checks a file to make sure it should be packaged as standard resources.
|
static long |
computeApplicationHash(java.io.File projectDir)
Computes an "application hash", a reasonably unique identifier for an app.
|
static java.util.function.Predicate<java.lang.String> |
getDefaultNoCompressPredicate() |
static com.android.tools.build.apkzlib.zfile.NativeLibrariesPackagingMode |
getNativeLibrariesLibrariesPackagingMode(java.io.File manifest,
java.util.function.BooleanSupplier isInExecutionPhase,
com.android.builder.errors.EvalIssueReporter issueReporter) |
static java.util.List<java.lang.String> |
getNoCompressGlobsForBundle(java.util.Collection<java.lang.String> aaptOptionsNoCompress) |
static java.util.function.Predicate<java.lang.String> |
getNoCompressPredicate(java.util.Collection<java.lang.String> aaptOptionsNoCompress,
java.io.File manifest,
java.util.function.BooleanSupplier isInExecutionPhase,
com.android.builder.errors.EvalIssueReporter issueReporter) |
static com.android.builder.packaging.PackageEmbeddedDex |
getUseEmbeddedDex(java.io.File manifest,
java.util.function.BooleanSupplier isInExecutionPhase,
com.android.builder.errors.EvalIssueReporter issueReporter) |
public static final com.google.common.collect.ImmutableSet<java.lang.String> DEFAULT_DONT_COMPRESS_EXTENSIONS
public static final com.google.common.collect.ImmutableList<java.lang.String> SIGNING_EXTENSIONS
public static boolean checkFileForApkPackaging(@NonNull
java.lang.String filePath,
boolean allowClassFiles)
filePath - OS-independent path of the file (including extension), relative to the
archiveallowClassFiles - whether to allow java class filespublic static long computeApplicationHash(@NonNull
java.io.File projectDir)
This is currently used by Instant Run to prevent apps on a device from guessing the authentication token associated with an instant run developed app on the same device.
This method creates the "secret", the field in the AppInfo class which is used as a simple authentication token between the IDE and the app server.
This is not a cryptographically strong unique id; we could attempt to make a truly random number here, but we'd need to store that id somewhere such that subsequent builds will use the same secret, to avoid having the IDE and the app getting out of sync, and there isn't really a natural place for us to store the key to make it survive across a clean build. (One possibility is putting it into local.properties).
However, we have much simpler needs: we just need a key that can't be guessed from a hostile app on the developer's device, and it only has a few guesses (after providing the wrong secret to the server a few times, the server will shut down.) We can't rely on the package name alone, since the port number is known, and the package name is discoverable by the hostile app (by querying the contents of /data/data/*). Therefore we also include facts that the hostile app can't know, such as as the path on the developer's machine to the app project and the name of the developer's machine, etc. The goal is for this secret to be reasonably stable (e.g. the same from build to build) yet not something an app could guess if it only has a couple of tries.
@NonNull public static java.util.function.Predicate<java.lang.String> getDefaultNoCompressPredicate()
@NonNull
public static java.util.function.Predicate<java.lang.String> getNoCompressPredicate(@Nullable
java.util.Collection<java.lang.String> aaptOptionsNoCompress,
@NonNull
java.io.File manifest,
@NonNull
java.util.function.BooleanSupplier isInExecutionPhase,
@Nullable
com.android.builder.errors.EvalIssueReporter issueReporter)
@NonNull
public static java.util.List<java.lang.String> getNoCompressGlobsForBundle(@NonNull
java.util.Collection<java.lang.String> aaptOptionsNoCompress)
@NonNull
public static com.android.tools.build.apkzlib.zfile.NativeLibrariesPackagingMode getNativeLibrariesLibrariesPackagingMode(@NonNull
java.io.File manifest,
@NonNull
java.util.function.BooleanSupplier isInExecutionPhase,
@Nullable
com.android.builder.errors.EvalIssueReporter issueReporter)
@NonNull
public static com.android.builder.packaging.PackageEmbeddedDex getUseEmbeddedDex(@NonNull
java.io.File manifest,
@NonNull
java.util.function.BooleanSupplier isInExecutionPhase,
@Nullable
com.android.builder.errors.EvalIssueReporter issueReporter)