Merge changes Ic5a3e169,I76daa3ab

* changes:
  Refactor applyUnderlyingCapabilities and its test.
  Move applyUnderlyingCapabilities to ConnectivityService.