Bluetooth: ensure adapter name and address can't be read from 3p apps
Privacy checks in Settings.getStringForUser are using reflection to find secured values, so move constant definition to proper place. Test: verified against PoC Bug: 172838801 Change-Id: I2d94101b677e71011273c2674edc197840fb1411
This commit is contained in:
@@ -6316,6 +6316,27 @@ public final class Settings {
|
||||
@Readable
|
||||
public static final String ALLOW_MOCK_LOCATION = "mock_location";
|
||||
|
||||
/**
|
||||
* This is used by Bluetooth Manager to store adapter name
|
||||
* @hide
|
||||
*/
|
||||
@Readable(maxTargetSdk = Build.VERSION_CODES.S)
|
||||
public static final String BLUETOOTH_NAME = "bluetooth_name";
|
||||
|
||||
/**
|
||||
* This is used by Bluetooth Manager to store adapter address
|
||||
* @hide
|
||||
*/
|
||||
@Readable(maxTargetSdk = Build.VERSION_CODES.S)
|
||||
public static final String BLUETOOTH_ADDRESS = "bluetooth_address";
|
||||
|
||||
/**
|
||||
* This is used by Bluetooth Manager to store whether adapter address is valid
|
||||
* @hide
|
||||
*/
|
||||
@Readable(maxTargetSdk = Build.VERSION_CODES.S)
|
||||
public static final String BLUETOOTH_ADDR_VALID = "bluetooth_addr_valid";
|
||||
|
||||
/**
|
||||
* Setting to indicate that on device captions are enabled.
|
||||
*
|
||||
|
||||
@@ -110,10 +110,6 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
||||
private static final String BLUETOOTH_PRIVILEGED =
|
||||
android.Manifest.permission.BLUETOOTH_PRIVILEGED;
|
||||
|
||||
private static final String SECURE_SETTINGS_BLUETOOTH_ADDR_VALID = "bluetooth_addr_valid";
|
||||
private static final String SECURE_SETTINGS_BLUETOOTH_ADDRESS = "bluetooth_address";
|
||||
private static final String SECURE_SETTINGS_BLUETOOTH_NAME = "bluetooth_name";
|
||||
|
||||
private static final int ACTIVE_LOG_MAX_SIZE = 20;
|
||||
private static final int CRASH_LOG_MAX_SIZE = 100;
|
||||
|
||||
@@ -636,7 +632,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
||||
if (mContext.getResources()
|
||||
.getBoolean(com.android.internal.R.bool.config_bluetooth_address_validation)
|
||||
&& Settings.Secure.getIntForUser(mContentResolver,
|
||||
SECURE_SETTINGS_BLUETOOTH_ADDR_VALID, 0, mUserId)
|
||||
Settings.Secure.BLUETOOTH_NAME, 0, mUserId)
|
||||
== 0) {
|
||||
// if the valid flag is not set, don't load the address and name
|
||||
if (DBG) {
|
||||
@@ -645,9 +641,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
||||
return;
|
||||
}
|
||||
mName = Settings.Secure.getStringForUser(
|
||||
mContentResolver, SECURE_SETTINGS_BLUETOOTH_NAME, mUserId);
|
||||
mContentResolver, Settings.Secure.BLUETOOTH_NAME, mUserId);
|
||||
mAddress = Settings.Secure.getStringForUser(
|
||||
mContentResolver, SECURE_SETTINGS_BLUETOOTH_ADDRESS, mUserId);
|
||||
mContentResolver, Settings.Secure.BLUETOOTH_ADDRESS, mUserId);
|
||||
if (DBG) {
|
||||
Slog.d(TAG, "Stored bluetooth Name=" + mName + ",Address=" + mAddress);
|
||||
}
|
||||
@@ -661,30 +657,30 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
||||
*/
|
||||
private void storeNameAndAddress(String name, String address) {
|
||||
if (name != null) {
|
||||
Settings.Secure.putStringForUser(mContentResolver, SECURE_SETTINGS_BLUETOOTH_NAME, name,
|
||||
Settings.Secure.putStringForUser(mContentResolver, Settings.Secure.BLUETOOTH_NAME, name,
|
||||
mUserId);
|
||||
mName = name;
|
||||
if (DBG) {
|
||||
Slog.d(TAG, "Stored Bluetooth name: " + Settings.Secure.getStringForUser(
|
||||
mContentResolver, SECURE_SETTINGS_BLUETOOTH_NAME,
|
||||
mContentResolver, Settings.Secure.BLUETOOTH_NAME,
|
||||
mUserId));
|
||||
}
|
||||
}
|
||||
|
||||
if (address != null) {
|
||||
Settings.Secure.putStringForUser(mContentResolver, SECURE_SETTINGS_BLUETOOTH_ADDRESS,
|
||||
Settings.Secure.putStringForUser(mContentResolver, Settings.Secure.BLUETOOTH_ADDRESS,
|
||||
address, mUserId);
|
||||
mAddress = address;
|
||||
if (DBG) {
|
||||
Slog.d(TAG,
|
||||
"Stored Bluetoothaddress: " + Settings.Secure.getStringForUser(
|
||||
mContentResolver, SECURE_SETTINGS_BLUETOOTH_ADDRESS,
|
||||
mContentResolver, Settings.Secure.BLUETOOTH_ADDRESS,
|
||||
mUserId));
|
||||
}
|
||||
}
|
||||
|
||||
if ((name != null) && (address != null)) {
|
||||
Settings.Secure.putIntForUser(mContentResolver, SECURE_SETTINGS_BLUETOOTH_ADDR_VALID, 1,
|
||||
Settings.Secure.putIntForUser(mContentResolver, Settings.Secure.BLUETOOTH_ADDR_VALID, 1,
|
||||
mUserId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user