问题原因:
不打开GPS可正常调用上次系统定制的APP通过BLE也可以扫描
思路:
添加白名单的方式
参考的文件:
packages/apps/Bluetooth/src/com/android/bluetooth/gatt/GattService.java
在void onScanResultInternal方法中,有针对权限的判断
1144 void onScanResultInternal(int eventType, int addressType, String address, int primaryPhy,
1145 int secondaryPhy, int advertisingSid, int txPower, int rssi, int periodicAdvInt,
1146 byte[] advData) {
...
boolean hasPermission = hasScanResultPermission(client);//判断是否打开了location权限
...
}
1298 private boolean hasScanResultPermission(final ScanClient client) {
1299 if (client.hasNetworkSettingsPermission
1300 || client.hasNetworkSetupWizardPermission
1301