Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7bdb73af authored by Ivan Chiang's avatar Ivan Chiang Committed by Android (Google) Code Review
Browse files

Merge "[PM] Send ACTION_PACKAGE_CHANGED when mimeGroups are changed" into tm-qpr-dev

parents 1ff5e85f fc7842aa
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -5855,9 +5855,26 @@ public class PackageManagerService implements PackageSender, TestUtilityService
                packageStateWrite.setMimeGroup(mimeGroup, mimeTypesSet);
            });
            if (mComponentResolver.updateMimeGroup(snapshotComputer(), packageName, mimeGroup)) {
                Binder.withCleanCallingIdentity(() ->
                Binder.withCleanCallingIdentity(() -> {
                    mPreferredActivityHelper.clearPackagePreferredActivities(packageName,
                                UserHandle.USER_ALL));
                            UserHandle.USER_ALL);
                    // Send the ACTION_PACKAGE_CHANGED when the mimeGroup has changes
                    final Computer snapShot = snapshotComputer();
                    final ArrayList<String> components = new ArrayList<>(
                            Collections.singletonList(packageName));
                    final int appId = packageState.getAppId();
                    final int[] userIds = resolveUserIds(UserHandle.USER_ALL);
                    final String reason = "The mimeGroup is changed";
                    for (int i = 0; i < userIds.length; i++) {
                        final PackageUserStateInternal pkgUserState =
                                packageState.getUserStates().get(userIds[i]);
                        if (pkgUserState != null && pkgUserState.isInstalled()) {
                            final int packageUid = UserHandle.getUid(userIds[i], appId);
                            sendPackageChangedBroadcast(snapShot, packageName,
                                    true /* dontKillApp */, components, packageUid, reason);
                        }
                    }
                });
            }

            scheduleWriteSettings();