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

Commit 6ffe926a authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

Fakestore doesn't have access to internet

parent 01d25a9e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -6112,6 +6112,12 @@
        <item>"com.android.phone"</item>
    </string-array>

    <!-- List of packages which requires permissions reset after update. -->
    <string-array name="config_network_policy_manager_replacing_packages">
        <!-- <item>packageName</item> -->
        <item>com.android.vending</item>
    </string-array>

    <!-- Whether the wake screen on notifications feature is available. -->
    <bool name="config_pulseOnNotificationsAvailable">true</bool>

+1 −0
Original line number Diff line number Diff line
@@ -4900,6 +4900,7 @@
  <java-symbol type="drawable" name="ic_swap_horiz" />
  <java-symbol type="array" name="config_deviceStatesAvailableForAppRequests" />
  <java-symbol type="array" name="config_serviceStateLocationAllowedPackages" />
  <java-symbol type="array" name="config_network_policy_manager_replacing_packages" />
  <java-symbol type="integer" name="config_deviceStateRearDisplay"/>
  <java-symbol type="bool" name="config_independentLockscreenLiveWallpaper"/>

+30 −2
Original line number Diff line number Diff line
@@ -177,9 +177,9 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PackageManagerInternal;
@@ -1287,7 +1287,7 @@ 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 (intent.getBooleanExtra(EXTRA_REPLACING, false) && !doesUidMatchPackages(uid)) {
                if (LOGV) Slog.v(TAG, "ACTION_PACKAGE_ADDED Not new app, skip it uid=" + uid);
                return;
            }
@@ -1437,6 +1437,34 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
        }
    };

    private boolean doesUidMatchPackages(int uid) {
        final String packageName = getPackageForUid(uid);
        if (packageName == null || !isSystemApp(uid)) return false;

        final Context deviceContext = mContext.createDeviceProtectedStorageContext();
        final File prefsFile = new File(new File(Environment.getDataSystemDirectory(),
                "shared_prefs"), "network_policy_whitelist_config.xml");
        SharedPreferences mSharedPreferences =
                deviceContext.getSharedPreferences(prefsFile, Context.MODE_PRIVATE);

        String[] packagePairs = mContext.getResources().getStringArray(
                com.android.internal.R.array.config_network_policy_manager_replacing_packages);

        for (String packageToMatch : packagePairs) {
            if (packageToMatch == null
                || mSharedPreferences.getBoolean(packageToMatch, false)) continue;

            if (packageName.equals(packageToMatch)) {
                if (LOGD) Log.d(TAG, "UID match found packageName: " + packageName);
                mSharedPreferences.edit().putBoolean(packageToMatch, true).apply();
                return !hasInternetPermissionUL(uid);
            }
        }

        if (LOGD) Log.d(TAG, "UID matches not found for packageName: " + packageName);
        return false;
    }

    private static boolean updateCapabilityChange(SparseBooleanArray lastValues, boolean newValue,
            Network network) {
        final boolean lastValue = lastValues.get(network.getNetId(), false);