termux / termux-widget

Termux add-on app which adds shortcuts to commands on the home screen.
https://f-droid.org/en/packages/com.termux.widget
Other
944 stars 111 forks source link

Disabling the launcher icon or not opening Termux:Widget app in the background stops my script from running #120

Closed emrys307 closed 1 month ago

emrys307 commented 2 months ago

Problem description

My task won't work if I have disabled the Termux:Widget launcher icon or if I don't have the Termux:Widget app open in the background. So in order for my task to work the app has to be open and the launcher icon working. When I start the Termux:Widget app on the background and try to run the widget, the Termux:Widget app comes to the foreground and the script properly runs. The only other way to make it work is to immediately after starting the task from the widget, clicking on the notification that says "0 session, 1 task" before it disappears which brings up the Termux terminal and the task works properly after that. Because of this I thought it may be a issue about starting from the background but Termux app has "Appear on top" permission which I assume is the Samsung equivalent of "Draw over other apps" permission.

Steps to reproduce

Follow the appropriate steps to install Termux, Termux:API and Termux:Widget app. Create a directory called node with my app. Point to the app with a bash script that uses the proper location for bash and my app on Termux, at .shortcuts/tasks folder created with chmod 700. Set up a widget for the script and try to run it. Notification appears for a second and disappears without the script being ran.

Expected behavior

My shortcut working in the background without there being a need to open the Termux:Widget app before.

Additional information

I don't know how safe sharing the logcat command output is and if I should delete something so I changed a couple numbers but here are the logs.

07-02 15:29:05.794 20189 20189 I DecorView: setWindowBackground: isPopOver=false color=ff010102 d=null 07-02 15:29:05.800 20189 20189 I Toast : show: caller = com.termux.widget.TermuxWidgetProvider.sendExecutionIntentToTermuxService:544 07-02 15:29:05.800 20189 20189 I Toast : show: contextDispId = 0 mCustomDisplayId = -1 focusedDisplayId = 0 isActivityContext = true 07-02 15:29:05.808 20189 20189 V Toast : HANDLE SHOW: android.widget.Toast$TN@d5y0258 mView=null mNextView=java.lang.ref.WeakReference@bb6ffb1 07-02 15:29:05.809 20189 20189 V ToastPresenter: yOffset = 0 07-02 15:29:05.809 20189 20189 V ToastPresenter: Text: Fxec in android.widget.ToastPresenter@2c5fc96 07-02 15:29:05.809 20189 20189 I WindowManager: WindowManagerGlobal#addView, ty=2005, view=android.widget.LinearLayout{7b7 V.E...... ......I. 0,0-0,0}, caller=android.view.WindowManagerImpl.addView:150 android.widget.ToastPresenter.addToastView:414 android.widget.ToastPresenter.show:335 07-02 15:29:05.810 20189 20210 D NativeCustomFrequencyManager: [NativeCFMS] BpCustomFrequencyManager::BpCustomFrequencyManager() 07-02 15:29:05.813 20189 20189 I InsetsController: onStateChanged: host=Toast, from=android.view.ViewRootImpl.setView:153, state=InsetsState: {mDisplayFrame=Rect(0, 0 - 1080, 2340), mDisplayCutout=DisplayCutout{insets=Rect(0, 80 - 0, 0) waterfall=Insets{left=0, top=0, right=0, bottom=0} boundingRect={Bounds=[Rect(0, 0 - 0, 0), Rect(411, 0 - 569, 80), Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0)]} cutoutPathParserInfo={CutoutPathParserInfo{displayWidth=1080 displayHeight=2340 physicalDisplayWidth=1080 physicalDisplayHeight=2340 density={2.8125} cutoutSpec={"some numbers"} rotation={0} scale={1.0} physicalPixelDisplaySizeRatio={1.0}}}}, mRoundedCorners=RoundedCorners{[RoundedCorner{position=TopLeft, radius=0, center=Point(0, 0)}, RoundedCorner{position=TopRight, radius=0, center=Point(0, 0)}, RoundedCorner{position=BottomRight, radius=0, center=Point(0, 0)}, RoundedCorner{position=BottomLeft, radius=0, center=Point(0, 0)}]} mRoundedCornerFrame=Rect(0, 0 - 0, 0), mPrivacyIndicatorBounds=PrivacyIndicatorBounds {static bounds=Rect(964, 0 - 1080, 80) rotation=0}, mDisplayShape=DisplayShape{ spec=-312193 displayWidth=1080 displayHeight=2340 physicalPixelDisplaySizeRatio=1.0 rotation=0 offsetX=0 offsetY=0 scale=1.0}, mSources= { InsetsSource: {d2270000 mType=statusBars mFrame=[0,0][1080,80] mVisible=true mFlags=[]}, InsetsSource: {d2270005 mType=mandatorySystemGestures mFrame=[0,0][1080,112] mVisible=true mFlags=[]}, InsetsSource: {d2270006 mType=tappableElement mFrame=[0,0][1080,80] mVisible=true mFlags=[]}, InsetsSource: {3 mType=ime mFrame=[0,0][0,0] mVisible=false mFlags=[]}, InsetsSource: {27 mType=displayCutout mFrame=[0,0][1080,80] mVisible=true mFlags=[]}, InsetsSource: {4fd20001 mType=navigationBars mFrame=[0,2214][1080,2340] mVisible=true mFlags=[]}, InsetsSource: {4fd20004 mType=systemGestures mFrame=[0,0][0,0] mVisible=true mFlags=[]}, InsetsSource: {4fd20005 mType=mandatorySystemGestures mFrame=[0,2214][1080,2340] mVisible=true mFlags=[]}, InsetsSource: {4fd20006 mType=tappableElement mFrame=[0,2214][1080,2340] mVisible=true mFlags=[]}, InsetsSource: {4fd20024 mType=systemGestures mFrame=[0,0][0,0] mVisible=true mFlags=[]} } 07-02 15:29:05.813 20189 20189 I ViewRootImpl@c99ec04[Toast]: synced displayState. AttachInfo displayState=2 07-02 15:29:05.814 20189 20189 I ViewRootImpl@c99ec04[Toast]: setView = android.widget.LinearLayout@7bd7017 TM=true 07-02 15:29:05.820 10485 10485 I NotificationManager: com.termux: notify(1337, null, Notification(channel=termux_notification_channel shortcut=null contentView=null vibrate=null sound=null defaults=0x0 flags=0x2 color=0xff607d8b actions=2 vis=PRIVATE semFlags=0x0 semPriority=0 semMissedCount=0)) as user 07-02 15:29:05.823 20189 20210 D OpenGLRenderer: HWUI - treat SMPTE_170M as sRGB 07-02 15:29:05.830 20189 20189 I BLASTBufferQueue_Java: new BLASTBufferQueue, mName= ViewRootImpl@c99ec04[Toast] mNativeObject= 0x707c9a9cd0 sc.mNativeObject= 0x70ac9a1410 caller= android.view.ViewRootImpl.updateBlastSurfaceIfNeeded:3028 android.view.ViewRootImpl.relayoutWindow:10131 android.view.ViewRootImpl.performTraversals:4110 android.view.ViewRootImpl.doTraversal:3288 android.view.ViewRootImpl$TraversalRunnable.run:11344 android.view.Choreographer$CallbackRecord.run:1689 android.view.Choreographer$CallbackRecord.run:1698 android.view.Choreographer.doCallbacks:1153 android.view.Choreographer.doFrame:1079 android.view.Choreographer$FrameDisplayEventReceiver.run:1646 07-02 15:29:05.830 20189 20189 I BLASTBufferQueue_Java: update, w= 493 h= 98 mName = ViewRootImpl@c99ec04[Toast] mNativeObject= 0x707c9a9cd0 sc.mNativeObject= 0x70ac9a1410 format= -3 caller= android.graphics.BLASTBufferQueue.:89 android.view.ViewRootImpl.updateBlastSurfaceIfNeeded:3028 android.view.ViewRootImpl.relayoutWindow:10131 android.view.ViewRootImpl.performTraversals:4110 android.view.ViewRootImpl.doTraversal:3288 android.view.ViewRootImpl$TraversalRunnable.run:11344 07-02 15:29:05.830 20189 20189 I ViewRootImpl@c99ec04[Toast]: Relayout returned: old=(0,80,1080,2214) new=(293,80,786,178) relayoutAsync=false req=(493,98)0 dur=5 res=0x3 s={true 0x6f7c9d29d0} ch=true seqId=0 07-02 15:29:05.830 20189 20189 I ViewRootImpl@c99ec04[Toast]: performConfigurationChange setNightDimText nightDimLevel=0 07-02 15:29:05.831 20189 20189 D ViewRootImpl@c99ec04[Toast]: mThreadedRenderer.initialize() mSurface={isValid=true 0x6f7c9d29d0} hwInitialized=true 07-02 15:29:05.833 20189 20189 D ViewRootImpl@c99ec04[Toast]: reportNextDraw android.view.ViewRootImpl.performTraversals:4718 android.view.ViewRootImpl.doTraversal:3288 android.view.ViewRootImpl$TraversalRunnable.run:11344 android.view.Choreographer$CallbackRecord.run:1689 android.view.Choreographer$CallbackRecord.run:1698 07-02 15:29:05.833 20189 20189 I ViewRootImpl@c99ec04[Toast]: Setup new sync=wmsSync-ViewRootImpl@c99ec04[Toast]#number 4 07-02 15:29:05.833 20189 20189 I ViewRootImpl@c99ec04[Toast]: Creating new active sync group ViewRootImpl@c99ec04[Toast]#number 5 07-02 15:29:05.834 20189 20189 I ViewRootImpl@c99ec04[Toast]: registerCallbacksForSync syncBuffer=false 07-02 15:29:05.834 20189 20229 I ViewRootImpl@c99ec04[Toast]: Received frameDrawingCallback syncResult=0 frameNum=1. 07-02 15:29:05.834 20189 20229 I ViewRootImpl@c99ec04[Toast]: mWNT: t=0x700c4tf950 mBlastBufferQueue=0x707c9a9cd0 fn= 1 mRenderHdrSdrRatio=1.0 caller= android.view.ViewRootImpl$8.onFrameDraw:13841 android.view.ThreadedRenderer$1.onFrameDraw:792 07-02 15:29:05.834 20189 20229 I ViewRootImpl@c99ec04[Toast]: Setting up sync and frameCommitCallback 07-02 15:29:05.839 20189 20210 I BLASTBufferQueue: ViewRootImpl@c99ec04[Toast]#number 2 onFrameAvailable the first frame is available 07-02 15:29:05.839 20189 20210 I ViewRootImpl@c99ec04[Toast]: Received frameCommittedCallback lastAttemptedDrawFrameNum=1 didProduceBuffer=true 07-02 15:29:05.840 20189 20210 D OpenGLRenderer: CFMS:: SetUp Pid : 20189 Tid : 20210 07-02 15:29:05.840 20189 20189 I ViewRootImpl@c99ec04[Toast]: reportDrawFinished seqId=0 07-02 15:29:05.867 20189 20210 D OpenGLRenderer: CacheManager::trimMemory(20) 07-02 15:29:06.876 23535 23535 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 10446 <<<<<< 07-02 15:29:06.891 23535 23535 I AndroidRuntime: Using default boot image 07-02 15:29:06.891 23535 23535 I AndroidRuntime: Leaving lock profiling enabled 07-02 15:29:06.892 23535 23535 W libc : Access denied finding property "odsign.verification.success" 07-02 15:29:06.893 23535 23535 D SecNativeFeatureCppIf: encoded 07-02 15:29:06.893 23535 23535 D SecNativeFeatureCppIf: decoding and unzip finish 07-02 15:29:06.893 23535 23535 D SecNativeFeatureCppIf: use unCompDataBuff. encoded 07-02 15:29:06.893 23535 23535 D SecNativeFeatureCppIf: Free unCompDataBuff 07-02 15:29:06.893 23535 23535 D AndroidRuntime: addProductProperty not brand or 7 07-02 15:29:06.901 23535 23535 W app_process: ART APEX data files are untrusted. 07-02 15:29:06.902 23535 23535 I app_process: Using CollectorTypeCMC GC. 07-02 15:29:06.904 23535 23535 E app_process: Error reading named image component header for /system/framework/boot.art, error: Failed to open oat file '/system/framework/arm64/boot.oat' when validating it for image '/system/framework/boot.art': In oat file '/system/framework/boot.oat', dex file checksum 0x55199551 does not match checksum 0x67c7743e of external dex file '/apex/com.android.art/javalib/core-oj.jar' 07-02 15:29:06.904 23535 23535 E app_process: Could not create image space with image file '/system/framework/boot.art!/apex/com.android.art/etc/boot-image.prof!/system/etc/boot-image.prof:/system/framework/boot-framework-adservices.art'. Attempting to fall back to imageless running. Error was: Failed to open oat file '/system/framework/arm64/boot.oat' when validating it for image '/system/framework/boot.art': In oat file '/system/framework/boot.oat', dex file checksum 0x55199551 does not match checksum 0x67c7743e of external dex file '/apex/com.android.art/javalib/core-oj.jar' 07-02 15:29:06.905 23535 23535 W app_process: Bump pointer space is not aligned to 2048KB. This can lead to longer stop-the-world pauses for compaction 07-02 15:29:07.804 20189 20189 I WindowManager: WindowManagerGlobal#removeView, ty=2005, view=android.widget.LinearLayout{7bd7017 V.E...... ........ 0,0-493,98}, caller=android.view.WindowManagerGlobal.removeView:628 android.view.WindowManagerImpl.removeViewImmediate:208 android.widget.ToastPresenter.hide:358 07-02 15:29:07.804 20189 20189 W WindowOnBackDispatcher: sendCancelIfRunning: isInProgress=falsecallback=android.view.ViewRootImpl$$ExternalSyntheticLambda19@8cbc470 07-02 15:29:07.806 20189 20210 D OpenGLRenderer: CacheManager::trimMemory(20) 07-02 15:29:07.806 20189 20189 I ViewRootImpl@c99ec04[Toast]: dispatchDetachedFromWindow 07-02 15:29:07.810 20189 20189 D InputTransport: Input channel destroyed: 'f61bbd ', fd=91 07-02 15:29:07.817 20189 20210 D OpenGLRenderer: CacheManager::trimMemory(40) 07-02 15:29:07.818 20189 20210 D OpenGLRenderer: RenderThread::destroyRenderingContext() 07-02 15:29:07.944 23535 23535 D nativeloader: InitDefaultPublicLibraries for_preload=1: libandroid.so:libaaudio.so:libamidi.so:libbinder_ndk.so:libc.so:libcamera2ndk.so:libdl.so:libEGL.so:libGLESv1_CM.so:libGLESv2.so:libGLESv3.so:libicu.so:libicui18n.so:libicuuc.so:libjnigraphics.so:liblog.so:libmediandk.so:libm.so:libnativehelper.so:libnativewindow.so:libOpenMAXAL.so:libOpenSLES.so:libRS.so:libstdc++.so:libsync.so:libvulkan.so:libwebviewchromium_plat_support.so:libz.so 07-02 15:29:07.994 23535 23535 D app_process: Time zone APEX ICU file found: /apex/com.android.tzdata/etc/icu/icu_tzdata.dat 07-02 15:29:07.995 23535 23535 D app_process: I18n APEX ICU file found: /apex/com.android.i18n/etc/icu/icudt72l.dat 07-02 15:29:08.135 23535 23535 W ziparchive: Unable to open '/data/data/com.termux/files/usr/libexec/termux-am/am.dm': No such file or directory 07-02 15:29:08.614 23535 23535 E SemDvfsManager_JNI: SemDvfsManager: registerfunction enter 07-02 15:29:08.614 23535 23535 E SemAffinityControl: SemAffinityControl: registerfunction enter 07-02 15:29:08.711 23535 23535 W libc : Access denied finding property "ro.product.name_for_attestation" 07-02 15:29:08.711 23535 23535 W libc : Access denied finding property "ro.product.brand_for_attestation" 07-02 15:29:08.712 23535 23535 W libc : Access denied finding property "ro.product.model_for_attestation" 07-02 15:29:08.738 23535 23535 D AndroidRuntime: Calling main entry com.termux.termuxam.Am 07-02 15:29:08.870 23535 23535 I app_process: System.exit called, status: 0 07-02 15:29:08.870 23535 23535 I AndroidRuntime: VM exiting with result code 0. 07-02 15:29:08.874 20260 23553 E BroadcastReceiver: BroadcastReceiver trying to return result during a non-ordered broadcast 07-02 15:29:08.874 20260 23553 E BroadcastReceiver: java.lang.RuntimeException: BroadcastReceiver trying to return result during a non-ordered broadcast 07-02 15:29:08.874 20260 23553 E BroadcastReceiver: at android.content.BroadcastReceiver$PendingResult.checkSynchronousHint(BroadcastReceiver.java:351) 07-02 15:29:08.874 20260 23553 E BroadcastReceiver: at android.content.BroadcastReceiver$PendingResult.setResultCode(BroadcastReceiver.java:154) 07-02 15:29:08.874 20260 23553 E BroadcastReceiver: at com.termux.api.util.b.b(Unknown Source:153) 07-02 15:29:08.874 20260 23553 E BroadcastReceiver: at com.termux.api.util.a.run(Unknown Source:8) 07-02 15:29:08.874 20260 23553 E BroadcastReceiver: at java.lang.Thread.run(Thread.java:1012) 07-02 15:29:08.940 10485 10485 I NotificationManager: com.termux: notify(1337, null, Notification(channel=termux_notification_channel shortcut=null contentView=null vibrate=null sound=null defaults=0x0 flags=0x2 color=0xff607d8b actions=2 vis=PRIVATE semFlags=0x0 semPriority=0 semMissedCount=0)) as user 07-02 15:29:09.204 10485 10485 I ViewRootImpl@7963721[TermuxActivity]: onDisplayChanged oldDisplayState=2 newDisplayState=2