Merge "Rename ApexInfo.package{Name,Path} to module{Name,Path}" into stage-aosp-master am: 6a36ad8b7e
am: 0ad641f9f6
Change-Id: I895d342e2101fe14a905c8f600e5cf290ee27b40
This commit is contained in:
@@ -8391,7 +8391,7 @@ public class PackageParser {
|
||||
public static PackageInfo generatePackageInfoFromApex(ApexInfo apexInfo, int flags)
|
||||
throws PackageParserException {
|
||||
PackageParser pp = new PackageParser();
|
||||
File apexFile = new File(apexInfo.packagePath);
|
||||
File apexFile = new File(apexInfo.modulePath);
|
||||
final Package p = pp.parsePackage(apexFile, flags, false);
|
||||
PackageUserState state = new PackageUserState();
|
||||
PackageInfo pi = generatePackageInfo(p, EmptyArray.INT, flags, 0, 0,
|
||||
|
||||
@@ -498,14 +498,14 @@ public class PackageParserTest {
|
||||
|
||||
@Test
|
||||
public void testApexPackageInfoGeneration() throws Exception {
|
||||
String apexPackageName = "com.android.tzdata.apex";
|
||||
File apexFile = copyRawResourceToFile(apexPackageName,
|
||||
String apexModuleName = "com.android.tzdata.apex";
|
||||
File apexFile = copyRawResourceToFile(apexModuleName,
|
||||
R.raw.com_android_tzdata);
|
||||
ApexInfo apexInfo = new ApexInfo();
|
||||
apexInfo.isActive = true;
|
||||
apexInfo.isFactory = false;
|
||||
apexInfo.packageName = apexPackageName;
|
||||
apexInfo.packagePath = apexFile.getPath();
|
||||
apexInfo.moduleName = apexModuleName;
|
||||
apexInfo.modulePath = apexFile.getPath();
|
||||
apexInfo.versionCode = 191000070;
|
||||
int flags = PackageManager.GET_META_DATA | PackageManager.GET_SIGNING_CERTIFICATES;
|
||||
PackageInfo pi = PackageParser.generatePackageInfoFromApex(apexInfo, flags);
|
||||
|
||||
@@ -130,7 +130,7 @@ class ApexManager {
|
||||
for (ApexInfo ai : allPkgs) {
|
||||
// If the device is using flattened APEX, don't report any APEX
|
||||
// packages since they won't be managed or updated by PackageManager.
|
||||
if ((new File(ai.packagePath)).isDirectory()) {
|
||||
if ((new File(ai.modulePath)).isDirectory()) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
@@ -144,9 +144,9 @@ class ApexManager {
|
||||
"Two active packages have the same name: "
|
||||
+ pkg.packageName);
|
||||
}
|
||||
activePackagesSet.add(ai.packageName);
|
||||
activePackagesSet.add(pkg.packageName);
|
||||
// TODO(b/132324953): remove.
|
||||
mApexNameToPackageInfoCache.put(ai.packageName, pkg);
|
||||
mApexNameToPackageInfoCache.put(ai.moduleName, pkg);
|
||||
}
|
||||
if (ai.isFactory) {
|
||||
if (factoryPackagesSet.contains(pkg.packageName)) {
|
||||
@@ -154,7 +154,7 @@ class ApexManager {
|
||||
"Two factory packages have the same name: "
|
||||
+ pkg.packageName);
|
||||
}
|
||||
factoryPackagesSet.add(ai.packageName);
|
||||
factoryPackagesSet.add(pkg.packageName);
|
||||
}
|
||||
} catch (PackageParserException pe) {
|
||||
throw new IllegalStateException("Unable to parse: " + ai, pe);
|
||||
|
||||
@@ -104,7 +104,7 @@ public class StagingManager {
|
||||
return new ParceledListSlice<>(result);
|
||||
}
|
||||
|
||||
private boolean validateApexSignature(String apexPath, String packageName) {
|
||||
private boolean validateApexSignature(String apexPath, String apexModuleName) {
|
||||
final SigningDetails signingDetails;
|
||||
try {
|
||||
signingDetails = ApkSignatureVerifier.verify(apexPath, SignatureSchemeVersion.JAR);
|
||||
@@ -113,11 +113,11 @@ public class StagingManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
final PackageInfo packageInfo = mApexManager.getPackageInfoForApexName(packageName);
|
||||
final PackageInfo packageInfo = mApexManager.getPackageInfoForApexName(apexModuleName);
|
||||
|
||||
if (packageInfo == null) {
|
||||
// Don't allow installation of new APEX.
|
||||
Slog.e(TAG, "Attempted to install a new apex " + packageName + ". Rejecting");
|
||||
Slog.e(TAG, "Attempted to install a new apex " + apexModuleName + ". Rejecting");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -154,9 +154,9 @@ public class StagingManager {
|
||||
"APEX staging failed, check logcat messages from apexd for more details.");
|
||||
return false;
|
||||
}
|
||||
for (ApexInfo newPackage : apexInfoList.apexInfos) {
|
||||
for (ApexInfo newModule : apexInfoList.apexInfos) {
|
||||
PackageInfo activePackage = mApexManager.getPackageInfoForApexName(
|
||||
newPackage.packageName);
|
||||
newModule.moduleName);
|
||||
if (activePackage == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public class StagingManager {
|
||||
if (activeVersion != session.params.requiredInstalledVersionCode) {
|
||||
session.setStagedSessionFailed(
|
||||
SessionInfo.STAGED_SESSION_VERIFICATION_FAILED,
|
||||
"Installed version of APEX package " + newPackage.packageName
|
||||
"Installed version of APEX package " + activePackage.packageName
|
||||
+ " does not match required. Active version: " + activeVersion
|
||||
+ " required: " + session.params.requiredInstalledVersionCode);
|
||||
|
||||
@@ -179,12 +179,12 @@ public class StagingManager {
|
||||
|
||||
boolean allowsDowngrade = PackageManagerServiceUtils.isDowngradePermitted(
|
||||
session.params.installFlags, activePackage.applicationInfo.flags);
|
||||
if (activeVersion > newPackage.versionCode && !allowsDowngrade) {
|
||||
if (activeVersion > newModule.versionCode && !allowsDowngrade) {
|
||||
session.setStagedSessionFailed(
|
||||
SessionInfo.STAGED_SESSION_VERIFICATION_FAILED,
|
||||
"Downgrade of APEX package " + newPackage.packageName
|
||||
"Downgrade of APEX package " + activePackage.packageName
|
||||
+ " is not allowed. Active version: " + activeVersion
|
||||
+ " attempted: " + newPackage.versionCode);
|
||||
+ " attempted: " + newModule.versionCode);
|
||||
|
||||
if (!mApexManager.abortActiveSession()) {
|
||||
Slog.e(TAG, "Failed to abort apex session " + session.sessionId);
|
||||
@@ -242,13 +242,13 @@ public class StagingManager {
|
||||
// so we fail the session early if there is a signature mismatch. For APKs, the
|
||||
// signature verification will be done by the package manager at the point at which
|
||||
// it applies the staged install.
|
||||
for (ApexInfo apexPackage : apexInfoList.apexInfos) {
|
||||
if (!validateApexSignature(apexPackage.packagePath,
|
||||
apexPackage.packageName)) {
|
||||
for (ApexInfo apexModule : apexInfoList.apexInfos) {
|
||||
if (!validateApexSignature(apexModule.modulePath,
|
||||
apexModule.moduleName)) {
|
||||
session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_VERIFICATION_FAILED,
|
||||
"APK-container signature verification failed for package "
|
||||
+ apexPackage.packageName + ". Signature of file "
|
||||
+ apexPackage.packagePath + " does not match the signature of "
|
||||
+ apexModule.moduleName + ". Signature of file "
|
||||
+ apexModule.modulePath + " does not match the signature of "
|
||||
+ " the package already installed.");
|
||||
// TODO(b/118865310): abort the session on apexd.
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user