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

Commit 7d859aa9 authored by Oliver Scott's avatar Oliver Scott Committed by Michael Bestas
Browse files

Add custom handling for backup/restore of UIDS_ALLOWED_ON_RESTRICTED_NETWORKS

Change-Id: I8a4086692c385e9d6166a9bcb11d0a16c9fc7422
parent f507e578
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -2841,6 +2841,26 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
            out.endTag(null, TAG_UID_POLICY);
        }

        if (forBackup) {
            try {
                List<PackageInfo> packages = mIPm.getPackagesHoldingPermissions(
                        new String[]{android.Manifest.permission.INTERNET}, 0, userId
                ).getList();
                List<Integer> uids = packages.stream().map(packageInfo ->
                        packageInfo.applicationInfo.uid).collect(Collectors.toList());
                uids.removeAll(
                        ConnectivitySettingsManager.getUidsAllowedOnRestrictedNetworks(mContext));
                for (int uid : uids) {
                    out.startTag(null, TAG_UID_POLICY);
                    writeStringAttribute(out, ATTR_XML_UTILS_NAME, getPackageForUid(uid));
                    writeIntAttribute(out, ATTR_POLICY, POLICY_REJECT_ALL);
                    out.endTag(null, TAG_UID_POLICY);
                }
            } catch (RemoteException ignored) {

            }
        }

        // write all allowlists
        out.startTag(null, TAG_WHITELIST);