Send PACKAGE_ADDED and PACKAGE_REMOVED broadcasts to installer of
static shared libs Installers of static shared libs should receive PACKAGE_ADDED and PACKAGE_REMOVED broadcasts. Bug: 243669689 Test: atest CtsOsHostTestCases:StaticSharedLibsHostTests Change-Id: I3ff0f7076dd6b4d1a23cf38405469f6ca26171df
This commit is contained in:
@@ -2659,11 +2659,29 @@ final class InstallPackageHelper {
|
||||
}
|
||||
}
|
||||
|
||||
Bundle extras = new Bundle();
|
||||
extras.putInt(Intent.EXTRA_UID, request.getUid());
|
||||
if (update) {
|
||||
extras.putBoolean(Intent.EXTRA_REPLACING, true);
|
||||
}
|
||||
extras.putInt(PackageInstaller.EXTRA_DATA_LOADER_TYPE, dataLoaderType);
|
||||
|
||||
// If a package is a static shared library, then only the installer of the package
|
||||
// should get the broadcast.
|
||||
if (installerPackageName != null
|
||||
&& request.getPkg().getStaticSharedLibraryName() != null) {
|
||||
mPm.sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, packageName,
|
||||
extras, 0 /*flags*/,
|
||||
installerPackageName, null /*finishedReceiver*/,
|
||||
request.getNewUsers(), null /* instantUserIds*/,
|
||||
null /* broadcastAllowList */, null);
|
||||
}
|
||||
|
||||
// Send installed broadcasts if the package is not a static shared lib.
|
||||
if (request.getPkg().getStaticSharedLibraryName() == null) {
|
||||
mPm.mProcessLoggingHandler.invalidateBaseApkHash(request.getPkg().getBaseApkPath());
|
||||
|
||||
// Send added for users that see the package for the first time
|
||||
// Send PACKAGE_ADDED broadcast for users that see the package for the first time
|
||||
// sendPackageAddedForNewUsers also deals with system apps
|
||||
int appId = UserHandle.getAppId(request.getUid());
|
||||
boolean isSystem = request.getPkg().isSystem();
|
||||
@@ -2671,13 +2689,9 @@ final class InstallPackageHelper {
|
||||
isSystem || virtualPreload, virtualPreload /*startReceiver*/, appId,
|
||||
firstUserIds, firstInstantUserIds, dataLoaderType);
|
||||
|
||||
// Send added for users that don't see the package for the first time
|
||||
Bundle extras = new Bundle();
|
||||
extras.putInt(Intent.EXTRA_UID, request.getUid());
|
||||
if (update) {
|
||||
extras.putBoolean(Intent.EXTRA_REPLACING, true);
|
||||
}
|
||||
extras.putInt(PackageInstaller.EXTRA_DATA_LOADER_TYPE, dataLoaderType);
|
||||
// Send PACKAGE_ADDED broadcast for users that don't see
|
||||
// the package for the first time
|
||||
|
||||
// Send to all running apps.
|
||||
final SparseArray<int[]> newBroadcastAllowList;
|
||||
synchronized (mPm.mLock) {
|
||||
@@ -2690,8 +2704,8 @@ final class InstallPackageHelper {
|
||||
extras, 0 /*flags*/,
|
||||
null /*targetPackage*/, null /*finishedReceiver*/,
|
||||
updateUserIds, instantUserIds, newBroadcastAllowList, null);
|
||||
// Send to the installer, even if it's not running.
|
||||
if (installerPackageName != null) {
|
||||
// Send to the installer, even if it's not running.
|
||||
mPm.sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, packageName,
|
||||
extras, 0 /*flags*/,
|
||||
installerPackageName, null /*finishedReceiver*/,
|
||||
|
||||
@@ -111,12 +111,6 @@ final class PackageRemovedInfo {
|
||||
}
|
||||
|
||||
private void sendPackageRemovedBroadcastInternal(boolean killApp, boolean removedBySystem) {
|
||||
// Don't send static shared library removal broadcasts as these
|
||||
// libs are visible only the apps that depend on them an one
|
||||
// cannot remove the library if it has a dependency.
|
||||
if (mIsStaticSharedLib) {
|
||||
return;
|
||||
}
|
||||
Bundle extras = new Bundle();
|
||||
final int removedUid = mRemovedAppId >= 0 ? mRemovedAppId : mUid;
|
||||
extras.putInt(Intent.EXTRA_UID, removedUid);
|
||||
@@ -128,15 +122,22 @@ final class PackageRemovedInfo {
|
||||
extras.putBoolean(Intent.EXTRA_REPLACING, true);
|
||||
}
|
||||
extras.putBoolean(Intent.EXTRA_REMOVED_FOR_ALL_USERS, mRemovedForAllUsers);
|
||||
|
||||
// Send PACKAGE_REMOVED broadcast to the respective installer.
|
||||
if (mRemovedPackage != null && mInstallerPackageName != null) {
|
||||
mPackageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED,
|
||||
mRemovedPackage, extras, 0 /*flags*/,
|
||||
mInstallerPackageName, null, mBroadcastUsers, mInstantUserIds, null, null);
|
||||
}
|
||||
if (mIsStaticSharedLib) {
|
||||
// When uninstalling static shared libraries, only the package's installer needs to be
|
||||
// sent a PACKAGE_REMOVED broadcast. There are no other intended recipients.
|
||||
return;
|
||||
}
|
||||
if (mRemovedPackage != null) {
|
||||
mPackageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED,
|
||||
mRemovedPackage, extras, 0, null /*targetPackage*/, null,
|
||||
mBroadcastUsers, mInstantUserIds, mBroadcastAllowList, null);
|
||||
if (mInstallerPackageName != null) {
|
||||
mPackageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED,
|
||||
mRemovedPackage, extras, 0 /*flags*/,
|
||||
mInstallerPackageName, null, mBroadcastUsers, mInstantUserIds, null, null);
|
||||
}
|
||||
mPackageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED_INTERNAL,
|
||||
mRemovedPackage, extras, 0 /*flags*/, PLATFORM_PACKAGE_NAME,
|
||||
null /*finishedReceiver*/, mBroadcastUsers, mInstantUserIds,
|
||||
|
||||
Reference in New Issue
Block a user