Always restart apps if base.apk gets updated.

Bug: 219044664
Fixes: 219044664
Test: atest PackageManagerShellCommandTest
Change-Id: I27a0c5009b2d5f1ea51618b9acfa1e6ccee71296
Merged-In: I27a0c5009b2d5f1ea51618b9acfa1e6ccee71296
This commit is contained in:
Alex Buynytskyy
2022-02-24 21:40:13 -08:00
parent a683c9b0c2
commit 5b2e8af805
3 changed files with 24 additions and 0 deletions

View File

@@ -55,4 +55,5 @@ interface IPackageInstallerSession {
int getParentSessionId(); int getParentSessionId();
boolean isStaged(); boolean isStaged();
int getInstallFlags();
} }

View File

@@ -1431,6 +1431,18 @@ public class PackageInstaller {
} }
} }
/**
* @return Session's {@link SessionParams#installFlags}.
* @hide
*/
public int getInstallFlags() {
try {
return mSession.getInstallFlags();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/** /**
* @return the session ID of the multi-package session that this belongs to or * @return the session ID of the multi-package session that this belongs to or
* {@link SessionInfo#INVALID_ID} if it does not belong to a multi-package session. * {@link SessionInfo#INVALID_ID} if it does not belong to a multi-package session.

View File

@@ -126,6 +126,7 @@ import android.system.StructStat;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.ArrayMap; import android.util.ArrayMap;
import android.util.ArraySet; import android.util.ArraySet;
import android.util.EventLog;
import android.util.ExceptionUtils; import android.util.ExceptionUtils;
import android.util.MathUtils; import android.util.MathUtils;
import android.util.Slog; import android.util.Slog;
@@ -3097,6 +3098,11 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
if (mResolvedBaseFile == null) { if (mResolvedBaseFile == null) {
mResolvedBaseFile = new File(appInfo.getBaseCodePath()); mResolvedBaseFile = new File(appInfo.getBaseCodePath());
inheritFileLocked(mResolvedBaseFile); inheritFileLocked(mResolvedBaseFile);
} else if ((params.installFlags & PackageManager.INSTALL_DONT_KILL_APP) != 0) {
EventLog.writeEvent(0x534e4554, "219044664");
// Installing base.apk. Make sure the app is restarted.
params.setDontKillApp(false);
} }
// Inherit splits if not overridden. // Inherit splits if not overridden.
@@ -3742,6 +3748,11 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
return params.isStaged; return params.isStaged;
} }
@Override
public int getInstallFlags() {
return params.installFlags;
}
@Override @Override
public DataLoaderParamsParcel getDataLoaderParams() { public DataLoaderParamsParcel getDataLoaderParams() {
mContext.enforceCallingOrSelfPermission(Manifest.permission.USE_INSTALLER_V2, null); mContext.enforceCallingOrSelfPermission(Manifest.permission.USE_INSTALLER_V2, null);