termux-api icon indicating copy to clipboard operation
termux-api copied to clipboard

`termux-dialog` not working on Android 9

Open nenadilic84 opened this issue 8 years ago • 18 comments

I'm facing this issue on my oneplus 6.

I've already checked all the Termux:API permissions and all other commands I've tested are pretty much working properly expect the termux-dialog where it only locks down.

$ termux-info
Updatable packages:
All packages up to date
System information:
Linux localhost 4.9.106-perf+ #1 SMP PREEMPT Sat Sep 15 01:11:54 CST 2018 aarch64 Android
Termux-packages arch:
aarch64
Android version:
9
Device manufacturer:
OnePlus
Device model:
ONEPLUS A6003

Battery status working:

$ termux-battery-status
{
  "health": "GOOD",
  "percentage": 89,
  "plugged": "PLUGGED_USB",
  "status": "CHARGING",
  "temperature": 29.200000762939453
}
$ termux-dialog
^C

Logcat output:

$ logcat -s termux:* termux-api:*
--------- beginning of crash
--------- beginning of main

I've tried to debug this with Android Studio but the issue I'm facing after compiling the Termux APK and Termux:API apk, is that my debugger doesn't know how to start the Termux:API application as it is missing the main Activity.

Any help here would be appreciated in order to resolve it.

nenadilic84 avatar Oct 24 '18 15:10 nenadilic84

After changing the line: https://github.com/termux/termux-api/blob/master/app/src/main/java/com/termux/api/TermuxApiReceiver.java#L68 back to:

context.startActivity(new Intent(context, DialogActivity.class).putExtras(intent.getExtras()).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));

solved the problem, but this might cause other problems.

Any suggestions here?

nenadilic84 avatar Oct 24 '18 15:10 nenadilic84

It is related to the issue fixed here: https://github.com/termux/termux-api/pull/200

nenadilic84 avatar Oct 24 '18 15:10 nenadilic84

The same problem occurs also at least on Android 5.1 (#200).. wondering on which systems it works?

xandro0777 avatar Oct 29 '18 20:10 xandro0777

I can confirm this bug affects my setup:

$ termux-info
Updatable packages:
All packages up to date
System information:
Linux localhost 3.18.120-perf-g84a7475 #1 SMP PREEMPT Fri Jan 4 17:46:28 WIB 2019 aarch64 Android
Termux-packages arch:
aarch64
Android version:
9
Device manufacturer:
Xiaomi
Device model:
Mi A1
Terminated

NOTE after the termux-dialog hang, termux-info terminates due to an error, logcat says:

01-29 20:24:17.208 16191 16191 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 10151 <<<<<<
01-29 20:24:17.506 16191 16191 W main    : type=1400 audit(0.0:546): avc: denied { read } for name="u:object_r:vendor_mpctl_prop:s0" dev="tmpfs" ino=6391 scontext=u:r:untrusted_app:s0:c151,c256,c512,c768 tcontext=u:object_r:vendor_mpctl_prop:s0 tclass=file permissive=0
01-29 20:24:17.521 16191 16191 E libc    : Access denied finding property "ro.vendor.at_library"
01-29 20:24:17.533 16191 16191 D AndroidRuntime: Calling main entry com.example.termuxam.Am
01-29 20:24:17.566 16191 16191 D AndroidRuntime: Shutting down VM
01-29 20:24:19.923 16219 16219 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 10151 <<<<<<
01-29 20:24:20.066 16219 16219 W main    : type=1400 audit(0.0:547): avc: denied { read } for name="u:object_r:vendor_mpctl_prop:s0" dev="tmpfs" ino=6391 scontext=u:r:untrusted_app:s0:c151,c256,c512,c768 tcontext=u:object_r:vendor_mpctl_prop:s0 tclass=file permissive=0
01-29 20:24:20.078 16219 16219 E libc    : Access denied finding property "ro.vendor.at_library"
01-29 20:24:20.087 16219 16219 D AndroidRuntime: Calling main entry com.example.termuxam.Am
01-29 20:24:20.120 16219 16219 D AndroidRuntime: Shutting down VM

lorenzogrv avatar Jan 29 '19 19:01 lorenzogrv

This seems related to #207 , maybe problem is not specific to Android 9 P as seems affecting also 7.x and 6.x

lorenzogrv avatar Jan 29 '19 19:01 lorenzogrv

Also affecting 5.1

xandro0777 avatar Jan 29 '19 19:01 xandro0777

After full data + cache clean + uninstall both Termux and Termux:Api; and reinstalling both apps and termux-api, problem persists.

lorenzogrv avatar Jan 29 '19 19:01 lorenzogrv

Related:

  • issue https://github.com/termux/termux-api/issues/168 and it's solution at PR https://github.com/termux/termux-app/pull/811
  • issue https://github.com/termux/termux-packages/issues/334
  • https://github.com/termux/termux-packages/issues/361 (old issue related to device-specific firmware) solved at https://github.com/termux/termux-packages/issues/361#issuecomment-260208178

lorenzogrv avatar Jan 29 '19 20:01 lorenzogrv

After manually enable of "access to notifications" for Termux API, termux-info does not terminate.

termux-toast also working now, but termux-dialog still hangs with:

01-29 21:10:53.882 23517 23517 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 10151 <<<<<<
01-29 21:10:54.046 23517 23517 E libc    : Access denied finding property "ro.vendor.at_library"
01-29 21:10:54.038 23517 23517 W main    : type=1400 audit(0.0:553): avc: denied { read } for name="u:object_r:vendor_mpctl_prop:s0" dev="tmpfs" ino=6391 scontext=u:r:untrusted_app:s0:c151,c256,c512,c768 tcontext=u:object_r:vendor_mpctl_prop:s0 tclass=file permissive=0
01-29 21:10:54.057 23517 23517 D AndroidRuntime: Calling main entry com.example.termuxam.Am
01-29 21:10:54.096 23517 23517 D AndroidRuntime: Shutting down VM

The error above also appears on log running termux-toast

lorenzogrv avatar Jan 29 '19 20:01 lorenzogrv

This is the exact PR that killed it: https://github.com/termux/termux-api/pull/200 @cvirostek, @fornwall did you guys test this after merging the PR.

As I've mentioned reverting back to FLAG_ACTIVITY_NEW_TASK works just fine for me. I suggest in the next release we just have the PR #200 reverted. Unless @cvirostek has a proper fix.

@fornwall any objections?

nenadilic84 avatar Jan 29 '19 20:01 nenadilic84

did you guys test this after merging the PR.

Yes, it was tested.

screenshot_20190129-224538_termuxapi

ghost avatar Jan 29 '19 20:01 ghost

After fiddling a bit, I can confirm the E libc : Access denied finding property "ro.vendor.at_library" error is triggered on almost any call to iai-api commands.

lorenzogrv avatar Jan 29 '19 21:01 lorenzogrv

@nenadilic84 Where can I find info to test your solution? I mean, packaging the native apps on my computer to install them.

lorenzogrv avatar Jan 31 '19 14:01 lorenzogrv

On my LG Android 5, it says Termux:API has stopped, but works on my LG Android 7.

(This is the opposite of what happens on these devices with the dialog package.)

Logcat:

D/AndroidRuntime(19711): >>>>>> START com.android.internal.os.RuntimeInit uid 10115 <<<<<<
D/AndroidRuntime(19711): CheckJNI is OFF
D/AndroidRuntime(19711): Calling main entry com.example.termuxam.Am
D/AndroidRuntime(19711): Shutting down VM
D/AndroidRuntime(19562): Shutting down VM
E/AndroidRuntime(19562): FATAL EXCEPTION: main
E/AndroidRuntime(19562): Process: com.termux.api, PID: 19562
E/AndroidRuntime(19562): java.lang.RuntimeException: Unable to start receiver com.termux.api.TermuxApiReceiver: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
E/AndroidRuntime(19562):        at android.app.ActivityThread.handleReceiver(ActivityThread.java:2713)
E/AndroidRuntime(19562):        at android.app.ActivityThread.access$1700(ActivityThread.java:162)
E/AndroidRuntime(19562):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1425)
E/AndroidRuntime(19562):        at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(19562):        at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(19562):        at android.app.ActivityThread.main(ActivityThread.java:5422)
E/AndroidRuntime(19562):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(19562):        at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(19562):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:914)
E/AndroidRuntime(19562):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
E/AndroidRuntime(19562): Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
E/AndroidRuntime(19562):        at android.app.ContextImpl.startActivity(ContextImpl.java:1399)
E/AndroidRuntime(19562):        at android.app.ContextImpl.startActivity(ContextImpl.java:1386)
E/AndroidRuntime(19562):        at android.content.ContextWrapper.startActivity(ContextWrapper.java:323)
E/AndroidRuntime(19562):        at android.content.ContextWrapper.startActivity(ContextWrapper.java:323)
E/AndroidRuntime(19562):        at com.termux.api.TermuxApiReceiver.onReceive(TermuxApiReceiver.java:68)
E/AndroidRuntime(19562):        at android.app.ActivityThread.handleReceiver(ActivityThread.java:2701)
E/AndroidRuntime(19562):        ... 9 more
I/Process (19562): Sending signal. PID: 19562 SIG: 9
I/HyLog   (19756): I : openReadStream, /data/font/config/sfconfig.dat, case (2)
D/HyLog   (19756): D: Wrong tag (928 : loadPreData() : frameworks/base/core/jni/android/graphics/TypefaceHyFontManager.cpp)

Is am supposed to be under com.example?

Quasic avatar Feb 02 '19 21:02 Quasic

@laconbass, I've created a PR here. I usually build my APKs manually using the Android Studio. Thus I suggest you check out the branch, build it and run it. Please note that you also have to build the main Termux APK as well in order to have the same version. Hope this helps.

nenadilic84 avatar Feb 05 '19 17:02 nenadilic84

The #251 pull request has been merged and is part of the 0.31 version of the app, which should be available as an update shortly.

fornwall avatar Feb 05 '19 22:02 fornwall

Thanks @nenadilic84 !

fornwall avatar Feb 05 '19 22:02 fornwall

I can confirm this commit fixed the issue on my setup. Thanks!

lorenzogrv avatar Feb 06 '19 13:02 lorenzogrv