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

Unverified Commit d192e709 authored by Oliver Scott's avatar Oliver Scott Committed by Michael Bestas
Browse files

fixup! Firewall: Network access toggle support

Update restriction rules for an app when it is being updated/replaced,
not only when it is installed for the first time. Use the latest data
when checking for internet permission.

Issue: calyxos#2657
Reported-by: lucasmz
Change-Id: I608a792e54cad347f4c256029a2959d6f6b45e3b
parent 5e23d82b
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import static android.content.Intent.ACTION_PACKAGE_ADDED;
import static android.content.Intent.ACTION_UID_REMOVED;
import static android.content.Intent.ACTION_USER_ADDED;
import static android.content.Intent.ACTION_USER_REMOVED;
import static android.content.Intent.EXTRA_REPLACING;
import static android.content.Intent.EXTRA_UID;
import static android.content.pm.PackageManager.MATCH_ANY_USER;
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_AWARE;
@@ -1413,21 +1412,16 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
            final int uid = intent.getIntExtra(EXTRA_UID, -1);
            if (uid == -1) return;

            if (intent.getBooleanExtra(EXTRA_REPLACING, false)) {
                if (LOGV) Slog.v(TAG, "ACTION_PACKAGE_ADDED Not new app, skip it uid=" + uid);
                return;
            }

            if (ACTION_PACKAGE_ADDED.equals(action)) {
                // update rules for UID, since it might be subject to
                // global background data policy
                // Clear the cache for the app
                synchronized (mUidRulesFirstLock) {
                    mInternetPermissionMap.delete(uid);
                    if (!hasInternetPermissionUL(uid) && !isSystemApp(uid)) {
                        Slog.i(TAG, "ACTION_PACKAGE_ADDED for uid=" + uid + ", no INTERNET");
                        addUidPolicy(uid, POLICY_REJECT_ALL);
                    }
                    mInternetPermissionMap.delete(uid);
                    updateRestrictionRulesForUidUL(uid);
                }
            }