DO NOT MERGE ANYWHERE: Listen TRANSPORT_BLUETOOTH network change in GnssLocationProvider
TRANSPORT_BLUETOOTH is a essential network type for wearable device.
For non-master branch, only listen to Bluetooth on wearable device.
Bug: 64881794
Test: Trigger Bluetooth on/off on watch, check if UpdateNetworkState()
got called.
Change-Id: I30e39943220597987320ea7843d7d36827fdd0c7
(cherry picked from commit d6886710b5)
This commit is contained in:
@@ -30,6 +30,7 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
import android.hardware.location.GeofenceHardware;
|
||||
import android.hardware.location.GeofenceHardwareImpl;
|
||||
@@ -2250,6 +2251,12 @@ public class GnssLocationProvider implements LocationProviderInterface {
|
||||
NetworkRequest.Builder networkRequestBuilder = new NetworkRequest.Builder();
|
||||
networkRequestBuilder.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
|
||||
networkRequestBuilder.addTransportType(NetworkCapabilities.TRANSPORT_WIFI);
|
||||
// On watches, Bluetooth is the most important network type.
|
||||
boolean isWatch =
|
||||
mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
|
||||
if (isWatch) {
|
||||
networkRequestBuilder.addTransportType(NetworkCapabilities.TRANSPORT_BLUETOOTH);
|
||||
}
|
||||
NetworkRequest networkRequest = networkRequestBuilder.build();
|
||||
mConnMgr.registerNetworkCallback(networkRequest, mNetworkConnectivityCallback);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user