pixel-backup-gang icon indicating copy to clipboard operation
pixel-backup-gang copied to clipboard

Suggestion or workaround for adb push on Pixel 2 running LineageOS

Open milchalpenl opened this issue 1 year ago • 7 comments
trafficstars

Firstly congrats for this idea. Inspired by your idea... I did the following for pixel 2. Install lineageos (with microg). Enable adb root (in developer settings) and adb WiFi. Then connect via wifi and connect the appropriate USB storage (using fat32 usb ssd)

Now, connect via cable

adb tcpip 5555
adb connect 192.168.1.26:5555

disconnect USB cable to phone

adb root
adb shell
df -h  (snippet attached)
/dev/fuse                   50G  5.3G   45G  11% /storage/emulated
/dev/block/vold/public:8,1 128G  7.9G  119G   1% /mnt/media_rw/45E3-1D10

seems crude but... this works

mount  /mnt/media_rw/45E3-1D10/  /mnt/pass_through/0/emulated/0/DCIM
am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///storage/emulated/0/DCIM

(Note that all files in DCIM natively will disappear as it became mount point. They dont get deleted but just temporarily disappear). After the broadcast command files in the USB drive automatically are visible in the photos app recognises everything and starts uploading.

TODO: push things directly from adb push into the external device. At the moment if I try

adb push  foo.png /mnt/media_rw/45E3-1D10/
remote fchown failed: Operation not permitted

If that works then I can leave this setup forever at my router and RW only the USB disk but WIP.

milchalpenl avatar Jun 20 '24 09:06 milchalpenl

try pushing to the /mnt/pass_through directory instead of the /mnt/media_rw directory

try changing the file permissions & owner uid/gid of the images locally (before pushing) to match the existing file permissions in the /mnt/media_rw/45E3-1D10/ folder

also try running setenforce 0 to disable selinux, and see if it works after that (change persists until reboot)

master-hax avatar Jun 20 '24 10:06 master-hax

do you know if your pixel 2's kernel has NFS support? (cat /proc/filesystems)

master-hax avatar Jun 20 '24 10:06 master-hax

do you know if your pixel 2's kernel has NFS support? (cat /proc/filesystems)

nodev	sysfs
nodev	rootfs
nodev	ramfs
nodev	bdev
nodev	proc
nodev	cpuset
nodev	cgroup
nodev	cgroup2
nodev	tmpfs
nodev	configfs
nodev	debugfs
nodev	tracefs
nodev	sockfs
nodev	bpf
nodev	pipefs
nodev	devpts
	ext3
	ext2
	ext4
	vfat
nodev	ecryptfs
nodev	sdcardfs
	fuseblk
nodev	fuse
nodev	fusectl
nodev	overlay
	f2fs
nodev	pstore
nodev	selinuxfs
nodev	functionfs

milchalpenl avatar Jun 20 '24 12:06 milchalpenl

try pushing to the /mnt/pass_through directory instead of the /mnt/media_rw directory

same error

try changing the file permissions & owner uid/gid of the images locally (before pushing) to match the existing file permissions in the /mnt/media_rw/45E3-1D10/ folder

it is fat32. Just has owner/group permissions of /mnt/media_rw (i.e) root external_storage

also try running setenforce 0 to disable selinux, and see if it works after that (change persists until reboot)

did not work.

IMHO. I need to recompile by changing 0750 to 0755 at

https://android.googlesource.com/platform/system/core/+/master/rootdir/init.rc#278

or make it root everybody

snip
storage/emulated/0:
total 210
drwxrwx--- 2 root everybody   3488 2023-11-18 14:35 Alarms

At the moment, I don't so much need it... Lets see in the future.

milchalpenl avatar Jun 20 '24 12:06 milchalpenl

fwiw i am very confident that you can get this working without making changes to the OS or kernel.

absolute worst case scenario you can run an FTP or NFS server in userspace.

master-hax avatar Jun 20 '24 12:06 master-hax

one more thing you might consider trying:

cat ./some_file.jpg | adb shell /sbin/su --command "cat > /mnt/media_rw/45E3-1D10/some_file.jpg"

this might behave differently from adb push

master-hax avatar Jun 20 '24 13:06 master-hax

After a bit of googling it was so much easier. Edit

diff --git a/data/etc/platform.xml b/data/etc/platform.xml
index cf312165..417136e9 100644
--- a/data/etc/platform.xml
+++ b/data/etc/platform.xml
@@ -132,7 +132,11 @@
          the fragility as one can remove a built-in permission which
          no longer needs to be mapped to gids and break grant propagation. -->
     <permission name="android.permission.READ_EXTERNAL_STORAGE" />
-    <permission name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
+        <group gid="media_rw" />
+        <group gid="sdcard_r" />
+        <group gid="sdcard_rw" />
+    </permission>

and

diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index 60d2feab..f04f6b72 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -1535,7 +1535,7 @@ class StorageManagerService extends IStorageManager.Stub
 
             // Adoptable public disks are visible to apps, since they meet
             // public API requirement of being in a stable location.
-            if (vol.disk.isAdoptable()) {
+            if (true || vol.disk.isAdoptable()) {
                 vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
             } else if (vol.disk.isSd()) {
                 vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
  • Now the external storage appears as a microSD card in Google Photos app. Done.

Reference: https://github.com/android-rpi/device_brcm_rpi3/issues/82

milchalpenl avatar Jun 27 '24 12:06 milchalpenl

@milchalpenl how did you edit the above files? I was under the impression they were read-only unless you create a magisk module?

DevinDuricka avatar Sep 19 '24 19:09 DevinDuricka

Compile the source code and build the complete ROM. See for example https://wiki.lineageos.org/devices/walleye/build/

milchalpenl avatar Oct 06 '24 06:10 milchalpenl