Token
public final 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 methods |
|
|---|---|
static @Nullable Token |
create(@NonNull String packageName, @NonNull PackageManager packageManager)Creates a |
static @NonNull Token |
deserialize(@NonNull byte[] serialized) |
boolean |
matches(Whether the given package matches the package that was used to create the original Token. |
@NonNull byte[] |
Serializes the |
Public methods
create
public static @Nullable Token create(@NonNull String packageName, @NonNull PackageManager packageManager)
Creates a Token for the given package, taking into account the package name and its signing signature.
| Parameters | |
|---|---|
@NonNull String packageName |
The name of the package. |
@NonNull PackageManager packageManager |
A |
matches
public boolean matches(
@NonNull String packageName,
@NonNull PackageManager packageManager
)
Whether the given package matches the package that was used to create the original Token.
| Parameters | |
|---|---|
@NonNull String packageName |
The name of the package. |
@NonNull PackageManager packageManager |
A |
| Returns | |
|---|---|
boolean |
Whether the given package currently is the same as the one used to create the Token. |