OSDN Git Service

Cleanup SUPL network request parameters for requestRouteToHostAddress
authorAnil Admal <aadmal@google.com>
Wed, 10 Apr 2019 16:26:42 +0000 (09:26 -0700)
committerAnil Admal <aadmal@google.com>
Wed, 10 Apr 2019 16:59:32 +0000 (09:59 -0700)
This is a follow up CL to address a comment for Patch Set 4 in CL
ag/6957177. Some parameters set in the SUPL network request for
ConnectivtyService to support the deprecated requestRouteToHostAddress()
method for pre-gnss@2.0 HALs are not actually needed and the code
can be simplified.

Fixes: 121222025
Test: Verified on a Pixel device with gnss@1.1 HAL.
Change-Id: If894e9db8d39f43644fd7dfbb4421f493d3d24e6

services/core/java/com/android/server/location/GnssNetworkConnectivityHandler.java

index 2948aaf..2e72fbd 100644 (file)
@@ -457,15 +457,13 @@ class GnssNetworkConnectivityHandler {
         }
         mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPENING;
 
-        // The NetworkRequest.Builder class is not used to construct the network request because
-        // the ConnectivityService requires the network request to be constructed in this way
-        // to extend support for requestRouteToHostAddress() method for pre-gnss@2.0 devices.
-        NetworkCapabilities networkCapabilities = new NetworkCapabilities();
-        networkCapabilities.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
-        networkCapabilities.addCapability(getNetworkCapability(mAGpsType));
-        NetworkRequest networkRequest = new NetworkRequest(networkCapabilities,
-                getLegacyDataConnectionType(agpsType), ConnectivityManager.REQUEST_ID_UNSET,
-                NetworkRequest.Type.REQUEST);
+        // The transport type must be set to NetworkCapabilities.TRANSPORT_CELLULAR for the
+        // deprecated requestRouteToHostAddress() method in ConnectivityService to work for
+        // pre-gnss@2.0 devices.
+        NetworkRequest.Builder networkRequestBuilder = new NetworkRequest.Builder();
+        networkRequestBuilder.addCapability(getNetworkCapability(mAGpsType));
+        networkRequestBuilder.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
+        NetworkRequest networkRequest = networkRequestBuilder.build();
         mConnMgr.requestNetwork(
                 networkRequest,
                 mSuplConnectivityCallback,
@@ -487,19 +485,6 @@ class GnssNetworkConnectivityHandler {
         }
     }
 
-    private int getLegacyDataConnectionType(int agpsType) {
-        switch (agpsType) {
-            case AGPS_TYPE_C2K:
-            case AGPS_TYPE_SUPL:
-                return ConnectivityManager.TYPE_MOBILE_SUPL;
-            case AGPS_TYPE_EIMS:
-                return ConnectivityManager.TYPE_MOBILE_EMERGENCY;
-            case AGPS_TYPE_IMS:
-                return ConnectivityManager.TYPE_MOBILE_IMS;
-            default:
-                throw new IllegalArgumentException("agpsType: " + agpsType);
-        }
-    }
     private void handleReleaseSuplConnection(int agpsDataConnStatus) {
         if (DEBUG) {
             String message = String.format(