Merge "Remove system broadcasts related to appId transitioning" into tm-dev
This commit is contained in:
@@ -119,14 +119,10 @@ public final class BroadcastHelper {
|
||||
intent.setPackage(targetPkg);
|
||||
}
|
||||
// Modify the UID when posting to other users
|
||||
final String[] uidExtraNames =
|
||||
{ Intent.EXTRA_UID, Intent.EXTRA_PREVIOUS_UID, Intent.EXTRA_NEW_UID };
|
||||
for (String name : uidExtraNames) {
|
||||
int uid = intent.getIntExtra(name, -1);
|
||||
if (uid >= 0 && UserHandle.getUserId(uid) != userId) {
|
||||
uid = UserHandle.getUid(userId, UserHandle.getAppId(uid));
|
||||
intent.putExtra(name, uid);
|
||||
}
|
||||
int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
|
||||
if (uid >= 0 && UserHandle.getUserId(uid) != userId) {
|
||||
uid = UserHandle.getUid(userId, UserHandle.getAppId(uid));
|
||||
intent.putExtra(Intent.EXTRA_UID, uid);
|
||||
}
|
||||
if (broadcastAllowList != null && PLATFORM_PACKAGE_NAME.equals(targetPkg)) {
|
||||
intent.putExtra(Intent.EXTRA_VISIBILITY_ALLOW_LIST,
|
||||
|
||||
@@ -243,9 +243,7 @@ final class DeletePackageHelper {
|
||||
if (res) {
|
||||
final boolean killApp = (deleteFlags & PackageManager.DELETE_DONT_KILL_APP) == 0;
|
||||
info.sendPackageRemovedBroadcasts(killApp, removedBySystem);
|
||||
if (disabledSystemPs != null) {
|
||||
info.sendSystemPackageUpdatedBroadcasts(disabledSystemPs.getAppId());
|
||||
}
|
||||
info.sendSystemPackageUpdatedBroadcasts();
|
||||
}
|
||||
|
||||
// Force a gc to clear up things.
|
||||
@@ -603,9 +601,6 @@ final class DeletePackageHelper {
|
||||
if (outInfo != null) {
|
||||
// Delete the updated package
|
||||
outInfo.mIsRemovedPackageSystemUpdate = true;
|
||||
if (disabledPs.getAppId() != deletedPs.getAppId()) {
|
||||
outInfo.mNewAppId = disabledPs.getAppId();
|
||||
}
|
||||
}
|
||||
|
||||
if (disabledPs.getVersionCode() < deletedPs.getVersionCode()
|
||||
|
||||
@@ -958,10 +958,6 @@ final class InstallPackageHelper {
|
||||
createdAppId.put(packageName, optimisticallyRegisterAppId(result));
|
||||
versionInfos.put(result.mPkgSetting.getPkg().getPackageName(),
|
||||
mPm.getSettingsVersionForPackage(result.mPkgSetting.getPkg()));
|
||||
if (result.needsNewAppId()) {
|
||||
request.mInstallResult.mRemovedInfo.mNewAppId =
|
||||
result.mPkgSetting.getAppId();
|
||||
}
|
||||
} catch (PackageManagerException e) {
|
||||
request.mInstallResult.setError("Scanning Failed.", e);
|
||||
return;
|
||||
@@ -2594,8 +2590,6 @@ final class InstallPackageHelper {
|
||||
final int dataLoaderType = installArgs.mDataLoaderType;
|
||||
final boolean succeeded = res.mReturnCode == PackageManager.INSTALL_SUCCEEDED;
|
||||
final boolean update = res.mRemovedInfo != null && res.mRemovedInfo.mRemovedPackage != null;
|
||||
final int previousAppId = (res.mRemovedInfo != null && res.mRemovedInfo.mNewAppId >= 0)
|
||||
? res.mRemovedInfo.mUid : Process.INVALID_UID;
|
||||
final String packageName = res.mName;
|
||||
final PackageStateInternal pkgSetting =
|
||||
succeeded ? mPm.getPackageStateInternal(packageName) : null;
|
||||
@@ -2703,10 +2697,7 @@ final class InstallPackageHelper {
|
||||
// Send added for users that don't see the package for the first time
|
||||
Bundle extras = new Bundle();
|
||||
extras.putInt(Intent.EXTRA_UID, res.mUid);
|
||||
if (previousAppId != Process.INVALID_UID) {
|
||||
extras.putBoolean(Intent.EXTRA_UID_CHANGING, true);
|
||||
extras.putInt(Intent.EXTRA_PREVIOUS_UID, previousAppId);
|
||||
} else if (update) {
|
||||
if (update) {
|
||||
extras.putBoolean(Intent.EXTRA_REPLACING, true);
|
||||
}
|
||||
extras.putInt(PackageInstaller.EXTRA_DATA_LOADER_TYPE, dataLoaderType);
|
||||
@@ -2749,27 +2740,24 @@ final class InstallPackageHelper {
|
||||
|
||||
// Send replaced for users that don't see the package for the first time
|
||||
if (update) {
|
||||
// Only send PACKAGE_REPLACED if appId has not changed
|
||||
if (previousAppId == Process.INVALID_UID) {
|
||||
mPm.sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED,
|
||||
packageName, extras, 0 /*flags*/,
|
||||
null /*targetPackage*/, null /*finishedReceiver*/,
|
||||
updateUserIds, instantUserIds, res.mRemovedInfo.mBroadcastAllowList,
|
||||
mPm.sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED,
|
||||
packageName, extras, 0 /*flags*/,
|
||||
null /*targetPackage*/, null /*finishedReceiver*/,
|
||||
updateUserIds, instantUserIds, res.mRemovedInfo.mBroadcastAllowList,
|
||||
null);
|
||||
if (installerPackageName != null) {
|
||||
mPm.sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED, packageName,
|
||||
extras, 0 /*flags*/,
|
||||
installerPackageName, null /*finishedReceiver*/,
|
||||
updateUserIds, instantUserIds, null /*broadcastAllowList*/,
|
||||
null);
|
||||
}
|
||||
if (notifyVerifier) {
|
||||
mPm.sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED, packageName,
|
||||
extras, 0 /*flags*/,
|
||||
mPm.mRequiredVerifierPackage, null /*finishedReceiver*/,
|
||||
updateUserIds, instantUserIds, null /*broadcastAllowList*/,
|
||||
null);
|
||||
if (installerPackageName != null) {
|
||||
mPm.sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED, packageName,
|
||||
extras, 0 /*flags*/,
|
||||
installerPackageName, null /*finishedReceiver*/,
|
||||
updateUserIds, instantUserIds, null /*broadcastAllowList*/,
|
||||
null);
|
||||
}
|
||||
if (notifyVerifier) {
|
||||
mPm.sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED, packageName,
|
||||
extras, 0 /*flags*/,
|
||||
mPm.mRequiredVerifierPackage, null /*finishedReceiver*/,
|
||||
updateUserIds, instantUserIds, null /*broadcastAllowList*/,
|
||||
null);
|
||||
}
|
||||
}
|
||||
mPm.sendPackageBroadcast(Intent.ACTION_MY_PACKAGE_REPLACED,
|
||||
null /*package*/, null /*extras*/, 0 /*flags*/,
|
||||
|
||||
@@ -38,8 +38,6 @@ final class PackageRemovedInfo {
|
||||
String mInstallerPackageName;
|
||||
int mUid = -1;
|
||||
int mRemovedAppId = -1;
|
||||
// If not -1, the app is going through an appId change
|
||||
int mNewAppId = -1;
|
||||
int[] mOrigUsers;
|
||||
int[] mRemovedUsers = null;
|
||||
int[] mBroadcastUsers = null;
|
||||
@@ -67,22 +65,16 @@ final class PackageRemovedInfo {
|
||||
sendPackageRemovedBroadcastInternal(killApp, removedBySystem);
|
||||
}
|
||||
|
||||
void sendSystemPackageUpdatedBroadcasts(int newAppId) {
|
||||
void sendSystemPackageUpdatedBroadcasts() {
|
||||
if (mIsRemovedPackageSystemUpdate) {
|
||||
sendSystemPackageUpdatedBroadcastsInternal(newAppId);
|
||||
sendSystemPackageUpdatedBroadcastsInternal();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendSystemPackageUpdatedBroadcastsInternal(int newAppId) {
|
||||
private void sendSystemPackageUpdatedBroadcastsInternal() {
|
||||
Bundle extras = new Bundle(2);
|
||||
extras.putInt(Intent.EXTRA_UID, newAppId);
|
||||
// When appId changes, do not set the replacing extra
|
||||
if (mNewAppId >= 0) {
|
||||
extras.putBoolean(Intent.EXTRA_UID_CHANGING, true);
|
||||
extras.putInt(Intent.EXTRA_PREVIOUS_UID, mRemovedAppId >= 0 ? mRemovedAppId : mUid);
|
||||
} else {
|
||||
extras.putBoolean(Intent.EXTRA_REPLACING, true);
|
||||
}
|
||||
extras.putInt(Intent.EXTRA_UID, mRemovedAppId >= 0 ? mRemovedAppId : mUid);
|
||||
extras.putBoolean(Intent.EXTRA_REPLACING, true);
|
||||
mPackageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, mRemovedPackage, extras,
|
||||
0, null /*targetPackage*/, null, null, null, mBroadcastAllowList, null);
|
||||
if (mInstallerPackageName != null) {
|
||||
@@ -90,17 +82,13 @@ final class PackageRemovedInfo {
|
||||
mRemovedPackage, extras, 0 /*flags*/,
|
||||
mInstallerPackageName, null, null, null, null /* broadcastAllowList */,
|
||||
null);
|
||||
mPackageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED,
|
||||
mRemovedPackage, extras, 0 /*flags*/,
|
||||
mInstallerPackageName, null, null, null, null /* broadcastAllowList */,
|
||||
null);
|
||||
}
|
||||
if (mNewAppId < 0) {
|
||||
mPackageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED, mRemovedPackage,
|
||||
extras, 0, null /*targetPackage*/, null, null, null, mBroadcastAllowList, null);
|
||||
if (mInstallerPackageName != null) {
|
||||
mPackageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED,
|
||||
mRemovedPackage, extras, 0 /*flags*/,
|
||||
mInstallerPackageName, null, null, null, null /* broadcastAllowList */,
|
||||
null);
|
||||
}
|
||||
}
|
||||
mPackageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_REPLACED, mRemovedPackage,
|
||||
extras, 0, null /*targetPackage*/, null, null, null, mBroadcastAllowList, null);
|
||||
mPackageSender.sendPackageBroadcast(Intent.ACTION_MY_PACKAGE_REPLACED, null, null, 0,
|
||||
mRemovedPackage, null, null, null, null /* broadcastAllowList */,
|
||||
getTemporaryAppAllowlistBroadcastOptions(REASON_PACKAGE_REPLACED).toBundle());
|
||||
@@ -134,15 +122,10 @@ final class PackageRemovedInfo {
|
||||
extras.putBoolean(Intent.EXTRA_DATA_REMOVED, mDataRemoved);
|
||||
extras.putBoolean(Intent.EXTRA_DONT_KILL_APP, !killApp);
|
||||
extras.putBoolean(Intent.EXTRA_USER_INITIATED, !removedBySystem);
|
||||
|
||||
// When appId changes, do not set the replacing extra
|
||||
if (mNewAppId >= 0) {
|
||||
extras.putBoolean(Intent.EXTRA_UID_CHANGING, true);
|
||||
extras.putInt(Intent.EXTRA_NEW_UID, mNewAppId);
|
||||
} else if (mIsUpdate || mIsRemovedPackageSystemUpdate) {
|
||||
final boolean isReplace = mIsUpdate || mIsRemovedPackageSystemUpdate;
|
||||
if (isReplace) {
|
||||
extras.putBoolean(Intent.EXTRA_REPLACING, true);
|
||||
}
|
||||
|
||||
extras.putBoolean(Intent.EXTRA_REMOVED_FOR_ALL_USERS, mRemovedForAllUsers);
|
||||
if (mRemovedPackage != null) {
|
||||
mPackageSender.sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED,
|
||||
@@ -165,9 +148,9 @@ final class PackageRemovedInfo {
|
||||
}
|
||||
}
|
||||
if (mRemovedAppId >= 0) {
|
||||
// If the package is not actually removed, some services need to know the
|
||||
// package name affected.
|
||||
if (mNewAppId >= 0 || mIsUpdate || mIsRemovedPackageSystemUpdate) {
|
||||
// If a system app's updates are uninstalled the UID is not actually removed. Some
|
||||
// services need to know the package name affected.
|
||||
if (isReplace) {
|
||||
extras.putString(Intent.EXTRA_PACKAGE_NAME, mRemovedPackage);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user