Loading core/java/android/provider/Settings.java +6 −0 Original line number Diff line number Diff line Loading @@ -7439,6 +7439,12 @@ public final class Settings { public static final String BLUETOOTH_LE_BROADCAST_PROGRAM_INFO = "bluetooth_le_broadcast_program_info"; /** * This is used by LocalBluetoothLeBroadcast to store the broadcast name. * @hide */ public static final String BLUETOOTH_LE_BROADCAST_NAME = "bluetooth_le_broadcast_name"; /** * This is used by LocalBluetoothLeBroadcast to store the broadcast code. * @hide Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java +73 −3 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { private static final int UNKNOWN_VALUE_PLACEHOLDER = -1; private static final Uri[] SETTINGS_URIS = new Uri[] { Settings.Secure.getUriFor(Settings.Secure.BLUETOOTH_LE_BROADCAST_NAME), Settings.Secure.getUriFor(Settings.Secure.BLUETOOTH_LE_BROADCAST_PROGRAM_INFO), Settings.Secure.getUriFor(Settings.Secure.BLUETOOTH_LE_BROADCAST_CODE), Settings.Secure.getUriFor(Settings.Secure.BLUETOOTH_LE_BROADCAST_APP_SOURCE_NAME), Loading @@ -123,6 +124,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { private boolean mIsBroadcastAssistantProfileReady = false; private boolean mImproveCompatibility = false; private String mProgramInfo; private String mBroadcastName; private byte[] mBroadcastCode; private Executor mExecutor; private ContentResolver mContentResolver; Loading Loading @@ -456,6 +458,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { Log.d(TAG, "Skip starting the broadcast due to number limit."); return; } String broadcastName = getBroadcastName(); String programInfo = getProgramInfo(); boolean improveCompatibility = getImproveCompatibility(); if (DEBUG) { Loading @@ -463,6 +466,8 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { TAG, "startBroadcast: language = null , programInfo = " + programInfo + ", broadcastName = " + broadcastName + ", improveCompatibility = " + improveCompatibility); } Loading @@ -473,7 +478,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { BluetoothLeBroadcastSettings settings = buildBroadcastSettings( true, // TODO: set to false after framework fix TextUtils.isEmpty(programInfo) ? null : programInfo, TextUtils.isEmpty(broadcastName) ? null : broadcastName, (mBroadcastCode != null && mBroadcastCode.length > 0) ? mBroadcastCode : null, Loading Loading @@ -556,6 +561,36 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { } } public String getBroadcastName() { return mBroadcastName; } /** Set broadcast name. */ public void setBroadcastName(String broadcastName) { setBroadcastName(broadcastName, /* updateContentResolver= */ true); } private void setBroadcastName(String broadcastName, boolean updateContentResolver) { if (TextUtils.isEmpty(broadcastName)) { Log.d(TAG, "setBroadcastName: broadcastName is null or empty"); return; } if (mBroadcastName != null && TextUtils.equals(mBroadcastName, broadcastName)) { Log.d(TAG, "setBroadcastName: broadcastName is not changed"); return; } Log.d(TAG, "setBroadcastName: " + broadcastName); mBroadcastName = broadcastName; if (updateContentResolver) { if (mContentResolver == null) { Log.d(TAG, "mContentResolver is null"); return; } Settings.Secure.putString( mContentResolver, Settings.Secure.BLUETOOTH_LE_BROADCAST_NAME, broadcastName); } } public byte[] getBroadcastCode() { return mBroadcastCode; } Loading Loading @@ -690,6 +725,14 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { } setProgramInfo(programInfo, /* updateContentResolver= */ false); String broadcastName = Settings.Secure.getString( mContentResolver, Settings.Secure.BLUETOOTH_LE_BROADCAST_NAME); if (broadcastName == null) { broadcastName = getDefaultValueOfBroadcastName(); } setBroadcastName(broadcastName, /* updateContentResolver= */ false); String prefBroadcastCode = Settings.Secure.getString( mContentResolver, Settings.Secure.BLUETOOTH_LE_BROADCAST_CODE); Loading Loading @@ -719,6 +762,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { Log.d(TAG, "The bluetoothLeBroadcastMetadata is null"); return; } setBroadcastName(bluetoothLeBroadcastMetadata.getBroadcastName()); setBroadcastCode(bluetoothLeBroadcastMetadata.getBroadcastCode()); setLatestBroadcastId(bluetoothLeBroadcastMetadata.getBroadcastId()); Loading Loading @@ -777,7 +821,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { /** * Update the LE Broadcast by calling {@link BluetoothLeBroadcast#updateBroadcast(int, * BluetoothLeAudioContentMetadata)}, currently only updates programInfo. * BluetoothLeBroadcastSettings)}, currently only updates broadcast name and program info. */ public void updateBroadcast() { if (mServiceBroadcast == null) { Loading @@ -785,8 +829,28 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { return; } String programInfo = getProgramInfo(); String broadcastName = getBroadcastName(); mBluetoothLeAudioContentMetadata = mBuilder.setProgramInfo(programInfo).build(); mServiceBroadcast.updateBroadcast(mBroadcastId, mBluetoothLeAudioContentMetadata); // LeAudioService#updateBroadcast doesn't update broadcastCode, isPublicBroadcast and // preferredQuality, so we leave them unset here. // TODO: maybe setPublicBroadcastMetadata BluetoothLeBroadcastSettings settings = new BluetoothLeBroadcastSettings.Builder() .setBroadcastName(broadcastName) .addSubgroupSettings( new BluetoothLeBroadcastSubgroupSettings.Builder() .setContentMetadata(mBluetoothLeAudioContentMetadata) .build()) .build(); if (DEBUG) { Log.d( TAG, "updateBroadcast: broadcastName = " + broadcastName + " programInfo = " + programInfo); } mServiceBroadcast.updateBroadcast(mBroadcastId, settings); } /** Loading Loading @@ -985,6 +1049,12 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { } } private String getDefaultValueOfBroadcastName() { // set the default value; int postfix = ThreadLocalRandom.current().nextInt(DEFAULT_CODE_MIN, DEFAULT_CODE_MAX); return BluetoothAdapter.getDefaultAdapter().getName() + UNDERLINE + postfix; } private String getDefaultValueOfProgramInfo() { // set the default value; int postfix = ThreadLocalRandom.current().nextInt(DEFAULT_CODE_MIN, DEFAULT_CODE_MAX); Loading packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java +1 −0 Original line number Diff line number Diff line Loading @@ -243,6 +243,7 @@ public class SecureSettings { Settings.Secure.ASSIST_TOUCH_GESTURE_ENABLED, Settings.Secure.ASSIST_LONG_PRESS_HOME_ENABLED, Settings.Secure.BLUETOOTH_LE_BROADCAST_PROGRAM_INFO, Settings.Secure.BLUETOOTH_LE_BROADCAST_NAME, Settings.Secure.BLUETOOTH_LE_BROADCAST_CODE, Settings.Secure.BLUETOOTH_LE_BROADCAST_APP_SOURCE_NAME, Settings.Secure.BLUETOOTH_LE_BROADCAST_IMPROVE_COMPATIBILITY, Loading packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java +1 −0 Original line number Diff line number Diff line Loading @@ -393,6 +393,7 @@ public class SecureSettingsValidators { VALIDATORS.put(Secure.WEAR_TALKBACK_ENABLED, BOOLEAN_VALIDATOR); VALIDATORS.put(Secure.HBM_SETTING_KEY, BOOLEAN_VALIDATOR); VALIDATORS.put(Secure.BLUETOOTH_LE_BROADCAST_PROGRAM_INFO, ANY_STRING_VALIDATOR); VALIDATORS.put(Secure.BLUETOOTH_LE_BROADCAST_NAME, ANY_STRING_VALIDATOR); VALIDATORS.put(Secure.BLUETOOTH_LE_BROADCAST_CODE, ANY_STRING_VALIDATOR); VALIDATORS.put(Secure.BLUETOOTH_LE_BROADCAST_APP_SOURCE_NAME, ANY_STRING_VALIDATOR); VALIDATORS.put( Loading Loading
core/java/android/provider/Settings.java +6 −0 Original line number Diff line number Diff line Loading @@ -7439,6 +7439,12 @@ public final class Settings { public static final String BLUETOOTH_LE_BROADCAST_PROGRAM_INFO = "bluetooth_le_broadcast_program_info"; /** * This is used by LocalBluetoothLeBroadcast to store the broadcast name. * @hide */ public static final String BLUETOOTH_LE_BROADCAST_NAME = "bluetooth_le_broadcast_name"; /** * This is used by LocalBluetoothLeBroadcast to store the broadcast code. * @hide Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java +73 −3 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { private static final int UNKNOWN_VALUE_PLACEHOLDER = -1; private static final Uri[] SETTINGS_URIS = new Uri[] { Settings.Secure.getUriFor(Settings.Secure.BLUETOOTH_LE_BROADCAST_NAME), Settings.Secure.getUriFor(Settings.Secure.BLUETOOTH_LE_BROADCAST_PROGRAM_INFO), Settings.Secure.getUriFor(Settings.Secure.BLUETOOTH_LE_BROADCAST_CODE), Settings.Secure.getUriFor(Settings.Secure.BLUETOOTH_LE_BROADCAST_APP_SOURCE_NAME), Loading @@ -123,6 +124,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { private boolean mIsBroadcastAssistantProfileReady = false; private boolean mImproveCompatibility = false; private String mProgramInfo; private String mBroadcastName; private byte[] mBroadcastCode; private Executor mExecutor; private ContentResolver mContentResolver; Loading Loading @@ -456,6 +458,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { Log.d(TAG, "Skip starting the broadcast due to number limit."); return; } String broadcastName = getBroadcastName(); String programInfo = getProgramInfo(); boolean improveCompatibility = getImproveCompatibility(); if (DEBUG) { Loading @@ -463,6 +466,8 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { TAG, "startBroadcast: language = null , programInfo = " + programInfo + ", broadcastName = " + broadcastName + ", improveCompatibility = " + improveCompatibility); } Loading @@ -473,7 +478,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { BluetoothLeBroadcastSettings settings = buildBroadcastSettings( true, // TODO: set to false after framework fix TextUtils.isEmpty(programInfo) ? null : programInfo, TextUtils.isEmpty(broadcastName) ? null : broadcastName, (mBroadcastCode != null && mBroadcastCode.length > 0) ? mBroadcastCode : null, Loading Loading @@ -556,6 +561,36 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { } } public String getBroadcastName() { return mBroadcastName; } /** Set broadcast name. */ public void setBroadcastName(String broadcastName) { setBroadcastName(broadcastName, /* updateContentResolver= */ true); } private void setBroadcastName(String broadcastName, boolean updateContentResolver) { if (TextUtils.isEmpty(broadcastName)) { Log.d(TAG, "setBroadcastName: broadcastName is null or empty"); return; } if (mBroadcastName != null && TextUtils.equals(mBroadcastName, broadcastName)) { Log.d(TAG, "setBroadcastName: broadcastName is not changed"); return; } Log.d(TAG, "setBroadcastName: " + broadcastName); mBroadcastName = broadcastName; if (updateContentResolver) { if (mContentResolver == null) { Log.d(TAG, "mContentResolver is null"); return; } Settings.Secure.putString( mContentResolver, Settings.Secure.BLUETOOTH_LE_BROADCAST_NAME, broadcastName); } } public byte[] getBroadcastCode() { return mBroadcastCode; } Loading Loading @@ -690,6 +725,14 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { } setProgramInfo(programInfo, /* updateContentResolver= */ false); String broadcastName = Settings.Secure.getString( mContentResolver, Settings.Secure.BLUETOOTH_LE_BROADCAST_NAME); if (broadcastName == null) { broadcastName = getDefaultValueOfBroadcastName(); } setBroadcastName(broadcastName, /* updateContentResolver= */ false); String prefBroadcastCode = Settings.Secure.getString( mContentResolver, Settings.Secure.BLUETOOTH_LE_BROADCAST_CODE); Loading Loading @@ -719,6 +762,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { Log.d(TAG, "The bluetoothLeBroadcastMetadata is null"); return; } setBroadcastName(bluetoothLeBroadcastMetadata.getBroadcastName()); setBroadcastCode(bluetoothLeBroadcastMetadata.getBroadcastCode()); setLatestBroadcastId(bluetoothLeBroadcastMetadata.getBroadcastId()); Loading Loading @@ -777,7 +821,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { /** * Update the LE Broadcast by calling {@link BluetoothLeBroadcast#updateBroadcast(int, * BluetoothLeAudioContentMetadata)}, currently only updates programInfo. * BluetoothLeBroadcastSettings)}, currently only updates broadcast name and program info. */ public void updateBroadcast() { if (mServiceBroadcast == null) { Loading @@ -785,8 +829,28 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { return; } String programInfo = getProgramInfo(); String broadcastName = getBroadcastName(); mBluetoothLeAudioContentMetadata = mBuilder.setProgramInfo(programInfo).build(); mServiceBroadcast.updateBroadcast(mBroadcastId, mBluetoothLeAudioContentMetadata); // LeAudioService#updateBroadcast doesn't update broadcastCode, isPublicBroadcast and // preferredQuality, so we leave them unset here. // TODO: maybe setPublicBroadcastMetadata BluetoothLeBroadcastSettings settings = new BluetoothLeBroadcastSettings.Builder() .setBroadcastName(broadcastName) .addSubgroupSettings( new BluetoothLeBroadcastSubgroupSettings.Builder() .setContentMetadata(mBluetoothLeAudioContentMetadata) .build()) .build(); if (DEBUG) { Log.d( TAG, "updateBroadcast: broadcastName = " + broadcastName + " programInfo = " + programInfo); } mServiceBroadcast.updateBroadcast(mBroadcastId, settings); } /** Loading Loading @@ -985,6 +1049,12 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { } } private String getDefaultValueOfBroadcastName() { // set the default value; int postfix = ThreadLocalRandom.current().nextInt(DEFAULT_CODE_MIN, DEFAULT_CODE_MAX); return BluetoothAdapter.getDefaultAdapter().getName() + UNDERLINE + postfix; } private String getDefaultValueOfProgramInfo() { // set the default value; int postfix = ThreadLocalRandom.current().nextInt(DEFAULT_CODE_MIN, DEFAULT_CODE_MAX); Loading
packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java +1 −0 Original line number Diff line number Diff line Loading @@ -243,6 +243,7 @@ public class SecureSettings { Settings.Secure.ASSIST_TOUCH_GESTURE_ENABLED, Settings.Secure.ASSIST_LONG_PRESS_HOME_ENABLED, Settings.Secure.BLUETOOTH_LE_BROADCAST_PROGRAM_INFO, Settings.Secure.BLUETOOTH_LE_BROADCAST_NAME, Settings.Secure.BLUETOOTH_LE_BROADCAST_CODE, Settings.Secure.BLUETOOTH_LE_BROADCAST_APP_SOURCE_NAME, Settings.Secure.BLUETOOTH_LE_BROADCAST_IMPROVE_COMPATIBILITY, Loading
packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java +1 −0 Original line number Diff line number Diff line Loading @@ -393,6 +393,7 @@ public class SecureSettingsValidators { VALIDATORS.put(Secure.WEAR_TALKBACK_ENABLED, BOOLEAN_VALIDATOR); VALIDATORS.put(Secure.HBM_SETTING_KEY, BOOLEAN_VALIDATOR); VALIDATORS.put(Secure.BLUETOOTH_LE_BROADCAST_PROGRAM_INFO, ANY_STRING_VALIDATOR); VALIDATORS.put(Secure.BLUETOOTH_LE_BROADCAST_NAME, ANY_STRING_VALIDATOR); VALIDATORS.put(Secure.BLUETOOTH_LE_BROADCAST_CODE, ANY_STRING_VALIDATOR); VALIDATORS.put(Secure.BLUETOOTH_LE_BROADCAST_APP_SOURCE_NAME, ANY_STRING_VALIDATOR); VALIDATORS.put( Loading