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

Commit a67a758b authored by Alexandre Roux's avatar Alexandre Roux Committed by Aayush Gupta
Browse files

DefaultPermissionGrantPolicy: Grant required permissions to microG stack by default

parent 366a9ef7
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 * Copyright (C) 2021 EFOUNDATION
 * Copyright (C) 2020-2021 ECORP SAS
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -141,6 +143,18 @@ public final class DefaultPermissionGrantPolicy {
        CONTACTS_PERMISSIONS.add(Manifest.permission.GET_ACCOUNTS);
    }

    private static final Set<String> MICROG_PERMISSIONS = new ArraySet<>();
    static {
        MICROG_PERMISSIONS.add("android.permission.FAKE_PACKAGE_SIGNATURE");
        MICROG_PERMISSIONS.add("android.permission.INSTALL_LOCATION_PROVIDER");
        MICROG_PERMISSIONS.add("android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST");
    }

    private static final Set<String> FAKE_PACKAGE_SIGNATURE_PERMISSIONS = new ArraySet<>();
    static {
        FAKE_PACKAGE_SIGNATURE_PERMISSIONS.add("android.permission.FAKE_PACKAGE_SIGNATURE");
    }

    private static final Set<String> ALWAYS_LOCATION_PERMISSIONS = new ArraySet<>();
    static {
        ALWAYS_LOCATION_PERMISSIONS.add(Manifest.permission.ACCESS_FINE_LOCATION);
@@ -832,6 +846,12 @@ public final class DefaultPermissionGrantPolicy {
        grantSystemFixedPermissionsToSystemPackage(pm, "com.android.sharedstoragebackup", userId,
                STORAGE_PERMISSIONS);

        // MicroG
        grantSystemFixedPermissionsToSystemPackage(pm, "com.google.android.gms", userId,
                MICROG_PERMISSIONS);
        grantSystemFixedPermissionsToSystemPackage(pm, "com.android.vending", userId,
                FAKE_PACKAGE_SIGNATURE_PERMISSIONS);

        // System Captions Service
        String systemCaptionsServicePackageName =
                mContext.getPackageManager().getSystemCaptionsServicePackageName();