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

Commit a4407bfc authored by Jeff Vander Stoep's avatar Jeff Vander Stoep
Browse files

pm: selinux support for AutoPlay apps

Add AutoPlay flag to ApplicationInfo.

Append autoplay flag to seinfo string - passed to libselinux for
domain labeling decision.

Change-Id: Ieb45ba328140888c0b679bf344df154658f9fbae
parent 97f1fb2c
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -468,6 +468,14 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public static final int PRIVATE_FLAG_FORCE_DEVICE_ENCRYPTED = 1 << 5;

    /**
     * Value for {@link #privateFlags}: set to {@code true} if the application
     * is AutoPlay.
     *
     * {@hide}
     */
    public static final int PRIVATE_FLAG_AUTOPLAY = 1<<6;

    /**
     * Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
     * {@hide}
@@ -1030,6 +1038,13 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
                && (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
    }

    /**
     * @hide
     */
    public boolean isAutoPlayApp() {
        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_AUTOPLAY) != 0;
    }

    /**
     * @hide
     */
+6 −0
Original line number Diff line number Diff line
@@ -103,6 +103,9 @@ public final class SELinuxMMAC {
    // Append privapp to existing seinfo label
    private static final String PRIVILEGED_APP_STR = ":privapp";

    // Append autoplay to existing seinfo label
    private static final String AUTOPLAY_APP_STR = ":autoplayapp";

    /**
     * Load the mac_permissions.xml file containing all seinfo assignments used to
     * label apps. The loaded mac_permissions.xml file is determined by the
@@ -316,6 +319,9 @@ public final class SELinuxMMAC {
            }
        }

        if (pkg.applicationInfo.isAutoPlayApp())
            pkg.applicationInfo.seinfo += AUTOPLAY_APP_STR;

        if (pkg.applicationInfo.isPrivilegedApp())
            pkg.applicationInfo.seinfo += PRIVILEGED_APP_STR;