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

Commit 97fe63bb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Revert "Push mapping from file extension to GID.""

parents 9f864522 1009c08f
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -189,13 +189,6 @@ public class Process {
    /** {@hide} */
    public static final int LAST_APPLICATION_CACHE_GID = 29999;

    /** {@hide} */
    public static final int MEDIA_AUDIO_GID = 1055;
    /** {@hide} */
    public static final int MEDIA_VIDEO_GID = 1056;
    /** {@hide} */
    public static final int MEDIA_IMAGE_GID = 1057;

    /**
     * Standard priority of application threads.
     * Use with {@link #setThreadPriority(int)} and
+0 −5
Original line number Diff line number Diff line
@@ -108,8 +108,6 @@ import com.android.server.NativeDaemonConnector.Command;
import com.android.server.NativeDaemonConnector.SensitiveArg;
import com.android.server.pm.PackageManagerService;
import com.android.server.storage.AppFuseBridge;
import com.android.server.storage.FileCollector;

import libcore.io.IoUtils;
import libcore.util.EmptyArray;

@@ -819,9 +817,6 @@ class StorageManagerService extends IStorageManager.Stub
    }

    private void handleSystemReady() {
        // Register kernel mapping from extensions to statistics GIDs
        FileCollector.updateKernelExtensions();

        initIfReadyAndConnected();
        resetIfReadyAndConnected();

+3 −33
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.util.ArrayMap;
import java.io.File;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Map;

/**
 * FileCollector walks over a directory and categorizes storage usage by their type.
@@ -43,9 +44,8 @@ public class FileCollector {
            AUDIO })
    private @interface FileTypes {}

    // NOTE: If you update these extensions, you'll also want to update
    // matchgen.py over in installd which is used for non-quota stats.
    private static final ArrayMap<String, Integer> EXTENSION_MAP = new ArrayMap<>();

    private static final Map<String, Integer> EXTENSION_MAP = new ArrayMap<String, Integer>();
    static {
        // Audio
        EXTENSION_MAP.put("aac", AUDIO);
@@ -144,36 +144,6 @@ public class FileCollector {
        EXTENSION_MAP.put("xwd", IMAGES);
    }

    private static File mkdir(File parent, String name) {
        final File file = new File(parent, name);
        file.mkdir();
        return file;
    }

    /**
     * Update the mapping used by sdcardfs to map from file extensions to GIDs
     * used for statistics purposes.
     */
    public static void updateKernelExtensions() {
        final File root = new File("/config/sdcardfs/extensions/");
        if (!root.exists()) return;

        final File audio = mkdir(root, Integer.toString(android.os.Process.MEDIA_AUDIO_GID));
        final File video = mkdir(root, Integer.toString(android.os.Process.MEDIA_VIDEO_GID));
        final File image = mkdir(root, Integer.toString(android.os.Process.MEDIA_IMAGE_GID));

        for (int i = 0; i < EXTENSION_MAP.size(); i++) {
            final String ext = EXTENSION_MAP.keyAt(i);
            final int type = EXTENSION_MAP.valueAt(i);

            switch (type) {
                case AUDIO: mkdir(audio, ext); break;
                case VIDEO: mkdir(video, ext); break;
                case IMAGES: mkdir(image, ext); break;
            }
        }
    }

    /**
     * Returns the file categorization measurement result.
     * @param path Directory to collect and categorize storage in.