Loading src/com/android/bluetooth/gatt/GattService.java +20 −0 Original line number Diff line number Diff line Loading @@ -1274,6 +1274,9 @@ public class GattService extends ProfileService { List<ScanFilter> filters, List<List<ResultStorageDescriptor>> storages) { if (DBG) Log.d(TAG, "start scan with filters"); enforceAdminPermission(); if (needsPrivilegedPermissionForScan(settings)) { enforcePrivilegedPermission(); } mScanManager.startScan(new ScanClient(appIf, isServer, settings, filters, storages)); } Loading Loading @@ -1953,6 +1956,23 @@ public class GattService extends ProfileService { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); } private boolean needsPrivilegedPermissionForScan(ScanSettings settings) { // Regular scan, no special permission. if (settings == null) { return false; } // Hidden API for onLost/onFound if (settings.getScanMode() != ScanSettings.CALLBACK_TYPE_ALL_MATCHES) { return true; } // Regular scan, no special permission. if (settings.getReportDelayMillis() == 0) { return false; } // Batch scan, truncated mode needs permission. return settings.getScanResultType() == ScanSettings.SCAN_RESULT_TYPE_ABBREVIATED; } // Enforce caller has BLUETOOTH_PRIVILEGED permission. A {@link SecurityException} will be // thrown if the caller app does not have BLUETOOTH_PRIVILEGED permission. private void enforcePrivilegedPermission() { Loading Loading
src/com/android/bluetooth/gatt/GattService.java +20 −0 Original line number Diff line number Diff line Loading @@ -1274,6 +1274,9 @@ public class GattService extends ProfileService { List<ScanFilter> filters, List<List<ResultStorageDescriptor>> storages) { if (DBG) Log.d(TAG, "start scan with filters"); enforceAdminPermission(); if (needsPrivilegedPermissionForScan(settings)) { enforcePrivilegedPermission(); } mScanManager.startScan(new ScanClient(appIf, isServer, settings, filters, storages)); } Loading Loading @@ -1953,6 +1956,23 @@ public class GattService extends ProfileService { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); } private boolean needsPrivilegedPermissionForScan(ScanSettings settings) { // Regular scan, no special permission. if (settings == null) { return false; } // Hidden API for onLost/onFound if (settings.getScanMode() != ScanSettings.CALLBACK_TYPE_ALL_MATCHES) { return true; } // Regular scan, no special permission. if (settings.getReportDelayMillis() == 0) { return false; } // Batch scan, truncated mode needs permission. return settings.getScanResultType() == ScanSettings.SCAN_RESULT_TYPE_ABBREVIATED; } // Enforce caller has BLUETOOTH_PRIVILEGED permission. A {@link SecurityException} will be // thrown if the caller app does not have BLUETOOTH_PRIVILEGED permission. private void enforcePrivilegedPermission() { Loading