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

Commit b8789dd9 authored by Jaekyun Seok's avatar Jaekyun Seok
Browse files

Allow default permission exceptions to be read from vendor partition

Soc vendors should be allowed to add their own default permission
exceptions because they can install their own apps in /vendor/app.

Test: building succeeded and tested on sailfish.
Bug: 35369237
Change-Id: I7fd0044f4edee6524232c6f8d77481c26535e1d6
parent e3bf23be
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -1035,14 +1036,22 @@ final class DefaultPermissionGrantPolicy {
        }
    }

    private @NonNull ArrayMap<String, List<DefaultPermissionGrant>>
            readDefaultPermissionExceptionsLPw() {
    private File[] getDefaultPermissionFiles() {
        ArrayList<File> ret = new ArrayList<File>();
        File dir = new File(Environment.getRootDirectory(), "etc/default-permissions");
        if (!dir.exists() || !dir.isDirectory() || !dir.canRead()) {
            return new ArrayMap<>(0);
        if (dir.isDirectory() && dir.canRead()) {
            Collections.addAll(ret, dir.listFiles());
        }
        dir = new File(Environment.getVendorDirectory(), "etc/default-permissions");
        if (dir.isDirectory() && dir.canRead()) {
            Collections.addAll(ret, dir.listFiles());
        }
        return ret.isEmpty() ? null : ret.toArray(new File[0]);
    }

        File[] files = dir.listFiles();
    private @NonNull ArrayMap<String, List<DefaultPermissionGrant>>
            readDefaultPermissionExceptionsLPw() {
        File[] files = getDefaultPermissionFiles();
        if (files == null) {
            return new ArrayMap<>(0);
        }
@@ -1052,7 +1061,7 @@ final class DefaultPermissionGrantPolicy {
        // Iterate over the files in the directory and scan .xml files
        for (File file : files) {
            if (!file.getPath().endsWith(".xml")) {
                Slog.i(TAG, "Non-xml file " + file + " in " + dir + " directory, ignoring");
                Slog.i(TAG, "Non-xml file " + file + " in " + file.getParent() + " directory, ignoring");
                continue;
            }
            if (!file.canRead()) {