BestOwl / MyPhone

Connect your mobile devices (Android/iOS/WindowsPhone) to PC
MIT License
191 stars 37 forks source link

Not able to run the sample on windows 10 desktop #2

Closed hpxiong closed 3 years ago

hpxiong commented 3 years ago

Is there step missing to have this run on regular windows desktop?

According to MS, PhoneLineTransportDevice class only applies to WinRT Build 18362, Build 19041, Build 20348, Build 22000 (Preview) https://docs.microsoft.com/en-us/uwp/api/windows.applicationmodel.calls.phonelinetransportdevice?view=winrt-20348

Not Implemented exception was thrown here:

Feature com.microsoft.windows.applicationmodel.phonelinetransportdevice_v1 is not available Source= StackTrace:

at Windows.ApplicationModel.Calls.PhoneLineTransportDevice.GetDeviceSelector(PhoneLineTransport transport) at GoodTimeStudio.MyPhone.Models.BluetoothDeviceListViewModel..ctor() in C:\repos\MyPhone\MyPhone\Models\BluetoothDeviceListViewModel.cs:line 28 at GoodTimeStudio.MyPhone.BluetoothDeviceListView..ctor() in C:\repos\MyPhone\MyPhone\BluetoothDeviceListView.xaml.cs:line 29
hpxiong commented 3 years ago

I updated the device query to use: BluetoothDevice.GetDeviceSelectorFromPairingState(true) and this works for getting the BT device list. But now the problem is BT connect never comes back

While debugging, the program was never able to hit Connect method inside MyPhone.TrayApp BackgroundServer.cpp. Instead the console says:

Windows.UI.Xaml.dll!00007FFB6DD12A95: (caller: 00007FFAE4889825) ReturnHr(6) tid(5524) 80070057 The parameter is incorrect. 'MyPhone.exe' (Win32): Loaded 'C:\Windows\System32\xmllite.dll'. Symbols loaded. Exception thrown at 0x00007FFB828B3FE9 (KernelBase.dll) in MyPhone.exe: WinRT originate error - 0x80040155 : 'Failed to find proxy registration for IID: {AB8E5D11-B0C1-5A21-95AE-F16BF3A37624}.'. 'MyPhone.exe' (Win32): Loaded 'C:\Windows\System32\userenv.dll'. Symbols loaded. 'MyPhone.exe' (Win32): Loaded 'C:\Windows\System32\profext.dll'. Symbols loaded. 'MyPhone.exe' (Win32): Loaded 'C:\Windows\System32\rometadata.dll'. Symbols loaded. 'MyPhone.exe' (Win32): Loaded 'C:\Windows\System32\WinMetadata\Windows.Foundation.winmd'. Module was built without symbols. 'MyPhone.exe' (Win32): Loaded 'C:\Windows\System32\WinMetadata\Windows.UI.winmd'. Module was built without symbols. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(4) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(5) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(6) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(7) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(8) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(9) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(10) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(11) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(12) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(13) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(14) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(15) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(16) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(17) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(18) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(19) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(20) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(21) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(22) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(23) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(24) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(25) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(26) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(27) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(28) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(29) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(30) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(31) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(32) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(33) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(34) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(35) tid(5524) 80070490 Element not found. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFB734807D0: (caller: 00007FFB73480515) ReturnHr(36) tid(5524) 80070490 Element not found. 'MyPhone.exe' (Win32): Loaded 'C:\Windows\System32\dwmapi.dll'. Symbols loaded. 'MyPhone.exe' (Win32): Loaded 'C:\Windows\System32\ninput.dll'. Symbols loaded. 'MyPhone.exe' (Win32): Loaded 'C:\Windows\System32\PhoneOm.dll'. Symbols loaded. 'MyPhone.exe' (Win32): Loaded 'C:\Windows\System32\Phoneutil.dll'. Symbols loaded. The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core. The program '[32716] MyPhone.TrayApp.exe' has exited with code 0 (0x0). The thread 0x3d74 has exited with code 0 (0x0). The thread 0x54fc has exited with code 0 (0x0).

Any suggestions??

BestOwl commented 3 years ago

It should work on Windows 10 Version 1903 (build 18362) and above. I tested again on Windows 11 (build 22000), and it works fine. What‘s your OS version?

BestOwl commented 3 years ago

You can't change the device query to BluetoothDevice.GetDeviceSelectorFromPairingState(true) because BluetoothDevice and PhoneLineTransportDevice have different device id. image

https://github.com/BestOwl/MyPhone/blob/9cb86e823e6932e8fce70c4eee34e2f895cd96a4/MyPhone.TrayApp/BackgroundServer.cpp#L144-L156

The Connect method in BackgroundServer.cpp use PhoneLineTransportDevice::FromId() which requires a PhoneLineTransportDeviceId as input.

hpxiong commented 3 years ago

@BestOwl Thank you for the reply.

My system info:

image

Here is the exception I ran into

image

I see quite a lot WinRT originator errors:

'MyPhone.exe' (Win32): Loaded 'C:\Windows\System32\PhoneOm.dll'. Symbols loaded. 'MyPhone.exe' (Win32): Loaded 'C:\Windows\System32\Phoneutil.dll'. Symbols loaded. Exception thrown at 0x00007FFB828B3FE9 (KernelBase.dll) in MyPhone.exe: WinRT originate error - 0x80040111 : 'Windows.ApplicationModel.LimitedAccessFeatures'. onecore\com\combase\winrt\error\restrictederror.cpp(1014)\combase.dll!00007FFB82DEDD50: (caller: 00007FFB82D90D8C) ReturnHr(1) tid(7228) 8007007E The specified module could not be found. Exception thrown at 0x00007FFB828B3FE9 (KernelBase.dll) in MyPhone.exe: WinRT originate error - 0x80004001 : 'Feature com.microsoft.windows.applicationmodel.phonelinetransportdevice_v1 is not available'. onecore\com\combase\winrt\error\restrictederror.cpp(1014)\combase.dll!00007FFB82DEDD50: (caller: 00007FFB82D90D8C) ReturnHr(2) tid(7228) 8007007E The specified module could not be found. onecoreuap\net\phone\phoneom\winrt\phonelinetransportdevicestatics.cpp(31)\PhoneOm.dll!00007FFB7D890FC1: (caller: 00007FFB7D8912AE) ReturnHr(1) tid(7228) 80004001 Not implemented onecoreuap\net\phone\phoneom\winrt\phonelinetransportdevicestatics.cpp(108)\PhoneOm.dll!00007FFB7D8912CD: (caller: 00007FFA8F791AD1) ReturnHr(2) tid(7228) 80004001 Not implemented Exception thrown: 'System.NotImplementedException' in MyPhone.exe An exception of type 'System.NotImplementedException' occurred in MyPhone.exe but was not handled in user code Not implemented

Feature com.microsoft.windows.applicationmodel.phonelinetransportdevice_v1 is not available

BestOwl commented 3 years ago

Very strange, seems like 18363 doesn't support this API. I'm trying to install build 18363 and test it on my machine.

hpxiong commented 3 years ago

I tested again on another Windows 10 Pro and it worked this time. Not sure if it is due to Windows 10 Enterprise or special policy that prevents the access to certain library in Windows.ApplicationModel namespace.

I'm curious what is the status with SMS Message implementation. any code base to share? I'm interested in contributing. Thanks!

BestOwl commented 3 years ago

The MAP demo at https://github.com/BestOwl/MyPhone/blob/master/MyPhone.Demo/MAP.cs can now establish the MAS/MNS service connection and get the message info whenever a new SMS message arrived. What we need to do next is to implement a UI and register it as a UWP background service.

BestOwl commented 3 years ago

Glad to hear you are interested in this project btw, welcome aboard :)

hpxiong commented 3 years ago

@BestOwl I will check out the SMS code. Thanks! If you find out more on the original problem on the "WinRT originator error", "Not implemented exception", please share it here. Since the code works in another system, I will close this issue for now.