{"id":313,"date":"2015-02-22T07:49:46","date_gmt":"2015-02-22T04:49:46","guid":{"rendered":"http:\/\/handheld.computer\/?page_id=313"},"modified":"2019-05-12T17:13:14","modified_gmt":"2019-05-12T14:13:14","slug":"fixing_android_terminal","status":"publish","type":"page","link":"https:\/\/handheld.computer\/?page_id=313","title":{"rendered":"Fixing size of android terminal"},"content":{"rendered":"<h2>The issue<\/h2>\n<p>Since Android 4.3 the traditional way of gaining superuser access no longer works because the zygote process drops many capabilities, and the entire <code>\/system<\/code> partition is mounted nosuid. <a href=\"https:\/\/play.google.com\/store\/apps\/details?id=eu.chainfire.supersu&amp;hl=en\">SuperSU<\/a> (popular superuser access provider) solves this issue by proxying requests to a special daemon which is not a descendant of the zygote process. <a href=\"https:\/\/plus.google.com\/+Chainfire\/posts\/WqS2E9kkN1L\">Here<\/a> is the explanation of the new SuperSU architecture from its authors.<\/p>\n<p>This new architecture causes problems with handling terminal properly. When you start Android Terminal Emulator, it creates a terminal connected to some tty (<code>\/dev\/pts\/0<\/code>, for example). When you type <code>su<\/code>, the superuser process you get is connected to another tty (<code>\/dev\/pts\/2<\/code>), 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.<\/p>\n<h2>Possible solution<\/h2>\n<p>This issue has been discussed in this thread: <a href=\"http:\/\/forum.xda-developers.com\/showthread.php?t=2385428\">Terminal emulator size after upgrade Android 4.3<\/a>. There is a link to one possible solution of the issue: <a href=\"http:\/\/blog.tan-ce.com\/android-root-shell\/\">Android root shell<\/a>. In my opinion, it&#8217;s quite overcomplicated: it<br \/>\nrequires running another daemon (<code>pts-daemon<\/code>) and using a wrapper process (<code>pts-shell<\/code>). So I developed another solution, which is much simpler and is not dependent on the application providing superuser access.<\/p>\n<h2>My solution<\/h2>\n<p>The solution is based on maintaining a special file containing all superuser ttys and making Android Terminal Emulator notify each tty from that list.<\/p>\n<p>The <strong>first part<\/strong> can be done via editing <code>\/system\/etc\/mkshrc<\/code>. Add the following lines to the end of the file:<\/p>\n<pre><code>SUTTYS=\/data\/data\/jackpal.androidterm\/suttys\n\nfunction on_exit {\n    grep -v <code>tty<\/code> $SUTTYS > ${SUTTYS}.bak\n    mv ${SUTTYS}.bak $SUTTYS\n    chmod 644 $SUTTYS\n}\n\nif [ \"$USER\" = \"root\" ]; then\n  tty >> $SUTTYS\n  chmod 644 $SUTTYS\n  chmod 666 <code>tty<\/code>\n  trap on_exit EXIT\nfi<\/code><\/pre>\n<p>This code is executed each time new mksh is emerged. It makes mksh do the following:<\/p>\n<ol>\n<li>Add newly created root tty to the <code>suttys<\/code> file;<\/li>\n<li>Remove root tty from the file before exiting the shell.<\/li>\n<\/ol>\n<p>The <strong>second part<\/strong> requires patching Android Terminal Emulator. The patch is available <a href=\"http:\/\/vminko.org\/storage\/patches\/Android-Terminal-Emulator-1.0.63-su-pty.patch\">here<\/a>. And <a href=\"http:\/\/vminko.org\/storage\/android_term\/term-1.0.63-su-pty.apk\">here<\/a> 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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/handheld.computer\/?page_id=313\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Fixing size of android terminal&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":249,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"tags":[44,46],"class_list":["post-313","page","type-page","status-publish","hentry","tag-android","tag-terminal"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/handheld.computer\/index.php?rest_route=\/wp\/v2\/pages\/313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/handheld.computer\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/handheld.computer\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/handheld.computer\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/handheld.computer\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=313"}],"version-history":[{"count":1,"href":"https:\/\/handheld.computer\/index.php?rest_route=\/wp\/v2\/pages\/313\/revisions"}],"predecessor-version":[{"id":314,"href":"https:\/\/handheld.computer\/index.php?rest_route=\/wp\/v2\/pages\/313\/revisions\/314"}],"up":[{"embeddable":true,"href":"https:\/\/handheld.computer\/index.php?rest_route=\/wp\/v2\/pages\/249"}],"wp:attachment":[{"href":"https:\/\/handheld.computer\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=313"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/handheld.computer\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}