MuntashirAkon / AppManager

A full-featured package manager and viewer for Android
https://muntashirakon.github.io/AppManager/
Other
4.29k stars 252 forks source link

Problem with launching non-exported activities #1341

Closed GflowerG closed 1 month ago

GflowerG commented 1 month ago

Please check before submitting an issue

Describe the bug

I think that AM launches the assistant before the system has registered the selected activity. Or cancels registration before the system calls the assistant.

I think so, because the feature is triggered when the activity launch button is spammed. This means that the registration and launch of the activity are not synchronized even by a temporary pause. That is, these are parallel tasks.

To Reproduce

No response

Expected behavior

No response

Screenshots

No response

Logs

No response

Device info

Additional context

I don't use the default assistant. But when I install it, AM just launches it instead of launching the selected activity.

MuntashirAkon commented 1 month ago

Tested on Lineage OS 18.1 and 21 (A11 and A14) with assistant turned on and off. They worked fine. I don't know if it's a ROM related issue or you're whether you're using any non-standard assistants (e.g. some launchers support custom assistants that are triggered by the launcher rather than the system).

GflowerG commented 1 month ago

An important addition: the no-root mode works better than ADB, because the assistant has to be launched manually. It looks like there needs to be a more reliable synchronization method similar to this manual mode.

UPD. After experiments (MIUI ROM), I returned to the version that AM launches the restored assistant. AM does not give my system enough time to launch the selected activity...

vordx commented 1 month ago

https://github.com/MuntashirAkon/AppManager/assets/39927714/9f07a115-a998-49fb-8aba-fc7e5dee8477

https://github.com/MuntashirAkon/AppManager/assets/39927714/fad41a51-d875-43ed-b5db-042edffdb96a

I have the same issue but I thought i was doing something wrong because it works with Knox privilege activities launchers.

vordx commented 1 month ago

@MuntashirAkon

MuntashirAkon commented 1 month ago

UPD. After experiments (MIUI ROM), I returned to the version that AM launches the restored assistant. AM does not give my system enough time to launch the selected activity...

It's up to you to determine the amount of waiting time (in milliseconds) required by your system in order for it to realize the change in the assistant by following #1243. You can write a shell script with variable delays to figure out a minimum amount of waiting time or delay.


# Store the configured assistant
last_val=`settings get secure assistant`
# Replace `package/activity` with the one you need to open
settings put secure assistant package/activity
# Launch activity
input keyevent 219
# Empirically decided wait time (100 ms). Replace it with various values e.g., 0.3, 0.5 or 0.75 or 1.0 to find the best wait time
sleep 0.1
# Restore assistant
settings put secure assistant "$last_val"```
MuntashirAkon commented 1 month ago

I've added an empirical value of 500ms in 120a95dc3319a54d0619b5e489f2ffd80437071a