Remove usage of Context.NETWORK_STACK_SERVICE

The NetworkStack.getService() API should be used instead.

Bug: 151243982
Test: atest FrameworksNetTests TetheringTests
      Manual tethering test
Change-Id: I7855090bffbe895c8349ad4903b8f2eb55515f0b
This commit is contained in:
Remi NGUYEN VAN
2020-03-18 18:31:39 +09:00
parent ab74d2b865
commit b8fecf4b32

View File

@@ -33,6 +33,7 @@ import android.net.ITetheringConnector;
import android.net.ITetheringEventCallback;
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
import android.net.NetworkStack;
import android.net.TetheringRequestParcel;
import android.net.dhcp.DhcpServerCallbacks;
import android.net.dhcp.DhcpServingParamsParcel;
@@ -364,8 +365,7 @@ public class TetheringService extends Service {
IBinder connector;
try {
final long before = System.currentTimeMillis();
while ((connector = (IBinder) mContext.getSystemService(
Context.NETWORK_STACK_SERVICE)) == null) {
while ((connector = NetworkStack.getService()) == null) {
if (System.currentTimeMillis() - before > NETWORKSTACK_TIMEOUT_MS) {
Log.wtf(TAG, "Timeout, fail to get INetworkStackConnector");
return null;