I'm using an API called PhoneLineTransportDevice
to make an HFP
and SCO
connection between my windows and phone so that I can make and pick calls from my pc with a bluetooth connection
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.ApplicationModel.Calls;
using Windows.Devices.Enumeration;
namespace PhoneLinetransportdevice
{
internal class Program
{
static async Task Main(string[] args)
{
DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(PhoneLineTransportDevice.GetDeviceSelector(PhoneLineTransport.Bluetooth));
for (int i = 0; i < devices.Count; i++)
{
if (devices[i].Name== "OPPO F11 Pro")
{
Console.WriteLine(i + "#: " + devices[i].Name);
var PDevice = PhoneLineTransportDevice.FromId(devices[i].Id);
var result = await PDevice.RequestAccessAsync();
if (!PDevice.IsRegistered())
{
PDevice.RegisterApp();
}
var flag = await PDevice.ConnectAsync();
if (flag)
{
Console.WriteLine("Connected");
}
else
{
Console.WriteLine("Could not connect to PhoneLineDevice");
}
}
}
}
}
}
var result = await PDevice.RequestAccessAsync();
giving denied by the system
I get know that PhoneLineTransportdevice
automatically make a HFP
and SCO
connection instead of creating an HFP
connection first then SCO
connection but this is giving error anyone know why?
I have checked this API isnt depricated but still giving error
Unhandled Exception: System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) at Windows.ApplicationModel.Calls.PhoneLineTransportDevice.RegisterApp() at PhoneLinetransportdevice.Program.d__0.MoveNext() in C:\StudioApps\PhoneLinetransportdevice\PhoneLinetransportdevice\Program.cs:line 25 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at PhoneLinetransportdevice.Program.(String[] args)
I contacted Microsoft and they said they were not aware of this issue. After checking they said there is some permission issue with this API in Windows 11 and they will resolve it soon. We must wait for Microsoft to resolve this issue.