0

Android has various Settings classes, including Settings.Secure, Settings.System, Settings.Global. Within these classes, there are constants. For example, in Android 4.3 and above, Settings.Secure has "bluetooth_address" which contains the BT MAC address. It doesn't exist in older Android versions

Is there a way to find out what constants exist in these settings? I've tried looking at the AOSP source, and "bluetooth_address" exists in BluetoothManagerService.java, which only exists in 4.3 and above under the constant SECURE_SETTINGS_BLUETOOTH_ADDRESS. I guessed that there might be other secure settings using the SECURE_SETTINGS_ prefix, but a quick grep on the AOSP source didn't come up with anything.

user1118764
  • 9,255
  • 18
  • 61
  • 113
  • Did you try the docs? [`Settings.Secure`](https://developer.android.com/reference/android/provider/Settings.Secure.html), [`Settings.System`](https://developer.android.com/reference/android/provider/Settings.System.html), [`Settings.Global`](https://developer.android.com/reference/android/provider/Settings.Global.html) – Mike M. Feb 23 '17 at 01:49
  • Yes I have, but these don't list everything that's in the source, e.g. "bluetooth_address" doesn't exist there. – user1118764 Feb 23 '17 at 01:52
  • Oh, I see what you're saying. My bad. – Mike M. Feb 23 '17 at 01:56
  • Conversely, when I try to grep the AOSP source for constants that are in the docs (e.g. ADB_ENABLED), I get nothing as well. – user1118764 Feb 23 '17 at 01:58

1 Answers1

-1

Here is the list of constants

https://github.com/android/platform_frameworks_base/blob/master/core/java/android/provider/Settings.java#L1791-L1878

Edit: If you want the bluetooth macaddress, you can try this. https://developer.android.com/reference/android/bluetooth/BluetoothDevice.html#getAddress()

Sanyam Jain
  • 1,154
  • 6
  • 9
  • Thanks, is this for Settings.Global, Settings.Secure or Settings.System? I don't see "bluetooth_address" in the file. – user1118764 Feb 25 '17 at 09:49
  • Yea, its for Settings.Global, Settings.Secure or Settings.System. Although "bluetooth_address" is present only in BluetoothManagerService.java. – Sanyam Jain Feb 25 '17 at 10:04
  • Thanks. In this case, the list of constants you provided isn't comprehensive. Are there other constants that are not listed in Settings.java? Anyway, I'm asking because like you said, "bluetooth_address" is present only in BluetoothManagerService.java, which is present only from 4.3 onward. I'm trying to find if there's an equivalent constant in older versions of Android. – user1118764 Feb 25 '17 at 13:08
  • What are you trying to achieve? Maybe I can help. :D – Sanyam Jain Feb 25 '17 at 13:19
  • Thanks. Like I said, I would like to see if there's a way of obtaining the Bluetooth MAC address from older than 4.3 versions of Android from the Settings, or any other way that doesn't require any extra permissions. – user1118764 Feb 27 '17 at 00:53
  • You want MAC address of your device or the device to which you are connected to? – Sanyam Jain Feb 27 '17 at 07:05
  • The mobile device on which my mobile app is running on. – user1118764 Feb 28 '17 at 01:42
  • Check the post again. – Sanyam Jain Feb 28 '17 at 11:01
  • Thanks. BluetoothDevice represents a remote device. I'm trying to get the MAC address of the mobile device, not like a BT headset or something. BluetoothAdapter.getDefaultAdapter().getAddress() works for the mobile device, but requires the BLUETOOTH permission, and also no longer works (Android will now return a fake MAC address). – user1118764 Feb 28 '17 at 12:45