Merge changes Ie97c4815,Id104a400,Ib983354f,Id565986a into main

* changes:
  Remove ununsed com.android.sysprop.apex dependency
  Remove ro.apex.updatable check
  Revert "Treat allowlists differently for flattened apex"
  Remove ApexManagerFlattenedApex
This commit is contained in:
Jooyung Han
2023-07-13 01:37:21 +00:00
committed by Android (Google) Code Review
5 changed files with 3 additions and 231 deletions

View File

@@ -246,7 +246,6 @@ java_library {
"android.system.suspend.control.internal-java",
"devicepolicyprotosnano",
"com.android.sysprop.apex",
"com.android.sysprop.init",
"com.android.sysprop.localization",
"PlatformProperties",

View File

@@ -35,7 +35,6 @@ import android.os.VintfRuntimeInfo;
import android.os.incremental.IncrementalManager;
import android.os.storage.StorageManager;
import android.permission.PermissionManager.SplitPermissionInfo;
import android.sysprop.ApexProperties;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
@@ -1208,8 +1207,7 @@ public class SystemConfig {
boolean systemExt = permFile.toPath().startsWith(
Environment.getSystemExtDirectory().toPath() + "/");
boolean apex = permFile.toPath().startsWith(
Environment.getApexDirectory().toPath() + "/")
&& ApexProperties.updatable().orElse(false);
Environment.getApexDirectory().toPath() + "/");
if (vendor) {
readPrivAppPermissions(parser,
mPermissionAllowlist.getVendorPrivilegedAppAllowlist());

View File

@@ -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<ApexManager>() {
@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<ScanResult> scanResults) {
// No-op
}
@Override
public List<ActiveApexInfo> 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<ActiveApexInfo> 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<ApexSessionInfo> 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<String> 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<ApexSystemServiceInfo> 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;
}
}
}

View File

@@ -52,7 +52,6 @@ import android.os.ServiceManager;
import android.os.ShellCallback;
import android.os.SystemProperties;
import android.provider.DeviceConfig;
import android.sysprop.ApexProperties;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.FastImmutableArraySet;
@@ -921,10 +920,6 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
return rebootWithLskfImpl(packageName, reason, slotSwitch);
}
public static boolean isUpdatableApexSupported() {
return ApexProperties.updatable().orElse(false);
}
// Metadata should be no more than few MB, if it's larger than 100MB something is wrong.
private static final long APEX_INFO_SIZE_LIMIT = 24 * 1024 * 100;
@@ -975,11 +970,6 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
@Override
public boolean allocateSpaceForUpdate(String packageFile) {
allocateSpaceForUpdate_enforcePermission();
if (!isUpdatableApexSupported()) {
Log.i(TAG, "Updatable Apex not supported, "
+ "allocateSpaceForUpdate does nothing.");
return true;
}
final long token = Binder.clearCallingIdentity();
try {
CompressedApexInfoList apexInfoList = getCompressedApexInfoList(packageFile);

View File

@@ -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(