Loading android/app/src/com/android/bluetooth/gatt/GattService.java +40 −1 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ import android.os.ServiceManager; import android.os.SystemClock; import android.os.UserHandle; import android.os.WorkSource; import android.provider.DeviceConfig; import android.provider.Settings; import android.text.format.DateUtils; import android.util.Log; Loading Loading @@ -109,6 +110,11 @@ public class GattService extends ProfileService { private static final int TRUNCATED_RESULT_SIZE = 11; private static final int TIME_STAMP_LENGTH = 2; /** * The default floor value for LE batch scan report delays greater than 0 */ private static final long DEFAULT_REPORT_DELAY_FLOOR = 5000; // onFoundLost related constants private static final int ADVT_STATE_ONFOUND = 0; private static final int ADVT_STATE_ONLOST = 1; Loading Loading @@ -2217,6 +2223,7 @@ public class GattService extends ProfileService { enforcePrivilegedPermissionIfNeeded(settings); String callingPackage = attributionSource.getPackageName(); settings = enforceReportDelayFloor(settings); final ScanClient scanClient = new ScanClient(scannerId, settings, filters, storages); scanClient.userHandle = UserHandle.of(UserHandle.getCallingUserId()); mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); Loading Loading @@ -2270,8 +2277,8 @@ public class GattService extends ProfileService { this, attributionSource, "Starting GATT scan.")) { return; } enforcePrivilegedPermissionIfNeeded(settings); settings = enforceReportDelayFloor(settings); UUID uuid = UUID.randomUUID(); if (DBG) { Loading Loading @@ -3574,6 +3581,38 @@ public class GattService extends ProfileService { } } /** * Ensures the report delay is either 0 or at least the floor value (5000ms) * * @param settings are the scan settings passed into a request to start le scanning * @return the passed in ScanSettings object if the report delay is 0 or above the floor value; * a new ScanSettings object with the report delay being the floor value if the original * report delay was between 0 and the floor value (exclusive of both) */ private ScanSettings enforceReportDelayFloor(ScanSettings settings) { if (settings.getReportDelayMillis() == 0) { return settings; } long floor = DeviceConfig.getLong(DeviceConfig.NAMESPACE_BLUETOOTH, "report_delay", DEFAULT_REPORT_DELAY_FLOOR); if (settings.getReportDelayMillis() > floor) { return settings; } else { return new ScanSettings.Builder() .setCallbackType(settings.getCallbackType()) .setLegacy(settings.getLegacy()) .setMatchMode(settings.getMatchMode()) .setNumOfMatches(settings.getNumOfMatches()) .setPhy(settings.getPhy()) .setReportDelay(floor) .setScanMode(settings.getScanMode()) .setScanResultType(settings.getScanResultType()) .build(); } } private void stopNextService(int serverIf, int status) throws RemoteException { if (DBG) { Log.d(TAG, "stopNextService() - serverIf=" + serverIf + ", status=" + status); Loading Loading
android/app/src/com/android/bluetooth/gatt/GattService.java +40 −1 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ import android.os.ServiceManager; import android.os.SystemClock; import android.os.UserHandle; import android.os.WorkSource; import android.provider.DeviceConfig; import android.provider.Settings; import android.text.format.DateUtils; import android.util.Log; Loading Loading @@ -109,6 +110,11 @@ public class GattService extends ProfileService { private static final int TRUNCATED_RESULT_SIZE = 11; private static final int TIME_STAMP_LENGTH = 2; /** * The default floor value for LE batch scan report delays greater than 0 */ private static final long DEFAULT_REPORT_DELAY_FLOOR = 5000; // onFoundLost related constants private static final int ADVT_STATE_ONFOUND = 0; private static final int ADVT_STATE_ONLOST = 1; Loading Loading @@ -2217,6 +2223,7 @@ public class GattService extends ProfileService { enforcePrivilegedPermissionIfNeeded(settings); String callingPackage = attributionSource.getPackageName(); settings = enforceReportDelayFloor(settings); final ScanClient scanClient = new ScanClient(scannerId, settings, filters, storages); scanClient.userHandle = UserHandle.of(UserHandle.getCallingUserId()); mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); Loading Loading @@ -2270,8 +2277,8 @@ public class GattService extends ProfileService { this, attributionSource, "Starting GATT scan.")) { return; } enforcePrivilegedPermissionIfNeeded(settings); settings = enforceReportDelayFloor(settings); UUID uuid = UUID.randomUUID(); if (DBG) { Loading Loading @@ -3574,6 +3581,38 @@ public class GattService extends ProfileService { } } /** * Ensures the report delay is either 0 or at least the floor value (5000ms) * * @param settings are the scan settings passed into a request to start le scanning * @return the passed in ScanSettings object if the report delay is 0 or above the floor value; * a new ScanSettings object with the report delay being the floor value if the original * report delay was between 0 and the floor value (exclusive of both) */ private ScanSettings enforceReportDelayFloor(ScanSettings settings) { if (settings.getReportDelayMillis() == 0) { return settings; } long floor = DeviceConfig.getLong(DeviceConfig.NAMESPACE_BLUETOOTH, "report_delay", DEFAULT_REPORT_DELAY_FLOOR); if (settings.getReportDelayMillis() > floor) { return settings; } else { return new ScanSettings.Builder() .setCallbackType(settings.getCallbackType()) .setLegacy(settings.getLegacy()) .setMatchMode(settings.getMatchMode()) .setNumOfMatches(settings.getNumOfMatches()) .setPhy(settings.getPhy()) .setReportDelay(floor) .setScanMode(settings.getScanMode()) .setScanResultType(settings.getScanResultType()) .build(); } } private void stopNextService(int serverIf, int status) throws RemoteException { if (DBG) { Log.d(TAG, "stopNextService() - serverIf=" + serverIf + ", status=" + status); Loading