PackageIdentifier

  • PackageIdentifier uniquely identifies a package using its name and SHA-256 certificate digest.

  • You can create a PackageIdentifier using the package name and its SHA-256 certificate digest, obtainable via the apksigner tool.

  • This class provides methods to retrieve the package name (getPackageName) and SHA-256 certificate (getSha256Certificate).

  • PackageIdentifier includes standard methods like equals and hashCode for object comparison.

public class PackageIdentifier extends Object

This class represents a uniquely identifiable package.

Public Constructor Summary

PackageIdentifier(String packageName, byte[] sha256Certificate)
Creates a unique identifier for a package.

Public Method Summary

boolean
String
getPackageName()
Returns the name for a package.
byte[]
getSha256Certificate()
Returns the SHA-256 certificate for a package.
int

Inherited Method Summary

Public Constructors

public PackageIdentifier (String packageName, byte[] sha256Certificate)

Creates a unique identifier for a package.

SHA-256 certificate digests for a signed application can be retrieved with the apksigner tool that is part of the Android SDK build tools. Use apksigner verify --print-certs path/to/apk.apk to retrieve the SHA-256 certificate digest for the target application. Once retrieved, the SHA-256 certificate digest should be converted to a byte[] by decoding it in base16:

 new android.content.pm.Signature(outputDigest).toByteArray();
 
Parameters
packageName Name of the package.
sha256Certificate SHA-256 certificate digest of the package.

Public Methods

public boolean equals (Object obj)

public String getPackageName ()

Returns the name for a package.

public byte[] getSha256Certificate ()

Returns the SHA-256 certificate for a package.

public int hashCode ()