ale5000-git / tingle

Tingle - Android patcher
http://forum.xda-developers.com/showthread.php?t=3438764
GNU General Public License v3.0
160 stars 11 forks source link

Tingle script hangs after "Remounting /system..." #22

Open ecanja opened 7 years ago

ecanja commented 7 years ago

I want to patch my phone (Samsung Galaxy S3 Mini with unofficial CM12.1) with Tingle and it seemed to work, but it didn't finish the process. This is how far I got in the (Linux) Terminal:

$ python main.py 
MENU

    1 - Patch file from a device (adb)
    2 - Patch file from the input folder

> 1

 *** OS: Linux 4.4.0-59-generic (linux)
 *** Mode: 1
 *** Working dir: /tmp/Tingle-3sT0Ca
 *** Selected device: 479000eae2b811ba
 *** Pulling framework from device...
      DEBUG: 4004 KB/s (5535794 bytes in 1.349s)
 *** Decompressing framework...
      DEBUG: Decompressing framework.jar
 *** Disassembling classes...
      DEBUG: Disassembling framework/classes.dex
 *** Patching...
 *** Detected: Android 5.x / CyanogenMod 12
 *** Patching succeeded.
 *** Reassembling classes...
      DEBUG: Assembling out/classes.dex
 *** Recompressing framework...
      DEBUG: Compressing framework.jar
 *** Copying the patched file to the output folder...
 *** Rooting adbd...
      DEBUG: restarting adbd as root
 *** Unlocked ADB: True
 *** Remounting /system...

At this point, it stops going further, but it didn't crash. I'm not able to get a logcat (adb logcat in a different Terminal seems to hang as well and doesn't produce any output).

Any idea what could cause this? And what to do to get around?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/41400080-tingle-script-hangs-after-remounting-system?utm_campaign=plugin&utm_content=tracker%2F43052892&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F43052892&utm_medium=issues&utm_source=github).
ale5000-git commented 7 years ago

It is possibly a bug in the ROM.

Can you please try what happen if you run these commands from terminal? adb root adb remount

ecanja commented 7 years ago

It is possibly a bug in the ROM.

Definitely possible.

I'm still in the state of the hanging script and any adb commands don't do anything but hanging as well.

EDIT: Strg + C in the Terminal gives:

Traceback (most recent call last):
  File "main.py", line 531, in <module>
    enable_device_writing(chosen_one)
  File "main.py", line 219, in enable_device_writing
    remount_check = subprocess.check_output([DEPS_PATH["adb"], "-s", chosen_device, "remount", "/system"]).decode("utf-8")
  File "/usr/lib/python2.7/subprocess.py", line 567, in check_output
    output, unused_err = process.communicate()
  File "/usr/lib/python2.7/subprocess.py", line 791, in communicate
    stdout = _eintr_retry_call(self.stdout.read)
  File "/usr/lib/python2.7/subprocess.py", line 476, in _eintr_retry_call
    return func(*args)

And now, adb root (already ran as root) and adb remount (successful) go through without failure.

Don't know if that is of any help...

ale5000-git commented 7 years ago

@ecanja: Please try to reboot the phone, run the 2 commands (without running Tingle) to see what happens and post the ouput.

ecanja commented 7 years ago

Ok, did that:

$ adb logcat
# lot of output, worked as usual
$ adb shell
shell@golden:/ $ exit
~$ adb root
restarting adbd as root
~$ adb remount
^C
~$ adb logcat
^C
~$ adb shell
^C
~$

The first command adb root was ok, but adb remount hang up. Moreover, the usual adb commands adb logcat and adb shell were fine before this, but got stuck afterwards.

Does this mean that adb remount is not working on my phone and somehow crashes adb?

ale5000-git commented 7 years ago

@ecanja: It is possible.

adb remount remount the system partition as read-write.

Try this:

And see if it stuck.

ecanja commented 7 years ago

I have no terminal installed, but I did this and it stuck:

$ adb shell
shell@golden:/ $ su
root@golden:/ # mount -o rw,remount,rw /system
root@golden:/ # exit
shell@golden:/ $ exit
$ adb root
restarting adbd as root
~$ adb remount
^C
~$
ale5000-git commented 7 years ago

@ecanja: Try to update adb on your pc, just in case there is a problem in it, there should be version 1.0.36 if I'm not wrong.

ecanja commented 7 years ago

I updated adb, but the problem remains. I guess, it's an issue with the ROM. Seems as if I need to go with XPosed for signature spoofing.

Nevertheless, thanks a lot for your help!

ale5000-git commented 7 years ago

@ecanja: Probably I cannot fix it in the script if it is a ROM issue, but just for patching you can also do it from recovery. You just need to enter in recovery, mount the system partition, and then run Tingle on the pc.

georgedorn commented 7 years ago

Some ROMs / devices just don't let you remount /system in read-write mode via adb. I'm on a OnePlus X and no ROM I've put on it has allowed this to work.

Here is a workaround. Start in the tingle repo. You'll also need an su binary on your phone.

adb pull /system/framework/framework.jar ./input
python main.py  # (then select item 2 to work with a local file)
adb push ./output/framework.jar /data

Then, either via adb shell or in a terminal on the device:

su
mount -o remount,rw /system
cp /data/framework.jar /system/framework/framework.jar
reboot
ale5000-git commented 7 years ago

@georgedorn: The main problem isn't remounting, but it is the fact that the adb remount command freeze adb indefinitely and never return.

So, the only thing would be probably kill adb and re-try with a workaround. I will see what I can do.

ale5000-git commented 7 years ago

@ecanja: Could you please post a bug report about adb remount to the ROM author and post a link of the bug report here?

ecanja commented 7 years ago

Did so: https://github.com/NovaFusion/android_device_samsung_golden/issues/83.

Unfortunately, the issue tracker doesn't look like being very actively maintained.

ale5000-git commented 6 years ago

@ecanja @georgedorn

Could you please try the latest version of Tingle, tell me if there is any improvement and post the log? When the command hang it should go on after 6 seconds, I would like to know if it works.

ghost commented 6 years ago

I don't know if my issue is the same.. But for me it crashes after "Remounting /system..."

MENU

    1 - Patch file from a device (adb)
    2 - Patch file from the input folder

> 1

 *** OS: Linux 4.14.9-1-ARCH (linux)
 *** Python: 3.6.4 (64 bit)
 *** Mode: 1
 *** Working dir: /tmp/Tingle-x2vr8_to
 *** Selected device: 43f8c4790903
 *** Automounting /system...
      DEBUG: Already mounted
 *** Pulling framework from device...
 *** Device SDK: 25
 *** Decompressing framework...
      DEBUG: Decompressing framework.jar
 *** Disassembling classes...
      DEBUG: Disassembling framework/classes.dex
 *** Patching...
 *** Detected: Android 8.x / 7.x / 6.x (or LOS/CM 13-15)
 *** Patching succeeded.
 *** Reassembling classes...
      DEBUG: Assembling out/classes.dex
      WARNING: The reassembling has failed (probably we have exceeded the 64K methods limit)
               but do NOT worry, we will retry.
 *** Moving methods...
      WARNING: Experimental code.
      DEBUG: Disassembling framework/classes2.dex
 *** Reassembling classes...
      DEBUG: Assembling out/classes.dex
      DEBUG: Assembling out/classes2.dex
 *** Recompressing framework...
      DEBUG: Compressing framework.jar
 *** Copying the patched file to the output folder...
 *** Rooting adbd...
      DEBUG: adbd cannot run as root in production builds
 *** Unlocked ADB: False
 *** Remounting /system...

ERROR INFO
==========
Type: <class 'subprocess.CalledProcessError'>
Cmd: ['/usr/bin/adb', '-s', '43f8c4790903', 'shell', "su -c 'mount -o remount,rw /system /system && mount' | grep ' /system '"]
Return code: 1
Output: mount: '/system' not in /proc/mounts

Traceback (most recent call last):
  File "./main.py", line 720, in <module>
    enable_device_writing(SELECTED_DEVICE)
  File "./main.py", line 365, in enable_device_writing
    remount_check = safe_output_decode(safe_subprocess_run([DEPS_PATH["adb"], "-s", chosen_device, "shell", "su -c 'mount -o remount,rw /system /system && mount' | grep ' /system '"]))  # Untested
  File "./main.py", line 203, in safe_subprocess_run
    return subprocess.check_output(command, stderr=subprocess.STDOUT)
  File "/usr/lib/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/usr/bin/adb', '-s', '43f8c4790903', 'shell', "su -c 'mount -o remount,rw /system /system && mount' | grep ' /system '"]' returned non-zero exit status 1.

Any advice?

ale5000-git commented 6 years ago

@Ociramma: It isn't the same problem, could you please open a separate issue (to avoid confusion)?

ghost commented 6 years ago

Ok, no problem.