diff --git a/services/core/java/com/android/server/pm/ApexManager.java b/services/core/java/com/android/server/pm/ApexManager.java index 5e62b56c7bcd4..2206eacb82325 100644 --- a/services/core/java/com/android/server/pm/ApexManager.java +++ b/services/core/java/com/android/server/pm/ApexManager.java @@ -35,7 +35,6 @@ import android.os.Environment; 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; @@ -82,18 +81,12 @@ public abstract class ApexManager { new Singleton() { @Override protected ApexManager create() { - if (ApexProperties.updatable().orElse(false)) { - return new ApexManagerImpl(); - } else { - return new ApexManagerFlattenedApex(); - } + return new ApexManagerImpl(); } }; /** - * Returns an instance of either {@link ApexManagerImpl} or {@link ApexManagerFlattenedApex} - * depending on whether this device supports APEX, i.e. {@link ApexProperties#updatable()} - * evaluates to {@code true}. + * Returns an instance of {@link ApexManagerImpl} * @hide */ public static ApexManager getInstance() { @@ -991,203 +984,4 @@ public abstract class ApexManager { } } } - - /** - * An implementation of {@link ApexManager} that should be used in case device does not support - * updating APEX packages. - */ - @VisibleForTesting - static final class ApexManagerFlattenedApex extends ApexManager { - @Override - ApexInfo[] getAllApexInfos() { - return null; - } - - @Override - void notifyScanResult(List scanResults) { - // No-op - } - - @Override - public List getActiveApexInfos() { - // There is no apexd running in case of flattened apex - // We look up the /apex directory and identify the active APEX modules from there. - // As "preinstalled" path, we just report /system since in the case of flattened APEX - // the /apex directory is just a symlink to /system/apex. - List result = new ArrayList<>(); - File apexDir = Environment.getApexDirectory(); - if (apexDir.isDirectory()) { - File[] files = apexDir.listFiles(); - // listFiles might be null if system server doesn't have permission to read - // a directory. - if (files != null) { - for (File file : files) { - if (file.isDirectory() && !file.getName().contains("@") - // In flattened configuration, init special-cases the art directory - // and bind-mounts com.android.art.debug to com.android.art. - && !file.getName().equals("com.android.art.debug")) { - result.add( - new ActiveApexInfo(file, Environment.getRootDirectory(), file)); - } - } - } - } - return result; - } - - @Override - @Nullable - public String getActiveApexPackageNameContainingPackage( - @NonNull String containedPackageName) { - Objects.requireNonNull(containedPackageName); - - return null; - } - - @Override - ApexSessionInfo getStagedSessionInfo(int sessionId) { - throw new UnsupportedOperationException(); - } - - @Override - SparseArray getSessions() { - return new SparseArray<>(0); - } - - @Override - ApexInfoList submitStagedSession(ApexSessionParams params) - throws PackageManagerException { - throw new PackageManagerException(PackageManager.INSTALL_FAILED_INTERNAL_ERROR, - "Device doesn't support updating APEX"); - } - - @Override - ApexInfo[] getStagedApexInfos(ApexSessionParams params) { - throw new UnsupportedOperationException(); - } - - @Override - void markStagedSessionReady(int sessionId) { - throw new UnsupportedOperationException(); - } - - @Override - void markStagedSessionSuccessful(int sessionId) { - throw new UnsupportedOperationException(); - } - - @Override - boolean isApexSupported() { - return false; - } - - @Override - boolean revertActiveSessions() { - throw new UnsupportedOperationException(); - } - - @Override - boolean abortStagedSession(int sessionId) { - throw new UnsupportedOperationException(); - } - - @Override - boolean uninstallApex(String apexPackagePath) { - throw new UnsupportedOperationException(); - } - - @Override - void registerApkInApex(AndroidPackage pkg) { - // No-op - } - - @Override - void reportErrorWithApkInApex(String scanDirPath, String errorMsg) { - // No-op - } - - @Override - @Nullable - String getApkInApexInstallError(String apexPackageName) { - return null; - } - - @Override - List getApksInApex(String apexPackageName) { - return Collections.emptyList(); - } - - @Override - @Nullable - public String getApexModuleNameForPackageName(String apexPackageName) { - return null; - } - - @Override - @Nullable - public String getActivePackageNameForApexModuleName(String apexModuleName) { - return null; - } - - @Override - public boolean snapshotCeData(int userId, int rollbackId, String apexPackageName) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean restoreCeData(int userId, int rollbackId, String apexPackageName) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean destroyDeSnapshots(int rollbackId) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean destroyCeSnapshots(int userId, int rollbackId) { - return true; - } - - @Override - public boolean destroyCeSnapshotsNotSpecified(int userId, int[] retainRollbackIds) { - return true; - } - - @Override - public void markBootCompleted() { - // No-op - } - - @Override - public long calculateSizeForCompressedApex(CompressedApexInfoList infoList) { - throw new UnsupportedOperationException(); - } - - @Override - public void reserveSpaceForCompressedApex(CompressedApexInfoList infoList) { - throw new UnsupportedOperationException(); - } - - @Override - ApexInfo installPackage(File apexFile) { - throw new UnsupportedOperationException("APEX updates are not supported"); - } - - @Override - public List getApexSystemServices() { - // TODO(satayev): we can't really support flattened apex use case, and need to migrate - // the manifest entries into system's manifest asap. - return Collections.emptyList(); - } - - @Override - void dump(PrintWriter pw) { - } - - @Override - public File getBackingApexFile(File file) { - return null; - } - } } diff --git a/services/tests/mockingservicestests/src/com/android/server/pm/ApexManagerTest.java b/services/tests/mockingservicestests/src/com/android/server/pm/ApexManagerTest.java index 5b0e2f3800c32..1ae91241efd63 100644 --- a/services/tests/mockingservicestests/src/com/android/server/pm/ApexManagerTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/pm/ApexManagerTest.java @@ -473,15 +473,6 @@ public class ApexManagerTest { assertThat(mApexManager.getBackingApexFile(new File("/apex//"))).isNull(); } - @Test - public void testGetBackingApexFiles_flattenedApex() { - ApexManager flattenedApexManager = new ApexManager.ApexManagerFlattenedApex(); - final File backingApexFile = flattenedApexManager.getBackingApexFile( - new File(mMockSystem.system().getApexDirectory(), - "com.android.apex.cts.shim/app/CtsShim/CtsShim.apk")); - assertThat(backingApexFile).isNull(); - } - @Test public void testActiveApexChanged() throws RemoteException { ApexInfo apex1 = createApexInfo(