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