안드로이드 6.0 마시멜로에서 변경된 중요 사항 중 블루투스, WiFi 권한 관련


블루투스 관련 앱이 정상적으로 검색과 연결이 잘 되던 것이 안드로이드 버전 6.0의 기기에서는 검색해 내지를 못하는 경험이 있을 것이다.

이것은 6.0에서의 정책상의 변화로 인해 발생하는 문제이다.

6.0에서 블루투스가 정상적으로 동작하기 위해서는 아래 권한이 Manifest에 선언되어 있으야만 한다.


ACCESS_FINE_LOCATION 혹은 ACCESS_COARSE_LOCATION 권한이 없으면 주변 WiFi / Bluetooth 디바이스를 발견할 수 없다.


위의 권한이 선언되어 있지 않으면 다음과 같은 메서드가 정상적으로 동작하지 않는다.


WifiManager.getScanResults()

BluetoothDevice.ACTION_FOUND

BluetoothLeScanner.startScan()

...


아래는 구글 안드로이드 API Reference 문서에서 소개하고 있는 내용이다.


Access to Hardware Identifier


To provide users with greater data protection, starting in this release, Android removes programmatic access to the device’s local hardware identifier for apps using the Wi-Fi and Bluetooth APIs. The WifiInfo.getMacAddress() and the BluetoothAdapter.getAddress() methods now return a constant value of 02:00:00:00:00:00.

To access the hardware identifiers of nearby external devices via Bluetooth and Wi-Fi scans, your app must now have the ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION permissions:

Note: When a device running Android 6.0 (API level 23) initiates a background Wi-Fi or Bluetooth scan, the operation is visible to external devices as originating from a randomized MAC address.


https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html




+ Recent posts