This Method is deprecated from API level 30, so you can safely manage this situation with:
if (Build.VERSION.SDK_INT >= 30) {
InstallSourceInfo isi = getContext()
.getPackageManager()
.getInstallSourceInfo(getContext()
.getPackageName());
// now, with an InstallSourceInfo object, you have access to three useful methods
String initiating = isi.getInitiatingPackageName();
String installing = isi.getInstallingPackageName();
String originating = isi.getOriginatingPackageName();
} else { // continue to use the old version API
String installerPackageName = getContext()
.getPackageManager()
.getInstallerPackageName(
getContext().getPackageName()
);
}
getInitiatingPackageName returns the name of the package that requested the installation, or null if not available. This is normally the same as the old getInstallerPackageName.