Android adb推送到没有SD卡且没有root访问权限的设备中的位置

发布于 2024-11-18 22:41:21 字数 126 浏览 8 评论 0原文

如果设备没有 SD 卡并且我们没有 root 访问权限,那么 Android 设备上是否有任何位置可以推送文件(使用 adb)?

(我正在尝试将属性文件推送到设备上,因此我还需要能够从设备上运行的活动内的此位置读取数据)

Is there any location on an android device that we can push a file (using adb) if the device has no SD card and we do not have root access?

(I am trying to push a properties file onto the device, so I will also need to be able to read from this location inside an activity running on the device)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

第几種人 2024-11-25 22:41:21

每个设备都有不同的能力。在某些手机上,例如 Samsung Galaxy S Vibrant,/sdcard/ 挂载点可由通过 adb 连接的任何主机写入。在其他设备上,例如 MyTouch 4G,“adb Push”根本无法将任何文件发送到任何目的地。

如果您仅使用一两个设备进行测试,请打开 adb shell 并发出 dfls -l 等命令来查看安装的内容分别有点和文件权限。

如果您的用户可以在 Android 设备上执行 find,那真是一个福音,您可以使用它来查找当前有效 uid 可写(或所有人都可写)的文件。

一些可以尝试的目录:

    /sdcard
    /data
    /tmp
    /opt

您可能已经看过 adb 页面,但是我将其链接以防万一。

示例 df 输出:

    $ df 
    /dev: 318068K total, 64K used, 318004K available (block size 4096)
    /system: 558668K total, 468920K used, 89748K available (block size 4096)
    /data: 1190256K total, 129868K used, 1060388K available (block size 4096)
    /cache: 294628K total, 16720K used, 277908K available (block size 4096)
    /devlog: 21100K total, 6056K used, 15044K available (block size 4096)
    /mnt/asec: 318068K total, 0K used, 318068K available (block size 4096)
    /mnt/obb: 318068K total, 0K used, 318068K available (block size 4096)
    /app-cache: 8192K total, 0K used, 8192K available (block size 4096)

Every device has the capacity to be different. On some phones, such as the Samsung Galaxy S Vibrant, the /sdcard/ mount is writeable by any host connected through adb. On others, such as the MyTouch 4G, 'adb push' cannot send any files to any destination at all.

If you are testing with just one or two devices, open an adb shell and issue commands such as df and ls -l to see what mount points there are, and the file permissions, respectively.

If your user can execute find on the Android device, that's a real boon and you can probably use that to locate files writeable by the current effective uid (or writeable by all).

Some directories to try:

    /sdcard
    /data
    /tmp
    /opt

You've probably already seen the adb page but I'm linking it just in case.

Example df output:

    $ df 
    /dev: 318068K total, 64K used, 318004K available (block size 4096)
    /system: 558668K total, 468920K used, 89748K available (block size 4096)
    /data: 1190256K total, 129868K used, 1060388K available (block size 4096)
    /cache: 294628K total, 16720K used, 277908K available (block size 4096)
    /devlog: 21100K total, 6056K used, 15044K available (block size 4096)
    /mnt/asec: 318068K total, 0K used, 318068K available (block size 4096)
    /mnt/obb: 318068K total, 0K used, 318068K available (block size 4096)
    /app-cache: 8192K total, 0K used, 8192K available (block size 4096)

听你说爱我 2024-11-25 22:41:21

ADB 推送似乎与“/data/local/tmp”配合良好。

ADB push seems to work fine with '/data/local/tmp'.

挽容 2024-11-25 22:41:21

/data/local 通常可由 shell 用户(运行 adb shell 的用户)读写。所以你应该能够 adb 将文件推送到 /data/local。

为了使应用程序能够访问它,您还必须适当地设置文件的权限

adb push prefs.txt /data/local
adb shell chmod 664 /data/local/prefs.txt

另一种方法是让您的应用程序在设备上的应用程序数据目录下创建一个新目录,并设置权限该目录是世界可读/可写的,这应该允许您 adb Push 到那里。

/data/local is typically readable and writeable by the shell user (the user that adb shell runs under). So you should be able to adb push a file to /data/local.

In order for an application to be able to access it, you'll also have to set the permissions on the file appropriately

adb push prefs.txt /data/local
adb shell chmod 664 /data/local/prefs.txt

Another approach would be to have your application create a new directory under it's application data directory on the device and set the permissions on the directory to be world readable/writeable, which should allow you to adb push to there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文