Merge "Only consider active apexes for apex-system-service list."
This commit is contained in:
committed by
Android (Google) Code Review
commit
b48721f9fc
@@ -40,6 +40,7 @@ import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.Trace;
|
||||
import android.sysprop.ApexProperties;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.ArraySet;
|
||||
import android.util.PrintWriterPrinter;
|
||||
@@ -608,18 +609,21 @@ public abstract class ApexManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = service.getName();
|
||||
for (ApexSystemServiceInfo info : mApexSystemServices) {
|
||||
if (info.getName().equals(name)) {
|
||||
throw new IllegalStateException(String.format(
|
||||
"Duplicate apex-system-service %s from %s, %s",
|
||||
name, info.mJarPath, service.getJarPath()));
|
||||
if (ai.isActive) {
|
||||
String name = service.getName();
|
||||
for (int j = 0; j < mApexSystemServices.size(); j++) {
|
||||
ApexSystemServiceInfo info = mApexSystemServices.get(j);
|
||||
if (info.getName().equals(name)) {
|
||||
throw new IllegalStateException(TextUtils.formatSimple(
|
||||
"Duplicate apex-system-service %s from %s, %s", name,
|
||||
info.mJarPath, service.getJarPath()));
|
||||
}
|
||||
}
|
||||
ApexSystemServiceInfo info = new ApexSystemServiceInfo(
|
||||
service.getName(), service.getJarPath(),
|
||||
service.getInitOrder());
|
||||
mApexSystemServices.add(info);
|
||||
}
|
||||
|
||||
ApexSystemServiceInfo info = new ApexSystemServiceInfo(
|
||||
service.getName(), service.getJarPath(), service.getInitOrder());
|
||||
mApexSystemServices.add(info);
|
||||
}
|
||||
Collections.sort(mApexSystemServices);
|
||||
mPackageNameToApexModuleName.put(packageInfo.packageName, ai.moduleName);
|
||||
|
||||
@@ -132,7 +132,12 @@ public class ApexManagerTest {
|
||||
|
||||
@Test
|
||||
public void testGetApexSystemServices() throws RemoteException {
|
||||
when(mApexService.getAllPackages()).thenReturn(createApexInfoForTestPkg(true, false));
|
||||
when(mApexService.getAllPackages()).thenReturn(new ApexInfo[] {
|
||||
createApexInfoForTestPkg(false, true, 1),
|
||||
// only active apex reports apex-system-service
|
||||
createApexInfoForTestPkg(true, false, 2),
|
||||
});
|
||||
|
||||
mApexManager.scanApexPackagesTraced(mPackageParser2,
|
||||
ParallelPackageParser.makeExecutorService());
|
||||
|
||||
@@ -484,17 +489,20 @@ public class ApexManagerTest {
|
||||
assertThat(e).hasMessageThat().contains("Failed to collect certificates from ");
|
||||
}
|
||||
|
||||
private ApexInfo[] createApexInfoForTestPkg(boolean isActive, boolean isFactory) {
|
||||
private ApexInfo createApexInfoForTestPkg(boolean isActive, boolean isFactory, int version) {
|
||||
File apexFile = extractResource(TEST_APEX_PKG, TEST_APEX_FILE_NAME);
|
||||
ApexInfo apexInfo = new ApexInfo();
|
||||
apexInfo.isActive = isActive;
|
||||
apexInfo.isFactory = isFactory;
|
||||
apexInfo.moduleName = TEST_APEX_PKG;
|
||||
apexInfo.modulePath = apexFile.getPath();
|
||||
apexInfo.versionCode = 191000070;
|
||||
apexInfo.versionCode = version;
|
||||
apexInfo.preinstalledModulePath = apexFile.getPath();
|
||||
return apexInfo;
|
||||
}
|
||||
|
||||
return new ApexInfo[]{apexInfo};
|
||||
private ApexInfo[] createApexInfoForTestPkg(boolean isActive, boolean isFactory) {
|
||||
return new ApexInfo[]{createApexInfoForTestPkg(isActive, isFactory, 191000070)};
|
||||
}
|
||||
|
||||
private ApexInfo createApexInfo(String moduleName, int versionCode, boolean isActive,
|
||||
|
||||
Reference in New Issue
Block a user