}
/**
- * called from native code to update AGPS status
+ * Called from native code to update AGPS connection status, or to request or release a SUPL
+ * connection.
+ *
+ * <p>Note: {@code suplIpAddr} parameter is not present from IAGnssCallback.hal@2.0 onwards
+ * and is set to {@code null}.
*/
void onReportAGpsStatus(int agpsType, int agpsStatus, byte[] suplIpAddr) {
+ if (DEBUG) Log.d(TAG, "AGPS_DATA_CONNECTION: " + agpsDataConnStatusAsString(agpsStatus));
switch (agpsStatus) {
case GPS_REQUEST_AGPS_DATA_CONN:
- if (DEBUG) Log.d(TAG, "GPS_REQUEST_AGPS_DATA_CONN");
runOnHandler(() -> handleRequestSuplConnection(agpsType, suplIpAddr));
break;
case GPS_RELEASE_AGPS_DATA_CONN:
- if (DEBUG) Log.d(TAG, "GPS_RELEASE_AGPS_DATA_CONN");
runOnHandler(() -> handleReleaseSuplConnection(GPS_RELEASE_AGPS_DATA_CONN));
break;
case GPS_AGPS_DATA_CONNECTED:
- if (DEBUG) Log.d(TAG, "GPS_AGPS_DATA_CONNECTED");
- break;
case GPS_AGPS_DATA_CONN_DONE:
- if (DEBUG) Log.d(TAG, "GPS_AGPS_DATA_CONN_DONE");
- break;
case GPS_AGPS_DATA_CONN_FAILED:
- if (DEBUG) Log.d(TAG, "GPS_AGPS_DATA_CONN_FAILED");
break;
default:
- if (DEBUG) Log.d(TAG, "Received Unknown AGPS status: " + agpsStatus);
+ Log.w(TAG, "Received unknown AGPS status: " + agpsStatus);
}
}
}
mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPENING;
- NetworkRequest.Builder requestBuilder = new NetworkRequest.Builder();
- requestBuilder.addCapability(getNetworkCapability(mAGpsType));
- NetworkRequest request = requestBuilder.build();
+ // 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);
mConnMgr.requestNetwork(
- request,
+ networkRequest,
mSuplConnectivityCallback,
mHandler,
SUPL_NETWORK_REQUEST_TIMEOUT_MILLIS);
}
}
+ 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(
case AGPS_DATA_CONNECTION_OPENING:
return "OPENING";
default:
- return "<Unknown>";
+ return "<Unknown>(" + mAGpsDataConnectionState + ")";
}
}
case GPS_REQUEST_AGPS_DATA_CONN:
return "REQUEST";
default:
- return "<Unknown>";
+ return "<Unknown>(" + agpsDataConnStatus + ")";
}
}
case AGPS_TYPE_IMS:
return "IMS";
default:
- return "<Unknown>";
+ return "<Unknown>(" + agpsType + ")";
}
}
private native void native_update_network_state(boolean connected, int type, boolean roaming,
boolean available, String apn, long networkHandle, short capabilities);
-}
\ No newline at end of file
+}