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

Commit 935fef65 authored by lucaslin's avatar lucaslin Committed by Lucas Lin
Browse files

Call clearCallingIdentity when calling registerNetworkProvider in TNS

The caller to create a TestNetworkService via
ConnectivityManager#startOrGetTestNetworkManager should have
passed the MANAGE_TEST_NETWORKS permission check and the caller
doesn't need to declare the permission to pass the permission
check of registerNetworkProvider. So call clearCallingIdentity
when calling registerNetworkProvider in TestNetworkService.

Bug: 181573283
Test: atest CtsNetTestCases:ConnectivityManagerTest#testRequestBackgroundNetwork
Change-Id: Ia28627dacf933d1937978ed9709b975c9a4660ce
parent fe4b43da
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -90,7 +90,12 @@ class TestNetworkService extends ITestNetworkManager.Stub {
        mCm = mContext.getSystemService(ConnectivityManager.class);
        mNetworkProvider = new NetworkProvider(mContext, mHandler.getLooper(),
                TEST_NETWORK_PROVIDER_NAME);
        final long token = Binder.clearCallingIdentity();
        try {
            mCm.registerNetworkProvider(mNetworkProvider);
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }

    /**