The issue

Since Android 4.3 the traditional way of gaining superuser access no longer works because the zygote process drops many capabilities, and the entire /system partition is mounted nosuid. SuperSU (popular superuser access provider) solves this issue by proxying requests to a special daemon which is not a descendant of the zygote process. Here is the explanation of the new SuperSU architecture from its authors.

This new architecture causes problems with handling terminal properly. When you start Android Terminal Emulator, it creates a terminal connected to some tty (/dev/pts/0, for example). When you type su, the superuser process you get is connected to another tty (/dev/pts/2), which the terminal emulator is not aware of. After that, when you invoke or hide virtual keyboard, rotate your device, the terminal emulator notifies the original tty to change its size, but not the one, which the superuser process is connected to. This issue makes terminal emulator almost unusable.

Possible solution

This issue has been discussed in this thread: Terminal emulator size after upgrade Android 4.3. There is a link to one possible solution of the issue: Android root shell. In my opinion, it's quite overcomplicated: it requires running another daemon (pts-daemon) and using a wrapper process (pts-shell). So I developed another solution, which is much simpler and is not dependent on the application providing superuser access.

My solution

The solution is based on maintaining a special file containing all superuser ttys and making Android Terminal Emulator notify each tty from that list.

The first part can be done via editing /system/etc/mkshrc. Add the following lines to the end of the file:

SUTTYS=/data/data/jackpal.androidterm/suttys

function on_exit {
    grep -v `tty` $SUTTYS > ${SUTTYS}.bak
    mv ${SUTTYS}.bak $SUTTYS
    chmod 644 $SUTTYS
}

if [ "$USER" = "root" ]; then
  tty >> $SUTTYS
  chmod 644 $SUTTYS
  chmod 666 `tty`
  trap on_exit EXIT
fi

This code is executed each time new mksh is emerged. It makes mksh do the following:

  1. Add newly created root tty to the suttys file;
  2. Remove root tty from the file before exiting the shell.

The second part requires patching Android Terminal Emulator. The patch is available here. And here is the packaged version of the application with this patch applied. Once you install it, you should no longer experience any issues with the size of the terminal.