nix-community / nix-on-droid

Nix-enabled environment for your Android device. [maintainers=@t184256,@Gerschtli]
https://nix-on-droid.unboiled.info
MIT License
1.22k stars 66 forks source link

[Issue with the app itself] Shortcuts crash the app #16

Open vikanezrimaya opened 4 years ago

vikanezrimaya commented 4 years ago

Note: This is an issue probably with the app itself, but as the fork doesn't have issues open, I can't report it.

Shortcuts (termux-widget code) doesn't seem to work; Big widget crashes the app on click, small widget does nothing or opens the current Nix session.

t184256 commented 4 years ago

I hoped this would never happen, because I know absolutely nothing about Android app development. I have no idea what went wrong and how to fix that, except that I've renamed com.termux to com.termux.nix through ApplicationIdSuffix and something probably broke because of that. Sorry.

09-26 20:58:10.811  2402  5565 W ActivityManager: Permission Denial: Accessing service ComponentI[81/9851]
ermux/com.termux.app.TermuxService} from pid=15511, uid=10158 that is not exported from uid 10107
09-26 20:58:10.814 15511 15511 D AndroidRuntime: Shutting down VM
09-26 20:58:10.824 15511 15511 E AndroidRuntime: FATAL EXCEPTION: main
09-26 20:58:10.824 15511 15511 E AndroidRuntime: Process: com.termux.nix, PID: 15511
09-26 20:58:10.824 15511 15511 E AndroidRuntime: java.lang.RuntimeException: Unable to start receiver com.
termux.widget.TermuxWidgetProvider: java.lang.SecurityException: Not allowed to start service Intent { act
=com.termux.service_execute dat=com.termux.file:/data/data/com.termux.nix/files/home/.shortcuts/t1 cmp=com
.termux/.app.TermuxService } without permission not exported from uid 10107
09-26 20:58:10.824 15511 15511 E AndroidRuntime:        at android.app.ActivityThread.handleReceiver(Activ
ityThread.java:3426)
09-26 20:58:10.824 15511 15511 E AndroidRuntime:        at android.app.ActivityThread.access$1200(Activity
Thread.java:200)
09-26 20:58:10.824 15511 15511 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(Acti
vityThread.java:1667)
09-26 20:58:10.824 15511 15511 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java
:106)
09-26 20:58:10.824 15511 15511 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:193)
09-26 20:58:10.824 15511 15511 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.
java:6718)
09-26 20:58:10.824 15511 15511 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
09-26 20:58:10.824 15511 15511 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndAr
gsCaller.run(RuntimeInit.java:493)
09-26 20:58:10.824 15511 15511 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteI
nit.java:858)
09-26 20:58:10.824 15511 15511 E AndroidRuntime: Caused by: java.lang.SecurityException: Not allowed to start service Intent { act=com.termux.service_execute dat=com.termux.file:/data/data/com.termux.nix/files/home/.shortcuts/t1 cmp=com.termux/.app.TermuxService } without permission not exported from uid 10107
09-26 20:58:10.824 15511 15511 E AndroidRuntime:        at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1570)
09-26 20:58:10.824 15511 15511 E AndroidRuntime:        at android.app.ContextImpl.startForegroundService(ContextImpl.java:1538)
09-26 20:58:10.824 15511 15511 E AndroidRuntime:        at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:669)
09-26 20:58:10.824 15511 15511 E AndroidRuntime:        at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:669)
09-26 20:58:10.824 15511 15511 E AndroidRuntime:        at com.termux.widget.TermuxWidgetProvider.startTermuxService(TermuxWidgetProvider.java:121)
09-26 20:58:10.824 15511 15511 E AndroidRuntime:        at com.termux.widget.TermuxWidgetProvider.onReceive(TermuxWidgetProvider.java:105)
09-26 20:58:10.824 15511 15511 E AndroidRuntime:        at android.app.ActivityThread.handleReceiver(ActivityThread.java:3417)
09-26 20:58:10.824 15511 15511 E AndroidRuntime:        ... 8 more
09-26 20:58:10.837  2402  2860 I ActivityManager: Showing crash dialog for package com.termux.nix u0
vikanezrimaya commented 4 years ago

Seems like it calls Termux's services, not Nix-on-Droid's. I don't know a lot about Android development, so this is just based on log output.

vikanezrimaya commented 4 years ago

As you've moved com.termux namespace to com.termux.nix, you should try to find-replace instances of com.termux to com.termux.nix in Widget code.

t184256 commented 4 years ago

Yes. I've tried to, but, the thing is, a lot of other hard-coded stuff automatically picked up the suffix, and would actually break if I manually added it. Googling what should and should not be manually suffixed suggests 'nothing should be'. Maybe Termux should've followed some best practice for this to actually hold true. IDK. Android klowledge required, pull requests are welcome.

t184256 commented 4 years ago

Yes. I've tried to, but, the thing is, a lot of other hard-coded stuff automatically picked up the suffix, and would actually break if I manually added it. Googling what should and should not be manually suffixed suggests 'nothing should be'. Maybe Termux should've followed some best practice for this to actually hold true. IDK. Android knowledge required, pull requests are welcome.