Fetch currently loaded bluetooth name

Test: m
ROBOTEST_FILTER="BluetoothMaxConnectedAudioDevicesPreferenceControllerTest"
RunSettingsRoboTests -j40

Test: m ROBOTEST_FILTER="com.android.settings.bluetooth" RunSettingsRoboTests
Test: Open developer settings
Bug: 257158801
Change-Id: Ib40a6264d8d6908103d76b6401ddcfd3ffa7dd88
This commit is contained in:
William Escande
2022-11-03 12:09:55 -07:00
parent 2552ae08ae
commit 723df89aaa
4 changed files with 78 additions and 22 deletions

View File

@@ -24,6 +24,7 @@ import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.PowerManager;
import android.os.UserManager;
import android.util.Log;
@@ -125,8 +126,15 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver {
// Create an intent triggered by clicking on the
// "Clear All Notifications" button
String bluetoothName;
try {
bluetoothName = Utils.findBluetoothPackageName(context);
} catch (NameNotFoundException e) {
e.printStackTrace();
return;
}
Intent deleteIntent = new Intent(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY);
deleteIntent.setPackage("com.android.bluetooth");
deleteIntent.setPackage(bluetoothName);
deleteIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
deleteIntent.putExtra(BluetoothDevice.EXTRA_CONNECTION_ACCESS_RESULT,
BluetoothDevice.CONNECTION_ACCESS_NO);