TrianguloY / LightningLauncher

More than a simple Android launcher, Lightning is a fast, light and extremely customizable tool to build the perfect home screen. To build your home screen.
https://www.lightninglauncher.com/
MIT License
32 stars 3 forks source link

Some app shortcuts don't work #28

Open kazink opened 2 months ago

kazink commented 2 months ago

Hi, I have been using the original LL for several years, and only recently I stumbled upon the license issue, since it has been removed from Google. I then found your version and wanted to thank you for keeping the best launcher alive. Is there a way to support your effort with some money?

The only problem I can see after moving to this version is that some app shortcuts in the home screen stopped working. For example I have an LSPosed shortcut (the app LSPosed is not visible in order too hide the root from apps that don't like it). The shortcut worked fine in the original LL, but doesn't work now. When I tap it I'm getting the toast "Shortcut disabled".

Also recently I installed Island app, that can isolate other apps, and wanted to create a shortcut to a specific app that I want to open from inside the Island. But this shortcut doesn't work either (the same toast message). I tried this in another launcher (Quickstep) and the shortcut worked fine, so there seems to be something wrong with this version of LL.

ertmuirm commented 2 months ago

I had the same issue, you just need to recreate the shortcut using the lsposed native app

kazink commented 2 months ago

I had the same issue, you just need to recreate the shortcut using the lsposed native app

I thought that if it didn't work for Island, it wouldn't work for LSPosed too. But I tried now, and my effect is that LL crashes when I try to create the shortcut.

TrianguloY commented 2 months ago

The app shortcuts have a long-standing bug in the original version (and the patched one) where by moving one into a different folder/panel (or deleting then undoing) it stops working. I guess this also applies to backup/restore.

There is a workaround for the moving: create a copy, then move one, then delete the copy. For other cases like the one explained here, the only way to 'fix' it is to delete and create the shortcut again

kazink commented 2 months ago

The original shortcut has been moved into a different panel indeed, but it worked fine before the LL upgrade. But now LL crashes when I try to recreate the LSPosed shortcut. And the Island shortcut is created successfully, but doesn't work at all (without moving or doing anything).

TrianguloY commented 2 months ago

Hmm, are you using the patched or the patched_community version?

Also, how are you creating the shortcuts? Can you provide some basic step-by-step? I want to try to check myself. I'm personally using a shortcut...wait.

Did you uninstalled the original launcher? And is the shortcut in the original launcher? I think the issue is that shortcuts in the community patch are still being created with the non-community id...

kazink commented 2 months ago

My package name is net.pierrox.lightning_launcher_comunity. There is no 'patched' in the name, not sure if there should be? I have uninstalled the old version, because otherwise my Android wouldn't let me install any of the new versions. Then I restored the settings from backup. The LSPosed shortcut got restored, but wasn't working.

Steps to create the LSPosed shortcut:

  1. Tap LSPosed notification.
  2. Go to settings.
  3. Tap 'Create shortcut'.

For Island shortcut:

  1. Open Island.
  2. Tap any app on the Island.
  3. Tap three dots in the bottom right corner..
  4. Tap 'Create Unfreeze & Lanuch shortcut.
TrianguloY commented 2 months ago

My package name is net.pierrox.lightning_launcher_comunity

You are using the patched community version. That version was created for those of us to want to install it alongside the original launcher (not sure why it didn't work for you). If you have already uninstalled the original, I suggest to use the patched (non-community) one. Not sure if that could help, but depending on how the shortcuts are created they may.

LSPosed requires root, so unfortunately I can't test that one. Island is still in beta and I would prefer not to test on my main device, but I can try to check on an emulator. Will report if I find anything.

kazink commented 2 months ago

Thank you for trying to find the source of the problem. I couldn't install the non-community version, until I uninstalled LLW Simple Screen Switcher. Unfortunately the shortcut behaviour is exactly the same as in the community version (even without restoring my settings from backup.

TrianguloY commented 2 months ago

Oh! I totally forgot about that (and unfortunately that app code is not here). With different signatures they cannot work together anymore, I'm afraid.

As for the shortcuts themselve still not working, could you please answer these questions?

Which Android version do you have? Any ROM? And device?

Do Chrome (or Firefox) shortcuts work? (Open a web, menu, add to home screen)

kazink commented 2 months ago

I don't actually remember what that did, so perhaps it's not a big problem 😁 Android version 9, device is Ulefone Armor 3WT, stock ROM (just rooted). Firefox shortcut works fine.

kazink commented 2 months ago

Just restored old LL settings by a mistake, along with the old LSPosed shortcut. And surprisingly, it works in this version! Despite the fact that it has been moved to a side screen. It still crashes when I try to create another one, but it's a start. Perhaps I could try to install the original LL version, create the Island shortcut there, and it would work after moving to the patched version.

TrianguloY commented 2 months ago

Strange. Thanks for providing the details. Unfortunately I don't think I have time to test it on an emulator, but maybe someone else can? Sorry In any case, I'm happy to hear that restoring again made it work (although that's even more strange!)

kazink commented 2 months ago

Thank you for the work anyway. The apps work, but are just less convenient without the shortcuts.

I could probably work the problem around by creating a shortcut that calls a script. If I only knew what parameters to pass to 'am start' command. I have found some examples, but I'm having trouble applying them to the Island app. I have managed to run main Island app from a script, but not a specific app inside it.

What kind of testing would help you find the cause? Perhaps I could do it. I'm a software engineer, but not in Android area (I know mostly embedded C and some basics of Linux, I have done some simple ADB things too). If you tell me what to run, I can do it and gather the results. I guess the most helpful would be to know what the difference is between the working and non-working LSPosed shortcut, but I have no idea how to view what the shortcut is made of. I tried looking at the logcat, but couldn't find anything useful.

TrianguloY commented 2 months ago

I would like to help you troubleshoot the issue, and maybe even find a fix for it, but currently I'm already full on things to do (even more than I would like to) so unfortunately I can't be of much help.

Some ideas if you still want to take a look:

As for what to run in the 'am start', I think that's adb and is not needed while in the app itself. I don't know the exact details of how to launch these special shortcuts, but they usually either require LL.getContext().startActivity(...) or a bind that I have no idea how to run.

There is another thing, btw: I guess you are trying to create the shortcut from the add>shortcut menu, but is it also available by any chance in the shortcuts menu? (to open this menu you need to configure one item of the app to launch the 'show app shortcuts' action, for example when long click). If those shortcuts work, you can long-tap and drag them.

kazink commented 2 months ago

I have looked into the shortcuts, and this is what I have found:

  1. The LSPosed working shortcut has the following contents: {"b":163,"c":9,"d":1,"o":216,"p":277,"x":0,"i":{},"a":"SHORTCUT","am":"LSPosed","m":"#Intent;action=net.pierrox.lightning_launcher.APP_SHORTCUT;S.id=org.lsposed.manager.shortcut;S.pkg=com.android.shell;end"} I could not find a way to create a non-working LSPosed shortcut. I think it didn't work only in the community version. Interestingly, When I delete the shortcut and re-create it, Linghning Launcher still crashes, but the shortcut is created. Although with generic icon, but it works. Strange.

  2. The Island non-working shortcut has the following contents: {"b":167,"c":0,"d":1,"o":216,"p":277,"x":0,"i":{},"a":"SHORTCUT","am":"Swift Backup","m":"#Intent;action=net.pierrox.lightning_launcher.APP_SHORTCUT;S.id=launch%3Aorg.swiftapps.swiftbackup;S.pkg=com.oasisfeng.island;end"} It seems similar to the LSPosed one, but one thing is different: it contains the %3A code, which means a colon. Perhaps the special character code is not converted back to colon when calling the app from the shortcut? I tried to remove the "launch%3A" part (then save the backup file, and restore it in LL), but it didn't change anything. Can you translate the shortcut contents to a bash command that I have to call to run the app? If that works from termux, I will create a shortcut to run that bash command and I will be good.

I have searched google, but the only thing I have found was to run the 'am start' followed by parameters. I managed to find general examples only, like am start -a android.intent.action.MAIN -n com.android.browser/.BrowserActivity I can run the Island main app with the command am start -a com.oasisfeng.island.MAIN -n com.oasisfeng.island/.MainActivity, but I couldn't find a way to start a particular app inside the island. am start -a com.oasisfeng.island.launch:org.swiftapps.swiftbackup -n com.oasisfeng.island/.MainActivity still brings the main island window, and not the swiftbackup app.

I'm not sure what you mean by 'show app shortcuts', but I think I've done that. Created a shortcut that opens app shortcuts (screenshot attached). The LSPosed shortcut shows up there and works fine, but the shortcut created from Island does not show in this menu (don't look at the shortcut icon, I tried with the modified Island shortcut, and with a new shortcut, with Island shortcut created separately - it still didn't show).

Shortcut

ertmuirm commented 2 months ago

I just updated to the LL patched build, and had the same problem with Lsposed shortcut. Here's how I fixed it:

kazink commented 5 days ago

Hi again. I didn't solve the shortcut problem (LL shortcut created from the Island not working), but I found a workaround. Unfortunately it requires Macrodroid and root. This is how to do it:

  1. Create a new macro and add 'Shortcut launched' as the trigger.
  2. For the action select 'Applications -> Shell Script'. 3, For the script type: su -c "am start --user 10 -n your.app.package.name/.your.app.acitivity" Example for the SwiftBackup app: su -c "am start --user 10 -n org.swiftapps.swiftbackup/.intro.IntroActivity" Apparently the Island app works by having another user with the number 10, and all you have to to is launch the app as that user.
  3. Check 'Rooted' option above the script.
  4. Click OK and save the Macro.
  5. In the macros list long tap the macro and tap 'Create home screen shortcut'. This shortcut seems to be working fine.

There should be a way to do that without root, because Island itself does not require root to launch an app (but launching an app as another user does), but nothing I tried worked. The command that should be working is: am start -a com.oasisfeng.island.action.LAUNCH_APP -d "app://10@org.swiftapps.swiftbackup" -n com.oasisfeng.island/.shortcut.IslandAppShortcut$ShortcutLauncher but the $ in the activity name gets stripped from the command for some reason.

If anyone has an idea how to make the non-root command work, please share.

TrianguloY commented 4 days ago

Try this:

am start -a com.oasisfeng.island.action.LAUNCH_APP -d "app://10@org.swiftapps.swiftbackup" -n 'com.oasisfeng.island/.shortcut.IslandAppShortcut$ShortcutLauncher'

Dollar in the command line represents a variable. It is replacing the $ShortcutLauncher with the value, which is just an empty string because it's undefined. Single quotes (NOT double) will keep the dollar.

Also, that command should be the same as running this lightning script:

getHomeScreen().startActivity(Intent.parseUri("app://10@org.swiftapps.swiftbackup#Intent;action=com.oasisfeng.island.action.LAUNCH_APP;component=com.oasisfeng.island/.shortcut.IslandAppShortcut%24ShortcutLauncher;end",0))

Can you try it?

kazink commented 3 days ago

Both lines work great! Thank you very much.

I also tried a way I user previously to run shell scripts with LL shortcuts, but it wouldn't work for this: bindClass('java.lang.Runtime'); Runtime.getRuntime().exec("am start -a com.oasisfeng.island.action.LAUNCH_APP -d app://10@org.swiftapps.swiftbackup -n com.oasisfeng.island/.shortcut.IslandAppShortcut%24ShortcutLauncher"); But that doesn't matter since yours is working fine.

TrianguloY commented 3 days ago

Both lines work great! Thank you very much.

Glad it helped :) in the end the trick was to know exactly the intent generated.

I also tried a way I user previously to run shell scripts with LL shortcuts, but it wouldn't work for this: bindClass('java.lang.Runtime'); Runtime.getRuntime().exec("am start -a com.oasisfeng.island.action.LAUNCH_APP -d app://10@org.swiftapps.swiftbackup -n com.oasisfeng.island/.shortcut.IslandAppShortcut%24ShortcutLauncher");

I should read the docs again to be sure, but last time I used exec I had to separate the parameters like this:

Runtime.getRuntime().exec(["am", "start", "-a", "com.oasisfeng.island.action.LAUNCH_APP", "-d", "app://10@org.swiftapps.swiftbackup", "-n", "com.oasisfeng.island/.shortcut.IslandAppShortcut$ShortcutLauncher"]);
kazink commented 2 days ago
Runtime.getRuntime().exec(["am", "start", "-a", "com.oasisfeng.island.action.LAUNCH_APP", "-d", "app://10@org.swiftapps.swiftbackup", "-n", "com.oasisfeng.island/.shortcut.IslandAppShortcut$ShortcutLauncher"]);

This did not work. Perhaps I made a typo or something. But it doesn't matter any more. Thanks again.