首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >理解Android与iOS连接使用libimobiledevice时的连接问题

理解Android与iOS连接使用libimobiledevice时的连接问题
EN

Stack Overflow用户
提问于 2021-08-18 13:14:28
回答 1查看 390关注 0票数 1

我正在试图建立一个原型的安卓应用程序,用于无线连接我的安卓设备到一个iOS设备。在研究选项时,我偶然发现了libimobiledevice库,这似乎是合适的选择。我目前被困在似乎iOS设备正在接收请求,但拒绝它,这就是我想从这个论坛了解。

我到目前为止所做的事:

  • 我已经在我的安卓应用程序中将libimobiledevice库打包为一个.so文件,并且我能够从我的Android应用程序中调用JNI来调用库的方法。
  • 正如在依赖项中提到的那样,我还在libusbmuxd库利布利特中打包。
  • 对于原型,我正在创建一个wifi热点从我的安卓设备和连接的iOS设备。我也知道这两个设备的IP地址。我还知道,iOS上的锁定装置运行在端口62078上。给定IP地址和端口,当我调用套接字时,我确实看到idevice_new_with_options -> usbmuxd_get_device -> connect_usbmuxd_socket -> socket_connect能够接触到套接字上的iOS设备。通过查看iOS日志来确认
代码语言:javascript
运行
复制
lockdownd[70] <Notice>: _receive_message: <private>
symptomsd(SymptomEvaluator)[120] <Notice>: Data Usage for lockdownd - WiFi in/out: 181637370/198768065, WiFi delta_in/delta_out: 458/0, Cell in/out: 0/0, Cell delta_in/delta_out: 0/0, RNF: 0, subscriber tag: 0
  • 但在此之后,我立即看到连接被取消,可能是因为锁被拒绝了。我看到了错误104的这会被触发,意思是“点对点重置连接”。

问题:

  • 据我所知,libimobiledevice正在尝试与iPhone建立TCP/IP连接。一旦连接成功,我将能够使用库的其余功能,比如调用上述服务。
  • 我的设置是正确的还是我遗漏了什么?代码编译并没有崩溃,因此我感觉自己拥有所有所需的依赖项。
  • 我如何在iOS端进一步调试这一点,以防止锁定为什么要重新设置连接?

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2021-10-15 12:10:50

libimobiledevice依赖于usbmux,而对于Linux,它目前还不能无线工作。您可以通过使用usbmuxd2重新实现来克服这一点。

这是我的脚本,用于在raspberry Pi上启动和运行整个linux实现。我在这里也有一个更方便用户浏览的东西:nMirrior

代码语言:javascript
运行
复制
#!/bin/bash

echo "installing dependencies"

read -p "Do you want to update/install build tools (you need to if this is a new image) (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
    sudo apt-get -q update
    sudo apt-get -q install \
                    build-essential \
                    checkinstall \
                    git \
                    autoconf \
                    automake \
                    libtool-bin
fi


echo "installing libatomic"
sudo apt-get -q install libatomic-ops-dev libatomic1


echo "installing libimobiledevice dependencies"
sudo apt-get -q install \
                libplist-dev \
                libusbmuxd-dev \
                libimobiledevice-dev \
                libusb-1.0-0-dev \
                libplist++-dev \
                libssl-dev \
                usbmuxd \
                udev \
                libavahi-client-dev \
                avahi-utils 



echo "Starting nMirror setup"

# Configure source directories
nMirrorDir=~/nMirror

echo "The applications needed for nMirror will be installed in $nMirror"

libplistDir=$nMirrorDir/libplist
libusbmuxdDir=$nMirrorDir/libusbmuxd
libimobiledeviceDir=$nMirrorDir/libimobiledevice
libgeneralDir=$nMirrorDir/libgeneral
usbmuxd2Dir=$nMirrorDir/usbmuxd2

#Standard libimobiledevice repos
libplistGit=https://github.com/libimobiledevice/libplist.git
libusbmuxdGit=https://github.com/libimobiledevice/libusbmuxd.git
libimobiledeviceGit=https://github.com/libimobiledevice/libimobiledevice.git

#tihmstar repo for usbmuxd2 to support network connection to iDevice
usbmuxd2Git=https://github.com/tihmstar/usbmuxd2.git
libgeneralGit=https://github.com/tihmstar/libgeneral.git



# Create the project directory if it does not exist
mkdir -p $nMirrorDir
cd $nMirrorDir


# Fetch the repos

fetchnext=false
if test -d $libplistDir; then
    read -p "libplist directory exists. Remove and re-fetch new? (y/n): " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Yy]$ ]]
    then
        rm -rf $libplistDir
        fetchnext=true
    fi
else
    fetchnext=true
fi
if [ "$fetchnext" == true ]; then
    echo "Cloning from git.  1 - libplist"
    cd $nMirrorDir
    git clone --quiet $libplistGit
    cd $libplistDir
    # git checkout 2.2.0 # Cannot go back to the last tag (2.2.0) because usbmuxd2 want 2.2.1 - just get the head for now
fi


if test -d $libusbmuxdDir; then
    read -p "libusbmuxd directory exists. Remove and re-fetch new? (y/n): " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Yy]$ ]]
    then
        rm -rf $libusbmuxdDir
        fetchnext=true
    fi
else
    fetchnext=true
fi
if [ "$fetchnext" == true ]; then
    echo "Cloning from git.  2 - libusbmuxd (Normal)"
    cd $nMirrorDir
    git clone --quiet $libusbmuxdGit
    cd $libusbmuxdDir
    git checkout 2.0.2
fi

if test -d $libimobiledeviceDir; then
    read -p "libimobiledevice directory exists. Remove and re-fetch new? (y/n): " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Yy]$ ]]
    then
        rm -rf $libimobiledeviceDir
        fetchnext=true
    fi
else
    fetchnext=true
fi
if [ "$fetchnext" == true ]; then
    echo "Cloning from git.  3 - libimobiledevice"
    cd $nMirrorDir
    git clone --quiet $libimobiledeviceGit
    cd $libimobiledeviceDir
    git checkout 1.3.0
fi


#tihmstar repo for usbmuxd2 to support network connection to iDevice
if test -d $libgeneralDir; then
    read -p "libgeneral directory exists. Remove and re-fetch new? (y/n): " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Yy]$ ]]
    then
        rm -rf $libgeneralDir
        fetchnext=true
    fi
else
    fetchnext=true
fi
if [ "$fetchnext" == true ]; then
    echo "Cloning from git.  4 - libgeneral (tihmstar Experimental repo tag 55)"
    cd $nMirrorDir
    git clone --quiet $libgeneralGit
    cd $libgeneralDir
    git checkout 55
fi


if test -d $usbmuxd2Dir; then
    read -p "usbmuxd2 directory exists. Remove and re-fetch new? (y/n): " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Yy]$ ]]
    then
        rm -rf $usbmuxd2Dir
        fetchnext=true
    fi
else
    fetchnext=true
fi
if [ "$fetchnext" == true ]; then
    echo "Cloning from git.  5 - usbmuxd2 (tihmstar Eperimental repo)"
    cd $nMirrorDir
    git clone --quiet $usbmuxd2Git
    cd $usbmuxd2Dir
    git submodule init
    git submodule update
fi

#build stage

cd $libplistDir
./autogen.sh
make
sudo make install

cd $libusbmuxdDir
./autogen.sh
make
sudo make install

cd $libimobiledeviceDir
./autogen.sh
make
sudo make install

sudo ldconfig

#configure Avahi for zeroconf as per https://www.raspberrypi.org/forums/viewtopic.php?t=267113
#Note: Zeroconf may not be desirable - use with caution
cd $nMirrorDir

#create avahi patch
tee avahi.patch <<EOF
--- /etc/avahi/avahi-daemon.conf 2021-08-16 23:59:16.917672251 +0100
+++ /etc/avahi/avahi-daemon_usbmuxd.conf 2021-08-17 09:45:02.096575347 +0100
@@ -20,7 +20,7 @@
 
 [server]
 #host-name=foo
-#domain-name=local
+domain-name=local
 #browse-domains=0pointer.de, zeroconf.org
 use-ipv4=yes
 use-ipv6=yes
@@ -46,8 +46,8 @@
 #disable-user-service-publishing=no
 #add-service-cookie=no
 #publish-addresses=yes
-publish-hinfo=no
-publish-workstation=no
+publish-hinfo=yes
+publish-workstation=yes
 #publish-domain=yes
 #publish-dns-servers=192.168.50.1, 192.168.50.2
 #publish-resolv-conf-dns-servers=yes
EOF

cd /etc
sudo patch -p2 < $nMirrorDir/avahi.patch

#enable the avahi-daemon
systemctl list-unit-files avahi-daemon.service
#activate/enable the avahi-daemon.service
sudo systemctl enable avahi-daemon.service
sudo systemctl start avahi-daemon.service
sudo systemctl restart avahi-daemon.service
#enable ssh service
sudo systemctl enable ssh.service
sudo systemctl start ssh.service
#avahi-browse -a 


# if using gcc: the patch below works to include -latomic 
# if using clang: make CXX=clang++

cd $libgeneralDir
./autogen.sh
make CFLAGS="-g -O2 -std=c11 -latomic" LDFLAGS=-latomic
sudo make install

sudo ldconfig

cd $usbmuxd2Dir

#create log patch
#cassure only needed for versions after 55 - probably remove this as checkout is fixed to 55
tee log.patch <<EOF
--- a/configure.ac
+++ b/configure.ac
@@ -29,7 +29,7 @@ case $host_os in
         have_mdns="yes"
         ;;
   *)
-        LDFLAGS+=" -lstdc++fs"
+        LDFLAGS+="-latomic -lstdc++fs"
         ;;
 esac
 
EOF

git apply log.patch
./autogen.sh
make
sudo make install

sudo ldconfig


# get the BT PAN up and running
sudo apt-get install bluez-tools

sudo tee /etc/systemd/network/pan0.netdev <<EOF
[NetDev]
Name=pan0
Kind=bridge
EOF
 
 
sudo tee /etc/systemd/network/pan0.network <<EOF
[Match]
Name=pan0
[Network]
Address=172.20.1.1/24
DHCPServer=yes
EOF
 
sudo tee /etc/systemd/system/bt-agent.service <<EOF
[Unit]
Description=Bluetooth Auth Agent
 
[Service]
#ExecStart=/usr/bin/bt-agent -c NoInputNoOutput
ExecStart=/bin/sh -c '/usr/bin/yes | /usr/bin/bt-agent --capability=NoInputNoOutput' #autoaccept
Type=simple
 
[Install]
WantedBy=multi-user.target
EOF
 
sudo tee /etc/systemd/system/bt-network.service <<EOF
[Unit]
Description=Bluetooth NEP PAN
After=pan0.network
[Service]
ExecStart=/usr/bin/bt-network -s nap pan0
Type=simple
[Install]
WantedBy=multi-user.target
EOF

sudo systemctl enable systemd-networkd
sudo systemctl enable bt-agent
sudo systemctl enable bt-network
sudo systemctl start systemd-networkd
sudo systemctl start bt-agent
sudo systemctl start bt-network

sudo bt-adapter --set Discoverable 1

# list devices. Need to ask the user to connect via USB the first time using idevicesyslog. Then make the BT PAN connection and connect via idevicesyslog -n

/usr/local/bin/idevice_id 
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68833133

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档