Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java +15 −5 Original line number Diff line number Diff line Loading @@ -39,10 +39,10 @@ import androidx.annotation.RequiresApi; import com.android.settingslib.R; import java.nio.charset.StandardCharsets; import java.security.SecureRandom; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.UUID; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.ThreadLocalRandom; Loading @@ -56,6 +56,10 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { private static final String TAG = "LocalBluetoothLeBroadcast"; private static final int UNKNOWN_VALUE_PLACEHOLDER = -1; private static final boolean DEBUG = BluetoothUtils.D; private static final String VALID_PASSWORD_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_=+[]{}|;:," + ".<>?/"; private static final int PASSWORD_LENGTH = 16; static final String NAME = "LE_AUDIO_BROADCAST"; // Order of this profile in device profiles list Loading Loading @@ -502,9 +506,15 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { mBroadcastId = UNKNOWN_VALUE_PLACEHOLDER; } private String generateRandomPassword() { String randomUUID = UUID.randomUUID().toString(); //first 12 chars from xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx return randomUUID.substring(0, 8) + randomUUID.substring(9, 13); private static String generateRandomPassword() { SecureRandom random = new SecureRandom(); StringBuilder stringBuilder = new StringBuilder(PASSWORD_LENGTH); for (int i = 0; i < PASSWORD_LENGTH; i++) { int randomIndex = random.nextInt(VALID_PASSWORD_CHARACTERS.length()); stringBuilder.append(VALID_PASSWORD_CHARACTERS.charAt(randomIndex)); } return stringBuilder.toString(); } } Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java +15 −5 Original line number Diff line number Diff line Loading @@ -39,10 +39,10 @@ import androidx.annotation.RequiresApi; import com.android.settingslib.R; import java.nio.charset.StandardCharsets; import java.security.SecureRandom; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.UUID; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.ThreadLocalRandom; Loading @@ -56,6 +56,10 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { private static final String TAG = "LocalBluetoothLeBroadcast"; private static final int UNKNOWN_VALUE_PLACEHOLDER = -1; private static final boolean DEBUG = BluetoothUtils.D; private static final String VALID_PASSWORD_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_=+[]{}|;:," + ".<>?/"; private static final int PASSWORD_LENGTH = 16; static final String NAME = "LE_AUDIO_BROADCAST"; // Order of this profile in device profiles list Loading Loading @@ -502,9 +506,15 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { mBroadcastId = UNKNOWN_VALUE_PLACEHOLDER; } private String generateRandomPassword() { String randomUUID = UUID.randomUUID().toString(); //first 12 chars from xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx return randomUUID.substring(0, 8) + randomUUID.substring(9, 13); private static String generateRandomPassword() { SecureRandom random = new SecureRandom(); StringBuilder stringBuilder = new StringBuilder(PASSWORD_LENGTH); for (int i = 0; i < PASSWORD_LENGTH; i++) { int randomIndex = random.nextInt(VALID_PASSWORD_CHARACTERS.length()); stringBuilder.append(VALID_PASSWORD_CHARACTERS.charAt(randomIndex)); } return stringBuilder.toString(); } }