Merge "Fix appMetadataFilePath when restoring system app" into udc-dev

This commit is contained in:
William Loh
2023-05-11 04:11:39 +00:00
committed by Android (Google) Code Review
3 changed files with 12 additions and 7 deletions

View File

@@ -499,13 +499,6 @@ final class InstallPackageHelper {
mPm.setUpCustomResolverActivity(pkg, pkgSetting);
}
File appMetadataFile = new File(pkgSetting.getPath(), APP_METADATA_FILE_NAME);
if (appMetadataFile.exists()) {
pkgSetting.setAppMetadataFilePath(appMetadataFile.getAbsolutePath());
} else {
pkgSetting.setAppMetadataFilePath(null);
}
if (pkg.getPackageName().equals("android")) {
mPm.setPlatformPackage(pkg, pkgSetting);
}
@@ -2124,6 +2117,13 @@ final class InstallPackageHelper {
installRequest.setNewUsers(
ps.queryInstalledUsers(mPm.mUserManager.getUserIds(), true));
ps.setUpdateAvailable(false /*updateAvailable*/);
File appMetadataFile = new File(ps.getPath(), APP_METADATA_FILE_NAME);
if (appMetadataFile.exists()) {
ps.setAppMetadataFilePath(appMetadataFile.getAbsolutePath());
} else {
ps.setAppMetadataFilePath(null);
}
}
if (installRequest.getReturnCode() == PackageManager.INSTALL_SUCCEEDED) {
mPm.updateSequenceNumberLP(ps, installRequest.getNewUsers());

View File

@@ -16,6 +16,7 @@
package com.android.server.pm;
import static android.Manifest.permission.GET_APP_METADATA;
import static android.content.pm.PackageInstaller.LOCATION_DATA_APP;
import static android.content.pm.PackageManager.FLAG_PERMISSION_REVIEW_REQUIRED;
import static android.content.pm.PackageManager.FLAG_PERMISSION_REVOKED_COMPAT;
@@ -3576,6 +3577,7 @@ class PackageManagerShellCommand extends ShellCommand {
}
private int runGetAppMetadata() {
mContext.enforceCallingOrSelfPermission(GET_APP_METADATA, "getAppMetadataFd");
final PrintWriter pw = getOutPrintWriter();
String pkgName = getNextArgRequired();
ParcelFileDescriptor pfd = null;

View File

@@ -921,6 +921,7 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile
p.getUsesStaticLibraries(), p.getUsesStaticLibrariesVersions(), p.getMimeGroups(),
mDomainVerificationManager.generateNewId());
if (ret != null) {
ret.setAppMetadataFilePath(p.getAppMetadataFilePath());
ret.getPkgState().setUpdatedSystemApp(false);
}
mDisabledSysPackages.remove(name);
@@ -3700,6 +3701,8 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile
ps.setSharedUserAppId(sharedUserAppId);
}
ps.setAppMetadataFilePath(parser.getAttributeValue(null, "appMetadataFilePath"));
int outerDepth = parser.getDepth();
int type;
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT