|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.android.ide.common.packaging.PackagingUtils
public class PackagingUtils
Utility class for packaging.
Field Summary | |
---|---|
static com.google.common.collect.ImmutableList<java.lang.String> |
NON_RESOURCES_EXTENSIONS
Returns the list of file extensions that represents non resources files. |
static com.google.common.collect.ImmutableList<java.lang.String> |
NON_RESOURCES_FILENAMES
Return file names that are not resource files. |
Constructor Summary | |
---|---|
PackagingUtils()
|
Method Summary | |
---|---|
static boolean |
checkFileForPackaging(java.lang.String fileName)
Checks a file to make sure it should be packaged as standard resources. |
static boolean |
checkFileForPackaging(java.lang.String fileName,
boolean allowClassFiles)
Checks a file to make sure it should be packaged as standard resources. |
static boolean |
checkFileForPackaging(java.lang.String fileName,
java.lang.String extension)
Checks a file to make sure it should be packaged as standard resources. |
static boolean |
checkFileForPackaging(java.lang.String fileName,
java.lang.String extension,
boolean allowClassFiles)
Checks a file to make sure it should be packaged as standard resources. |
static boolean |
checkFolderForPackaging(java.lang.String folderName)
Checks whether a folder and its content is valid for packaging into the .apk as standard Java resource. |
static long |
computeApplicationHash(java.io.File projectDir)
Computes an "application hash", a reasonably unique identifier for an app. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final com.google.common.collect.ImmutableList<java.lang.String> NON_RESOURCES_EXTENSIONS
public static final com.google.common.collect.ImmutableList<java.lang.String> NON_RESOURCES_FILENAMES
Constructor Detail |
---|
public PackagingUtils()
Method Detail |
---|
public static boolean checkFolderForPackaging(@NonNull java.lang.String folderName)
folderName
- the name of the folder.
public static boolean checkFileForPackaging(@NonNull java.lang.String fileName, boolean allowClassFiles)
fileName
- the name of the file (including extension)allowClassFiles
- whether to allow java class files
public static boolean checkFileForPackaging(@NonNull java.lang.String fileName)
fileName
- the name of the file (including extension)
public static boolean checkFileForPackaging(@NonNull java.lang.String fileName, @NonNull java.lang.String extension, boolean allowClassFiles)
fileName
- the name of the file (including extension)extension
- the extension of the file (excluding '.')allowClassFiles
- whether to allow java class files
public static boolean checkFileForPackaging(@NonNull java.lang.String fileName, @NonNull java.lang.String extension)
fileName
- the name of the file (including extension)extension
- the extension of the file (excluding '.')
public 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 along, 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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |