Merge "Bluetooth: ensure adapter name and address can't be read from 3p apps" into sc-qpr1-dev am: 16dcbdc0b8

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15924163

Change-Id: I6bc239671d7c399588707472149f4131237a0575
This commit is contained in:
Jakub Pawłowski
2021-12-30 14:39:52 +00:00
committed by Automerger Merge Worker
2 changed files with 29 additions and 12 deletions

View File

@@ -6363,6 +6363,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.
*

View File

@@ -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);
}
}