Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b92b05bb authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Report FBE through a feature string.

Since devices can be converted to enable/disable FBE across a
factory reset, we offer to add the features dynamically depending
on device status.

Bug: 26808417
Change-Id: I905140ba500a5e69756b547f2b1d6167b9a37dc6
parent dc5f0277
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2017,6 +2017,11 @@ public abstract class PackageManager {
    public static final String FEATURE_SECURELY_REMOVES_USERS
            = "android.software.securely_removes_users";

    /** {@hide} */
    @SdkConstant(SdkConstantType.FEATURE)
    public static final String FEATURE_FILE_BASED_ENCRYPTION
            = "android.software.file_based_encryption";

    /**
     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
     * The device has a full implementation of the android.webkit.* APIs. Devices
+5 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.os.Binder;
import android.os.Environment;
import android.os.StatFs;
import android.os.SystemClock;
import android.os.storage.StorageManager;

import java.io.File;
import java.io.FileDescriptor;
@@ -79,6 +80,10 @@ public class DiskStatsService extends Binder {
        reportFreeSpace(Environment.getDownloadCacheDirectory(), "Cache", pw);
        reportFreeSpace(new File("/system"), "System", pw);

        if (StorageManager.isNativeFileBasedEncryptionEnabled()) {
            pw.println("File-based Encryption: true");
        }

        // TODO: Read /proc/yaffs and report interesting values;
        // add configurable (through args) performance test parameters.
    }
+31 −13
Original line number Diff line number Diff line
@@ -16,20 +16,24 @@

package com.android.server;

import static com.android.internal.util.ArrayUtils.appendInt;

import android.app.ActivityManager;
import android.content.pm.FeatureInfo;
import android.os.*;
import android.content.pm.PackageManager;
import android.os.Environment;
import android.os.Process;
import android.os.storage.StorageManager;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Slog;
import android.util.SparseArray;
import android.util.Xml;

import libcore.io.IoUtils;

import com.android.internal.util.XmlUtils;

import libcore.io.IoUtils;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

@@ -38,8 +42,6 @@ import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import static com.android.internal.util.ArrayUtils.appendInt;

/**
 * Loads global system configuration info.
 */
@@ -351,10 +353,7 @@ public class SystemConfig {
                        Slog.w(TAG, "<feature> without name in " + permFile + " at "
                                + parser.getPositionDescription());
                    } else if (allowed) {
                        //Log.i(TAG, "Got feature " + fname);
                        FeatureInfo fi = new FeatureInfo();
                        fi.name = fname;
                        mAvailableFeatures.put(fname, fi);
                        addFeature(fname);
                    }
                    XmlUtils.skipCurrentTag(parser);
                    continue;
@@ -443,10 +442,29 @@ public class SystemConfig {
            IoUtils.closeQuietly(permReader);
        }

        for (String fname : mUnavailableFeatures) {
            if (mAvailableFeatures.remove(fname) != null) {
                Slog.d(TAG, "Removed unavailable feature " + fname);
        // Some devices can be field-converted to FBE, so offer to splice in
        // those features if not already defined by the static config
        if (StorageManager.isNativeFileBasedEncryptionEnabled()) {
            addFeature(PackageManager.FEATURE_FILE_BASED_ENCRYPTION);
            addFeature(PackageManager.FEATURE_SECURELY_REMOVES_USERS);
        }

        for (String featureName : mUnavailableFeatures) {
            removeFeature(featureName);
        }
    }

    private void addFeature(String featureName) {
        if (!mAvailableFeatures.containsKey(featureName)) {
            final FeatureInfo fi = new FeatureInfo();
            fi.name = featureName;
            mAvailableFeatures.put(featureName, fi);
        }
    }

    private void removeFeature(String featureName) {
        if (mAvailableFeatures.remove(featureName) != null) {
            Slog.d(TAG, "Removed unavailable feature " + featureName);
        }
    }

+1 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ import static android.os.Process.SYSTEM_UID;
import static android.os.Trace.TRACE_TAG_PACKAGE_MANAGER;
import static android.system.OsConstants.O_CREAT;
import static android.system.OsConstants.O_RDWR;
import static com.android.internal.app.IntentForwarderActivity.FORWARD_INTENT_TO_MANAGED_PROFILE;
import static com.android.internal.app.IntentForwarderActivity.FORWARD_INTENT_TO_PARENT;
import static com.android.internal.content.NativeLibraryHelper.LIB64_DIR_NAME;