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

Commit 62f2f437 authored by Yash Garg's avatar Yash Garg 💬 Committed by Yash Garg
Browse files

load force enabled apps for notifications from resources

parent 67a8d6ed
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -34,4 +34,7 @@
    <!-- The list of components which should be forced to be enabled. -->
    <string-array name="config_forceEnabledComponents" translatable="false">
    </string-array>

    <!-- Component names of the packages to force allow notification permissions -->
    <string name="config_forceNotificationPermission" translatable="false">foundation.e.blisslauncher</string>
</resources>
+1 −0
Original line number Diff line number Diff line
@@ -25,4 +25,5 @@
    <java-symbol type="array" name="config_deviceDisabledComponents" />
    <java-symbol type="array" name="config_globallyDisabledComponents" />
    <java-symbol type="array" name="config_forceEnabledComponents" />
    <java-symbol type="string" name="config_forceNotificationPermission" />
</resources>
+25 −0
Original line number Diff line number Diff line
@@ -806,6 +806,7 @@ public class NotificationManagerService extends SystemService {
        if (DBG) Slog.d(TAG, "loadPolicyFile");
        synchronized (mPolicyFile) {
            InputStream infile = null;
            mListeners.loadForceNotificationEnabledServices();
            try {
                infile = mPolicyFile.openRead();
                readPolicyXml(infile, false /*forRestore*/, UserHandle.USER_ALL);
@@ -9564,6 +9565,30 @@ public class NotificationManagerService extends SystemService {
            }
        }

        
        protected void loadForceNotificationEnabledServices() {
            String forceEnabledPackages = mContext.getResources().getString(
                    R.string.config_forceNotificationPermission);

            if (forceEnabledPackages != null) {
                String[] packages =
                        forceEnabledPackages.split(ManagedServices.ENABLED_SERVICES_SEPARATOR);
                for (int i = 0; i < packages.length; i++) {
                    if (TextUtils.isEmpty(packages[i])) {
                        continue;
                    }

                    ArraySet<ComponentName> approvedListeners =
                            this.queryPackageForServices(listeners[i],
                                MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE, USER_SYSTEM);
                    for (int k = 0; k < approvedListeners.size(); k++) {
                        ComponentName cn = approvedListeners.valueAt(k);
                        addDefaultComponentOrPackage(cn.flattenToString());
                    }
                }
            }
        }

        @Override
        protected int getBindFlags() {
            // Most of the same flags as the base, but also add BIND_NOT_PERCEPTIBLE