Phone support (MTP) on Haiku

Summary

I finally took the decision of going ahead with the tool, and put some effort on “cleaning the code” before going public .

Here it is, with a core codebase that I operate from a main file. With some tweaks it might be exported as a shared object lib and be called from non-gui apps, or python code.
There’s no upload feature yet, cause of the refactorization :smiley:

Any comment/suggestion and testing results is really appreciated.

Building

It contains a Makefile file, so running make is enough to get the lib working, asuming you have the Haiku packages: libusb , libusb_devel. Tested ok on 64bits Beta.

Configuring

To solve the not-everyhone-has-my-huawei problem, I made the code read the values from a simple ini format file, which for Haiku should work in one of this folders:

./mumtp.ini
/boot/home/config/settings/mumtp/mumtp.ini

The binary has an argument that creates a dummy file for you in the current dir, so you dont need to look any further for a sample file.
To know the values, simply run a scan procedure:

./mumtp --scan
./mumtp --createconf
<<Fill your values>>

Android users

To download files and show every file on your device , you need to set “Transfer files” as the USB mode when plugged on a PC. If you pick “Transfer images”, you may get it working, but the available files would be less (image folders only)

iPhone users

I have no iPhone devices at hand to test, but reading on the internet, i saw that to let any program to sync to the device you need to allow the PC you have your device plugged to, using a setting called “Trust this computer”. Further info on this topic after testing the library is much appreciated.

Didnt work when tested on a real iphone. Work needs to be done.

Official apple support info link

Snapshots

15 Likes

Replying to myself to say that this doesnt work (yet) on Iphones.

Got a chance to temporary have an used Iphone 4, so i was able to plug it into a Linux pc and enabled the “Trust this computer” option, without success (storage syncing was not ok / refused on the protocol side).

Good news is that I can use the device to test myself, apart from the android ones. :thinking:

2 Likes

Hi Pahefu

I’m surprised there’s not been more interest in this which kinda tells me that most people are still running Haiku in a VM and so likely don’t need something like this.

I’m keen to see if I can get this to work but its not building for me under the latest nightly

g++  -c  ".//fileWriter.cpp" -g -O0 -std=c++11 -Wall  -o ./Debug/fileWriter.cpp.o -I. -I.
.//fileWriter.cpp: In member function 'bool FileWriter::OpenFile(const char*, int, const char*)':
.//fileWriter.cpp:27:31: error: ordered comparison of pointer with integer zero ('FILE*' and 'int')
   27 |                 fileOpen = (fd>0);
      |                             ~~^~
Makefile:144: recipe for target 'Debug/fileWriter.cpp.o' failed
make: *** [Debug/fileWriter.cpp.o] Error 1

Thanks for working on this!

1 Like

You can do the following change in fileWriter.cpp:27:
- fileOpen = (fd>0);
+ fileOpen = (fd!=0);

2 Likes

thanks for posting the fix.

i was going to write it, but have no pc around and very busy too.

3 Likes

Thanks for that single op fix Diver! Indeed, with that one change mumtp builds and I have got its ls command working.

The phone I’m testing with has an SD card slot too which usually gets mounted alongside its internal memory. Does mumtp support mounting MicroSD cards over MTP yet? Would it be hard to add?

Your notes say that uploading files isn’t current supported? Could you please give an example command for copying a file from the phone onto the local disk please?

It would also be good to see the GH Readme updated with the instructions when you find the time.

Thanks Pahefu have a great Christmas!

2 Likes

not sure on sdcard support. it’s more like what the android os shows through mtp tham what you could achieve.

file upload was out of the scope back in the day and the code remained like that since Feb 2019, since i didnt code more for it or Haiku in general.

download to your pc by path or mtp handle it’s shown and explained above on the parrot image post

probably better than my present self could explain.

2 Likes

I reverted my install to an updated b3 (ie latest stable) Haiku install today. mumtp builds fine after applying the patch but I get a KDL if I try to run a mumtp --ls command.

It looks like I’ll have to return to running the nightlies to try the mumtp get command.

2 Likes

I updated my Haiku back to the latest master/nightly packages which got mumtps ls command working again but I haven’t had any luck in copying a file using:

./mumtp --get=/path/to/file.ext

When I try that I get:

[Error] Failed to download file by name: ‘/path/to/file.ext’ . Error code: 12

/path/to/file.ext is a file known to exist on the device by using --ls=

1 Like

I have tried photograbber which claims to support PTP but it crashes for me under nightly and b3.

EDIT

Turns out I don’t need mumtp. There is a working Haiku GUI app for MTP called android_file_transfer.

1 Like