termux / termux-api

Termux add-on app which exposes device functionality as API to command line programs.
https://f-droid.org/en/packages/com.termux.api/
2.33k stars 459 forks source link

termux-usb -l Command Hangs on Google Pixel 7 with Android 14 #638

Closed Daplugg23 closed 10 months ago

Daplugg23 commented 12 months ago

Problem description

Problem: The termux-usb -l command is consistently hanging without listing any connected USB devices on my Google Pixel 7 running Android 14. This issue occurs even when no USB device is connected. **Steps to reproduce**
  1. Open Termux.
  2. Run termux-usb -l.
  3. Observe that the command hangs indefinitely without output.

Expected behavior

The command should either list connected USB devices or exit gracefully if none are connected. **Additional information** Actual Behavior: The command hangs indefinitely, requiring forceful termination of the session. Environment: Device: Google Pixel 7 Android Version: 14 Termux Version: 0.118.0 (F-Droid) Termux:API Version: 0.50.1 (F-Droid) Termux:API Package Version 0.57 Attempts to Resolve: Reinstalled Termux and Termux:API. Updated and upgraded all packages within Termux. Ensured all permissions for Termux and Termux:API are granted.
sylirre commented 12 months ago

Seems like https://github.com/termux/termux-packages/issues/16255

Try this command

chmod 400 $PREFIX/libexec/termux-am/am.apk

then try to use termux-usb again

Daplugg23 commented 12 months ago

Seems like termux/termux-packages#16255

Try this command

chmod 400 $PREFIX/libexec/termux-am/am.apk

then try to use termux-usb again

Despite following the suggested solution of applying chmod 400 $PREFIX/libexec/termux-am/am.apk, the issue with the termux-usb -l command hanging remains unresolved.

sylirre commented 12 months ago

Provide output of logcat captured when you executed termux-usb -l.

Daplugg23 commented 12 months ago

Here's the logcat.

logcat.txt

agnostic-apollo commented 12 months ago

There is no reference to termux-usb, you need to run logcat immediately after. If it was writable issue, command would exit, if it's hanging, it's a different issue. What's output for apt show termux-am.

Daplugg23 commented 12 months ago

I'll try the logcat again. Here's the other information

apt show termux-am Package: termux-am Version: 0.6.0 Maintainer: Michal Bednarski @michalbednarski Installed-Size: 77.8 kB Conflicts: termux-tools (<< 0.51) Homepage: https://github.com/termux/TermuxAm Download-Size: 26.2 kB APT-Manual-Installed: yes APT-Sources: https://packages-cf.termux.dev/apt/termux-main stable/main aarch64 Packages Description: Android Oreo-compatible am command reimplementation

Daplugg23 commented 12 months ago

I tried the logcat again.

logcat.txt

sylirre commented 12 months ago
11-15 11:51:07.359 23403 23403 W bash    : type=1400 audit(0.0:4020): avc:  granted  { execute } for  name="termux-usb" dev="dm-56" ino=689169 scontext=u:r:untrusted_app_27:s0:c117,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c117,c257,c512,c768 tclass=file app=com.termux.api
11-15 11:51:07.363 23403 23403 W bash    : type=1400 audit(0.0:4021): avc:  granted  { execute } for  name="termux-usb" dev="dm-56" ino=689169 scontext=u:r:untrusted_app_27:s0:c117,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c117,c257,c512,c768 tclass=file app=com.termux.api
11-15 11:51:07.363 23403 23403 W bash    : type=1400 audit(0.0:4022): avc:  granted  { execute_no_trans } for  path="/data/data/com.termux/files/usr/bin/termux-usb" dev="dm-56" ino=689169 scontext=u:r:untrusted_app_27:s0:c117,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c117,c257,c512,c768 tclass=file app=com.termux.api
11-15 11:51:07.367 23403 23403 W termux-usb: type=1400 audit(0.0:4024): avc:  granted  { execute } for  path="/data/data/com.termux/files/usr/bin/bash" dev="dm-56" ino=131720 scontext=u:r:untrusted_app_27:s0:c117,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c117,c257,c512,c768 tclass=file app=com.termux.api
11-15 11:51:07.371 23403 23403 W termux-usb: type=1400 audit(0.0:4025): avc:  denied  { search } for  name="tests" dev="dm-56" ino=107 scontext=u:r:untrusted_app_27:s0:c117,c257,c512,c768 tcontext=u:object_r:shell_test_data_file:s0 tclass=dir permissive=0 app=com.termux.api
11-15 11:51:07.371 23403 23403 W termux-usb: type=1400 audit(0.0:4026): avc:  denied  { search } for  name="tests" dev="dm-56" ino=107 scontext=u:r:untrusted_app_27:s0:c117,c257,c512,c768 tcontext=u:object_r:shell_test_data_file:s0 tclass=dir permissive=0 app=com.termux.api
11-15 11:51:07.371 23403 23403 W termux-usb: type=1400 audit(0.0:4027): avc:  denied  { search } for  name="tests" dev="dm-56" ino=107 scontext=u:r:untrusted_app_27:s0:c117,c257,c512,c768 tcontext=u:object_r:shell_test_data_file:s0 tclass=dir permissive=0 app=com.termux.api

These few lines is everything that is shown by logcat?

Daplugg23 commented 12 months ago

Sorry here's a complete logcat.

logcat.txt

agnostic-apollo commented 12 months ago

TL;DR: Run adb shell "settings put global cached_apps_freezer disabled" disable android app freezer at your own risk as negative consequences are currently unknown.


You won't fine the reason if logcat is run as termux app process, it needs to be run with adb shell or su to get system logs.

The reason is Android's cached app freezer added in Android 11 via bdaf16e managed by CachedAppOptimizer. I haven't looked into it much, but apps that are cached will be frozen and intents sent to them will not be received until they are unfrozen. To unfreeze an app requires starting them with some specific reasons (check below), like starting their (launcher) activity, like Termux:API app's launcher activity. I currently don't know why this has become more of an issue on Android 14, maybe due to reducing DEFAULT_FREEZER_DEBOUNCE_TIMEOUT from 10 minutes to 10 seconds in 912a866d.

When an app is frozen, ActivityManager system_server D freezing <pid> <package_name> will be logged.

When an app is unfrozen, ActivityManager system_server D sync unfroze <pid> <package_name> for <reason> where reason is one of @UnfreezeReason, also defined in ActivityManagerInternal.

The app freezer can be controlled with the cached_apps_freezer setting in the global namespace. The value of enabled enables the app freezer, disabled disables it and device_default will let the system decide whether to enable the freezer or not, as it may not be supported on all systems (`cgroup freeze state file needs to be present).

There is also a use_freezer device_config setting in the activity_manager_native_boot namespace that acts as a secondary setting.

https://cs.android.com/android/platform/superproject/+/android-14.0.0_r9:frameworks/base/services/core/java/com/android/server/am/CachedAppOptimizer.java;l=1098

https://cs.android.com/android/platform/superproject/+/android-14.0.0_r9:frameworks/base/core/java/android/provider/Settings.java;l=17517

# To disable freezer
## adb
adb shell "settings put global cached_apps_freezer disabled"
## root
su -c "settings put global cached_apps_freezer disabled"

# To re-enable or restore freezer to default
## adb
adb shell "settings delete global cached_apps_freezer"
## root
su -c "settings delete global cached_apps_freezer"

# To check current settings value
## adb
adb shell "settings get global cached_apps_freezer"
## root
su -c "settings get global cached_apps_freezer"

To view current freezer status only.

## adb
adb shell "dumpsys activity | grep use_freezer="
## root
su -c "dumpsys activity | grep use_freezer="

Output:

  use_freezer=true

To view current freezer status, settings and view list of frozen processes.

## adb
adb shell "dumpsys activity | sed -n '/use_freezer=/,/CacheOomRanker/p'"
## root
su -c "dumpsys activity | sed -n '/use_freezer=/,/CacheOomRanker/p'"

Output:

use_freezer=true
  freeze_statsd_sample_rate=0.1
  freeze_debounce_timeout=10000
  freeze_exempt_inst_pkg=false
  freeze_binder_enabled=true
  freeze_binder_threshold=1000
  freeze_binder_divisor=4
  freeze_binder_offset=500
  Apps frozen: 102
   ...
    2803411: 14658 com.termux.api

Related commits:

Disabling battery optimizations for the app does not prevent it from being frozen. Sending an intent to start a foreground service for the app with am start will not resume a frozen app, like termux-api-start does to start KeepAliveService, however if started in unfrozen state, it does seem to prevent app being shortly frozen, I guess until it is killed.

The issue can be reproduced by removing Termux:API from recent apps screen after launching its activity, waiting a while and then running termux-api commands. If command hangs and dumpsys shows com.termux.api in frozen apps list or freezing <pid> com.termux.api was logged in system logcat, then start the Termux:API activity from launcher and command should resume. If you kill the hung command with ctrl+c before starting Termux:API, then when app resumes again, ResultReturner will throw a java.io.IOException: Connection refused exception since it will fail to connect to the socket previously started by termux-api that is no longer available.

Daplugg23 commented 12 months ago

I rooted my device and disabled freeze. termux-usb -l is still hanging.

su -c "settings get global cached_apps_freezer" disabled ~ $ su -c "dumpsys activity | grep use_freezer=" use_freezer=false ~ $ su -c "dumpsys activity | sed -n '/use_freezer=/,/CacheOomRanker/p'" use_freezer=false freeze_statsd_sample_rate=0.1 freeze_debounce_timeout=10000 freeze_exempt_inst_pkg=false freeze_binder_enabled=true freeze_binder_threshold=1000 freeze_binder_divisor=4 freeze_binder_offset=500 Apps frozen: 125 134429: 2111 com.google.android.flipendo 647281: 0 com.android.settings 663376: 0 com.google.android.cellbroadcastreceiver 646049: 2760 com.google.android.permissioncontroller 92134: 0 com.google.android.apps.wellbeing 67225: 0 com.google.android.apps.work.clouddpc 67228: 0 com.google.android.deskclock 631964: 0 android.process.acore 67228: 0 com.google.android.devicelockcontroller 345577: 0 com.google.android.carrier 70187: 0 com.google.euiccpixel 22692: 0 com.android.carrierdefaultapp 71579: 0 com.shannon.rcsservice:shannonrcsservice 132505: 0 com.google.android.dialer 95826: 0 app.revanced.android.apps.youtube.music 132120: 0 app.revanced.android.youtube 675725: 0 com.google.process.gservices 40765: 0 com.piyush.music 58469: 0 com.spotify.music 508813: 0 org.telegram.messenger 416231: 0 com.android.keychain 59012: 0 org.videolan.vlc 61923: 0 com.google.android.apps.dreamliner 629718: 0 com.android.vending 675725: 0 com.google.process.gapps 162518: 0 com.google.android.carriersetup 113983: 4603 com.google.android.as.oss 567861: 0 com.google.android.apps.messaging 193285: 0 com.google.omadm.trigger 105952: 0 com.android.providers.calendar 313433: 0 com.verizon.mips.services 577539: 0 com.google.android.apps.tachyon 416234: 0 com.android.localtransport 87657: 0 com.touchtype.swiftkey.beta 313398: 0 com.verizon.mips.services:remote 82927: 0 com.verizon.messaging.vzmsgs 83102: 0 com.vzw.hss.myverizon 86456: 5695 com.android.traceur 56381: 0 com.google.android.onetimeinitializer 647429: 0 android.process.media 42204: 0 com.android.printspooler 86797: 6097 com.google.android.projection.gearhead:shared 38115: 0 com.android.externalstorage 67229: 6175 com.android.musicfx 416233: 0 com.android.dynsystem 416232: 0 com.android.dynsystem:dynsystem 59715: 0 com.android.imsserviceentitlement 59731: 0 com.google.RilConfigService 131789: 0 com.google.android.apps.carrier.carrierwifi 60474: 0 com.google.android.wfcactivation 60473: 0 com.android.hotwordenrollment.okgoogle 60475: 0 com.android.hotwordenrollment.xgoogle 60475: 0 com.android.managedprovisioning 61011: 0 com.android.omadm.service 61024: 0 com.android.shell 92514: 6768 com.google.android.apps.carrier.log 91560: 0 com.google.android.apps.docs 76004: 0 com.google.android.apps.gcs 64545: 0 com.google.android.apps.healthdata 91271: 0 com.google.android.apps.maps 66151: 0 com.google.android.apps.maps:server_recovery_process 78821: 7084 com.google.android.rkpdapp 64923: 0 com.google.android.apps.nbu.files 294097: 0 com.google.android.apps.safetyhub 86457: 7407 com.google.android.apps.tips 173705: 0 com.google.android.apps.turbo:aab 567862: 7684 com.google.android.setupwizard:remote 86798: 7733 com.google.android.projection.gearhead:car 109127: 7770 com.google.android.projection.gearhead:provider 69440: 7799 com.google.android.apps.turbo:ssb 67227: 0 com.google.android.apps.wallpaper 67226: 0 com.google.android.apps.work.oobconfig 91552: 0 com.google.android.calendar 67675: 0 com.google.android.configupdater 91269: 0 com.google.android.contacts 161777: 0 com.google.android.gm 647319: 0 com.google.android.turboadapter 69125: 0 com.google.android.hardwareinfo 69439: 0 com.google.android.odad 71528: 8414 com.google.android.packageinstaller 79002: 0 com.google.android.partnersetup 647248: 0 com.google.android.settings.intelligence 70070: 0 com.google.android.setupwizard 70188: 0 com.google.android.tts 70372: 8609 com.google.android.uvexposurereporter 91015: 0 com.google.android.videos 70492: 0 com.google.pixel.livewallpaper 604202: 0 com.google.android.gms.unstable 131325: 0 com.google.android.apps.docs.editors.docs 71578: 0 com.google.android.apps.docs.editors.sheets 91550: 0 com.google.android.apps.magazines 92566: 0 com.google.android.apps.podcasts 162421: 9289 com.google.android.apps.subscriptions.red 76353: 9427 com.google.android.apps.translate 91554: 0 com.google.android.apps.walletnfcrel 137889: 0 com.google.android.keep 452431: 9568 com.instagram.barcelona 79153: 0 com.microsoft.bing 81433: 0 com.microsoft.office.excel 86516: 9825 com.google.android.accessibility.switchaccess 604204: 0 com.google.android.gms.ui 86661: 9912 com.google.android.healthconnect.controller 86794: 9957 com.google.android.projection.gearhead:projection 81432: 0 com.microsoft.office.officehubrow 312469: 0 com.microsoft.office.outlook 81433: 0 com.microsoft.office.word 80773: 0 com.mixplorer.beta 629712: 0 com.openai.chatgpt 143624: 10702 com.instagram.barcelona:mqtt 94628: 0 com.microsoft.skydrive 133029: 11055 com.vcast.mediamanager 82250: 0 com.android.vending:instant_app_installer 93173: 11420 com.instagram.android:pretosproc 452468: 0 com.instagram.android 138286: 0 com.joeykrim.rootcheck 344201: 0 com.google.android.webview:webview_service 138287: 0 com.google.android.webview:sandboxed_process0:org.chromium.content.app.SandboxedProcessService0:0 75560: 12151 com.google.android.webview:webview_apk 630927: 0 com.android.providers.partnerbookmarks 151416: 0 com.instagram.android:mqtt 388705: 13068 com.topjohnwu.magisk 106408: 13570 com.android.systemui:screenshot 153122: 14440 com.android.vending:quick_launch 361284: 0 com.discord 380648: 0 com.draco.ladb CacheOomRanker settings ~ $

Daplugg23 commented 12 months ago

After installing pkg install root-repo and then apt update && apt upgrade. It's now working. Thank you for the help.

agnostic-apollo commented 12 months ago

Android 14 requires termux-am v0.6.0.

https://github.com/termux/TermuxAm/commit/8761289ba6ff3639e9b9c6af0d2d267e01dfccdb

Welcome.

Daplugg23 commented 11 months ago

After performing a factory reset on my phone, I'm encountering the same issue again where the termux-usb -l command in Termux hangs. Despite attempting the same troubleshooting steps as before, the problem persists. Attached is the logcat output for your review. Could you please assist in resolving this? logcat.txt

CrazyCraftix commented 11 months ago

I have the same problem. For me, it seems to affect all termux-api commands.

dumpsys does not show com.termux.api as frozen and I have version 0.6.0 of the package termux-am installed.

I'm using the latest F-Droid versions of Termux and Termux API. I don't want to try a newer, non-F-Droid build (as done in #640), because I'm afraid I might lose the keys inside the Android Keystore (I was using tergent).

The only notable events between everything working and now (that I remember) was a minor system update and pkg update && pkg upgrade.

alexfarseer commented 11 months ago

I have this problem as well for all termux-api commands after I updated my Pixel 6a to December security update. Before that it was working without any problem.

But I managed to find a workaround. First update Termux to the GitHub build if you are using the F-Droid version. And get the latest build of Termux-API from here: https://github.com/termux/termux-api/actions/runs/6717239830

Termux-API now comes with a frontend. So open Termux-API and give it the two special permissions it requires now. After that all the api commands from Termux should work. If you don't want to open Termux-API app every time, just execute termux-api-start from Termux. That should keep it alive in the background.

The bug is that Termux is not able to start the Termux-API app by itself (except for termux-api-start).

Also, here is termux-usb, it does not hang anymore:

$ termux-usb -l
[]
txoof commented 11 months ago

@alexfarseer Can you offer a more detailed description of how to work through these steps:

First update Termux to the GitHub build if you are using the F-Droid version. And get the latest build of Termux-API from here: https://github.com/termux/termux-api/actions/runs/6717239830

I just installed the December patch this morning (15 Dec) and all the termux-api commands hang as described above. I tried uninstalling and reinstalling the F-Droid package as well as pkg uninstall termux-api && pkg install termux-api

Current versions:

Thanks for the help!

alexfarseer commented 11 months ago

@txoof Okey, first of all uninstall the F-Droid packages. Latest build of Termux-API does not work with them. Get the Termux app from here: https://github.com/termux/termux-app/releases/tag/v0.118.0

And Termux-API app from here: https://github.com/termux/termux-api/actions/runs/6717239830

Install them both and give all the permissions to Termux-API, including the two special permissions from inside the app. After that run termux-api-start from Termux and all the API commands should work.

txoof commented 11 months ago

@alexfarseer

Fantastic! Thank you for the instructions. This worked perfectly.

When I run termux-api-start I get a notifciation: Termux:API Error Error in ResultReturner, but after that things work as expected. I see the following on the command line:

$ termux-api-start                                                  
Starting service: Intent { cmp=com.termux.api/.KeepAliveService }

Any idea if this is important?

I have noticed that after a bit, the API commands hang again and I have to run the termux-api-start command again. Any solution for that other than shoving it into my scripts?

txoof commented 11 months ago

@agnostic-apollo I managed to get to a working version of termux:API by following alexfarseer's instructions above. Is there a more sustainable way to keep an up-to-date version of termux on my devices? Previously I was working from F-Droid and that worked great up until the December 2023 security patch broke something.

alexfarseer commented 11 months ago

@txoof Unfortunately it looks like termux-api-start is not working for you. There should be no errors and it should be alive until you stop it with termux-api-stop.

Run termux-api-stop after running termux-api-start, that will show you if the keep alive service was successfully started or not. Also, make sure you have enabled the special permissions inside Termux-API app. These permissions are battery optimisations and display over other apps.

txoof commented 11 months ago

Interesting. termux-api-start occasionally yields the notification error, but then all the API commands start functioning.

Whatever api-start does is only temporary and needs to be done again after an hour or so. I've solved this by sticking the command in all of the automation scripts that have API commands.

Thanks again for your help in getting this far.

ghost commented 10 months ago

I have similar problems using the GitHub release of Termux and Termux:API from GitHub Actions. termux-location works immediately after termux-api-start, but hangs later when started by termux-job-scheduler. Running termux-api-start (or termux-api-stop+termux-api-start) in the script before termux-location did not help in my case. During my experiments I have also experienced the "Termutx:API Error Error in ResultReturner" notification and random crashes (see below) , but cannot relate them to a particular sequence of actions. Up to now, they did not occur when I run termux-location in a script triggered by termux-job-scheduler.

## Crash Details

**Crash Thread**: `Thread[main,5,main]`  
**Crash Timestamp**: `2023-12-17 18:39:40.539 UTC`  

**Crash Message**:

Unable to start activity ComponentInfo{com.termux/com.termux.shared.activities.ReportActivity}: android.os.BadParcelableException: Parcelable encountered IOException reading a Serializable object (name = com.termux.shared.models.ReportInfo)


### Stacktrace

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.termux/com.termux.shared.activities.ReportActivity}: android.os.BadParcelableException: Parcelable enco untered IOException reading a Serializable object (name = com.termux.shared.models.ReportInfo) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3813) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3953) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2455) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8216) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987) Caused by: android.os.BadParcelableException: Parcelable encountered IOException reading a Serializable object (name = com.termux.shared.models.ReportInfo) at android.os.Parcel.readSerializableInternal(Parcel.java:5194) at android.os.Parcel.readValue(Parcel.java:4713) at android.os.Parcel.readValue(Parcel.java:4410) at android.os.Parcel.-$$Nest$mreadValue(Unknown Source:0) at android.os.Parcel$LazyValue.apply(Parcel.java:4508) at android.os.Parcel$LazyValue.apply(Parcel.java:4467) at android.os.BaseBundle.unwrapLazyValueFromMapLocked(BaseBundle.java:417) at android.os.BaseBundle.getValueAt(BaseBundle.java:403) at android.os.BaseBundle.getValue(BaseBundle.java:383) at android.os.BaseBundle.getValue(BaseBundle.java:366) at android.os.BaseBundle.getValue(BaseBundle.java:359) at android.os.BaseBundle.getSerializable(BaseBundle.java:1494) at android.os.Bundle.getSerializable(Bundle.java:1171) at com.termux.shared.activities.ReportActivity.updateUI(ReportActivity.java:136) at com.termux.shared.activities.ReportActivity.onCreate(ReportActivity.java:89) at android.app.Activity.performCreate(Activity.java:8677) at android.app.Activity.performCreate(Activity.java:8655) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1461) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3795) ... 12 more Caused by: java.io.InvalidClassException: com.termux.shared.models.ReportInfo; local class incompatible: stream classdesc serialVersionUID = -5165426368218339031, local class serialVersionUID = 3324698011185826218 at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:652) at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1743) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1624) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1902) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1442) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430) at android.os.Parcel.readSerializableInternal(Parcel.java:5181) ... 30 more

##

## Termux App Info

**APP_NAME**: `Termux`  
**PACKAGE_NAME**: `com.termux`  
**VERSION_NAME**: `0.118.0`  
**VERSION_CODE**: `118`  
**TARGET_SDK**: `28`  
**IS_DEBUGGABLE_BUILD**: `true`  
**APK_RELEASE**: `Github`  
**SIGNING_CERTIFICATE_SHA256_DIGEST**: `B6DA01480EEFD5FBF2CD3771B8D1021EC791304BDD6C4BF41D3FAABAD48EE5E1`  
##

## Device Info

### Software

**OS_VERSION**: `4.19.282-gc92b5172dbc7`  
**SDK_INT**: `34`  
**RELEASE**: `14`  
**ID**: `UP1A.231105.001`  
**DISPLAY**: `UP1A.231105.001.2023121200`  
**INCREMENTAL**: `2023121200`  
**SECURITY_PATCH**: `2023-12-01`  
**IS_TREBLE_ENABLED**: `true`  
**TYPE**: `user`  
**TAGS**: `release-keys`  

### Hardware

**MANUFACTURER**: `Google`  
**BRAND**: `google`  
**MODEL**: `Pixel 4a (5G)`  
**PRODUCT**: `bramble`  
**BOARD**: `bramble`  
**HARDWARE**: `bramble`  
**DEVICE**: `bramble`  
**SUPPORTED_ABIS**: `arm64-v8a, armeabi-v7a, armeabi`  
##
fritzbauer commented 10 months ago

Same problem here after December update. Fixed with the termux & termux-api versions from github. As a newer termux-api version seems to resolve the issue, would it be possible to create a new release of termux-api so F-Droid builds the new version as well?

astral-l commented 10 months ago

Seconding the interest in a new release for F-Droid users. If a full release isn't planned soon, it might be easier to create a smaller patch release with just this issue fixed.

agnostic-apollo commented 10 months ago

Check https://github.com/termux/termux-api-package/commit/e8b001399ac679eb48590cfbc7d63e55104d8629 and https://github.com/termux/TermuxAm/commit/8a08e9bd31f3bc763f30ee1bf9c32204d0a89a53 for detail. Hanging issues for github action builds should be resolved now.

Update to termux-api v0.58.0 and termux-am v0.8.0 with apt update; apt install termux-api termux-am. Packages are available in termux default repo and should be synced to other mirrors depending on their sync strategy.

I was wrong in the above comment, a frozen can still be started with an intent. I did not previously realize that termux-api was hanging at the read() call instead of the process not starting again. You should not need to disable freezing as previously suggested, although it may cause some performance issues if app process gets frozen as wake up times should cause latency issues.

An app update is not required to fix this specific issue, but F-Droid builds are broken since exceptions are not caught and if app crash multiple times, it will never restart until manually started with a launcher and there is no launcher icon in fdroid builds. I should be able to start working on the pre-releases some time next week, it requires working on like 5 different repos to fix issues before I can make releases.

Those ResultReturner notifications can be opened to see the exception by tapping. There was likely due to the app failing to connect the socket sent by the termux-api command when it got unfroozen if ctrl+c was used to kill the command before that.

Caused by: java.io.InvalidClassException: com.termux.shared.models.ReportInfo; local class incompatible: stream classdesc serialVersionUID = -5165426368218339031, local class serialVersionUID = 3324698011185826218

This is unrelated to current issue, probably some pre/post update mismatch issue.

I'm encountering the same issue again where the termux-usb -l command in Termux hangs. Despite attempting the same troubleshooting steps as before, the problem persists. Attached is the logcat output for your review. Could you please assist in resolving this? logcat.txt

You are getting selinux denials, don't know why, maybe that is causing the hanging for some reason. Not sure why logs are labelled by adb, how are you running the termux-usb commads?

bash : type=1400 audit(0.0:8641): avc: granted { execute } for name="termux-usb" dev="dm-58" ino=86932 scontext=u:r:untrusted_app_27:s0:c90,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c90,c257,c512,c768 tclass=file app=com.termux.api adb : type=1400 audit(0.0:8694): avc: denied { read } for comm=64657669636520706F6C6C name="usb" dev="tmpfs" ino=494 scontext=u:r:untrusted_app_27:s0:c90,c257,c512,c768 tcontext=u:object_r:usb_device:s0 tclass=dir permissive=0 app=com.termux.api