The Linux (>= 2.6.4) terminal driver uses the IUTF8 flag for
termios.c_iflag to implement correct character erase behavior in cooked
mode. The flag has to be set from native code, so provide a method to
do it.
Go through the default PATH and remove directories without the execute
bit set (meaning we can't access files in that directory). Requires
File.canExecute() from API 9 or later. This will prevent the misleading
"permission denied" errors which come up when you try to run a
nonexistent command; instead, the correct "not found" error will appear.
Add a preference to control the behavior (defaulting to true) so that
people who insist on always running as root can turn this off.
file.canExecute() is equivalent to access(file.getAbsolutePath(), X_OK),
so add native code to do just that to implement canExecute() for older
devices.
We'd like to provide native methods for more than one class, so move the
initialization stuff into its own file and provide for the possibility
of registering methods for more than one class.
Instead of crashing or exiting immediately when something is wrong with
the user's chosen shell, fall back to the default shell, which gives the
user a chance to go into the preferences and fix the error.
This helps on devices that place the menu key in the status bar. On those
devices the user is stuck because they can't get to the menu key without
showing the status bar, and they can't change the status bar preference
without using the menu key.
(Users on those devices can paint themselves into a corner by hiding the
status bar manually, but hopefully they'll figure out that uninstalling
and re-installing ATE will reset the preferences.)
We originally hid the status bar by default way back in Android 1.0, when
the standard screen size was 320 x 200. Screens are larger now, which
makes it more reasonable to show the status bar by default.
This change won't affect anyone who has already run ATE once, since the
preferences will have already been set to the default value on the first
run of the program.
Should fix a frequently-reported crash on Market:
java.lang.NullPointerException
at jackpal.androidterm.session.TranscriptScreen.fastResize(TranscriptScreen.java:395)
at jackpal.androidterm.session.TerminalEmulator.updateSize(TerminalEmulator.java:370)
at jackpal.androidterm.session.TermSession.updateSize(TermSession.java:287)
at jackpal.androidterm.EmulatorView.updateSize(EmulatorView.java:980)
at jackpal.androidterm.EmulatorView.updateSize(EmulatorView.java:1014)
at jackpal.androidterm.EmulatorView.onDraw(EmulatorView.java:1033)
at android.view.View.draw(View.java:6903)
at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
at android.view.View.draw(View.java:6906)
at android.widget.FrameLayout.draw(FrameLayout.java:352)
at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
at android.view.View.draw(View.java:6906)
at android.widget.FrameLayout.draw(FrameLayout.java:352)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1868)
at android.view.ViewRoot.draw(ViewRoot.java:1407)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1163)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
at dalvik.system.NativeStart.main(Native Method)
Signed-off-by: Jack Palevich <jackpal@google.com>
Should fix a frequently-reported crash on Market:
java.lang.StringIndexOutOfBoundsException: length=0; regionStart=0; regionLength=1
at java.lang.String.startEndAndLength(String.java:593)
at java.lang.String.substring(String.java:1474)
at jackpal.androidterm.EmulatorView$4.getSelectedText(EmulatorView.java:594)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:234)
at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:77)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4507)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
Signed-off-by: Jack Palevich <jackpal@google.com>
Move the screen resize check code out of EmulatorView and into
TermViewFlipper, where it logically fits now that there are multiple
EmulatorViews per Term activity. While we're at it, instead of making
the activity tell us how much of the window doesn't belong to us, use
getGlobalVisibleRect() to figure that out ourselves, eliminating the
need for a WindowSizeCallback.
Signed-off-by: Jack Palevich <jackpal@google.com>
At the moment, combining characters which follow an East Asian wide
character are not being stored in the same column as the characters they
modify. Fix this by keeping track of the width of the last spacing mark
emitted and using this to place combining characters into the correct
column.
Signed-off-by: Jack Palevich <jackpal@google.com>
Applications which emit UTF-8 sequences that decode to C1 control
characters expect these sequences to be interpreted as C1 control
characters, so send them back through process() instead of trying to
emit them.
Signed-off-by: Jack Palevich <jackpal@google.com>
Each C1 control character (U+0080-U+009F) maps to a corresponding
seven-bit-clean escape sequence (ESC U+0040-U+005F). We already handle
most of these escape sequences, so instead of just handling CSI (U+009B)
in an ad-hoc fashion, handle all the C1 controls systematically.
Signed-off-by: Jack Palevich <jackpal@google.com>
The current intent script execution mechanism has at least two
serious problems:
* If a Term activity is already running, it will just bring the activity
to the top, without opening a new window or running the provided
script.
* It allows any other application to use our permissions, even if they
don't have those permissions themselves.
Replace the current ad-hoc mechanism with a more formally defined remote
intent interface, which provides two actions:
* jackpal.androidterm.OPEN_NEW_WINDOW opens a new terminal window. No
script execution is allowed, and no permissions are required to use
this action.
* jackpal.androidterm.RUN_SCRIPT opens a new window and runs the script
specified in the jackpal.androidterm.iInitialCommand extra.
Applications using this intent must have the
jackpal.androidterm.permission.RUN_SCRIPT permission, which must be
approved by the user at install time.
Signed-off-by: Jack Palevich <jackpal@google.com>
The function key translation is hard to achieve so I try to do it this
way and after I get the translated package I look at it again to
correct it.
Change-Id: I7418f61c497a38378444a150d788acfee1c2fc47