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

Commit 473eb872 authored by Luke Huang's avatar Luke Huang
Browse files

Strict-related commands porting

remove strict enable command
netd will handle it

Test: runtest frameworks-net passes
Test: run cts StrictModeTest
Change-Id: I34c4f270ec1d4d9ae1f60c0f9abec2a7d966ce9b
parent 716c04b2
Loading
Loading
Loading
Loading
+9 −13
Original line number Original line Diff line number Diff line
@@ -641,12 +641,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub


            SystemProperties.set(PROP_QTAGUID_ENABLED, mBandwidthControlEnabled ? "1" : "0");
            SystemProperties.set(PROP_QTAGUID_ENABLED, mBandwidthControlEnabled ? "1" : "0");


            try {
                mConnector.execute("strict", "enable");
            mStrictEnabled = true;
            mStrictEnabled = true;
            } catch (NativeDaemonConnectorException e) {
                Log.wtf(TAG, "Failed strict enable", e);
            }


            setDataSaverModeEnabled(mDataSaverMode);
            setDataSaverModeEnabled(mDataSaverMode);


@@ -1805,26 +1800,26 @@ public class NetworkManagementService extends INetworkManagementService.Stub
    }
    }


    private void applyUidCleartextNetworkPolicy(int uid, int policy) {
    private void applyUidCleartextNetworkPolicy(int uid, int policy) {
        final String policyString;
        final int policyValue;
        switch (policy) {
        switch (policy) {
            case StrictMode.NETWORK_POLICY_ACCEPT:
            case StrictMode.NETWORK_POLICY_ACCEPT:
                policyString = "accept";
                policyValue = INetd.PENALTY_POLICY_ACCEPT;
                break;
                break;
            case StrictMode.NETWORK_POLICY_LOG:
            case StrictMode.NETWORK_POLICY_LOG:
                policyString = "log";
                policyValue = INetd.PENALTY_POLICY_LOG;
                break;
                break;
            case StrictMode.NETWORK_POLICY_REJECT:
            case StrictMode.NETWORK_POLICY_REJECT:
                policyString = "reject";
                policyValue = INetd.PENALTY_POLICY_REJECT;
                break;
                break;
            default:
            default:
                throw new IllegalArgumentException("Unknown policy " + policy);
                throw new IllegalArgumentException("Unknown policy " + policy);
        }
        }


        try {
        try {
            mConnector.execute("strict", "set_uid_cleartext_policy", uid, policyString);
            mNetdService.strictUidCleartextPenalty(uid, policyValue);
            mUidCleartextPolicy.put(uid, policy);
            mUidCleartextPolicy.put(uid, policy);
        } catch (NativeDaemonConnectorException e) {
        } catch (RemoteException | ServiceSpecificException e) {
            throw e.rethrowAsParcelableException();
            throw new IllegalStateException(e);
        }
        }
    }
    }


@@ -1842,6 +1837,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
                return;
                return;
            }
            }


            // TODO: remove this code after removing prepareNativeDaemon()
            if (!mStrictEnabled) {
            if (!mStrictEnabled) {
                // Module isn't enabled yet; stash the requested policy away to
                // Module isn't enabled yet; stash the requested policy away to
                // apply later once the daemon is connected.
                // apply later once the daemon is connected.