Token
class Token
Stores a package's identity, a combination of its package name and signing certificate. It is designed to be persistable as a byte[], so you can do this:
Token token = Token.create(packageName, packageManager); byte[] serialized = token.serialize(); // Persist serialized. // Some time later... Token verified = Token.deserialize(serialized); verified.matches(packageName, packageManager);
Summary
Public functions |
|
|---|---|
java-static Token? |
create(packageName: String, packageManager: PackageManager)Creates a |
java-static Token |
deserialize(serialized: ByteArray) |
Boolean |
matches(packageName: String, packageManager: PackageManager)Whether the given package matches the package that was used to create the original Token. |
ByteArray<Byte> |
Serializes the |
Public functions
create
java-static fun create(packageName: String, packageManager: PackageManager): Token?
Creates a Token for the given package, taking into account the package name and its signing signature.
| Parameters | |
|---|---|
packageName: String |
The name of the package. |
packageManager: PackageManager |
A |
deserialize
java-static fun deserialize(serialized: ByteArray): Token
Reconstructs a Token from the output of its serialize.
| Returns | |
|---|---|
Token |
The deserialized Token. |
matches
fun matches(packageName: String, packageManager: PackageManager): Boolean
Whether the given package matches the package that was used to create the original Token.
| Parameters | |
|---|---|
packageName: String |
The name of the package. |
packageManager: PackageManager |
A |
| Returns | |
|---|---|
Boolean |
Whether the given package currently is the same as the one used to create the Token. |