Merge "Consolidate isApkVeritySupported to VerityUtils" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0f9e86ac95
@@ -41,7 +41,6 @@ import com.android.internal.util.DumpUtils;
|
|||||||
import com.android.internal.util.Preconditions;
|
import com.android.internal.util.Preconditions;
|
||||||
import com.android.server.LocalServices;
|
import com.android.server.LocalServices;
|
||||||
import com.android.server.SystemService;
|
import com.android.server.SystemService;
|
||||||
import com.android.server.security.FileIntegrityService;
|
|
||||||
import com.android.server.security.VerityUtils;
|
import com.android.server.security.VerityUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -226,7 +225,7 @@ public final class FontManagerService extends IFontManager.Stub {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private static UpdatableFontDir createUpdatableFontDir() {
|
private static UpdatableFontDir createUpdatableFontDir() {
|
||||||
// If apk verity is supported, fs-verity should be available.
|
// If apk verity is supported, fs-verity should be available.
|
||||||
if (!FileIntegrityService.isApkVeritySupported()) return null;
|
if (!VerityUtils.isFsVeritySupported()) return null;
|
||||||
return new UpdatableFontDir(new File(FONT_FILES_DIR),
|
return new UpdatableFontDir(new File(FONT_FILES_DIR),
|
||||||
Arrays.asList(new File(SystemFonts.SYSTEM_FONT_DIR),
|
Arrays.asList(new File(SystemFonts.SYSTEM_FONT_DIR),
|
||||||
new File(SystemFonts.OEM_FONT_DIR)),
|
new File(SystemFonts.OEM_FONT_DIR)),
|
||||||
|
|||||||
@@ -23,10 +23,8 @@ import android.content.Context;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManagerInternal;
|
import android.content.pm.PackageManagerInternal;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.SystemProperties;
|
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.security.IFileIntegrityService;
|
import android.security.IFileIntegrityService;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
@@ -60,7 +58,7 @@ public class FileIntegrityService extends SystemService {
|
|||||||
private final IBinder mService = new IFileIntegrityService.Stub() {
|
private final IBinder mService = new IFileIntegrityService.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isApkVeritySupported() {
|
public boolean isApkVeritySupported() {
|
||||||
return FileIntegrityService.isApkVeritySupported();
|
return VerityUtils.isFsVeritySupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -69,7 +67,7 @@ public class FileIntegrityService extends SystemService {
|
|||||||
checkCallerPermission(packageName);
|
checkCallerPermission(packageName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!isApkVeritySupported()) {
|
if (!VerityUtils.isFsVeritySupported()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (certificateBytes == null) {
|
if (certificateBytes == null) {
|
||||||
@@ -110,11 +108,6 @@ public class FileIntegrityService extends SystemService {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static boolean isApkVeritySupported() {
|
|
||||||
return Build.VERSION.FIRST_SDK_INT >= Build.VERSION_CODES.R
|
|
||||||
|| SystemProperties.getInt("ro.apk_verity.mode", 0) == 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileIntegrityService(final Context context) {
|
public FileIntegrityService(final Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -17,7 +17,9 @@
|
|||||||
package com.android.server.security;
|
package com.android.server.security;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.SharedMemory;
|
import android.os.SharedMemory;
|
||||||
|
import android.os.SystemProperties;
|
||||||
import android.system.ErrnoException;
|
import android.system.ErrnoException;
|
||||||
import android.system.Os;
|
import android.system.Os;
|
||||||
import android.system.OsConstants;
|
import android.system.OsConstants;
|
||||||
@@ -57,6 +59,11 @@ abstract public class VerityUtils {
|
|||||||
|
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
|
|
||||||
|
public static boolean isFsVeritySupported() {
|
||||||
|
return Build.VERSION.FIRST_SDK_INT >= Build.VERSION_CODES.R
|
||||||
|
|| SystemProperties.getInt("ro.apk_verity.mode", 0) == 2;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns true if the given file looks like containing an fs-verity signature. */
|
/** Returns true if the given file looks like containing an fs-verity signature. */
|
||||||
public static boolean isFsveritySignatureFile(File file) {
|
public static boolean isFsveritySignatureFile(File file) {
|
||||||
return file.getName().endsWith(FSVERITY_SIGNATURE_FILE_EXTENSION);
|
return file.getName().endsWith(FSVERITY_SIGNATURE_FILE_EXTENSION);
|
||||||
|
|||||||
Reference in New Issue
Block a user